mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-22 13:16:07 +03:00
Changed user interface, implemented Daemon Collector
This commit is contained in:
parent
276024a5e5
commit
c51e4a35a4
@ -84,6 +84,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
*/
|
*/
|
||||||
public function uninstall()
|
public function uninstall()
|
||||||
{
|
{
|
||||||
|
$this->uninstall_collector();
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
$this->model_setting_setting
|
$this->model_setting_setting
|
||||||
->editSetting('retailcrm', array('retailcrm_status' => 0));
|
->editSetting('retailcrm', array('retailcrm_status' => 0));
|
||||||
@ -92,6 +93,32 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
$this->model_extension_event->deleteEvent('retailcrm');
|
$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
|
* Setup page
|
||||||
*
|
*
|
||||||
@ -99,6 +126,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$this->load->model('extension/extension');
|
||||||
$this->load->model('localisation/country');
|
$this->load->model('localisation/country');
|
||||||
$this->load->model('setting/setting');
|
$this->load->model('setting/setting');
|
||||||
$this->load->model('extension/module');
|
$this->load->model('extension/module');
|
||||||
@ -108,6 +136,16 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
|
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
|
||||||
|
|
||||||
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
|
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'])){
|
if (parse_url($this->request->post['retailcrm_url'])){
|
||||||
$crm_url = parse_url($this->request->post['retailcrm_url'], PHP_URL_HOST);
|
$crm_url = parse_url($this->request->post['retailcrm_url'], PHP_URL_HOST);
|
||||||
$this->request->post['retailcrm_url'] = 'https://'.$crm_url;
|
$this->request->post['retailcrm_url'] = 'https://'.$crm_url;
|
||||||
@ -150,7 +188,14 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
'text_success_catalog',
|
'text_success_catalog',
|
||||||
'retailcrm_upload_order',
|
'retailcrm_upload_order',
|
||||||
'text_error_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');
|
$this->load->model('extension/extension');
|
||||||
@ -263,7 +308,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
$_data['catalog'] = $this->request->server['HTTPS'] ? HTTPS_CATALOG : HTTP_CATALOG;
|
$_data['catalog'] = $this->request->server['HTTPS'] ? HTTPS_CATALOG : HTTP_CATALOG;
|
||||||
$_data['token'] = $this->request->get['token'];
|
$_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;
|
$_data['export_file'] = false;
|
||||||
} else {
|
} else {
|
||||||
$_data['export_file'] = true;
|
$_data['export_file'] = true;
|
||||||
@ -427,7 +472,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
|||||||
|
|
||||||
$this->load->model('extension/retailcrm/order');
|
$this->load->model('extension/retailcrm/order');
|
||||||
$this->model_extension_retailcrm_order->uploadToCrm($fullOrders);
|
$this->model_extension_retailcrm_order->uploadToCrm($fullOrders);
|
||||||
$file = fopen(DIR_SYSTEM . '/cron/export_done.txt', "x");
|
$file = fopen(DIR_SYSTEM . '/cron/export_done', "x");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,8 +12,14 @@ $_['retailcrm_base_settings'] = 'Connection settings';
|
|||||||
$_['retailcrm_dict_settings'] = 'Dictionary settings';
|
$_['retailcrm_dict_settings'] = 'Dictionary settings';
|
||||||
$_['retailcrm_countries_settings'] = 'Trading zones setting';
|
$_['retailcrm_countries_settings'] = 'Trading zones setting';
|
||||||
$_['retailcrm_upload_order'] = 'Unload single order';
|
$_['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_url'] = 'RetailCRM URL';
|
||||||
$_['retailcrm_apikey'] = 'RetailCRM API Key';
|
$_['retailcrm_apikey'] = 'RetailCRM API Key';
|
||||||
|
$_['collector_site_key'] = 'Site key';
|
||||||
|
|
||||||
$_['text_success_export'] = 'Orders and customers successfully unloaded';
|
$_['text_success_export'] = 'Orders and customers successfully unloaded';
|
||||||
$_['text_success_export_order'] = 'Order successfully unloaded';
|
$_['text_success_export_order'] = 'Order successfully unloaded';
|
||||||
@ -36,6 +42,8 @@ $_['color'] = 'Color';
|
|||||||
$_['weight'] = 'Weight';
|
$_['weight'] = 'Weight';
|
||||||
$_['size'] = 'Size';
|
$_['size'] = 'Size';
|
||||||
|
|
||||||
|
$_['text_yes'] = 'Yes';
|
||||||
|
$_['text_no'] = 'No';
|
||||||
// Errors
|
// Errors
|
||||||
$_['error_permission'] = 'Warning! You do not have permission to modify module';
|
$_['error_permission'] = 'Warning! You do not have permission to modify module';
|
||||||
|
|
||||||
|
@ -12,9 +12,14 @@ $_['retailcrm_base_settings'] = 'Настройки соединения';
|
|||||||
$_['retailcrm_dict_settings'] = 'Настройки соответствия справочников';
|
$_['retailcrm_dict_settings'] = 'Настройки соответствия справочников';
|
||||||
$_['retailcrm_countries_settings'] = 'Настройка торговых зон';
|
$_['retailcrm_countries_settings'] = 'Настройка торговых зон';
|
||||||
$_['retailcrm_upload_order'] = 'Выгрузка одного заказа';
|
$_['retailcrm_upload_order'] = 'Выгрузка одного заказа';
|
||||||
|
$_['daemon_collector'] = 'Демон Collector';
|
||||||
|
$_['general_tab_text'] = 'Главная';
|
||||||
|
$_['references_tab_text'] = 'Справочники';
|
||||||
|
$_['collector_tab_text'] = 'Collector';
|
||||||
|
|
||||||
$_['retailcrm_url'] = 'Адрес RetailCRM';
|
$_['retailcrm_url'] = 'Адрес RetailCRM';
|
||||||
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
||||||
|
$_['collector_site_key'] = 'Ключ сайта';
|
||||||
|
|
||||||
$_['text_success_export'] = 'Заказы и клиенты успешно выгружены';
|
$_['text_success_export'] = 'Заказы и клиенты успешно выгружены';
|
||||||
$_['text_success_export_order'] = 'Заказ успешно выгружен';
|
$_['text_success_export_order'] = 'Заказ успешно выгружен';
|
||||||
@ -25,6 +30,7 @@ $_['text_success_catalog'] = 'Каталог успешно выгруже
|
|||||||
$_['text_error_order'] = 'Ошибка! Заказ не выгружен!';
|
$_['text_error_order'] = 'Ошибка! Заказ не выгружен!';
|
||||||
$_['text_error_order_id'] = 'Ошибка! Введите корректный номер заказа!';
|
$_['text_error_order_id'] = 'Ошибка! Введите корректный номер заказа!';
|
||||||
|
|
||||||
|
|
||||||
$_['retailcrm_dict_delivery'] = 'Способы доставки';
|
$_['retailcrm_dict_delivery'] = 'Способы доставки';
|
||||||
$_['retailcrm_dict_status'] = 'Статусы';
|
$_['retailcrm_dict_status'] = 'Статусы';
|
||||||
$_['retailcrm_dict_payment'] = 'Способы оплаты';
|
$_['retailcrm_dict_payment'] = 'Способы оплаты';
|
||||||
@ -37,6 +43,8 @@ $_['color'] = 'Цвет';
|
|||||||
$_['weight'] = 'Вес';
|
$_['weight'] = 'Вес';
|
||||||
$_['size'] = 'Размер';
|
$_['size'] = 'Размер';
|
||||||
|
|
||||||
|
$_['text_yes'] = 'Да';
|
||||||
|
$_['text_no'] = 'Нет';
|
||||||
// Errors
|
// Errors
|
||||||
$_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля';
|
$_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля';
|
||||||
|
|
||||||
|
@ -38,6 +38,17 @@
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-retailcrm">
|
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-retailcrm">
|
||||||
|
<!------------------------- -->
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li class="active"><a href="#tab-general" data-toggle="tab"><?php echo $general_tab_text; ?></a></li>
|
||||||
|
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
||||||
|
<li><a href="#tab-references" data-toggle="tab"><?php echo $references_tab_text; ?></a></li>
|
||||||
|
<li><a href="#tab-collector" data-toggle="tab"><?php echo $collector_tab_text; ?></a></li>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane active" id="tab-general">
|
||||||
<input type="hidden" name="retailcrm_status" value="1">
|
<input type="hidden" name="retailcrm_status" value="1">
|
||||||
|
|
||||||
<h3><?php echo $retailcrm_base_settings; ?></h3>
|
<h3><?php echo $retailcrm_base_settings; ?></h3>
|
||||||
@ -76,6 +87,9 @@
|
|||||||
<label><?php echo $text_button_export_order; ?> № </label><input type="text" name="order_id">
|
<label><?php echo $text_button_export_order; ?> № </label><input type="text" name="order_id">
|
||||||
<button type="button" id="export_order" data-toggle="tooltip" title="<?php echo $text_button_export_order; ?>" class="btn btn-success"><i class="fa fa-download"></i></button>
|
<button type="button" id="export_order" data-toggle="tooltip" title="<?php echo $text_button_export_order; ?>" class="btn btn-success"><i class="fa fa-download"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="tab-references">
|
||||||
<h3><?php echo $retailcrm_dict_settings; ?></h3>
|
<h3><?php echo $retailcrm_dict_settings; ?></h3>
|
||||||
|
|
||||||
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
||||||
@ -129,6 +143,36 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="tab-collector">
|
||||||
|
<h4><?php echo $daemon_collector; ?></h4>
|
||||||
|
|
||||||
|
<div class="retailcrm_unit">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_collector_active" value="1" <?php if (isset($saved_settings['retailcrm_collector_active']) &&
|
||||||
|
$saved_settings['retailcrm_collector_active'] == 1) :
|
||||||
|
echo 'checked'; endif; ?>>
|
||||||
|
<?php echo $text_yes; ?>
|
||||||
|
</label>
|
||||||
|
<label class="radio-inline">
|
||||||
|
<input type="radio" name="retailcrm_collector_active" value="0" <?php if (!isset($saved_settings['retailcrm_collector_active']) ||
|
||||||
|
$saved_settings['retailcrm_collector_active'] == 0) :
|
||||||
|
echo 'checked'; endif; ?>>
|
||||||
|
<?php echo $text_no; ?>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="retailcrm_unit">
|
||||||
|
<label for="retailcrm_collector_site_key"><?php echo $collector_site_key; ?></label><br>
|
||||||
|
<input id="retailcrm_collector_site_key" type="text" name="retailcrm_collector_site_key" value="<?php if (isset($saved_settings['retailcrm_collector_site_key'])): echo $saved_settings['retailcrm_collector_site_key']; endif; ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!------------------------- -->
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
22
catalog/controller/extension/analytics/daemon_collector.php
Normal file
22
catalog/controller/extension/analytics/daemon_collector.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
class ControllerExtensionAnalyticsDaemonCollector extends Controller {
|
||||||
|
public function index() {
|
||||||
|
$siteCode = $this->config->get('retailcrm_collector_site_key');
|
||||||
|
|
||||||
|
if ($this->customer->isLogged()) $customerId = $this->customer->getID();
|
||||||
|
|
||||||
|
$customer = isset($customerId) ? "'customerId': '" . $customerId . "'" : "";
|
||||||
|
|
||||||
|
$js = "<script type='text/javascript'>
|
||||||
|
(function(_,r,e,t,a,i,l){_['retailCRMObject']=a;_[a]=_[a]||function(){(_[a].q=_[a].q||[]).push(arguments)};_[a].l=1*new Date();l=r.getElementsByTagName(e)[0];i=r.createElement(e);i.async=!0;i.src=t;l.parentNode.insertBefore(i,l)})(window,document,'script','https://collector.retailcrm.pro/w.js','_rc');
|
||||||
|
|
||||||
|
_rc('create', '" . $siteCode . "', {
|
||||||
|
" . $customer . "
|
||||||
|
});
|
||||||
|
|
||||||
|
_rc('send', 'pageView');
|
||||||
|
</script>";
|
||||||
|
|
||||||
|
return html_entity_decode($js, ENT_QUOTES, 'UTF-8');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user