From 08c51694175ba3f39793b594b2358a1605959ca8 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Tue, 28 Jan 2014 17:44:21 +0400 Subject: [PATCH] fix orderHistory init time; --- .../classes/general/ICrmOrderActions.php | 37 +++++++++++-------- .../classes/general/events/ICrmOrderEvent.php | 4 +- intaro.intarocrm/install/index.php | 4 +- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index f16cbdd4..d499a58f 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -20,6 +20,7 @@ class ICrmOrderActions /** * Mass order uploading, without repeating; always returns true, but writes error log + * @param $pSize * @param $failed -- flag to export failed orders * @return boolean */ @@ -365,7 +366,6 @@ class ICrmOrderActions $dateStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY_DATE, null); - if(!$dateStart) { $dateStart = new \DateTime(); $dateStart = $dateStart->format('Y-m-d H:i:s'); @@ -373,8 +373,15 @@ class ICrmOrderActions $orderHistory = $api->orderHistory($dateStart); + echo $dateStart; + echo '
'; + $dateStart = new \DateTime($dateStart); + echo json_encode($orderHistory); + + self::eventLog('ICrmOrderActions::orderHistory', 'history_log', json_encode($orderHistory)); + // pushing existing orders foreach ($orderHistory as $order) { @@ -399,7 +406,7 @@ class ICrmOrderActions $arUser = $dbUser->Fetch(); $registeredUserID = $arUser['ID']; } else { - $loginEmail ? $login = $order['customer']['email'] : $login = 'user_' . (microtime(true) * 100); + $login = 'user_' . (microtime(true) * 100); $registerNewUser = true; } } @@ -504,7 +511,7 @@ class ICrmOrderActions break; } - if (count($optionsOrderProps[$arFields['PERSON_TYPE_ID']] > 4)) { + if (count($optionsOrderProps[$arFields['PERSON_TYPE_ID']]) > 4) { switch ($ar['CODE']) { /* case $optionsOrderProps[$arFields['PERSON_TYPE_ID']]['country']: $resOrderDeliveryAddress['country'] = self::toJSON($ar['VALUE']); break; @@ -573,7 +580,7 @@ class ICrmOrderActions if (isset($order['deliveryAddress']['text'])) self::addOrderProperty($optionsOrderProps[$arFields['PERSON_TYPE_ID']]['text'], self::fromJSON($order['deliveryAddress']['text']), $order['externalId']); - if (count($optionsOrderProps[$arFields['PERSON_TYPE_ID']] > 4)) { + if (count($optionsOrderProps[$arFields['PERSON_TYPE_ID']]) > 4) { if (isset($order['deliveryAddress']['street'])) self::addOrderProperty($optionsOrderProps[$arFields['PERSON_TYPE_ID']]['street'], self::fromJSON($order['deliveryAddress']['street']), $order['externalId']); @@ -875,10 +882,10 @@ class ICrmOrderActions * * creates order or returns array of order and customer for mass upload * - * @param type $orderId - * @param type $api - * @param type $arParams - * @param type $send + * @param array $arFields + * @param $api + * @param $arParams + * @param $send * @return boolean * @return array - array('order' = $order, 'customer' => $customer) */ @@ -1117,7 +1124,7 @@ class ICrmOrderActions * removes all empty fields from arrays * working with nested arrs * - * @param type $arr + * @param array $arr * @return boolean */ public static function clearArr($arr) { @@ -1137,9 +1144,9 @@ class ICrmOrderActions /** * - * @global type $APPLICATION - * @param type $str in SITE_CHARSET - * @return type $str in utf-8 + * @global $APPLICATION + * @param $str in SITE_CHARSET + * @return $str in utf-8 */ public static function toJSON($str) { global $APPLICATION; @@ -1149,9 +1156,9 @@ class ICrmOrderActions /** * - * @global type $APPLICATION - * @param type $str in utf-8 - * @return type $str in SITE_CHARSET + * @global $APPLICATION + * @param $str in utf-8 + * @return $str in SITE_CHARSET */ public static function fromJSON($str) { global $APPLICATION; diff --git a/intaro.intarocrm/classes/general/events/ICrmOrderEvent.php b/intaro.intarocrm/classes/general/events/ICrmOrderEvent.php index 0ebb4e3b..d2bc424f 100644 --- a/intaro.intarocrm/classes/general/events/ICrmOrderEvent.php +++ b/intaro.intarocrm/classes/general/events/ICrmOrderEvent.php @@ -75,7 +75,9 @@ class ICrmOrderEvent { /** * writeDataOnOrderCreate via api * - * @param integer $ID - Order Id + * @param $ID - Order Id + * @param array $arFields + * @return boolean */ function writeDataOnOrderCreate($ID, $arFields) { diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 6fe9aa43..e09548ab 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -807,7 +807,6 @@ class intaro_intarocrm extends CModule { COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 1); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, serialize(array())); - COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY_DATE, date('Y-m-d H:i:s')); $APPLICATION->IncludeAdminFile( GetMessage('MODULE_INSTALL_TITLE'), @@ -1159,6 +1158,9 @@ class intaro_intarocrm extends CModule { $this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key); $this->INTARO_CRM_API->statisticUpdate(); + // in fin order + COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY_DATE, date('Y-m-d H:i:s')); + $APPLICATION->IncludeAdminFile( GetMessage('MODULE_INSTALL_TITLE'), $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step6.php'