diff --git a/CHANGELOG.md b/CHANGELOG.md index 08b53aea..332ee959 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2024-10-30 v6.5.37 +- Исправлена подписка модуля на событие сохранения заказа + ## 2024-10-24 v6.5.36 - Добавлена передача профилей доставки Официального модуля Почты России diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 1672b415..0f5d5e40 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Добавлена передача профилей доставки Официального модуля Почты России +- Исправлена подписка модуля на событие сохранения заказа diff --git a/intaro.retailcrm/install/index.php b/intaro.retailcrm/install/index.php index 12a4c52d..a4c4cb9c 100644 --- a/intaro.retailcrm/install/index.php +++ b/intaro.retailcrm/install/index.php @@ -26,6 +26,7 @@ use Intaro\RetailCrm\Component\Advanced\LoyaltyInstaller; Loader::IncludeModule('highloadblock'); IncludeModuleLangFile(__FILE__); + if (class_exists('intaro_retailcrm')) { return false; } @@ -51,10 +52,11 @@ class intaro_retailcrm extends CModule public function __construct() { - $arModuleVersion = []; - $path = str_replace("\\", '/', __FILE__); - $path = substr($path, 0, strlen($path) - strlen('/index.php')); + $arModuleVersion = []; + $path = str_replace("\\", '/', __FILE__); + $path = substr($path, 0, strlen($path) - strlen('/index.php')); $this->INSTALL_PATH = $path; + include($path . '/version.php'); $this->MODULE_VERSION = $arModuleVersion['VERSION']; $this->MODULE_VERSION_DATE = $arModuleVersion['VERSION_DATE']; diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 6edbb19c..3ef34253 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.5.36', - 'VERSION_DATE' => '2024-10-24 15:00:00' + 'VERSION' => '6.5.37', + 'VERSION_DATE' => '2024-10-30 14:00:00' ]; diff --git a/intaro.retailcrm/lib/component/advanced/loyaltyinstaller.php b/intaro.retailcrm/lib/component/advanced/loyaltyinstaller.php index b764b243..faca6c57 100644 --- a/intaro.retailcrm/lib/component/advanced/loyaltyinstaller.php +++ b/intaro.retailcrm/lib/component/advanced/loyaltyinstaller.php @@ -161,6 +161,7 @@ class LoyaltyInstaller 'EDIT_FORM_LABEL' => ['ru' => $filed['title']], ]; + $props = array_merge($arProps, $customProps); $obUserField = new CUserTypeEntity(); $dbRes = CUserTypeEntity::GetList([], ['FIELD_NAME' => $filed['name']])->fetch(); diff --git a/intaro.retailcrm/lib/component/constants.php b/intaro.retailcrm/lib/component/constants.php index a8ef89d6..37f28c0b 100644 --- a/intaro.retailcrm/lib/component/constants.php +++ b/intaro.retailcrm/lib/component/constants.php @@ -18,7 +18,7 @@ namespace Intaro\RetailCrm\Component; */ class Constants { - public const MODULE_VERSION = '6.5.36'; + public const MODULE_VERSION = '6.5.37'; public const CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; public const BITRIX_USER_ID_PREFIX = 'bitrixUserId-'; public const CRM_USERS_MAP = 'crm_users_map'; diff --git a/intaro.retailcrm/lib/component/handlers/eventshandlers.php b/intaro.retailcrm/lib/component/handlers/eventshandlers.php index f084b75f..a388cb6d 100644 --- a/intaro.retailcrm/lib/component/handlers/eventshandlers.php +++ b/intaro.retailcrm/lib/component/handlers/eventshandlers.php @@ -83,7 +83,8 @@ class EventsHandlers $isWriteOffAvailable = $bonusInput > 0 && $availableBonuses > 0 - && $jsDataTotal['ORDER_TOTAL_PRICE'] >= $bonusDiscount + $loyaltyDiscountInput; + && $jsDataTotal['ORDER_TOTAL_PRICE'] >= $bonusDiscount + $loyaltyDiscountInput + ; if ($isWriteOffAvailable || $loyaltyDiscountInput > 0) { $jsDataTotal['ORDER_TOTAL_PRICE'] diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index fdaf5d65..36291d03 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -604,17 +604,22 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) { } } catch (Exception $exception) { RCrmActions::eventLog( - 'intaro.retailcrm/options.php', 'OrderLoyaltyDataService::createLoyaltyHlBlock', + 'intaro.retailcrm/options.php', 'Options_Loyalty_toggle::enable', $e->getCode() . ': ' . $exception->getMessage() ); } ConfigProvider::setLoyaltyProgramStatus('Y'); } else { - ConfigProvider::setLoyaltyProgramStatus('N'); - $loyaltyEventClass = 'Intaro\RetailCrm\Component\Handlers\EventsHandlers'; - UnRegisterModuleDependences('sale', 'OnSaleOrderSaved', 'intaro.retailcrm', $loyaltyEventClass, 'OnSaleOrderSavedHandler'); - UnRegisterModuleDependences('sale', 'OnSaleComponentOrderResultPrepared', 'intaro.retailcrm', $loyaltyEventClass, 'OnSaleComponentOrderResultPreparedHandler'); + try { + ConfigProvider::setLoyaltyProgramStatus('N'); + $loyaltySetup->deleteLPEvents(); + } catch (Exception $exception) { + RCrmActions::eventLog( + 'intaro.retailcrm/options.php', 'Options_Loyalty_toggle::disable', + $e->getCode() . ': ' . $exception->getMessage() + ); + } } try { diff --git a/intaro.retailcrm/updater.php b/intaro.retailcrm/updater.php index 1bb1eadb..49ce7fc5 100644 --- a/intaro.retailcrm/updater.php +++ b/intaro.retailcrm/updater.php @@ -401,7 +401,8 @@ class LoyaltyProgramUpdater ['to_method', '=', $event['EVENT_NAME'] . 'Handler'], ['to_class', '=', 'Intaro\RetailCrm\Component\Handlers\EventsHandlers'], ]) - ->fetchCollection(); + ->fetchCollection() + ; if (null === $events || 0 === count($events)) { $eventManager->registerEventHandler( @@ -613,6 +614,7 @@ class LoyaltyProgramUpdater 'NAME' => 'LoyaltyProgramRetailCRM', 'TABLE_NAME' => 'loyalty_program' ]); + $arLangs = [ 'ru' => 'Программа лояльности', 'en' => 'Loyalty Program' @@ -661,7 +663,8 @@ class LoyaltyProgramUpdater $persons = PersonTypeTable::query() ->setSelect(['ID']) ->where([]) - ->fetchCollection(); + ->fetchCollection() + ; foreach ($persons as $person) { $personId = $person->getID(); @@ -691,7 +694,8 @@ class LoyaltyProgramUpdater ['NAME', '=', $lpOrderGroupName], ] ) - ->fetch(); + ->fetch() + ; if (is_array($lpGroup)) { return $lpGroup['ID']; @@ -728,7 +732,8 @@ class LoyaltyProgramUpdater ['PERSON_TYPE_ID', '=', $personId], ['PROPS_GROUP_ID', '=', $groupId], ]) - ->fetchObject(); + ->fetchObject() + ; if ($bonusProp === null) { $lang = Context::getCurrent()->getLanguage(); @@ -869,7 +874,8 @@ class LoyaltyProgramUpdater ->where([ ['CODE', '=', 'AGREEMENT_PERSONAL_DATA_CODE'] ]) - ->fetch(); + ->fetch() + ; if (!isset($isAgreementPersonalProgram['ID'])) { /** @var EntityObject|null $agreementPersonalData */