diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index 9d0542c4..c4c38e41 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -11,6 +11,7 @@ class ICrmOrderActions protected static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; protected static $CRM_PAYMENT = 'payment_arr'; //order payment Y/N protected static $CRM_ORDER_LAST_ID = 'order_last_id'; + protected static $CRM_ORDER_PROPS = 'order_props'; /** * Mass order uploading, without repeating; always returns true, but writes error log @@ -54,6 +55,7 @@ class ICrmOrderActions $optionsPayTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_TYPES, 0)); $optionsPayStatuses = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0)); // --statuses $optionsPayment = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT, 0)); + $optionsOrderProps = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_PROPS, 0)); $api = new IntaroCrm\RestApi($api_host, $api_key); @@ -62,7 +64,8 @@ class ICrmOrderActions 'optionsDelivTypes' => $optionsDelivTypes, 'optionsPayTypes' => $optionsPayTypes, 'optionsPayStatuses' => $optionsPayStatuses, - 'optionsPayment' => $optionsPayment + 'optionsPayment' => $optionsPayment, + 'optionsOrderProps' => $optionsOrderProps ); // pack mode enable / disable @@ -251,22 +254,31 @@ class ICrmOrderActions $rsOrderProps = CSaleOrderPropsValue::GetList(array(), array('ORDER_ID' => $arFields['ID'])); while ($ar = $rsOrderProps->Fetch()) { switch ($ar['CODE']) { - case 'ZIP': $resOrderDeliveryAddress['index'] = self::toJSON($ar['VALUE']); + case $arParams['optionsOrderProps']['index']: $resOrderDeliveryAddress['index'] = self::toJSON($ar['VALUE']); break; - case 'CITY': $resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']); + case $arParams['optionsOrderProps']['city']: if ($arParams['optionsOrderProps']['index'] == 'LOCATION') { + if (!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city']) { + $resOrderDeliveryAddress['city'] = CSaleLocation::GetByID($ar['VALUE']); + $resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']); + } + } else + $resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']); break; - case 'ADDRESS': $resOrderDeliveryAddress['text'] = self::toJSON($ar['VALUE']); + case 'CITY': if (!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city']) + $resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']); // we check both locations & city for export break; - case 'LOCATION': if(!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city']) { + case $arParams['optionsOrderProps']['text']: $resOrderDeliveryAddress['text'] = self::toJSON($ar['VALUE']); + break; + case 'LOCATION': if (!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city']) { $resOrderDeliveryAddress['city'] = CSaleLocation::GetByID($ar['VALUE']); $resOrderDeliveryAddress['city'] = self::toJSON($resOrderDeliveryAddress['city']['CITY_NAME_LANG']); } break; - case 'FIO': $resOrder['contactName'] = explode(" ", self::toJSON($ar['VALUE'])); + case $arParams['optionsOrderProps']['fio']: $resOrder['contactName'] = explode(" ", self::toJSON($ar['VALUE'])); break; - case 'PHONE': $resOrder['phone'] = $ar['VALUE']; + case $arParams['optionsOrderProps']['phone']: $resOrder['phone'] = $ar['VALUE']; break; - case 'EMAIL': $resOrder['email'] = $ar['VALUE']; + case $arParams['optionsOrderProps']['email']: $resOrder['email'] = $ar['VALUE']; break; } } diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 6250d562..6bf27495 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -30,6 +30,7 @@ class intaro_intarocrm extends CModule var $CRM_PAYMENT_STATUSES = 'pay_statuses_arr'; var $CRM_PAYMENT = 'payment_arr'; //order payment Y/N var $CRM_ORDER_LAST_ID = 'order_last_id'; + var $CRM_ORDER_PROPS = 'order_props'; var $INSTALL_PATH; @@ -363,6 +364,16 @@ class intaro_intarocrm extends CModule $paymentArr = array(); $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); + + // orderProps assoc arr + $orderPropsArr = array( + 'city' => 'CITY', + 'fio' => 'FIO', + 'index' => 'ZIP', + 'text' => 'ADDRESS', + 'phone' => 'PHONE', + 'email' => 'EMAIL' + ); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_TYPES_ARR, serialize($orderTypesArr)); COption::SetOptionString($this->MODULE_ID, $this->CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr)); @@ -370,6 +381,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_PROPS, serialize($orderPropsArr)); $APPLICATION->IncludeAdminFile( GetMessage('MODULE_INSTALL_TITLE'), diff --git a/intaro.intarocrm/lang/ru/options.php b/intaro.intarocrm/lang/ru/options.php index 473cf341..6def8ea0 100755 --- a/intaro.intarocrm/lang/ru/options.php +++ b/intaro.intarocrm/lang/ru/options.php @@ -1,6 +1,7 @@ GetMessage('CANCELED') ); + $dbProp = CSaleOrderProps::GetList(array(), array()); + //bitrix pyament Y/N $arResult['bitrixPaymentList'][0]['NAME'] = GetMessage('PAYMENT_Y'); $arResult['bitrixPaymentList'][0]['ID'] = 'Y'; $arResult['bitrixPaymentList'][1]['NAME'] = GetMessage('PAYMENT_N'); $arResult['bitrixPaymentList'][1]['ID'] = 'N'; + while ($arProp = $dbProp->GetNext()) { + $arResult['arProp'][] = $arProp; + } + //saved cat params $optionsOrderTypes = unserialize(COption::GetOptionString($mid, $CRM_ORDER_TYPES_ARR, 0)); $optionsDelivTypes = unserialize(COption::GetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, 0)); $optionsPayTypes = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_TYPES, 0)); $optionsPayStatuses = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_STATUSES, 0)); // --statuses $optionsPayment = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT, 0)); - + $optionsOrderProps = unserialize(COption::GetOptionString($mid, $CRM_ORDER_PROPS, 0)); + $aTabs = array( array( "DIV" => "edit1", @@ -263,6 +287,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { "ICON" => '', "TITLE" => GetMessage('ICRM_OPTIONS_CATALOG_CAPTION') ), + array( + "DIV" => "edit3", + "TAB" => GetMessage('ICRM_OPTIONS_ORDER_PROPS_TAB'), + "ICON" => '', + "TITLE" => GetMessage('ICRM_OPTIONS_ORDER_PROPS_CAPTION') + ), ); $tabControl = new CAdminTabControl("tabControl", $aTabs); $tabControl->Begin(); @@ -390,6 +420,28 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { +BeginNextTab(); ?> + + + + + + + + + + + + + + BeginNextTab(); ?> Buttons(); ?>