403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sproduction.datasync/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sproduction.datasync/lib/portalofflineevents.php
<?php
/**
 * Offline events
 *
 * @mail support@s-production.online
 * @link s-production.online
 */
//TODO
namespace SProduction\Datasync;

use Bitrix\Main,
    Bitrix\Main\DB\Exception,
    Bitrix\Main\Config\Option;

class PortalOfflineEvents
{
    const MODULE_ID = 'sproduction.datasync';

	public static function eventsBind() {
		try {
			Rest::execute('event.bind', [
				'event'      => 'ONCRMPRODUCTUPDATE',
				'event_type' => 'offline',
			]);
		} catch (\Exception $e) {}
	}

	public static function eventsUnbind() {
		try {
			Rest::execute('event.unbind', [
				'event'      => 'ONCRMPRODUCTUPDATE',
				'event_type' => 'offline',
			]);
		} catch (\Exception $e) {}
	}

    public static function getChangedItems($type='update') {
    	$list = [];
	    $res = Rest::execute('event.offline.get', []);
	    foreach ($res['events'] as $item) {
		    if ($type == 'update' && $item['EVENT_NAME'] == 'ONCRMPRODUCTUPDATE') {
		    	$item_id = (int)$item['EVENT_DATA']['FIELDS']['ID'];
		    	if ($item_id) {
		    		$list[] = $item_id;
			    }
		    }
	    }
	    return $list;
    }

    public static function processEvents($other_deals_ids=[]) {
	    $items_ids = self::getChangedItems();
	    $items_ids = array_unique(array_merge($items_ids, $other_deals_ids));
	    FileLog::put('(processEvents) changed items: ' . print_r($items_ids, true));
	    // Wait for changes fix
	    if (Settings::get('products_last_change_ts') > time() - 2) {
		    FileLog::put('(processEvents) wait 2 sec');
	    	sleep(2);
	    }
		// TODO: Product data

//	    $items = PortalData::getDeal($items_ids);
//	    foreach ($items as $item) {
//		    $order_id = (int) $item[Settings::getOrderIDField()];
//		    FileLog::put('(processEvents) deal ' . print_r($item, true));
//		    if ( ! $order_id) {
//			    continue;
//		    }
//		    // Change fields in the order
//		    $opt_direction = \SProduction\Datasync\Settings::get("direction");
//		    if ( ! $opt_direction || $opt_direction == 'full' || $opt_direction == 'ctos') {
//			    SyncStore::runSync($item);
//		    }
//	    }
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit