diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index d47064b0..9ec6299f 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -646,7 +646,7 @@ class ICrmOrderActions if(isset($arParams['optionsSites']) && is_array($arParams['optionsSites']) && in_array($arFields['LID'], $arParams['optionsSites'])) $resOrder['site'] = $arFields['LID']; - + // parse fio if(count($contactNameArr) == 1) { $resOrder['firstName'] = $contactNameArr[0]; @@ -655,8 +655,10 @@ class ICrmOrderActions $resOrder['firstName'] = $contactNameArr[1]; $resOrder['patronymic'] = $contactNameArr[2]; } - + $resOrder = self::clearArr($resOrder); + + self::eventLog('ICrmOrderActions::orderHistory', 'iblock', json_encode($resOrder)); if($send) return $api->orderEdit($resOrder); @@ -729,4 +731,22 @@ class ICrmOrderActions return $newArray; } + + public static function addOrderProperty($code, $value, $order) { + if (!$code) + return; + + if (!CModule::IncludeModule('sale')) + return; + + if ($arProp = CSaleOrderProps::GetList(array(), array('CODE' => $code))->Fetch()) { + return CSaleOrderPropsValue::Add(array( + 'NAME' => $arProp['NAME'], + 'CODE' => $arProp['CODE'], + 'ORDER_PROPS_ID' => $arProp['ID'], + 'ORDER_ID' => $order, + 'VALUE' => $value, + )); + } + } } \ No newline at end of file diff --git a/intaro.intarocrm/description.ru b/intaro.intarocrm/description.ru deleted file mode 100644 index e7c53b7d..00000000 --- a/intaro.intarocrm/description.ru +++ /dev/null @@ -1,4 +0,0 @@ -* Доработан скрипт генерации ICML-файла в части работы со спецсимволами -* Добавлена поддержка многосайтовости -* Добавлена возможность выгрузки способов доставки на втором шаге установки -* Проверка временной зоны перед установкой \ No newline at end of file diff --git a/intaro.intarocrm/include.php b/intaro.intarocrm/include.php new file mode 100755 index 00000000..933ef5fa --- /dev/null +++ b/intaro.intarocrm/include.php @@ -0,0 +1,10 @@ + 'classes/general/RestApi.php', + 'ICrmOrderActions' => 'classes/general/ICrmOrderActions.php', + 'ICMLLoader' => 'classes/general/ICMLLoader.php', + 'ICrmOrderEvent' => 'classes/general/events/ICrmOrderEvent.php' + ) +); \ No newline at end of file diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index b6005234..2979d7b9 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -32,6 +32,7 @@ class intaro_intarocrm extends CModule { var $CRM_ORDER_LAST_ID = 'order_last_id'; var $CRM_ORDER_SITES = 'sites_ids'; var $CRM_ORDER_PROPS = 'order_props'; + var $CRM_ORDER_DISCHARGE = 'order_discharge'; var $INSTALL_PATH; function intaro_intarocrm() { @@ -67,7 +68,6 @@ class intaro_intarocrm extends CModule { } } - if (!date_default_timezone_get()) { if (!ini_get('date.timezone')) { $APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR")); @@ -714,6 +714,7 @@ class intaro_intarocrm extends CModule { COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT_STATUSES, serialize($paymentStatusesArr)); COption::SetOptionString($this->MODULE_ID, $this->CRM_PAYMENT, serialize($paymentArr)); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0); + COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 0); $APPLICATION->IncludeAdminFile( GetMessage('MODULE_INSTALL_TITLE'), @@ -866,8 +867,7 @@ class intaro_intarocrm extends CModule { $arResult['errCode'] = 'ERR_FIELDS_FILE'; if (isset($arResult['errCode']) && $arResult['errCode']) { - - + $arOldValues = Array( 'IBLOCK_EXPORT' => $iblocks, 'IBLOCK_PROPERTY_ARTICLE' => $articleProperties, @@ -1034,6 +1034,7 @@ class intaro_intarocrm extends CModule { global $APPLICATION; CAgent::RemoveAgent("ICrmOrderActions::uploadOrdersAgent();", $this->MODULE_ID); + CAgent::RemoveAgent("ICrmOrderActions::orderHistoryAgent();", $this->MODULE_ID); COption::RemoveOption($this->MODULE_ID, $this->CRM_API_HOST_OPTION); COption::RemoveOption($this->MODULE_ID, $this->CRM_API_KEY_OPTION); @@ -1044,6 +1045,7 @@ class intaro_intarocrm extends CModule { COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_LAST_ID); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_SITES); COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_PROPS); + COption::RemoveOption($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE); 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 3ce0ef26..a394538c 100755 --- a/intaro.intarocrm/options.php +++ b/intaro.intarocrm/options.php @@ -245,17 +245,18 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { RegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail"); RegisterModuleDependences("sale", "OnOrderUpdate", $mid, "ICrmOrderEvent", "onUpdateOrder"); - $orderPropsArr = array(); - foreach ($orderTypesList as $orderType) { - $propsCount = 0; - $_orderPropsArr = array(); - foreach ($arResult['orderProps'] as $orderProp) { - if ((!(int) htmlspecialchars(trim($_POST['address-detail-' . $orderType['ID']]))) && $propsCount > 5) - break; - $_orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID'] . '-' . $orderType['ID']])); - $propsCount++; + $orderPropsArr = array(); + foreach ($orderTypesList as $orderType) { + $propsCount = 0; + $_orderPropsArr = array(); + foreach ($arResult['orderProps'] as $orderProp) { + if ((!(int) htmlspecialchars(trim($_POST['address-detail-' . $orderType['ID']]))) && $propsCount > 5) + break; + $_orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID'] . '-' . $orderType['ID']])); + $propsCount++; + } + $orderPropsArr[$orderType['ID']] = $_orderPropsArr; } - $orderPropsArr[$orderType['ID']] = $_orderPropsArr; } COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize($orderTypesArr)); @@ -407,15 +408,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { ), array( "DIV" => "edit3", - "TAB" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_TAB'), - "ICON" => '', - "TITLE" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_CAPTION') - ), - array( - "DIV" => "edit4", "TAB" => GetMessage('ICRM_OPTIONS_ORDER_PROPS_TAB'), "ICON" => '', "TITLE" => GetMessage('ICRM_OPTIONS_ORDER_PROPS_CAPTION') + ), + array( + "DIV" => "edit4", + "TAB" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_TAB'), + "ICON" => '', + "TITLE" => GetMessage('ICRM_OPTIONS_ORDER_DISCHARGE_CAPTION') ) ); $tabControl = new CAdminTabControl("tabControl", $aTabs); @@ -453,7 +454,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {