mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-22 13:16:07 +03:00
fix icml and daemon collector (#33)
This commit is contained in:
parent
d75366274a
commit
84b851d79b
@ -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,21 @@ 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',
|
||||
'text_collector_activity',
|
||||
'text_collector_form_capture',
|
||||
'text_collector_period',
|
||||
'text_label_promo',
|
||||
'text_label_send',
|
||||
'collector_custom_text',
|
||||
'text_require'
|
||||
);
|
||||
|
||||
$this->load->model('extension/extension');
|
||||
@ -200,8 +252,14 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$_data['error_warning'] = $this->error['warning'];
|
||||
if (isset($this->_error['warning'])) {
|
||||
$_data['error_warning'] = $this->_error['warning'];
|
||||
} else {
|
||||
$_data['error_warning'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->_error['fields'])) {
|
||||
$_data['error_warning'] = $this->_error['fields'];
|
||||
} else {
|
||||
$_data['error_warning'] = '';
|
||||
}
|
||||
@ -263,12 +321,20 @@ 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;
|
||||
}
|
||||
|
||||
$collectorFields = array(
|
||||
'name' => $this->language->get('field_name'),
|
||||
'email' => $this->language->get('field_email'),
|
||||
'phone' => $this->language->get('field_phone')
|
||||
);
|
||||
|
||||
$_data['collectorFields'] = $collectorFields;
|
||||
|
||||
$this->response->setOutput(
|
||||
$this->load->view('extension/module/retailcrm.tpl', $_data)
|
||||
);
|
||||
@ -427,7 +493,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");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -441,6 +507,15 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
$this->_error['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (isset($this->request->post['retailcrm_collector']['custom']) &&
|
||||
$this->request->post['retailcrm_collector']['custom_form'] == 1) {
|
||||
$customField = $this->request->post['retailcrm_collector']['custom'];
|
||||
|
||||
if (empty($customField['name']) && empty($customField['email']) && empty($customField['phone'])) {
|
||||
$this->_error['fields'] = $this->language->get('text_error_collector_fields');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->_error) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -12,8 +12,15 @@ $_['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';
|
||||
$_['collector_custom_text'] = 'Custom form';
|
||||
|
||||
$_['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';
|
||||
@ -23,6 +30,16 @@ $_['text_button_catalog'] = 'Unload catalog';
|
||||
$_['text_success_catalog'] = 'Catalog successfully unloaded';
|
||||
$_['text_error_order'] = 'Error! Order is not unloaded!';
|
||||
$_['text_error_order_id'] = 'Error! Enter the correct order number!';
|
||||
$_['text_collector_activity'] = 'Use Daemon Collector';
|
||||
$_['text_collector_form_capture']= 'Show capture form';
|
||||
$_['text_collector_period'] = 'Form show period (in minutes)';
|
||||
$_['text_label_promo'] = 'Text form title';
|
||||
$_['text_label_send'] = 'Text button';
|
||||
$_['field_name'] = 'Name';
|
||||
$_['field_email'] = 'Email';
|
||||
$_['field_phone'] = 'Phone';
|
||||
$_['text_require'] = 'Require';
|
||||
$_['text_error_collector_fields']= 'Fill in the field names Daemon Collector';
|
||||
|
||||
$_['retailcrm_dict_delivery'] = 'Shipment methods';
|
||||
$_['retailcrm_dict_status'] = 'Order statuses';
|
||||
@ -36,6 +53,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';
|
||||
|
||||
|
@ -12,9 +12,15 @@ $_['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';
|
||||
$_['collector_custom_text'] = 'Настройка полей формы';
|
||||
|
||||
$_['retailcrm_url'] = 'Адрес RetailCRM';
|
||||
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
||||
$_['collector_site_key'] = 'Ключ сайта';
|
||||
|
||||
$_['text_success_export'] = 'Заказы и клиенты успешно выгружены';
|
||||
$_['text_success_export_order'] = 'Заказ успешно выгружен';
|
||||
@ -24,6 +30,16 @@ $_['text_button_catalog'] = 'Выгрузить каталог';
|
||||
$_['text_success_catalog'] = 'Каталог успешно выгружен';
|
||||
$_['text_error_order'] = 'Ошибка! Заказ не выгружен!';
|
||||
$_['text_error_order_id'] = 'Ошибка! Введите корректный номер заказа!';
|
||||
$_['text_collector_activity'] = 'Использовать Демон Collector';
|
||||
$_['text_collector_form_capture']= 'Показывать форму захвата';
|
||||
$_['text_collector_period'] = 'Периодичность всплывания формы (в минутах)';
|
||||
$_['text_label_promo'] = 'Текст заголовка формы';
|
||||
$_['text_label_send'] = 'Текст кнопки';
|
||||
$_['field_name'] = 'Имя';
|
||||
$_['field_email'] = 'Email';
|
||||
$_['field_phone'] = 'Телефон';
|
||||
$_['text_require'] = 'Обязательно для заполнения';
|
||||
$_['text_error_collector_fields']= 'Заполните названия полей формы Демон Collector';
|
||||
|
||||
$_['retailcrm_dict_delivery'] = 'Способы доставки';
|
||||
$_['retailcrm_dict_status'] = 'Статусы';
|
||||
@ -37,6 +53,8 @@ $_['color'] = 'Цвет';
|
||||
$_['weight'] = 'Вес';
|
||||
$_['size'] = 'Размер';
|
||||
|
||||
$_['text_yes'] = 'Да';
|
||||
$_['text_no'] = 'Нет';
|
||||
// Errors
|
||||
$_['error_permission'] = 'У вас недостаточно прав на изменение настроек модуля';
|
||||
|
||||
|
@ -121,13 +121,20 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||
// Если первая итерация
|
||||
if(empty($offers)) {
|
||||
foreach($requiredOption['product_option_value'] as $optionValue) {
|
||||
$offers[$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = (float)$optionValue['price'];
|
||||
$offers[$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
||||
'price' => (float)$optionValue['price'],
|
||||
'qty' => $optionValue['quantity']
|
||||
);
|
||||
}
|
||||
} else {
|
||||
foreach($offers as $optionKey => $optionCost) {
|
||||
foreach($offers as $optionKey => $optionAttr) {
|
||||
unset($offers[$optionKey]); // Работая в контексте обязательных опций не забываем удалять прошлые обязательные опции, т.к. они должны быть скомбинированы с другими обязательными опциями
|
||||
foreach($requiredOption['product_option_value'] as $optionValue) {
|
||||
$offers[$optionKey.'_'.$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = $optionCost + (float)$optionValue['price'];
|
||||
$offers[$optionKey.'_'.$requiredOption['product_option_id'].':'.$requiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
||||
'price' => $optionAttr['price'] + (float)$optionValue['price'],
|
||||
'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ?
|
||||
$optionValue['quantity'] : $optionAttr['qty']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -138,21 +145,28 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||
if(empty($offers)) {
|
||||
$offers['0:0-0'] = 0; // В случае работы с необязательными опциями мы должны учитывать товарное предложение без опций, поэтому создадим "пустую" опцию
|
||||
foreach($notRequiredOption['product_option_value'] as $optionValue) {
|
||||
$offers[$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = (float)$optionValue['price'];
|
||||
$offers[$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
||||
'price' => (float)$optionValue['price'],
|
||||
'qty' => $optionValue['quantity']
|
||||
);
|
||||
}
|
||||
} else {
|
||||
foreach($offers as $optionKey => $optionCost) {
|
||||
foreach($offers as $optionKey => $optionAttr) {
|
||||
foreach($notRequiredOption['product_option_value'] as $optionValue) {
|
||||
$offers[$optionKey.'_'.$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = $optionCost + (float)$optionValue['price'];
|
||||
$offers[$optionKey.'_'.$notRequiredOption['product_option_id'].':'.$notRequiredOption['option_id'].'-'.$optionValue['option_value_id']] = array(
|
||||
'price' => $optionAttr['price'] + (float)$optionValue['price'],
|
||||
'qty' => ($optionAttr['qty'] > $optionValue['quantity']) ?
|
||||
$optionValue['quantity'] : $optionAttr['qty']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($offers)) {
|
||||
$offers = array('0:0-0' => '0');
|
||||
$offers = array('0:0-0' => array('price' => '0', 'qty' => '0'));
|
||||
}
|
||||
|
||||
foreach($offers as $optionsString => $optionsTotalCost) {
|
||||
foreach($offers as $optionsString => $optionsValues) {
|
||||
$optionsString = explode('_', $optionsString);
|
||||
$options = array();
|
||||
foreach($optionsString as $optionString) {
|
||||
@ -174,12 +188,16 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||
}
|
||||
$offerId = implode('_', $offerId);
|
||||
$e = $this->eOffers->appendChild($this->dd->createElement('offer'));
|
||||
if(!empty($offerId))
|
||||
if(!empty($offerId)) {
|
||||
$e->setAttribute('id', $product['product_id'].'#'.$offerId);
|
||||
else
|
||||
$e->setAttribute('productId', $product['product_id']);
|
||||
$e->setAttribute('quantity', $optionsValues['qty']);
|
||||
}
|
||||
else {
|
||||
$e->setAttribute('id', $product['product_id']);
|
||||
$e->setAttribute('productId', $product['product_id']);
|
||||
$e->setAttribute('quantity', $product['quantity']);
|
||||
$e->setAttribute('productId', $product['product_id']);
|
||||
$e->setAttribute('quantity', $product['quantity']);
|
||||
}
|
||||
/**
|
||||
* Offer activity
|
||||
*/
|
||||
@ -220,7 +238,7 @@ class ModelExtensionRetailcrmIcml extends Model
|
||||
->appendChild($this->dd->createTextNode($product['name']));
|
||||
}
|
||||
$e->appendChild($this->dd->createElement('price'))
|
||||
->appendChild($this->dd->createTextNode($product['price'] + $optionsTotalCost));
|
||||
->appendChild($this->dd->createTextNode($product['price'] + $optionsValues['price']));
|
||||
/**
|
||||
* Vendor
|
||||
*/
|
||||
|
@ -1,3 +1,4 @@
|
||||
.retailcrm_unit {margin-bottom: 10px;}
|
||||
.retailcrm_unit input {width: 30%;}
|
||||
.checkbox input{width: auto;}
|
||||
.retailcrm_unit input[type=checkbox] {width: 13px;}
|
@ -38,97 +38,196 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form-retailcrm">
|
||||
<input type="hidden" name="retailcrm_status" value="1">
|
||||
<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>
|
||||
|
||||
<h3><?php echo $retailcrm_base_settings; ?></h3>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_url"><?php echo $retailcrm_url; ?></label><br>
|
||||
<input id="retailcrm_url" type="text" name="retailcrm_url" value="<?php if (isset($saved_settings['retailcrm_url'])): echo $saved_settings['retailcrm_url']; endif; ?>">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_apikey"><?php echo $retailcrm_apikey; ?></label><br>
|
||||
<input id="retailcrm_apikey" type="text" name="retailcrm_apikey" value="<?php if (isset($saved_settings['retailcrm_apikey'])): echo $saved_settings['retailcrm_apikey']; endif;?>">
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="tab-general">
|
||||
<input type="hidden" name="retailcrm_status" value="1">
|
||||
|
||||
<h3><?php echo $retailcrm_countries_settings; ?></h3>
|
||||
<div class="retailcrm_unit">
|
||||
<div class="well well-sm" style="height: 150px; overflow: auto; width: 30%;">
|
||||
<?php foreach($countries as $country) : ?>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="<?php echo 'retailcrm_country[]'; ?>" value="<?php echo $country['country_id']; ?>" <?php if(isset($saved_settings['retailcrm_country']) && in_array($country['country_id'], $saved_settings['retailcrm_country'])): echo 'checked'; endif;?>>
|
||||
<?php echo $country['name']; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
||||
|
||||
<?php if (!empty($retailcrm_errors)) : ?>
|
||||
<?php foreach($retailcrm_errors as $retailcrm_error): ?>
|
||||
<div class="warning"><?php echo $retailcrm_error ?></div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<h3><?php echo $retailcrm_upload_order; ?></h3>
|
||||
<div class="retailcrm_unit">
|
||||
<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>
|
||||
</div>
|
||||
<h3><?php echo $retailcrm_dict_settings; ?></h3>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
||||
<?php foreach($delivery['opencart'] as $value): ?>
|
||||
|
||||
<div class="pm"><?php echo $value['title'].':'; ?></div>
|
||||
<?php unset($value['title']); ?>
|
||||
<?php foreach ($value as $key => $val): ?>
|
||||
<h3><?php echo $retailcrm_base_settings; ?></h3>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_delivery_<?php echo $val['code']; ?>" name="retailcrm_delivery[<?php echo $val['code']; ?>]" >
|
||||
<?php foreach ($delivery['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_delivery'][$key]) && $v['code'] == $saved_settings['retailcrm_delivery'][$key]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_pm_<?php echo $val['code']; ?>"><?php echo $val['title']; ?></label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<label for="retailcrm_url"><?php echo $retailcrm_url; ?></label><br>
|
||||
<input id="retailcrm_url" type="text" name="retailcrm_url" value="<?php if (isset($saved_settings['retailcrm_url'])): echo $saved_settings['retailcrm_url']; endif; ?>">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_apikey"><?php echo $retailcrm_apikey; ?></label><br>
|
||||
<input id="retailcrm_apikey" type="text" name="retailcrm_apikey" value="<?php if (isset($saved_settings['retailcrm_apikey'])): echo $saved_settings['retailcrm_apikey']; endif;?>">
|
||||
</div>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_status; ?></h4>
|
||||
<?php foreach ($statuses['opencart'] as $status): ?>
|
||||
<?php $uid = $status['order_status_id']?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_status_<?php echo $uid; ?>" name="retailcrm_status[<?php echo $uid; ?>]" >
|
||||
<?php foreach ($statuses['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_status'][$uid]) && $v['code'] == $saved_settings['retailcrm_status'][$uid]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<h3><?php echo $retailcrm_countries_settings; ?></h3>
|
||||
<div class="retailcrm_unit">
|
||||
<div class="well well-sm" style="height: 150px; overflow: auto; width: 30%;">
|
||||
<?php foreach($countries as $country) : ?>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="<?php echo 'retailcrm_country[]'; ?>" value="<?php echo $country['country_id']; ?>" <?php if(isset($saved_settings['retailcrm_country']) && in_array($country['country_id'], $saved_settings['retailcrm_country'])): echo 'checked'; endif;?>>
|
||||
<?php echo $country['name']; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
|
||||
|
||||
<?php if (!empty($retailcrm_errors)) : ?>
|
||||
<?php foreach($retailcrm_errors as $retailcrm_error): ?>
|
||||
<div class="warning"><?php echo $retailcrm_error ?></div>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_status_<?php echo $status['order_status_id']; ?>"><?php echo $status['name']; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<h3><?php echo $retailcrm_upload_order; ?></h3>
|
||||
<div class="retailcrm_unit">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_payment; ?></h4>
|
||||
<?php foreach ($payments['opencart'] as $key => $value): ?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_payment_<?php echo $key; ?>" name="retailcrm_payment[<?php echo $key; ?>]" >
|
||||
<?php foreach ($payments['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_payment'][$key]) && $v['code'] == $saved_settings['retailcrm_payment'][$key]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<div class="tab-pane" id="tab-references">
|
||||
<h3><?php echo $retailcrm_dict_settings; ?></h3>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
||||
<?php foreach($delivery['opencart'] as $value): ?>
|
||||
|
||||
<div class="pm"><?php echo $value['title'].':'; ?></div>
|
||||
<?php unset($value['title']); ?>
|
||||
<?php foreach ($value as $key => $val): ?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_delivery_<?php echo $val['code']; ?>" name="retailcrm_delivery[<?php echo $val['code']; ?>]" >
|
||||
<?php foreach ($delivery['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_delivery'][$key]) && $v['code'] == $saved_settings['retailcrm_delivery'][$key]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_pm_<?php echo $val['code']; ?>"><?php echo $val['title']; ?></label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_payment_<?php echo $key; ?>"><?php echo $value; ?></label>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_status; ?></h4>
|
||||
<?php foreach ($statuses['opencart'] as $status): ?>
|
||||
<?php $uid = $status['order_status_id']?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_status_<?php echo $uid; ?>" name="retailcrm_status[<?php echo $uid; ?>]" >
|
||||
<?php foreach ($statuses['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_status'][$uid]) && $v['code'] == $saved_settings['retailcrm_status'][$uid]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_status_<?php echo $status['order_status_id']; ?>"><?php echo $status['name']; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_payment; ?></h4>
|
||||
<?php foreach ($payments['opencart'] as $key => $value): ?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_payment_<?php echo $key; ?>" name="retailcrm_payment[<?php echo $key; ?>]" >
|
||||
<?php foreach ($payments['retailcrm'] as $k => $v): ?>
|
||||
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_payment'][$key]) && $v['code'] == $saved_settings['retailcrm_payment'][$key]):?>selected="selected"<?php endif;?>>
|
||||
<?php echo $v['name'];?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label for="retailcrm_payment_<?php echo $key; ?>"><?php echo $value; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane" id="tab-collector">
|
||||
<h3><?php echo $daemon_collector; ?></h3>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector_active" class="col-md-4"><?php echo $text_collector_activity; ?></label>
|
||||
<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 class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $collector_site_key; ?></label>
|
||||
<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>
|
||||
<?php if (!empty($saved_settings['retailcrm_collector']['site_key']) &&
|
||||
$saved_settings['retailcrm_collector_active'] == 1) :?>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $text_collector_form_capture; ?></label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_collector[form_capture]" value="1" <?php if (isset($saved_settings['retailcrm_collector']['form_capture']) &&
|
||||
$saved_settings['retailcrm_collector']['form_capture'] == 1) :
|
||||
echo 'checked'; endif; ?>>
|
||||
<?php echo $text_yes; ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_collector[form_capture]" value="0" <?php if (!isset($saved_settings['retailcrm_collector']['form_capture']) ||
|
||||
$saved_settings['retailcrm_collector']['form_capture'] == 0) :
|
||||
echo 'checked'; endif; ?>>
|
||||
<?php echo $text_no; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php if (isset($saved_settings['retailcrm_collector']['form_capture']) &&
|
||||
$saved_settings['retailcrm_collector']['form_capture'] == 1) :?>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $text_collector_period; ?></label>
|
||||
<input id="retailcrm_collector_period" type="text" name="retailcrm_collector[period]" value="<?php if (isset($saved_settings['retailcrm_collector']['period'])): echo $saved_settings['retailcrm_collector']['period']; endif; ?>">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $text_label_promo; ?></label>
|
||||
<input id="retailcrm_collector[]" type="text" name="retailcrm_collector[label_promo]" value="<?php if (isset($saved_settings['retailcrm_collector']['label_promo'])): echo $saved_settings['retailcrm_collector']['label_promo']; endif; ?>">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $text_label_send; ?></label>
|
||||
<input id="retailcrm_collector_label_send" type="text" name="retailcrm_collector[label_send]" value="<?php if (isset($saved_settings['retailcrm_collector']['label_send'])): echo $saved_settings['retailcrm_collector']['label_send']; endif; ?>">
|
||||
</div>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $collector_custom_text; ?></label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_collector[custom_form]" value="1" <?php if (isset($saved_settings['retailcrm_collector']['custom_form']) &&
|
||||
$saved_settings['retailcrm_collector']['custom_form'] == 1) :
|
||||
echo 'checked'; endif; ?>>
|
||||
<?php echo $text_yes; ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_collector[custom_form]" value="0" <?php if (!isset($saved_settings['retailcrm_collector']['custom_form']) ||
|
||||
$saved_settings['retailcrm_collector']['custom_form'] == 0) :
|
||||
echo 'checked'; endif; ?>>
|
||||
<?php echo $text_no; ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php if (isset($saved_settings['retailcrm_collector']['custom_form']) &&
|
||||
$saved_settings['retailcrm_collector']['custom_form'] == 1) :?>
|
||||
<?php foreach ($collectorFields as $field => $label) : ?>
|
||||
<div class="retailcrm_unit">
|
||||
<label for="retailcrm_collector" class="col-md-4"><?php echo $label; ?></label>
|
||||
<div class="col-md-8">
|
||||
<input id="retailcrm_collector" type="text" name="retailcrm_collector[custom][<?php echo $field; ?>]" value="<?php if (isset($saved_settings['retailcrm_collector']['custom'][$field])) : echo $saved_settings['retailcrm_collector']['custom'][$field]; endif; ?>">
|
||||
<input type="checkbox" name="retailcrm_collector[require][<?php echo $field; ?>_require]" value="1" <?php if (isset($saved_settings['retailcrm_collector']['require'][$field.'_require'])) : echo 'checked'; endif;?>>
|
||||
<label for="retailcrm_collector"><?php echo $text_require; ?></label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
81
catalog/controller/extension/analytics/daemon_collector.php
Normal file
81
catalog/controller/extension/analytics/daemon_collector.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
class ControllerExtensionAnalyticsDaemonCollector extends Controller {
|
||||
public function index() {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$settings = $this->model_setting_setting->getSetting('retailcrm');
|
||||
$setting = $settings['retailcrm_collector'];
|
||||
$siteCode = isset($setting['site_key']) ? $setting['site_key'] : '';
|
||||
|
||||
if ($this->customer->isLogged()) $customerId = $this->customer->getID();
|
||||
|
||||
$customer = isset($customerId) ? "'customerId': '" . $customerId . "'" : "";
|
||||
$labelPromo = !empty($setting['label_promo']) ? $setting['label_promo'] : null;
|
||||
$labelSend = !empty($setting['label_send']) ? $setting['label_send'] : null;
|
||||
$customForm = '';
|
||||
|
||||
if (isset($setting['custom']) && $setting['custom_form'] == 1) {
|
||||
$customForm = "'fields': {";
|
||||
$cntEmpty = 0;
|
||||
|
||||
foreach ($setting['custom'] as $field => $label) {
|
||||
if (empty($label)) { $cntEmpty += 1; continue; }
|
||||
|
||||
if (isset($setting['require'][$field . '_require'])) {
|
||||
$customForm .= "\n\t'$field': { required: true, label: '$label' },";
|
||||
} else {
|
||||
$customForm .= "\n\t'$field': { label: '$label' },";
|
||||
}
|
||||
}
|
||||
$customForm .= "\n\t},";
|
||||
|
||||
if ($cntEmpty == count($setting['custom'])) $customForm = '';
|
||||
}
|
||||
|
||||
if (isset($setting['form_capture']) && $setting['form_capture'] == 1) {
|
||||
|
||||
if (!empty($setting['period']) && is_numeric($setting['period'])) {
|
||||
|
||||
if ($labelPromo != null || $labelSend != null){
|
||||
$captureForm = "_rc('require', 'capture-form', {
|
||||
'period': " . $setting['period'] . ",
|
||||
" . $customForm . "
|
||||
labelPromo: '" . $labelPromo . "',
|
||||
labelSend: '" . $labelSend . "'
|
||||
});";
|
||||
} else {
|
||||
$captureForm = "_rc('require', 'capture-form', {
|
||||
'period': " . $settings['retailcrm_collector']['period'] . ",
|
||||
" . $customForm . "
|
||||
});";
|
||||
}
|
||||
} elseif ($labelPromo != null || $labelSend != null) {
|
||||
$captureForm = "_rc('require', 'capture-form', {
|
||||
" . $customForm . "
|
||||
labelPromo: '" . $labelPromo . "',
|
||||
labelSend: '" . $labelSend . "'
|
||||
});";
|
||||
} elseif (isset($setting['custom'])){
|
||||
$captureForm = "_rc('require', 'capture-form', {
|
||||
" . $customForm . "
|
||||
});";
|
||||
} else {
|
||||
$captureForm = "_rc('require', 'capture-form');";
|
||||
}
|
||||
} else {
|
||||
$captureForm = "";
|
||||
}
|
||||
|
||||
$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 . "
|
||||
});
|
||||
" . $captureForm . "
|
||||
_rc('send', 'pageView');
|
||||
</script>";
|
||||
|
||||
return html_entity_decode($js, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
@ -43,11 +43,6 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
|
||||
}
|
||||
|
||||
$data['totals'][] = array(
|
||||
'code' => 'shipping',
|
||||
'value' => $this->session->data['shipping_method']['cost']
|
||||
);
|
||||
|
||||
$this->load->model('extension/retailcrm/order');
|
||||
$this->model_extension_retailcrm_order->sendToCrm($data, $data['order_id']);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
$productOptions = $this->model_catalog_product->getProductOptions($product['product_id']);
|
||||
|
||||
foreach($product['option'] as $option) {
|
||||
if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox') {
|
||||
if ($option['type'] == 'checkbox') {
|
||||
$properties[] = array(
|
||||
'code' => $option['product_option_value_id'],
|
||||
'name' => $option['name'],
|
||||
@ -204,8 +204,13 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
if ($totals['code'] == 'shipping') {
|
||||
$deliveryCost = $totals['value'];
|
||||
}
|
||||
|
||||
if ($totals['code'] == 'coupon') {
|
||||
$couponTotal = abs($totals['value']);
|
||||
}
|
||||
}
|
||||
|
||||
$order['discount'] = $couponTotal;
|
||||
$order['createdAt'] = $order_data['date_added'];
|
||||
$order['paymentType'] = $settings['retailcrm_payment'][$payment_code];
|
||||
|
||||
@ -250,7 +255,7 @@ class ModelExtensionRetailcrmOrder extends Model {
|
||||
$productOptions = $this->model_catalog_product->getProductOptions($product['product_id']);
|
||||
|
||||
foreach($product['option'] as $option) {
|
||||
if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox') {
|
||||
if ($option['type'] == 'checkbox') {
|
||||
$properties[] = array(
|
||||
'code' => $option['product_option_value_id'],
|
||||
'name' => $option['name'],
|
||||
|
Loading…
Reference in New Issue
Block a user