From 83c7a3305be12d07fb75ec4b74e3ab73339261cc Mon Sep 17 00:00:00 2001 From: Uryvskiy Dima Date: Mon, 29 May 2023 14:26:39 +0300 Subject: [PATCH] =?UTF-8?q?ref=20#78215=20=D0=A3=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B0=D0=BA=D1=82=D0=B8=D0=B2?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D1=8C=D1=8E=20=D0=B8=D0=BD=D1=82=D0=B5?= =?UTF-8?q?=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D1=87=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B7=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81?= =?UTF-8?q?=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F=20(#291)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +- doc/Module settings/Deactivate module.md | 11 +++ doc/README.md | 1 + intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 4 +- intaro.retailcrm/lang/en/options.php | 3 + intaro.retailcrm/lang/ru/options.php | 2 + intaro.retailcrm/options.php | 114 ++++++++++++++++++++++- 8 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 doc/Module settings/Deactivate module.md create mode 100644 doc/README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 51f8a445..a5cfe112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -## 2023-05-18 v.6.3.5 -- Добавлен функционал обновления номера телефона, адреса и других полей заказа, связанных с курьерской доставкой +## 2023-05-19 v.6.3.6 +- В настройки добавлена опция деактивации модуля + ## 2023-04-26 v.6.3.4 - Оптимизирован алгоритм получения истории заказов и клиентов diff --git a/doc/Module settings/Deactivate module.md b/doc/Module settings/Deactivate module.md new file mode 100644 index 00000000..3c3cce4d --- /dev/null +++ b/doc/Module settings/Deactivate module.md @@ -0,0 +1,11 @@ +### Настройки активности модуля + +В версии 6.3.6 в настройки модуля добавлена опция деактивации модуля. + +Для деактивации модуля в настройках необходимо выбрать опцию ***Деактивировать модуль*** + +Данная опция необходима для кейсов: +* проверка работоспособности Bitrix в целом, с исключением внешних факторов; +* при некорректной передачи данных из CMS в CRM и обратно. + +При деактивации модуля, данные передаваться не будут, но все пользовательские настройки будут сохранены. diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 00000000..ee196791 --- /dev/null +++ b/doc/README.md @@ -0,0 +1 @@ +# Developers documentation diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 464f841d..5d3ee001 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Добавлен функционал обновления номера телефона, адреса и других полей заказа, связанных с курьерской доставкой \ No newline at end of file +- В настройки добавлена опция деактивации модуля \ No newline at end of file diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 0b5427f8..c6253225 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.3.5', - 'VERSION_DATE' => '2023-05-18 18:00:00' + 'VERSION' => '6.3.6', + 'VERSION_DATE' => '2023-05-19 12:00:00' ]; diff --git a/intaro.retailcrm/lang/en/options.php b/intaro.retailcrm/lang/en/options.php index bd14cce6..c6dd9beb 100644 --- a/intaro.retailcrm/lang/en/options.php +++ b/intaro.retailcrm/lang/en/options.php @@ -96,3 +96,6 @@ $MESS ['ONLINE_CONSULTANT'] = 'Activate Online Consultant'; $MESS ['ONLINE_CONSULTANT_LABEL'] = 'Online Consultant script'; $MESS ['INTEGRATION_PAYMENT_LIST'] = 'The status will not be transferred for integration payments'; $MESS ['INTEGRATIONS'] = ' (integration)'; + +$MESS ['ACTIVITY_SETTINGS'] = 'Module activity settings'; +$MESS ['DEACTIVATE_MODULE'] = 'Deactivate the module'; diff --git a/intaro.retailcrm/lang/ru/options.php b/intaro.retailcrm/lang/ru/options.php index aff7189f..432a62f3 100644 --- a/intaro.retailcrm/lang/ru/options.php +++ b/intaro.retailcrm/lang/ru/options.php @@ -156,3 +156,5 @@ $MESS ['TEMPLATES_SUCCESS_COPING'] = 'Шаблоны успешно скопир $MESS ['TEMPLATES_COPING_ERROR'] = 'Ошибка копирования шаблонов'; $MESS ['TEMPLATE_COPING_ERROR'] = 'Ошибка копирования шаблона'; +$MESS ['ACTIVITY_SETTINGS'] = 'Настройки активности модуля'; +$MESS ['DEACTIVATE_MODULE'] = 'Деактивировать модуль'; diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index 7d52f64f..3a79e06e 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -63,6 +63,9 @@ $CRM_DIMENSIONS = 'order_dimensions'; $PROTOCOL = 'protocol'; $CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; $CRM_CART = 'cart'; +$MODULE_DEACTIVATE = 'module_deactivate'; +$AGENTS_DEACTIVATE = 'agents_deactivate'; +$EVENTS_DEACTIVATE = 'events_deactivate'; if (!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale') || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog')) { return; @@ -386,6 +389,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { foreach ($orderTypesList as $orderType) { $contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']])); } + //order numbers $orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ? htmlspecialchars(trim($_POST['order-numbers'])) : 'N'; $orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ? htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) : 'N'; @@ -631,6 +635,100 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { RetailcrmConfigProvider::setIntegrationPaymentTypes($integrationPayments); RetailcrmConfigProvider::setIntegrationDelivery($integrationDeliveries); + $moduleDeactivateParam = htmlspecialchars(trim($_POST['module-deactivate'])) ?? 'N'; + + if ('Y' === $moduleDeactivateParam) { + global $DB; + + $agents = $DB->Query("SELECT * FROM `b_agent` WHERE `MODULE_ID` = 'intaro.retailcrm';"); + $events = $DB->Query("SELECT * FROM `b_module_to_module` WHERE `TO_MODULE_ID` = 'intaro.retailcrm';"); + $deactivateAgents = []; + $deactivateEvents = []; + + // Fetch - If the last record is reached (or there are no records as a result), the method returns false + while ($agent = $agents->Fetch()) { + $deactivateAgents[] = $agent; + + CAgent::RemoveAgent($agent['NAME'], $agent['MODULE_ID'], $agent['USER_ID']); + } + + // Fetch - If the last record is reached (or there are no records as a result), the method returns false + while ($event = $events->Fetch()) { + $deactivateEvents[] = $event; + + UnRegisterModuleDependences( + $event['FROM_MODULE_ID'], + $event['MESSAGE_ID'], + $event['TO_MODULE_ID'], + $event['TO_CLASS'], + $event['TO_METHOD'] + ); + } + + if ($deactivateAgents !== []) { + COption::SetOptionString($mid, $AGENTS_DEACTIVATE, serialize($deactivateAgents)); + } + + if ($deactivateEvents !== []) { + COption::SetOptionString($mid, $EVENTS_DEACTIVATE, serialize($deactivateEvents)); + } + } else { + $deactivateAgents = unserialize(COption::GetOptionString($mid, $AGENTS_DEACTIVATE, [])); + $deactivateEvents = unserialize(COption::GetOptionString($mid, $EVENTS_DEACTIVATE, [])); + + if (!empty($deactivateAgents)) { + $dateAgent = new DateTime(); + + // PT60S - 60 sec; + $dateAgent->add(new DateInterval('PT60S')); + + foreach ($deactivateAgents as $agent) { + CAgent::AddAgent( + $agent['NAME'], + $agent['MODULE_ID'], + 'N', + $agent['AGENT_INTERVAL'], + $dateAgent->format('d.m.Y H:i:s'), + $agent['ACTIVE'], + $dateAgent->format('d.m.Y H:i:s') + ); + } + + COption::SetOptionString($mid, $AGENTS_DEACTIVATE, serialize([])); + } + + if (!empty($deactivateEvents)) { + $eventManager = EventManager::getInstance(); + + foreach ($deactivateEvents as $event) { + if (strpos($event['TO_METHOD'], 'Handler') !== false) { + $eventManager->registerEventHandler( + $event['FROM_MODULE_ID'], + $event['MESSAGE_ID'], + $event['TO_MODULE_ID'], + $event['TO_CLASS'], + $event['TO_METHOD'] + ); + } else { + RegisterModuleDependences( + $event['FROM_MODULE_ID'], + $event['MESSAGE_ID'], + $event['TO_MODULE_ID'], + $event['TO_CLASS'], + $event['TO_METHOD'] + ); + } + } + + COption::SetOptionString($mid, $EVENTS_DEACTIVATE, serialize([])); + } + } + + COption::SetOptionString( + $mid, + $MODULE_DEACTIVATE, + serialize($moduleDeactivateParam) + ); COption::SetOptionString( $mid, $CRM_ADDRESS_OPTIONS, @@ -885,7 +983,8 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { $arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList(); $arResult['bitrixPricesExportList'] = RCrmActions::PricesExportList(); - //saved cat params + //saved params + $moduleDeactivate = unserialize(COption::GetOptionString($mid, $MODULE_DEACTIVATE, 'N')); $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)); @@ -2458,6 +2557,19 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { + + + + + + + + + + + Buttons(); ?>