diff --git a/admin/controller/extension/module/retailcrm.php b/admin/controller/extension/module/retailcrm.php index f36fc49..f4595fc 100644 --- a/admin/controller/extension/module/retailcrm.php +++ b/admin/controller/extension/module/retailcrm.php @@ -83,7 +83,8 @@ class ControllerExtensionModuleRetailcrm extends Controller * @return void */ public function uninstall() - { + { + $this->uninstall_collector(); $this->load->model('setting/setting'); $this->model_setting_setting ->editSetting('retailcrm', array('retailcrm_status' => 0)); @@ -92,13 +93,40 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->model_extension_event->deleteEvent('retailcrm'); } + /** + * Install Demon Collector method + * + * @return void + */ + public function install_collector() + { + $this->load->model('extension/extension'); + $this->load->model('setting/setting'); + $this->model_extension_extension->install('analytics', 'daemon_collector'); + $this->model_setting_setting->editSetting('daemon_collector', array('daemon_collector_status' => 1)); + } + + /** + * Uninstall Demon Collector method + * + * @return void + */ + public function uninstall_collector() + { + $this->load->model('extension/extension'); + $this->load->model('setting/setting'); + $this->model_setting_setting->editSetting('daemon_collector', array('daemon_collector_status' => 0)); + $this->model_extension_extension->uninstall('analytics', 'daemon_collector'); + } + /** * Setup page * * @return void */ public function index() - { + { + $this->load->model('extension/extension'); $this->load->model('localisation/country'); $this->load->model('setting/setting'); $this->load->model('extension/module'); @@ -108,6 +136,16 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->document->addStyle('/admin/view/stylesheet/retailcrm.css'); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) { + $analytics = $this->model_extension_extension->getInstalled('analytics'); + + if ($this->request->post['retailcrm_collector_active'] == 1 && + !in_array('daemon_collector', $analytics)) { + $this->install_collector(); + } elseif ($this->request->post['retailcrm_collector_active'] == 0 && + in_array('daemon_collector', $analytics)) { + $this->uninstall_collector(); + } + if (parse_url($this->request->post['retailcrm_url'])){ $crm_url = parse_url($this->request->post['retailcrm_url'], PHP_URL_HOST); $this->request->post['retailcrm_url'] = 'https://'.$crm_url; @@ -150,7 +188,14 @@ class ControllerExtensionModuleRetailcrm extends Controller 'text_success_catalog', 'retailcrm_upload_order', 'text_error_order', - 'text_error_order_id' + 'text_error_order_id', + 'daemon_collector', + 'general_tab_text', + 'references_tab_text', + 'collector_tab_text', + 'text_yes', + 'text_no', + 'collector_site_key' ); $this->load->model('extension/extension'); @@ -263,7 +308,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $_data['catalog'] = $this->request->server['HTTPS'] ? HTTPS_CATALOG : HTTP_CATALOG; $_data['token'] = $this->request->get['token']; - if(file_exists(DIR_SYSTEM . '/cron/export_done.txt')) { + if(file_exists(DIR_SYSTEM . '/cron/export_done')) { $_data['export_file'] = false; } else { $_data['export_file'] = true; @@ -427,7 +472,7 @@ class ControllerExtensionModuleRetailcrm extends Controller $this->load->model('extension/retailcrm/order'); $this->model_extension_retailcrm_order->uploadToCrm($fullOrders); - $file = fopen(DIR_SYSTEM . '/cron/export_done.txt', "x"); + $file = fopen(DIR_SYSTEM . '/cron/export_done', "x"); } /** diff --git a/admin/language/en-gb/extension/module/retailcrm.php b/admin/language/en-gb/extension/module/retailcrm.php index 0ca1927..3ba4800 100644 --- a/admin/language/en-gb/extension/module/retailcrm.php +++ b/admin/language/en-gb/extension/module/retailcrm.php @@ -12,8 +12,14 @@ $_['retailcrm_base_settings'] = 'Connection settings'; $_['retailcrm_dict_settings'] = 'Dictionary settings'; $_['retailcrm_countries_settings'] = 'Trading zones setting'; $_['retailcrm_upload_order'] = 'Unload single order'; +$_['daemon_collector'] = 'Daemon Collector'; +$_['general_tab_text'] = 'General'; +$_['references_tab_text'] = 'References'; +$_['collector_tab_text'] = 'Collector'; + $_['retailcrm_url'] = 'RetailCRM URL'; $_['retailcrm_apikey'] = 'RetailCRM API Key'; +$_['collector_site_key'] = 'Site key'; $_['text_success_export'] = 'Orders and customers successfully unloaded'; $_['text_success_export_order'] = 'Order successfully unloaded'; @@ -36,6 +42,8 @@ $_['color'] = 'Color'; $_['weight'] = 'Weight'; $_['size'] = 'Size'; +$_['text_yes'] = 'Yes'; +$_['text_no'] = 'No'; // Errors $_['error_permission'] = 'Warning! You do not have permission to modify module'; diff --git a/admin/language/ru-ru/extension/module/retailcrm.php b/admin/language/ru-ru/extension/module/retailcrm.php index 9672dd5..9b6c7c6 100644 --- a/admin/language/ru-ru/extension/module/retailcrm.php +++ b/admin/language/ru-ru/extension/module/retailcrm.php @@ -12,9 +12,14 @@ $_['retailcrm_base_settings'] = 'Настройки соединения'; $_['retailcrm_dict_settings'] = 'Настройки соответствия справочников'; $_['retailcrm_countries_settings'] = 'Настройка торговых зон'; $_['retailcrm_upload_order'] = 'Выгрузка одного заказа'; +$_['daemon_collector'] = 'Демон Collector'; +$_['general_tab_text'] = 'Главная'; +$_['references_tab_text'] = 'Справочники'; +$_['collector_tab_text'] = 'Collector'; $_['retailcrm_url'] = 'Адрес RetailCRM'; $_['retailcrm_apikey'] = 'Api ключ RetailCRM'; +$_['collector_site_key'] = 'Ключ сайта'; $_['text_success_export'] = 'Заказы и клиенты успешно выгружены'; $_['text_success_export_order'] = 'Заказ успешно выгружен'; @@ -25,6 +30,7 @@ $_['text_success_catalog'] = 'Каталог успешно выгруже $_['text_error_order'] = 'Ошибка! Заказ не выгружен!'; $_['text_error_order_id'] = 'Ошибка! Введите корректный номер заказа!'; + $_['retailcrm_dict_delivery'] = 'Способы доставки'; $_['retailcrm_dict_status'] = 'Статусы'; $_['retailcrm_dict_payment'] = 'Способы оплаты'; @@ -37,6 +43,8 @@ $_['color'] = 'Цвет'; $_['weight'] = 'Вес'; $_['size'] = 'Размер'; +$_['text_yes'] = 'Да'; +$_['text_no'] = 'Нет'; // Errors $_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля'; diff --git a/admin/view/template/extension/module/retailcrm.tpl b/admin/view/template/extension/module/retailcrm.tpl index 8703791..a2768c7 100644 --- a/admin/view/template/extension/module/retailcrm.tpl +++ b/admin/view/template/extension/module/retailcrm.tpl @@ -38,97 +38,141 @@