From a0005e1ff8bccf1a9bb987351263ef758b4286a3 Mon Sep 17 00:00:00 2001 From: Uryvskiy Dima Date: Wed, 18 Oct 2023 16:16:35 +0300 Subject: [PATCH] =?UTF-8?q?ref=20#92177=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D1=87=D0=B0=20=D0=B0=D0=B4=D1=80=D0=B5=D1=81=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=82=D0=B0=20=D1=81=D0=B0=D0=BC=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=BE=D0=B7=D0=B0=20=D0=B2=20=D0=B7=D0=B0=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D0=B5=20=D0=B8=D0=B7=20Bitrix=20=D0=B2=20CRM=20(#3?= =?UTF-8?q?17)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 + .../general/order/RetailCrmOrder_v5.php | 16 +++-- .../general/services/BitrixOrderService.php | 50 ++++++++++++++++ .../general/services/RetailCrmService.php | 18 ------ intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 4 +- .../general/history/RetailCrmHistory_v4.php | 4 -- .../general/services/BitrixOrderService.php | 3 + intaro.retailcrm/lang/en/options.php | 2 + .../general/history/RetailCrmHistory_v4.php | 4 -- .../general/services/BitrixOrderService.php | 3 + intaro.retailcrm/lang/ru/options.php | 2 + .../lib/component/configprovider.php | 5 ++ intaro.retailcrm/lib/component/constants.php | 1 + intaro.retailcrm/options.php | 58 ++++++++++++++----- 15 files changed, 129 insertions(+), 46 deletions(-) create mode 100644 intaro.retailcrm/classes/general/services/BitrixOrderService.php delete mode 100644 intaro.retailcrm/lang/en/classes/general/history/RetailCrmHistory_v4.php create mode 100644 intaro.retailcrm/lang/en/classes/general/services/BitrixOrderService.php delete mode 100644 intaro.retailcrm/lang/ru/classes/general/history/RetailCrmHistory_v4.php create mode 100644 intaro.retailcrm/lang/ru/classes/general/services/BitrixOrderService.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 0929c39a..ff22aa3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-10-17 v.6.4.8 +- Добавлена передача адреса пункта самовывоза в заказе из Bitrix в CRM + ## 2023-10-10 v.6.4.7 - Изменена логика передачи адреса доставки в заказе из Bitrix в CRM diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index 25bb1c23..5292c5f3 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -120,8 +120,7 @@ class RetailCrmOrder $order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arOrder['PERSON_TYPE_ID']]; - - $countryList = RetailCrmService::getCountryList(); + $countryList = BitrixOrderService::getCountryList(); $deliveryAddress = ['city' => '', 'text' => '', 'index' => '', 'region' => '', 'countryIso' => '']; //Order fields @@ -175,10 +174,19 @@ class RetailCrmOrder } } - // Clear empty fields + // Удаляем пустые значения $deliveryAddress = array_filter($deliveryAddress); - if (!empty($deliveryAddress)) { + // Пункт самовывоза + $pickupPointAddress = ''; + + if (RetailcrmConfigProvider::needSendPickupPointAddress() === 'Y') { + $pickupPointAddress = BitrixOrderService::getPickupPointAddress($arOrder); + } + + if ($pickupPointAddress !== '') { + $order['delivery']['address']['text'] = $pickupPointAddress; + } elseif(!empty($deliveryAddress)) { $order['delivery']['address'] = $deliveryAddress; } diff --git a/intaro.retailcrm/classes/general/services/BitrixOrderService.php b/intaro.retailcrm/classes/general/services/BitrixOrderService.php new file mode 100644 index 00000000..f0f3c9ae --- /dev/null +++ b/intaro.retailcrm/classes/general/services/BitrixOrderService.php @@ -0,0 +1,50 @@ +getServer()->getDocumentRoot(); + $countryList = []; + + if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) { + $countryFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml'); + + foreach ($countryFile->country as $country) { + $countryList[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha; + } + } + + return $countryList; + } + + public static function getPickupPointAddress($arOrder) + { + $address = ''; + $orderInfo = Order::load($arOrder['ID']); + + foreach ($orderInfo->getShipmentCollection() as $store) { + $storeId = $store->getStoreId(); + + if ($storeId) { + $arStore = StoreTable::getRow([ + 'filter' => [ + 'ID' => $storeId, + ] + ]); + + if (!empty($arStore['ADDRESS'])) { + $address = GetMessage('PICKUP_POINT') . $arStore['ADDRESS']; + + break; + } + } + } + + return $address; + } +} diff --git a/intaro.retailcrm/classes/general/services/RetailCrmService.php b/intaro.retailcrm/classes/general/services/RetailCrmService.php index 2978eb6f..58081426 100644 --- a/intaro.retailcrm/classes/general/services/RetailCrmService.php +++ b/intaro.retailcrm/classes/general/services/RetailCrmService.php @@ -1,7 +1,5 @@ getServer()->getDocumentRoot(); - $countryList = []; - - if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) { - $countryFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml'); - - foreach ($countryFile->country as $country) { - $countryList[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha; - } - } - - return $countryList; - } } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 6d3d910a..b526db0b 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Изменена логика передачи адреса доставки в заказе из Bitrix в CRM +- Добавлена передача адреса пункта самовывоза в заказе из Bitrix в CRM diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 7c5315c8..4a7de548 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.4.7', - 'VERSION_DATE' => '2023-10-10 18:00:00' + 'VERSION' => '6.4.8', + 'VERSION_DATE' => '2023-10-17 18:00:00' ]; diff --git a/intaro.retailcrm/lang/en/classes/general/history/RetailCrmHistory_v4.php b/intaro.retailcrm/lang/en/classes/general/history/RetailCrmHistory_v4.php deleted file mode 100644 index dd398abf..00000000 --- a/intaro.retailcrm/lang/en/classes/general/history/RetailCrmHistory_v4.php +++ /dev/null @@ -1,4 +0,0 @@ - 'OnSaleOrderSaved', 'FROM_MODULE' => 'sale'], ['EVENT_NAME' => 'OnSaleComponentOrderResultPrepared', 'FROM_MODULE' => 'sale'], diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index d00bee64..51413dd2 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -406,13 +406,6 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { $contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']])); } - //order numbers - $orderVat = htmlspecialchars(trim($_POST['order-vat'])) ?: 'N'; - $orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N'; - $orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N'; - $sendPaymentAmount = htmlspecialchars(trim($_POST[RetailcrmConstants::SEND_PAYMENT_AMOUNT])) ?: 'N'; - $crmCouponFiled = htmlspecialchars(trim($_POST['crm-coupon-field'])) ?: 'N'; - //stores $bitrixStoresArr = []; $bitrixShopsArr = []; @@ -810,17 +803,22 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { COption::SetOptionString( $mid, $CRM_ORDER_NUMBERS, - $orderNumbers + htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N' ); COption::SetOptionString( $mid, $CRM_ORDER_VAT, - $orderVat + htmlspecialchars(trim($_POST['order-vat'])) ?: 'N' ); COption::SetOptionString( $mid, $CRM_COUPON_FIELD, - $crmCouponFiled + htmlspecialchars(trim($_POST['crm-coupon-field'])) ?: 'N' + ); + COption::SetOptionString( + $mid, + Constants::CRM_SEND_PICKUP_POINT_ADDRESS, + htmlspecialchars(trim($_POST['send-pickup-point-address'])) ?: 'N' ); COption::SetOptionString( $mid, @@ -894,9 +892,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { COption::SetOptionString( $mid, $CRM_DIMENSIONS, - $orderDimensions + htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N' ); - RetailcrmConfigProvider::setSendPaymentAmount($sendPaymentAmount); + RetailcrmConfigProvider::setSendPaymentAmount(htmlspecialchars(trim($_POST[Constants::SEND_PAYMENT_AMOUNT])) ?: 'N'); RetailCrmConfigProvider::setDiscountRound($discount_round); RetailcrmConfigProvider::setCart($optionCart); COption::SetOptionString( @@ -1024,8 +1022,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { $optionsLegalDetails = unserialize(COption::GetOptionString($mid, $CRM_LEGAL_DETAILS, 0)); $optionsCustomFields = unserialize(COption::GetOptionString($mid, $CRM_CUSTOM_FIELDS, 0)); $optionsOrderNumbers = COption::GetOptionString($mid, $CRM_ORDER_NUMBERS, 0); - $optionsOrderVat= COption::GetOptionString($mid, $CRM_ORDER_VAT, 0); + $optionsOrderVat = COption::GetOptionString($mid, $CRM_ORDER_VAT, 0); $canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0)); + $sendPickupPointAddress = COption::GetOptionString($mid, Constants::CRM_SEND_PICKUP_POINT_ADDRESS, 'N'); $optionInventotiesUpload = COption::GetOptionString($mid, $CRM_INVENTORIES_UPLOAD, 0); $optionStores = unserialize(COption::GetOptionString($mid, $CRM_STORES, 0)); @@ -2194,6 +2193,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { return false; }); + + $('input[name="send-pickup-point-address"]').change( + function(){ + if ($(this).is(':checked')) { + alert(''); + } + }); }); @@ -2237,6 +2243,32 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { + + + + + + + + + + + + + + + ', $warningMessage); + } ?> + + +