1
0
mirror of synced 2024-11-29 16:56:07 +03:00

event side effects (hisotry) fix

This commit is contained in:
Grisha Pomadchin 2014-03-13 12:58:52 +04:00
parent 2f309dee4a
commit 274fd7a9a4
3 changed files with 17 additions and 7 deletions

View File

@ -368,10 +368,10 @@ class ICrmOrderActions
$dateStart = $dateStart->format('Y-m-d H:i:s'); $dateStart = $dateStart->format('Y-m-d H:i:s');
} }
$dateFinish = new \DateTime();
$orderHistory = $api->orderHistory($dateStart); $orderHistory = $api->orderHistory($dateStart);
$dateStart = new \DateTime($dateStart);
// pushing existing orders // pushing existing orders
foreach ($orderHistory as $order) { foreach ($orderHistory as $order) {
@ -866,11 +866,13 @@ class ICrmOrderActions
// set PAYED // set PAYED
if($optionsPayment[$order['paymentStatus']]) if($optionsPayment[$order['paymentStatus']])
CSaleOrder::PayOrder($order['externalId'], $optionsPayment[$order['paymentStatus']]); CSaleOrder::PayOrder($order['externalId'], $optionsPayment[$order['paymentStatus']]);
$dateStart = new \DateTime();
} }
} }
if(count($orderHistory)) if(count($orderHistory))
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY_DATE, $dateFinish->format('Y-m-d H:i:s')); COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY_DATE, $dateStart->format('Y-m-d H:i:s'));
$USER->Logout(); $USER->Logout();
if($realUser) $USER->Authorize($realUser); if($realUser) $USER->Authorize($realUser);

View File

@ -59,6 +59,9 @@ class ICrmOrderEvent {
* @param mixed $arFields - Order arFields for sending template * @param mixed $arFields - Order arFields for sending template
*/ */
function onSendOrderMail($ID, &$eventName, &$arFields) { function onSendOrderMail($ID, &$eventName, &$arFields) {
if(isset($GLOBALS['INTARO_CRM_FROM_HISTORY']) && $GLOBALS['INTARO_CRM_FROM_HISTORY'])
return;
if(self::writeDataOnOrderCreate($ID)) if(self::writeDataOnOrderCreate($ID))
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, $ID); COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, $ID);
else { else {
@ -160,6 +163,9 @@ class ICrmOrderEvent {
* @return boolean * @return boolean
*/ */
function onSaleCancelOrder($ID, $cancel, $reason) { function onSaleCancelOrder($ID, $cancel, $reason) {
if(isset($GLOBALS['INTARO_CRM_FROM_HISTORY']) && $GLOBALS['INTARO_CRM_FROM_HISTORY'])
return;
if(!$ID || !$cancel) if(!$ID || !$cancel)
return true; return true;
@ -223,6 +229,9 @@ class ICrmOrderEvent {
* @return boolean * @return boolean
*/ */
function onSalePayOrder($ID, $payed) { function onSalePayOrder($ID, $payed) {
if(isset($GLOBALS['INTARO_CRM_FROM_HISTORY']) && $GLOBALS['INTARO_CRM_FROM_HISTORY'])
return;
if(!$ID || !$payed || ($payed != 'Y')) if(!$ID || !$payed || ($payed != 'Y'))
return true; return true;
@ -259,7 +268,6 @@ class ICrmOrderEvent {
$api->orderEdit($order); $api->orderEdit($order);
// error pushing order // error pushing order
if ($api->getStatusCode() != 201) if ($api->getStatusCode() != 201)
ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'IntaroCrm\RestApi::orderEdit', $api->getLastError()); ICrmOrderActions::eventLog('ICrmOrderEvent::onSalePayOrder', 'IntaroCrm\RestApi::orderEdit', $api->getLastError());

View File

@ -1,5 +1,5 @@
<? <?
$arModuleVersion = array( $arModuleVersion = array(
"VERSION" => "1.0.1", "VERSION" => "0.5.3",
"VERSION_DATE" => "2014-03-13 11:57:00", "VERSION_DATE" => "2014-01-28 12:55:00",
); );