From 89356392654bdb3d376bea9cff87490ba9ed0916 Mon Sep 17 00:00:00 2001 From: Grisha Pomadchin Date: Fri, 2 Aug 2013 17:05:12 +0400 Subject: [PATCH] working props order settings --- .../classes/general/ICrmOrderActions.php | 33 ++++++-- intaro.intarocrm/install/index.php | 1 - intaro.intarocrm/install/version.php~ | 5 ++ intaro.intarocrm/lang/ru/options.php | 15 +++- intaro.intarocrm/options.php | 75 +++++++++++++++---- 5 files changed, 104 insertions(+), 25 deletions(-) create mode 100755 intaro.intarocrm/install/version.php~ diff --git a/intaro.intarocrm/classes/general/ICrmOrderActions.php b/intaro.intarocrm/classes/general/ICrmOrderActions.php index c4c38e41..d1327776 100755 --- a/intaro.intarocrm/classes/general/ICrmOrderActions.php +++ b/intaro.intarocrm/classes/general/ICrmOrderActions.php @@ -256,14 +256,6 @@ class ICrmOrderActions switch ($ar['CODE']) { case $arParams['optionsOrderProps']['index']: $resOrderDeliveryAddress['index'] = self::toJSON($ar['VALUE']); break; - 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 'CITY': if (!isset($resOrderDeliveryAddress['city']) && !$resOrderDeliveryAddress['city']) $resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']); // we check both locations & city for export break; @@ -281,6 +273,31 @@ class ICrmOrderActions case $arParams['optionsOrderProps']['email']: $resOrder['email'] = $ar['VALUE']; break; } + + if (count($arParams['optionsOrderProps'] > 5)) { + switch ($ar['CODE']) { + case $arParams['optionsOrderProps']['country']: $resOrderDeliveryAddress['country'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['region']: $resOrderDeliveryAddress['region'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['city']: $resOrderDeliveryAddress['city'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['street']: $resOrderDeliveryAddress['street'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['building']: $resOrderDeliveryAddress['building'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['flat']: $resOrderDeliveryAddress['flat'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['inercomcode']: $resOrderDeliveryAddress['intercomcode'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['floor']: $resOrderDeliveryAddress['floor'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['block']: $resOrderDeliveryAddress['block'] = self::toJSON($ar['VALUE']); + break; + case $arParams['optionsOrderProps']['house']: $resOrderDeliveryAddress['house'] = self::toJSON($ar['VALUE']); + break; + } + } } $items = array(); diff --git a/intaro.intarocrm/install/index.php b/intaro.intarocrm/install/index.php index 6bf27495..84b38aff 100755 --- a/intaro.intarocrm/install/index.php +++ b/intaro.intarocrm/install/index.php @@ -367,7 +367,6 @@ class intaro_intarocrm extends CModule // orderProps assoc arr $orderPropsArr = array( - 'city' => 'CITY', 'fio' => 'FIO', 'index' => 'ZIP', 'text' => 'ADDRESS', diff --git a/intaro.intarocrm/install/version.php~ b/intaro.intarocrm/install/version.php~ new file mode 100755 index 00000000..b0b13837 --- /dev/null +++ b/intaro.intarocrm/install/version.php~ @@ -0,0 +1,5 @@ + '0.4.6', + 'VERSION_DATE' => '2013-07-25 15:35:00', +); diff --git a/intaro.intarocrm/lang/ru/options.php b/intaro.intarocrm/lang/ru/options.php index 6def8ea0..4237d5cf 100755 --- a/intaro.intarocrm/lang/ru/options.php +++ b/intaro.intarocrm/lang/ru/options.php @@ -26,8 +26,19 @@ $MESS ['CANCELED'] = 'Флаг «Отменен»'; $MESS ['ORDER_PROPS'] = 'Настройки соответствия полей заказа IntaroCRM свойствам заказа 1С-Битрикс'; $MESS ['FIO'] = 'ф.И.О.'; -$MESS ['CITY'] = 'Город'; $MESS ['ZIP'] = 'Индекс'; $MESS ['ADDRESS'] = 'Адрес (строкой)'; $MESS ['PHONE'] = 'Телефон'; -$MESS ['EMAIL'] = 'E-mail'; \ No newline at end of file +$MESS ['EMAIL'] = 'E-mail'; +$MESS ['COUNTRY'] = 'Страна'; +$MESS ['REGION'] = 'Область / Край'; +$MESS ['CITY'] = 'Город'; +$MESS ['STREET'] = 'Улица'; +$MESS ['BUILDING'] = 'Строение'; +$MESS ['FLAT'] = 'Квартира'; +$MESS ['INTERCOMCODE'] = 'Домофон'; +$MESS ['FLOOR'] = 'Этаж'; +$MESS ['BLOCK'] = 'Подъезд'; +$MESS ['HOUSE'] = 'Строение / корпус'; +$MESS ['ADDRESS_SHORT'] = 'Краткий адрес'; +$MESS ['ADDRESS_FULL'] = 'Детальный адрес'; \ No newline at end of file diff --git a/intaro.intarocrm/options.php b/intaro.intarocrm/options.php index edf81a90..534c89f1 100755 --- a/intaro.intarocrm/options.php +++ b/intaro.intarocrm/options.php @@ -26,16 +26,35 @@ if($_GET['ok'] && $_GET['ok'] == 'Y') echo CAdminMessage::ShowNote(GetMessage('I $arResult = array(); $arResult['orderProps'][0]['NAME'] = GetMessage('FIO'); $arResult['orderProps'][0]['ID'] = 'fio'; -$arResult['orderProps'][1]['NAME'] = GetMessage('CITY'); -$arResult['orderProps'][1]['ID'] = 'city'; -$arResult['orderProps'][2]['NAME'] = GetMessage('ZIP'); -$arResult['orderProps'][2]['ID'] = 'index'; -$arResult['orderProps'][3]['NAME'] = GetMessage('ADDRESS'); -$arResult['orderProps'][3]['ID'] = 'text'; -$arResult['orderProps'][4]['NAME'] = GetMessage('PHONE'); -$arResult['orderProps'][4]['ID'] = 'phone'; -$arResult['orderProps'][5]['NAME'] = GetMessage('EMAIL'); -$arResult['orderProps'][5]['ID'] = 'email'; +$arResult['orderProps'][1]['NAME'] = GetMessage('ZIP'); +$arResult['orderProps'][1]['ID'] = 'index'; +$arResult['orderProps'][2]['NAME'] = GetMessage('PHONE'); +$arResult['orderProps'][2]['ID'] = 'phone'; +$arResult['orderProps'][3]['NAME'] = GetMessage('EMAIL'); +$arResult['orderProps'][3]['ID'] = 'email'; +// address +$arResult['orderProps'][4]['NAME'] = GetMessage('ADDRESS'); +$arResult['orderProps'][4]['ID'] = 'text'; +$arResult['orderProps'][5]['NAME'] = GetMessage('COUNTRY'); +$arResult['orderProps'][5]['ID'] = 'country'; +$arResult['orderProps'][6]['NAME'] = GetMessage('REGION'); +$arResult['orderProps'][6]['ID'] = 'region'; +$arResult['orderProps'][7]['NAME'] = GetMessage('CITY'); +$arResult['orderProps'][7]['ID'] = 'city'; +$arResult['orderProps'][8]['NAME'] = GetMessage('STREET'); +$arResult['orderProps'][8]['ID'] = 'street'; +$arResult['orderProps'][9]['NAME'] = GetMessage('BUILDING'); +$arResult['orderProps'][9]['ID'] = 'building'; +$arResult['orderProps'][10]['NAME'] = GetMessage('FLAT'); +$arResult['orderProps'][10]['ID'] = 'flat'; +$arResult['orderProps'][11]['NAME'] = GetMessage('INTERCOMCODE'); +$arResult['orderProps'][11]['ID'] = 'intercomecode'; +$arResult['orderProps'][12]['NAME'] = GetMessage('FLOOR'); +$arResult['orderProps'][12]['ID'] = 'floor'; +$arResult['orderProps'][13]['NAME'] = GetMessage('BLOCK'); +$arResult['orderProps'][13]['ID'] = 'block'; +$arResult['orderProps'][14]['NAME'] = GetMessage('HOUSE'); +$arResult['orderProps'][14]['ID'] = 'house'; //update connection settings if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { @@ -145,8 +164,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $paymentArr['Y'] = htmlspecialchars(trim($_POST['payment-Y'])); $paymentArr['N'] = htmlspecialchars(trim($_POST['payment-N'])); - foreach($arResult['orderProps'] as $orderProp) + $propsCount = 0; + foreach($arResult['orderProps'] as $orderProp) { + if((!(int) htmlspecialchars(trim($_POST['address-detail']))) && $propsCount > 4) + break; $orderPropsArr[$orderProp['ID']] = htmlspecialchars(trim($_POST['order-prop-' . $orderProp['ID']])); + $propsCount++; + } COption::SetOptionString($mid, $CRM_ORDER_TYPES_ARR, serialize($orderTypesArr)); COption::SetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, serialize($deliveryTypesArr)); @@ -297,6 +321,19 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $tabControl = new CAdminTabControl("tabControl", $aTabs); $tabControl->Begin(); ?> +AddHeadString(''); ?> + +
- - + + + + + + > + 5) echo "checked"; ?>> + + + + + 4) echo 'class="address-detail"'; if(($countProps > 4) && (count($optionsOrderProps) < 6)) echo 'style="display:none;"';?>> @@ -441,7 +488,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { - + BeginNextTab(); ?> Buttons(); ?>