From 559ff1d8f7074ac0676f5dd4ff3adc84dc215e55 Mon Sep 17 00:00:00 2001 From: RenCurs <34103666+RenCurs@users.noreply.github.com> Date: Tue, 24 Nov 2020 12:14:26 +0300 Subject: [PATCH] OnlineConsultant (#154) --- CHANGELOG.md | 6 +++ .../general/RetailcrmConfigProvider.php | 41 ++++++++++++++++++ .../classes/general/RetailcrmConstants.php | 2 + .../consultant/RetailCrmOnlineConsultant.php | 26 ++++++++++++ intaro.retailcrm/description.ru | 5 ++- intaro.retailcrm/include.php | 3 +- intaro.retailcrm/install/version.php | 4 +- intaro.retailcrm/lang/en/options.php | 2 + intaro.retailcrm/lang/ru/options.php | 3 ++ intaro.retailcrm/options.php | 42 +++++++++++++++++++ 10 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 intaro.retailcrm/classes/general/consultant/RetailCrmOnlineConsultant.php diff --git a/CHANGELOG.md b/CHANGELOG.md index ff28ba48..6a30fc5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2020-11-24 v.5.6.0 +* Добавлена возможность активации онлайн-консультанта +* Обновлен список стран +* Улучшена синхронизация ФИО в истории +* Добавлен перевод на английский язык + ## 2020-10-14 v.5.5.3 * Исправлено затирание полей при создании заказа по агенту diff --git a/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php b/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php index 09639809..46f74a75 100644 --- a/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php +++ b/intaro.retailcrm/classes/general/RetailcrmConfigProvider.php @@ -198,6 +198,47 @@ class RetailcrmConfigProvider return static::$sitesListCorporate; } + /** + * isOnlineConsultantEnabled + * + * @return bool + */ + public static function isOnlineConsultantEnabled() + { + return static::getOption(RetailcrmConstants::CRM_ONLINE_CONSULTANT) === 'Y'; + } + + /** + * getOnlineConsultantScript + * + * @return string + */ + public static function getOnlineConsultantScript() + { + return trim(static::getOption(RetailcrmConstants::CRM_ONLINE_CONSULTANT_SCRIPT, "")); + } + + /** + * setOnlineConsultant + * + * @param string $value + */ + public static function setOnlineConsultant($value) + { + static::setOption(RetailcrmConstants::CRM_ONLINE_CONSULTANT, $value); + } + + /** + * setOnlineConsultantScript + * + * @param string $value + */ + public function setOnlineConsultantScript($value) + { + static::setOption(RetailcrmConstants::CRM_ONLINE_CONSULTANT_SCRIPT, $value); + } + + /** * getOrderTypes * diff --git a/intaro.retailcrm/classes/general/RetailcrmConstants.php b/intaro.retailcrm/classes/general/RetailcrmConstants.php index ee25a628..e36967a5 100644 --- a/intaro.retailcrm/classes/general/RetailcrmConstants.php +++ b/intaro.retailcrm/classes/general/RetailcrmConstants.php @@ -78,4 +78,6 @@ class RetailcrmConstants const CRM_INTEGRATION_DELIVERY = 'integration_delivery'; const CRM_SHIPMENT_DEDUCTED = 'shipment_deducted'; const SEND_PAYMENT_AMOUNT = 'send_payment_amount'; + const CRM_ONLINE_CONSULTANT = 'online_consultant'; + const CRM_ONLINE_CONSULTANT_SCRIPT = 'online_consultant_script'; } diff --git a/intaro.retailcrm/classes/general/consultant/RetailCrmOnlineConsultant.php b/intaro.retailcrm/classes/general/consultant/RetailCrmOnlineConsultant.php new file mode 100644 index 00000000..3332c0bb --- /dev/null +++ b/intaro.retailcrm/classes/general/consultant/RetailCrmOnlineConsultant.php @@ -0,0 +1,26 @@ +addString( + RetailcrmConfigProvider::getOnlineConsultantScript(), + true + ); + + return true; + } else { + return false; + } + } +} diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 8c94d1d6..31f3ed7e 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1,4 @@ -- Исправлено затирание полей при создании заказа по агенту +- Добавлена возможность активации онлайн-консультанта +- Обновлен список стран +- Улучшена синхронизация ФИО в истории +- Добавлен перевод на английский язык diff --git a/intaro.retailcrm/include.php b/intaro.retailcrm/include.php index f7eb8d87..cece9049 100644 --- a/intaro.retailcrm/include.php +++ b/intaro.retailcrm/include.php @@ -38,6 +38,7 @@ CModule::AddAutoloadClasses( 'AddressBuilder' => 'classes/general/AddressBuilder.php', 'AbstractBuilder' => 'classes/general/AbstractBuilder.php', 'BaseModel' => 'classes/general/Model/BaseModel.php', - 'RetailCrmService' => 'classes/general/services/RetailCrmService.php' + 'RetailCrmService' => 'classes/general/services/RetailCrmService.php', + 'RetailCrmOnlineConsultant' => 'classes/general/consultant/RetailCrmOnlineConsultant.php' ) ); diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 8c4a7638..26213407 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,5 +1,5 @@ "5.5.3", - "VERSION_DATE" => "2020-10-15 15:48:00" + "VERSION" => "5.6.0", + "VERSION_DATE" => "2020-11-24 11:42:00" ); diff --git a/intaro.retailcrm/lang/en/options.php b/intaro.retailcrm/lang/en/options.php index e58c4835..81c5917c 100644 --- a/intaro.retailcrm/lang/en/options.php +++ b/intaro.retailcrm/lang/en/options.php @@ -92,3 +92,5 @@ $MESS['PURCHASE_ICML'] = "If enabled, ICML generation will reset the purchase pr $MESS['PURCHASE_HEADER'] = "Reset purchase price in ICML"; $MESS['PHONE_REQUIRED'] = "In the main module settings «Phone Number is required» option was enabled, so it may cause problems with reverse synchronization. For proper work you must disable this option."; $MESS['CHANGE_SHIPMENT_STATUS_FROM_CRM'] = "Change the shipment status when corresponding flag is received from retailCRM"; +$MESS ['ONLINE_CONSULTANT'] = 'Activate Online Consultant'; +$MESS ['ONLINE_CONSULTANT_LABEL'] = 'Online Consultant script'; diff --git a/intaro.retailcrm/lang/ru/options.php b/intaro.retailcrm/lang/ru/options.php index db9f93df..b87d7c8a 100644 --- a/intaro.retailcrm/lang/ru/options.php +++ b/intaro.retailcrm/lang/ru/options.php @@ -92,6 +92,9 @@ $MESS ['SHOPS_PRICES_UPLOAD'] = 'Магазины в которые будут $MESS ['DEMON_COLLECTOR'] = 'Активировать Демон Collector'; $MESS ['DEMON_KEY'] = 'Ключ для'; +$MESS ['ONLINE_CONSULTANT'] = 'Активировать Онлайн-консультанта'; +$MESS ['ONLINE_CONSULTANT_LABEL'] = 'Скрипт для Онлайн-консультанта'; + $MESS ['UNIVERSAL_ANALYTICS'] = 'Включить интеграцию с UA'; $MESS ['ID_UA'] = 'Идентификатор отслеживания:'; $MESS ['INDEX_UA'] = 'Индекс пользовательского параметра:'; diff --git a/intaro.retailcrm/options.php b/intaro.retailcrm/options.php index d603593f..85c8122d 100644 --- a/intaro.retailcrm/options.php +++ b/intaro.retailcrm/options.php @@ -453,6 +453,17 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmUa", "add"); } + //online_consultant + if (htmlspecialchars(trim($_POST['online_consultant'] == 'Y'))) { + $onlineConsultant = 'Y'; + $onlineConsultantScript = trim($_POST['online_consultant_script']); + RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmOnlineConsultant", "add"); + } else { + $onlineConsultant = 'N'; + $onlineConsultantScript = RetailcrmConfigProvider::getOnlineConsultantScript(); + UnRegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmOnlineConsultant", "add"); + } + //discount_round if (htmlspecialchars(trim($_POST['discount_round'])) == 'Y') { $discount_round = 'Y'; @@ -564,6 +575,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { COption::SetOptionString($mid, $CRM_COLLECTOR, $collector); COption::SetOptionString($mid, $CRM_COLL_KEY, serialize(RCrmActions::clearArr($collectorKeys))); + RetailCrmConfigProvider::setOnlineConsultant($onlineConsultant); + RetailCrmConfigProvider::setOnlineConsultantScript($onlineConsultantScript); + COption::SetOptionString($mid, $CRM_UA, $ua); COption::SetOptionString($mid, $CRM_UA_KEYS, serialize(RCrmActions::clearArr($uaKeys))); COption::SetOptionString($mid, $CRM_DIMENSIONS, $orderDimensions); @@ -685,6 +699,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { $optionCollector = COption::GetOptionString($mid, $CRM_COLLECTOR, 0); $optionCollectorKeys = unserialize(COption::GetOptionString($mid, $CRM_COLL_KEY)); + + $optionOnlineConsultant = RetailcrmConfigProvider::isOnlineConsultantEnabled(); + $optionOnlineConsultantScript = RetailcrmConfigProvider::getOnlineConsultantScript(); $optionUa = COption::GetOptionString($mid, $CRM_UA, 0); $optionUaKeys = unserialize(COption::GetOptionString($mid, $CRM_UA_KEYS)); @@ -833,6 +850,16 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { return true; }); + $('.r-consultant-button label').change(function(){ + if($(this).find('input').is(':checked') === true){ + $('tr.r-consultant').show('slow'); + } else if($(this).find('input').is(':checked') === false){ + $('tr.r-consultant').hide('slow'); + } + + return true; + }); + $('.r-purchaseprice-button label').change(function() { if($(this).find('input').is(':checked') === true) { $('tr.r-purchaseprice').show('slow'); @@ -1423,6 +1450,21 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) { + + + + + + + + + + > + + + + +