1
0
mirror of synced 2024-11-24 22:36:07 +03:00

ref #78215 Управление активностью интеграции через интерфейс модуля (#291)

This commit is contained in:
Uryvskiy Dima 2023-05-29 14:26:39 +03:00 committed by GitHub
parent cbf8c9ac17
commit 83c7a3305b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 136 additions and 6 deletions

View File

@ -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 ## 2023-04-26 v.6.3.4
- Оптимизирован алгоритм получения истории заказов и клиентов - Оптимизирован алгоритм получения истории заказов и клиентов

View File

@ -0,0 +1,11 @@
### Настройки активности модуля
В версии 6.3.6 в настройки модуля добавлена опция деактивации модуля.
Для деактивации модуля в настройках необходимо выбрать опцию ***Деактивировать модуль***
Данная опция необходима для кейсов:
* проверка работоспособности Bitrix в целом, с исключением внешних факторов;
* при некорректной передачи данных из CMS в CRM и обратно.
При деактивации модуля, данные передаваться не будут, но все пользовательские настройки будут сохранены.

1
doc/README.md Normal file
View File

@ -0,0 +1 @@
# Developers documentation

View File

@ -1 +1 @@
- Добавлен функционал обновления номера телефона, адреса и других полей заказа, связанных с курьерской доставкой - В настройки добавлена опция деактивации модуля

View File

@ -1,6 +1,6 @@
<?php <?php
$arModuleVersion = [ $arModuleVersion = [
'VERSION' => '6.3.5', 'VERSION' => '6.3.6',
'VERSION_DATE' => '2023-05-18 18:00:00' 'VERSION_DATE' => '2023-05-19 12:00:00'
]; ];

View File

@ -96,3 +96,6 @@ $MESS ['ONLINE_CONSULTANT'] = 'Activate Online Consultant';
$MESS ['ONLINE_CONSULTANT_LABEL'] = 'Online Consultant script'; $MESS ['ONLINE_CONSULTANT_LABEL'] = 'Online Consultant script';
$MESS ['INTEGRATION_PAYMENT_LIST'] = 'The status will not be transferred for integration payments'; $MESS ['INTEGRATION_PAYMENT_LIST'] = 'The status will not be transferred for integration payments';
$MESS ['INTEGRATIONS'] = ' (integration)'; $MESS ['INTEGRATIONS'] = ' (integration)';
$MESS ['ACTIVITY_SETTINGS'] = 'Module activity settings';
$MESS ['DEACTIVATE_MODULE'] = 'Deactivate the module';

View File

@ -156,3 +156,5 @@ $MESS ['TEMPLATES_SUCCESS_COPING'] = 'Шаблоны успешно скопир
$MESS ['TEMPLATES_COPING_ERROR'] = 'Ошибка копирования шаблонов'; $MESS ['TEMPLATES_COPING_ERROR'] = 'Ошибка копирования шаблонов';
$MESS ['TEMPLATE_COPING_ERROR'] = 'Ошибка копирования шаблона'; $MESS ['TEMPLATE_COPING_ERROR'] = 'Ошибка копирования шаблона';
$MESS ['ACTIVITY_SETTINGS'] = 'Настройки активности модуля';
$MESS ['DEACTIVATE_MODULE'] = 'Деактивировать модуль';

View File

@ -63,6 +63,9 @@ $CRM_DIMENSIONS = 'order_dimensions';
$PROTOCOL = 'protocol'; $PROTOCOL = 'protocol';
$CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; $CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null';
$CRM_CART = 'cart'; $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')) { if (!CModule::IncludeModule('intaro.retailcrm') || !CModule::IncludeModule('sale') || !CModule::IncludeModule('iblock') || !CModule::IncludeModule('catalog')) {
return; return;
@ -386,6 +389,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
foreach ($orderTypesList as $orderType) { foreach ($orderTypesList as $orderType) {
$contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']])); $contragentTypeArr[$orderType['ID']] = htmlspecialchars(trim($_POST['contragent-type-' . $orderType['ID']]));
} }
//order numbers //order numbers
$orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ? htmlspecialchars(trim($_POST['order-numbers'])) : 'N'; $orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ? htmlspecialchars(trim($_POST['order-numbers'])) : 'N';
$orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ? htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) : '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::setIntegrationPaymentTypes($integrationPayments);
RetailcrmConfigProvider::setIntegrationDelivery($integrationDeliveries); 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( COption::SetOptionString(
$mid, $mid,
$CRM_ADDRESS_OPTIONS, $CRM_ADDRESS_OPTIONS,
@ -885,7 +983,8 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
$arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList(); $arResult['bitrixStoresExportList'] = RCrmActions::StoresExportList();
$arResult['bitrixPricesExportList'] = RCrmActions::PricesExportList(); $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)); $optionsOrderTypes = unserialize(COption::GetOptionString($mid, $CRM_ORDER_TYPES_ARR, 0));
$optionsDelivTypes = unserialize(COption::GetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, 0)); $optionsDelivTypes = unserialize(COption::GetOptionString($mid, $CRM_DELIVERY_TYPES_ARR, 0));
$optionsPayTypes = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_TYPES, 0)); $optionsPayTypes = unserialize(COption::GetOptionString($mid, $CRM_PAYMENT_TYPES, 0));
@ -2458,6 +2557,19 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<tr class="heading">
<td colspan="2" class="option-other-bottom"><b><?php echo GetMessage('ACTIVITY_SETTINGS'); ?></b></td>
</tr>
<tr>
<td colspan="2" class="option-head option-other-top option-other-bottom">
<b>
<label><input class="addr" type="checkbox" name="module-deactivate" value="Y" <?php if ($moduleDeactivate === 'Y') {
echo "checked";
} ?>> <?php echo GetMessage('DEACTIVATE_MODULE'); ?></label>
</b>
</td>
</tr>
<?php $tabControl->Buttons(); ?> <?php $tabControl->Buttons(); ?>
<input type="hidden" name="Update" value="Y"/> <input type="hidden" name="Update" value="Y"/>
<input type="submit" title="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_TITLE'); ?>" value="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_VALUE'); ?>" name="btn-update" class="adm-btn-save"/> <input type="submit" title="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_TITLE'); ?>" value="<?php echo GetMessage('ICRM_OPTIONS_SUBMIT_VALUE'); ?>" name="btn-update" class="adm-btn-save"/>