From 6603923d5304f6b8b8cb9734b3ae1349a7b6cf21 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Tue, 29 Oct 2013 19:16:32 +0400 Subject: [PATCH] cancel status fix --- .../classes/general/ICrmOrderActions.php | 8 ++-- .../classes/general/events/ICrmOrderEvent.php | 3 +- intaro.intarocrm/install/index.php | 38 +++++++++---------- intaro.intarocrm/options.php | 20 +++++----- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index 06749116..8f498638 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -676,7 +676,7 @@ class ICrmOrderActions if(!$api || empty($arParams)) { // add cond to check $arParams return false; } - + if (empty($arFields)) { //handle err self::eventLog('ICrmOrderActions::orderCreate', 'empty($arFields)', 'incorrect order'); @@ -803,9 +803,9 @@ class ICrmOrderActions $p['DISCOUNT_PRICE'] = null; $items[] = array( - 'initialPrice' => (double) $p['PRICE'] + (double) $p['DISCOUNT_PRICE'], + 'initialPrice' => (double) $p['PRICE'] + (double) $p['DISCOUNT_PRICE'], 'purchasePrice' => $pr, - 'discount' => $p['DISCOUNT_PRICE'], + 'discount' => $p['DISCOUNT_PRICE'], 'discountPercent' => $p['DISCOUNT_VALUE'], 'quantity' => $p['QUANTITY'], 'productId' => $p['PRODUCT_ID'], @@ -814,7 +814,7 @@ class ICrmOrderActions } if($arFields['CANCELED'] == 'Y') - $arFields['STATUS_ID'] = $arFields['CANCELED']; + $arFields['STATUS_ID'] = $arFields['CANCELED'].$arFields['CANCELED']; $createdAt = new \DateTime($arFields['DATE_INSERT']); $createdAt = $createdAt->format('Y-m-d H:i:s'); diff --git a/intaro.intarocrm/classes/general/events/ICrmOrderEvent.php b/intaro.intarocrm/classes/general/events/ICrmOrderEvent.php index cead90e0..083ce94f 100644 --- a/intaro.intarocrm/classes/general/events/ICrmOrderEvent.php +++ b/intaro.intarocrm/classes/general/events/ICrmOrderEvent.php @@ -122,6 +122,7 @@ class ICrmOrderEvent { $arOrder = CSaleOrder::GetById($ID); if (is_array($arFields) && !empty($arFields)) { + $arFieldsNew = array( 'USER_ID' => $arOrder['USER_ID'], 'ID' => $ID, @@ -185,7 +186,7 @@ class ICrmOrderEvent { $order = array( 'externalId' => (int) $ID, - 'status' => $optionsPayStatuses[$cancel], + 'status' => $optionsPayStatuses[$cancel.$cancel], 'statusComment' => ICrmOrderActions::toJSON($reason) ); diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 554ffed3..02171659 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -2,8 +2,8 @@ /** * Module Install/Uninstall script - * Module name: intaro.intarocrm - * Class name: intaro_intarocrm + * Module name: intaro.intarocrm + * Class name: intaro_intarocrm */ global $MESS; IncludeModuleLangFile(__FILE__); @@ -34,7 +34,6 @@ class intaro_intarocrm extends CModule { var $CRM_ORDER_PROPS = 'order_props'; var $CRM_ORDER_DISCHARGE = 'order_discharge'; var $CRM_ORDER_FAILED_IDS = 'order_failed_ids'; - var $CRM_ORDER_HISTORY_DATE = 'order_history_date'; var $INSTALL_PATH; function intaro_intarocrm() { @@ -278,7 +277,7 @@ class intaro_intarocrm extends CModule { ); //form payment statuses ids arr - $paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y'])); + $paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY'])); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { do { $arResult['bitrixPaymentStatusesList'][] = $arPaymentStatusesList; @@ -287,7 +286,7 @@ class intaro_intarocrm extends CModule { } $arResult['bitrixPaymentStatusesList'][] = array( - 'ID' => 'Y', + 'ID' => 'YY', 'NAME' => GetMessage('CANCELED') ); @@ -441,6 +440,7 @@ class intaro_intarocrm extends CModule { // form correct url $api_host = parse_url($api_host); + if($api_host['scheme'] != 'https') $api_host['scheme'] = 'https'; $api_host = $api_host['scheme'] . '://' . $api_host['host']; if (!$api_host || !$api_key) { @@ -545,7 +545,7 @@ class intaro_intarocrm extends CModule { } $arResult['bitrixPaymentStatusesList'][] = array( - 'ID' => 'Y', + 'ID' => 'YY', 'NAME' => GetMessage('CANCELED') ); @@ -676,7 +676,7 @@ class intaro_intarocrm extends CModule { ); //form payment statuses ids arr - $paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y'])); + $paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY'])); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { do { @@ -703,7 +703,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, 0); 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'), @@ -915,15 +914,15 @@ class intaro_intarocrm extends CModule { } $ar = $this->GetProfileSetupVars($iblocks, $propertiesProduct, $propertiesSKU, $filename); $PROFILE_ID = CCatalogExport::Add(array( - "LAST_USE" => false, - "FILE_NAME" => $this->INTARO_CRM_EXPORT, - "NAME" => $profileName, + "LAST_USE" => false, + "FILE_NAME" => $this->INTARO_CRM_EXPORT, + "NAME" => $profileName, "DEFAULT_PROFILE" => "N", - "IN_MENU" => "N", - "IN_AGENT" => "N", - "IN_CRON" => "N", - "NEED_EDIT" => "N", - "SETUP_VARS" => $ar + "IN_MENU" => "N", + "IN_AGENT" => "N", + "IN_CRON" => "N", + "NEED_EDIT" => "N", + "SETUP_VARS" => $ar )); if (intval($PROFILE_ID) <= 0) { $arResult['errCode'] = 'ERR_IBLOCK'; @@ -936,7 +935,7 @@ class intaro_intarocrm extends CModule { $dateAgent->add($intAgent); CAgent::AddAgent( "CCatalogExport::PreGenerateExport(" . $PROFILE_ID . ");", "catalog", "N", 86400, $dateAgent->format('d.m.Y H:i:s'), // date of first check - "Y", // агент активен + "Y", // àãåíò àêòèâåí $dateAgent->format('d.m.Y H:i:s'), // date of first start 30 ); @@ -1008,7 +1007,7 @@ class intaro_intarocrm extends CModule { CAgent::AddAgent( "ICrmOrderActions::uploadOrdersAgent();", $this->MODULE_ID, "N", 600, // interval - 10 mins $dateAgent->format('d.m.Y H:i:s'), // date of first check - "Y", // агент активен + "Y", // àãåíò àêòèâåí $dateAgent->format('d.m.Y H:i:s'), // date of first start 30 ); @@ -1019,7 +1018,7 @@ class intaro_intarocrm extends CModule { "N", 600, // interval - 10 mins $dateAgent->format('d.m.Y H:i:s'), // date of first check - "Y", // агент активен + "Y", // àãåíò àêòèâåí $dateAgent->format('d.m.Y H:i:s'), // date of first start 30 ); @@ -1053,7 +1052,6 @@ class intaro_intarocrm extends CModule { COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_PROPS); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS); - COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_HISTORY_DATE); UnRegisterModuleDependences("sale", "OnSalePayOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSalePayOrder"); UnRegisterModuleDependences("sale", "OnSaleCancelOrder", $this->MODULE_ID, "ICrmOrderEvent", "onSaleCancelOrder"); diff --git a/intaro.intarocrm/options.php b/intaro.intarocrm/options.php index b5004e13..aa6c59f9 100755 --- a/intaro.intarocrm/options.php +++ b/intaro.intarocrm/options.php @@ -116,7 +116,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { COption::SetOptionString($mid, 'api_key', $api_key); } } - + //bitrix orderTypesList -- personTypes $dbOrderTypesList = CSalePersonType::GetList( array( @@ -140,7 +140,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $orderTypesList[] = $arOrderTypesList; } while ($arOrderTypesList = $dbOrderTypesList->Fetch()); } - + //bitrix deliveryTypesList $dbDeliveryTypesList = CSaleDelivery::GetList( array( @@ -162,7 +162,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $deliveryTypesArr[$arDeliveryTypesList['ID']] = htmlspecialchars(trim($_POST['delivery-type-' . $arDeliveryTypesList['ID']])); } while ($arDeliveryTypesList = $dbDeliveryTypesList->Fetch()); } - + //bitrix paymentTypesList $dbPaymentTypesList = CSalePaySystem::GetList( array( @@ -195,7 +195,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { ); //form payment statuses ids arr - $paymentStatusesArr['Y'] = htmlspecialchars(trim($_POST['payment-status-Y'])); + $paymentStatusesArr['YY'] = htmlspecialchars(trim($_POST['payment-status-YY'])); if ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()) { do { $paymentStatusesArr[$arPaymentStatusesList['ID']] = htmlspecialchars(trim($_POST['payment-status-' . $arPaymentStatusesList['ID']])); @@ -350,7 +350,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { } while ($arPaymentStatusesList = $dbPaymentStatusesList->Fetch()); } $arResult['bitrixPaymentStatusesList'][] = array( - 'ID' => 'Y', + 'ID' => 'YY', 'NAME' => GetMessage('CANCELED') ); @@ -457,7 +457,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { - + + + +