diff --git a/src/upload/admin/controller/extension/module/retailcrm.php b/src/upload/admin/controller/extension/module/retailcrm.php index 949f800..5b2e177 100644 --- a/src/upload/admin/controller/extension/module/retailcrm.php +++ b/src/upload/admin/controller/extension/module/retailcrm.php @@ -105,6 +105,34 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->{'model_' . $this->modelExtension}->uninstall('analytics', 'daemon_collector'); } + /** + * Install OnlineConsultant method + * + * @return void + */ + public function install_consultant() + { + $consultant = $this->getConsultantTitle(); + $this->loadModels(); + $this->load->model('setting/setting'); + $this->{'model_' . $this->modelExtension}->install('analytics', 'online_consultant'); + $this->model_setting_setting->editSetting($consultant, array($consultant . '_status' => 1)); + } + + /** + * Uninstall OnlineConsultant method + * + * @return void + */ + public function uninstall_consultant() + { + $consultant = $this->getConsultantTitle(); + $this->loadModels(); + $this->load->model('setting/setting'); + $this->model_setting_setting->editSetting($consultant, array($consultant . '_status' => 0)); + $this->{'model_' . $this->modelExtension}->uninstall('analytics', 'online_consultant'); + } + /** * Setup page * @@ -124,6 +152,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->document->addStyle('/admin/view/stylesheet/retailcrm.css'); $collector = $this->getCollectorTitle(); + $consultant = $this->getConsultantTitle(); $history_setting = $this->model_setting_setting->getSetting('retailcrm_history'); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) { @@ -144,6 +173,12 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->uninstall_collector(); } + if ($this->request->post[$this->moduleTitle . '_online_consultant_active'] == 1) { + $this->install_consultant(); + } elseif ($this->request->post[$this->moduleTitle . '_online_consultant_active'] == 0) { + $this->uninstall_consultant(); + } + if (parse_url($this->request->post[$this->moduleTitle . '_url'])) { $crm_url = parse_url($this->request->post[$this->moduleTitle . '_url'], PHP_URL_HOST); $this->request->post[$this->moduleTitle . '_url'] = 'https://' . $crm_url; @@ -265,6 +300,7 @@ class ControllerExtensionModuleRetailcrm extends Controller 'general_tab_text', 'references_tab_text', 'collector_tab_text', + 'consultant_tab_text', 'logs_tab_text', 'text_yes', 'text_no', @@ -300,7 +336,9 @@ class ControllerExtensionModuleRetailcrm extends Controller 'text_status_changes', 'text_lenght', 'text_lenght_label', - 'corporate_enabled_label' + 'corporate_enabled_label', + 'entry_code', + 'entry_status' ); $_data = &$data; @@ -737,6 +775,22 @@ class ControllerExtensionModuleRetailcrm extends Controller return $title; } + /** + * Get consultant module name + * + * @return string + */ + private function getConsultantTitle() + { + if (version_compare(VERSION, '3.0', '<')) { + $title = 'online_consultant'; + } else { + $title = 'analytics_online_consultant'; + } + + return $title; + } + /** * Check file size * diff --git a/src/upload/admin/language/en-gb/extension/module/retailcrm.php b/src/upload/admin/language/en-gb/extension/module/retailcrm.php index f3884a4..c7036d2 100644 --- a/src/upload/admin/language/en-gb/extension/module/retailcrm.php +++ b/src/upload/admin/language/en-gb/extension/module/retailcrm.php @@ -13,6 +13,7 @@ $_['retailcrm_dict_settings'] = 'Configuration of directories correspondence' $_['retailcrm_countries_settings'] = 'Setting of trade zones'; $_['retailcrm_upload_order'] = 'Uploading one order'; $_['daemon_collector'] = 'Daemon Collector'; +$_['consultant_tab_text'] = 'Online Consultant'; $_['general_tab_text'] = 'Main'; $_['references_tab_text'] = 'Directories'; $_['collector_tab_text'] = 'Daemon Collector'; @@ -86,5 +87,8 @@ $_['size'] = 'Size'; $_['text_yes'] = 'Yes'; $_['text_no'] = 'No'; + +$_['entry_code'] = 'Online consultant code'; +$_['entry_status'] = 'Use code for online consultant'; // Errors $_['error_permission'] = 'You do not have rights for changing the module settings'; diff --git a/src/upload/admin/language/es-es/extension/module/retailcrm.php b/src/upload/admin/language/es-es/extension/module/retailcrm.php index 2e7db08..a13bfd3 100644 --- a/src/upload/admin/language/es-es/extension/module/retailcrm.php +++ b/src/upload/admin/language/es-es/extension/module/retailcrm.php @@ -13,6 +13,7 @@ $_['retailcrm_dict_settings'] = 'Ajustes de coincidencia de directorios'; $_['retailcrm_countries_settings'] = 'Configurar zonas comerciales'; $_['retailcrm_upload_order'] = 'Exportación de un pedido'; $_['daemon_collector'] = 'Daemon Collector'; +$_['consultant_tab_text'] = 'Online Consultant'; $_['general_tab_text'] = 'Inicio'; $_['references_tab_text'] = 'Directorios'; $_['collector_tab_text'] = 'Daemon Collector'; @@ -86,5 +87,8 @@ $_['size'] = 'Tamaño'; $_['text_yes'] = 'Sí'; $_['text_no'] = 'No'; + +$_['entry_code'] = 'Código para online consultant'; +$_['entry_status'] = 'Usar código para online consultant'; // Errors $_['error_permission'] = 'No tiene suficientes permisos para cambiar la configuración del módulo'; diff --git a/src/upload/admin/language/ru-ru/extension/module/retailcrm.php b/src/upload/admin/language/ru-ru/extension/module/retailcrm.php index 47da0d1..446afda 100644 --- a/src/upload/admin/language/ru-ru/extension/module/retailcrm.php +++ b/src/upload/admin/language/ru-ru/extension/module/retailcrm.php @@ -16,6 +16,7 @@ $_['daemon_collector'] = 'Демон Collector'; $_['general_tab_text'] = 'Главная'; $_['references_tab_text'] = 'Справочники'; $_['collector_tab_text'] = 'Daemon Collector'; +$_['consultant_tab_text'] = 'Online Consultant'; $_['logs_tab_text'] = 'Логи'; $_['collector_custom_text'] = 'Настройка полей формы'; $_['custom_fields_tab_text'] = 'Пользовательские поля'; @@ -88,3 +89,8 @@ $_['text_yes'] = 'Да'; $_['text_no'] = 'Нет'; // Errors $_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля'; + +//online consultant +$_['entry_code'] = 'Код для online consultant'; +$_['entry_status'] = 'Использовать код для online consultant'; + diff --git a/src/upload/admin/view/template/extension/module/retailcrm.tpl b/src/upload/admin/view/template/extension/module/retailcrm.tpl index 2e6f3da..aee1f3b 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.tpl +++ b/src/upload/admin/view/template/extension/module/retailcrm.tpl @@ -40,6 +40,7 @@
  • +
  • @@ -456,6 +457,37 @@ +
    +
    + + {* onlineConsultant *} +
    + +
    + +
    +
    +
    + +
    + + +
    +
    +
    +
    @@ -655,3 +687,4 @@ } }); + diff --git a/src/upload/admin/view/template/extension/module/retailcrm.twig b/src/upload/admin/view/template/extension/module/retailcrm.twig index de5c92d..a29ee26 100644 --- a/src/upload/admin/view/template/extension/module/retailcrm.twig +++ b/src/upload/admin/view/template/extension/module/retailcrm.twig @@ -39,6 +39,7 @@ {% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %}
  • {{ references_tab_text }}
  • {{ collector_tab_text }}
  • +
  • {{ consultant_tab_text }}
  • {{ custom_fields_tab_text }}
  • {{ logs_tab_text }}
  • {% endif %} @@ -465,6 +466,38 @@ {% endfor %}
    +
    + {{ consultant_tab_text }} +
    + {# online cosultant #} +
    + +
    + +
    +
    +
    + +
    + + +
    +
    +
    +
    {{ retailcrm_dict_custom_fields }} @@ -665,3 +698,4 @@ } }); + diff --git a/src/upload/catalog/controller/extension/analytics/online_consultant.php b/src/upload/catalog/controller/extension/analytics/online_consultant.php new file mode 100644 index 0000000..af75d7c --- /dev/null +++ b/src/upload/catalog/controller/extension/analytics/online_consultant.php @@ -0,0 +1,26 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://www.retailcrm.ru/docs/Developers/ApiVersion5 + */ +class ControllerExtensionAnalyticsOnlineConsultant extends Controller { + /** + * @return string + */ + public function index() { + $this->load->model('setting/setting'); + $this->load->library('retailcrm/retailcrm'); + + $moduleTitle = $this->retailcrm->getModuleTitle(); + $settings = $this->model_setting_setting->getSetting($moduleTitle); + $setting = trim($settings['module_retailcrm_online_consultant_code']); + + return html_entity_decode($setting, ENT_QUOTES, 'UTF-8'); + } +}