mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-22 05:06:07 +03:00
commit
54312edd18
51
README.md
51
README.md
@ -1,62 +1,59 @@
|
||||
Opencart module
|
||||
===============
|
||||
|
||||
Модуль интеграции CMS Openacrt c [RetailCRM](http://retailcrm.ru)
|
||||
Module allows integrate CMS Openacart with [retailCRM](http://retailcrm.ru)
|
||||
|
||||
#### Модуль позволяет:
|
||||
#### Module allows:
|
||||
|
||||
* Экспортировать в CRM данные о заказах и клиентах и получать обратно изменения по этим данным
|
||||
* Синхронизировать справочники (способы доставки и оплаты, статусы заказов и т.п.)
|
||||
* Выгружать каталог товаров в формате [ICML](http://retailcrm.ru/docs/Разработчики/ФорматICML) (IntaroCRM Markup Language)
|
||||
* Export orders to retailCRM & fetch changes back
|
||||
* Export product catalog into [ICML](http://www.retailcrm.ru/docs/Developers/ICML) format
|
||||
|
||||
#### Установка
|
||||
#### Install
|
||||
|
||||
Установите модуль скопировав необходимые файлы в корень сайта
|
||||
Copy files to the site root
|
||||
|
||||
```
|
||||
unzip master.zip
|
||||
cp -r opencart-module/* /path/to/site/root
|
||||
```
|
||||
|
||||
#### Активируйте модуль
|
||||
#### Setup
|
||||
|
||||
В списке модулей нажмите "Установить"
|
||||
|
||||
#### Настройте параметры интеграции
|
||||
|
||||
На странице настроек модуля укажите URL Вашей CRM и ключ авторизации, после сохранения этих данных укажите соответствия справочников типов доставок, оплат и статусов заказа.
|
||||
* Go to Admin -> Extensions -> Modules -> retailCRM
|
||||
* Fill you api url & api key
|
||||
* Specify directories matching
|
||||
|
||||
|
||||
#### Выгрузка новых заказов в CRM (для версии opencart 1.5.x.x, для версии 2.0 и старше не требуется)
|
||||
#### Export orders to retailCRM (for opencart 1.5.x, for version 2.x this step is unnecessary)
|
||||
|
||||
##### VQmod
|
||||
|
||||
Скопируйте xml-файл модифицирующий работу моделей _admin/model/sale/order.php_ и _catalog/model/checkout/order.php_ в _/path/to/site/root/vqmod/xml_.
|
||||
Copy _retailcrm_create_order.xml_ into _/path/to/site/root/vqmod/xml_.
|
||||
|
||||
Для обновления кеша VQmod может потрбоваться удалить файлы _/path/to/site/root/vqmod/vqcache/vq2-admin_model_sale_order.php_ и _/path/to/site/root/vqmod/vqcache/vq2-catalog_model_checkout_order.php_
|
||||
For VQmod cache renewal you may need to delete files _/path/to/site/root/vqmod/vqcache/vq2-admin_model_sale_order.php_ & _/path/to/site/root/vqmod/vqcache/vq2-catalog_model_checkout_order.php_
|
||||
|
||||
##### Ручная установка
|
||||
##### Manual setup
|
||||
|
||||
В файле:
|
||||
In the file:
|
||||
|
||||
```
|
||||
/catalog/model/checkout/order.php
|
||||
```
|
||||
|
||||
Добавьте следующие строки в метод addOrder непосредственно перед языковой конструкцией return:
|
||||
add theese lines into addOrder method right before return statement:
|
||||
|
||||
```php
|
||||
$this->load->model('retailcrm/order');
|
||||
$this->model_retailcrm_order->sendToCrm($data, $order_id);
|
||||
```
|
||||
|
||||
В файле:
|
||||
In the file:
|
||||
|
||||
```
|
||||
/admin/model/sale/order.php
|
||||
```
|
||||
|
||||
Добавьте следующие строки в методы addOrder и editOrder в самом конце каждого метода:
|
||||
add theese lines into addOrder & editOrder methods right before return statement:
|
||||
|
||||
```php
|
||||
if (!isset($data['fromApi'])) {
|
||||
@ -76,24 +73,24 @@ if (!isset($data['fromApi'])) {
|
||||
}
|
||||
```
|
||||
|
||||
#### Получение измений из CRM
|
||||
#### Getting changes in orders
|
||||
|
||||
Для получения изменений и новых данных добавьте в cron следующую запись:
|
||||
Add to cron:
|
||||
|
||||
```
|
||||
*/5 * * * * /usr/bin/php /path/to/opencart/system/cron/history.php >> /path/to/opencart/system/logs/cronjob_history.log 2>&1
|
||||
```
|
||||
|
||||
#### Настройка экспорта каталога
|
||||
#### Setting product catalog export
|
||||
|
||||
Для периодической выгрузки каталога добавьте в cron следующую запись:
|
||||
Add to cron:
|
||||
|
||||
```
|
||||
* */4 * * * /usr/bin/php /path/to/opencart/system/cron/export.php >> /path/to/opencart/system/logs/cronjob_export.log 2>&1
|
||||
```
|
||||
|
||||
В настройках CRM установите путь к файлу выгрузки
|
||||
Your export file will be available by following url
|
||||
|
||||
```
|
||||
http://myopencartsite.ru/download/retailcrm.xml
|
||||
http://youropencartsite.com/retailcrm.xml
|
||||
```
|
||||
|
99
README.ru.md
Normal file
99
README.ru.md
Normal file
@ -0,0 +1,99 @@
|
||||
Opencart module
|
||||
===============
|
||||
|
||||
Модуль интеграции CMS Openacart c [RetailCRM](http://retailcrm.ru)
|
||||
|
||||
#### Модуль позволяет:
|
||||
|
||||
* Экспортировать в CRM данные о заказах и клиентах и получать обратно изменения по этим данным
|
||||
* Синхронизировать справочники (способы доставки и оплаты, статусы заказов и т.п.)
|
||||
* Выгружать каталог товаров в формате [ICML](http://www.retailcrm.ru/docs/Developers/ICML)
|
||||
|
||||
#### Установка
|
||||
|
||||
Установите модуль скопировав необходимые файлы в корень сайта
|
||||
|
||||
```
|
||||
unzip master.zip
|
||||
cp -r opencart-module/* /path/to/site/root
|
||||
```
|
||||
|
||||
#### Активируйте модуль
|
||||
|
||||
В списке модулей нажмите "Установить"
|
||||
|
||||
#### Настройте параметры интеграции
|
||||
|
||||
На странице настроек модуля укажите URL Вашей CRM и ключ авторизации, после сохранения этих данных укажите соответствия справочников типов доставок, оплат и статусов заказа.
|
||||
|
||||
|
||||
#### Выгрузка новых заказов в CRM (для версии opencart 1.5.x.x, для версии 2.0 и старше не требуется)
|
||||
|
||||
##### VQmod
|
||||
|
||||
Скопируйте файл _retailcrm_create_order.xml_ в _/path/to/site/root/vqmod/xml_.
|
||||
|
||||
Для обновления кеша VQmod может потрбоваться удалить файлы _/path/to/site/root/vqmod/vqcache/vq2-admin_model_sale_order.php_ и _/path/to/site/root/vqmod/vqcache/vq2-catalog_model_checkout_order.php_
|
||||
|
||||
##### Ручная установка
|
||||
|
||||
В файле:
|
||||
|
||||
```
|
||||
/catalog/model/checkout/order.php
|
||||
```
|
||||
|
||||
Добавьте следующие строки в метод addOrder непосредственно перед языковой конструкцией return:
|
||||
|
||||
```php
|
||||
$this->load->model('retailcrm/order');
|
||||
$this->model_retailcrm_order->sendToCrm($data, $order_id);
|
||||
```
|
||||
|
||||
В файле:
|
||||
|
||||
```
|
||||
/admin/model/sale/order.php
|
||||
```
|
||||
|
||||
Добавьте следующие строки в методы addOrder и editOrder в самом конце каждого метода:
|
||||
|
||||
```php
|
||||
if (!isset($data['fromApi'])) {
|
||||
$this->load->model('setting/setting');
|
||||
$status = $this->model_setting_setting->getSetting('retailcrm');
|
||||
|
||||
if (!empty($data['order_status_id'])) {
|
||||
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
|
||||
}
|
||||
|
||||
$this->load->model('retailcrm/order');
|
||||
if (isset ($order_query)) {
|
||||
$this->model_retailcrm_order->changeInCrm($data, $order_id);
|
||||
} else {
|
||||
$this->model_retailcrm_order->sendToCrm($data, $order_id);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Получение измений из CRM
|
||||
|
||||
Для получения изменений и новых данных добавьте в cron следующую запись:
|
||||
|
||||
```
|
||||
*/5 * * * * /usr/bin/php /path/to/opencart/system/cron/history.php >> /path/to/opencart/system/logs/cronjob_history.log 2>&1
|
||||
```
|
||||
|
||||
#### Настройка экспорта каталога
|
||||
|
||||
Для периодической выгрузки каталога добавьте в cron следующую запись:
|
||||
|
||||
```
|
||||
* */4 * * * /usr/bin/php /path/to/opencart/system/cron/export.php >> /path/to/opencart/system/logs/cronjob_export.log 2>&1
|
||||
```
|
||||
|
||||
В настройках CRM установите путь к файлу выгрузки
|
||||
|
||||
```
|
||||
http://youropencartsite.com/retailcrm.xml
|
||||
```
|
@ -4,6 +4,12 @@ require_once DIR_SYSTEM . 'library/retailcrm/bootstrap.php';
|
||||
|
||||
/**
|
||||
* Class ControllerModule
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
||||
*/
|
||||
class ControllerModuleRetailcrm extends Controller
|
||||
{
|
||||
@ -21,6 +27,17 @@ class ControllerModuleRetailcrm extends Controller
|
||||
$this->load->model('setting/setting');
|
||||
$this->model_setting_setting
|
||||
->editSetting('retailcrm', array('retailcrm_status' => 1));
|
||||
|
||||
if (version_compare(VERSION, '2.0.1.0', '>')) {
|
||||
$this->load->model('extension/event');
|
||||
|
||||
$this->model_extension_event
|
||||
->addEvent(
|
||||
'retailcrm',
|
||||
'post.order.add',
|
||||
'module/retailcrm/order_create'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -33,25 +50,45 @@ class ControllerModuleRetailcrm extends Controller
|
||||
$this->load->model('setting/setting');
|
||||
$this->model_setting_setting
|
||||
->editSetting('retailcrm', array('retailcrm_status' => 0));
|
||||
|
||||
if (version_compare(VERSION, '2.0.1.0', '>')) {
|
||||
$this->load->model('extension/event');
|
||||
$this->model_extension_event->deleteEvent('retailcrm');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->load->model('setting/setting');
|
||||
$this->load->model('setting/extension');
|
||||
$this->load->model('extension/module');
|
||||
$this->load->model('retailcrm/references');
|
||||
$this->load->language('module/retailcrm');
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
|
||||
|
||||
if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
|
||||
$this->model_setting_setting->editSetting('retailcrm', $this->request->post);
|
||||
$this->model_setting_setting->editSetting(
|
||||
'retailcrm',
|
||||
$this->request->post
|
||||
);
|
||||
|
||||
$this->session->data['success'] = $this->language->get('text_success');
|
||||
$this->redirect($this->url->link('module/retailcrm', 'token=' . $this->session->data['token'], 'SSL'));
|
||||
$redirect = $this->url->link(
|
||||
'module/retailcrm', 'token=' . $this->session->data['token'],
|
||||
'SSL'
|
||||
);
|
||||
|
||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
||||
$this->redirect($redirect);
|
||||
} else {
|
||||
$this->response->redirect($redirect);
|
||||
}
|
||||
}
|
||||
|
||||
$text_strings = array(
|
||||
@ -61,6 +98,7 @@ class ControllerModuleRetailcrm extends Controller
|
||||
'button_save',
|
||||
'button_cancel',
|
||||
'text_notice',
|
||||
'retailcrm_title',
|
||||
'retailcrm_url',
|
||||
'retailcrm_apikey',
|
||||
'retailcrm_base_settings',
|
||||
@ -70,27 +108,43 @@ class ControllerModuleRetailcrm extends Controller
|
||||
'retailcrm_dict_payment',
|
||||
);
|
||||
|
||||
foreach ($text_strings as $text) {
|
||||
$this->data[$text] = $this->language->get($text);
|
||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
||||
$_data = &$this->data;
|
||||
$this->load->model('setting/extension');
|
||||
} else {
|
||||
$this->load->model('extension/extension');
|
||||
$_data = &$data;
|
||||
}
|
||||
|
||||
$this->data['retailcrm_errors'] = array();
|
||||
$this->data['saved_settings'] = $this->model_setting_setting->getSetting('retailcrm');
|
||||
foreach ($text_strings as $text) {
|
||||
$_data[$text] = $this->language->get($text);
|
||||
}
|
||||
|
||||
$url = isset($this->data['saved_settings']['retailcrm_url'])
|
||||
? $this->data['saved_settings']['retailcrm_url']
|
||||
$_data['retailcrm_errors'] = array();
|
||||
$_data['saved_settings'] = $this->model_setting_setting
|
||||
->getSetting('retailcrm');
|
||||
|
||||
$url = isset($_data['saved_settings']['retailcrm_url'])
|
||||
? $_data['saved_settings']['retailcrm_url']
|
||||
: null;
|
||||
$key = isset($this->data['saved_settings']['retailcrm_apikey'])
|
||||
? $this->data['saved_settings']['retailcrm_apikey']
|
||||
$key = isset($_data['saved_settings']['retailcrm_apikey'])
|
||||
? $_data['saved_settings']['retailcrm_apikey']
|
||||
: null;
|
||||
|
||||
if (!empty($url) && !empty($key)) {
|
||||
|
||||
$this->retailcrm = new RetailcrmProxy($url, $key, DIR_SYSTEM . 'logs/retailcrm.log');
|
||||
$this->retailcrm = new RetailcrmProxy(
|
||||
$url,
|
||||
$key,
|
||||
DIR_SYSTEM . 'logs/retailcrm.log'
|
||||
);
|
||||
|
||||
$this->data['delivery'] = $this->model_retailcrm_references->getDeliveryTypes();
|
||||
$this->data['statuses'] = $this->model_retailcrm_references->getOrderStatuses();
|
||||
$this->data['payments'] = $this->model_retailcrm_references->getPaymentTypes();
|
||||
$_data['delivery'] = $this->model_retailcrm_references
|
||||
->getDeliveryTypes();
|
||||
$_data['statuses'] = $this->model_retailcrm_references
|
||||
->getOrderStatuses();
|
||||
$_data['payments'] = $this->model_retailcrm_references
|
||||
->getPaymentTypes();
|
||||
|
||||
}
|
||||
|
||||
@ -100,21 +154,21 @@ class ControllerModuleRetailcrm extends Controller
|
||||
|
||||
foreach ($config_data as $conf) {
|
||||
if (isset($this->request->post[$conf])) {
|
||||
$this->data[$conf] = $this->request->post[$conf];
|
||||
$_data[$conf] = $this->request->post[$conf];
|
||||
} else {
|
||||
$this->data[$conf] = $this->config->get($conf);
|
||||
$_data[$conf] = $this->config->get($conf);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->error['warning'])) {
|
||||
$this->data['error_warning'] = $this->error['warning'];
|
||||
$_data['error_warning'] = $this->error['warning'];
|
||||
} else {
|
||||
$this->data['error_warning'] = '';
|
||||
$_data['error_warning'] = '';
|
||||
}
|
||||
|
||||
$this->data['breadcrumbs'] = array();
|
||||
$_data['breadcrumbs'] = array();
|
||||
|
||||
$this->data['breadcrumbs'][] = array(
|
||||
$_data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link(
|
||||
'common/home',
|
||||
@ -123,7 +177,7 @@ class ControllerModuleRetailcrm extends Controller
|
||||
'separator' => false
|
||||
);
|
||||
|
||||
$this->data['breadcrumbs'][] = array(
|
||||
$_data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('text_module'),
|
||||
'href' => $this->url->link(
|
||||
'extension/module',
|
||||
@ -132,8 +186,8 @@ class ControllerModuleRetailcrm extends Controller
|
||||
'separator' => ' :: '
|
||||
);
|
||||
|
||||
$this->data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('heading_title'),
|
||||
$_data['breadcrumbs'][] = array(
|
||||
'text' => $this->language->get('retailcrm_title'),
|
||||
'href' => $this->url->link(
|
||||
'module/retailcrm',
|
||||
'token=' . $this->session->data['token'], 'SSL'
|
||||
@ -141,40 +195,50 @@ class ControllerModuleRetailcrm extends Controller
|
||||
'separator' => ' :: '
|
||||
);
|
||||
|
||||
$this->data['action'] = $this->url->link(
|
||||
$_data['action'] = $this->url->link(
|
||||
'module/retailcrm',
|
||||
'token=' . $this->session->data['token'], 'SSL'
|
||||
);
|
||||
|
||||
$this->data['cancel'] = $this->url->link(
|
||||
$_data['cancel'] = $this->url->link(
|
||||
'extension/module',
|
||||
'token=' . $this->session->data['token'], 'SSL'
|
||||
);
|
||||
|
||||
|
||||
$this->data['modules'] = array();
|
||||
$_data['modules'] = array();
|
||||
|
||||
if (isset($this->request->post['retailcrm_module'])) {
|
||||
$this->data['modules'] = $this->request->post['retailcrm_module'];
|
||||
$_data['modules'] = $this->request->post['retailcrm_module'];
|
||||
} elseif ($this->config->get('retailcrm_module')) {
|
||||
$this->data['modules'] = $this->config->get('retailcrm_module');
|
||||
$_data['modules'] = $this->config->get('retailcrm_module');
|
||||
}
|
||||
|
||||
$this->load->model('design/layout');
|
||||
$_data['layouts'] = $this->model_design_layout->getLayouts();
|
||||
|
||||
$this->data['layouts'] = $this->model_design_layout->getLayouts();
|
||||
if (version_compare(VERSION, '2.0.1.0', '<')) {
|
||||
$this->template = 'module/retailcrm.1.x.tpl';
|
||||
$this->children = array(
|
||||
'common/header',
|
||||
'common/footer',
|
||||
);
|
||||
|
||||
$this->template = 'module/retailcrm.tpl';
|
||||
$this->children = array(
|
||||
'common/header',
|
||||
'common/footer',
|
||||
);
|
||||
$this->response->setOutput($this->render());
|
||||
} else {
|
||||
$_data['header'] = $this->load->controller('common/header');
|
||||
$_data['column_left'] = $this->load->controller('common/column_left');
|
||||
$_data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->render());
|
||||
$this->response->setOutput(
|
||||
$this->load->view('module/retailcrm.2.x.tpl', $_data)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* History method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function history()
|
||||
{
|
||||
@ -189,6 +253,8 @@ class ControllerModuleRetailcrm extends Controller
|
||||
|
||||
/**
|
||||
* ICML generation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function icml()
|
||||
{
|
||||
@ -201,6 +267,32 @@ class ControllerModuleRetailcrm extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create order on event
|
||||
*
|
||||
* @param int $order_id order identificator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function order_create($order_id)
|
||||
{
|
||||
|
||||
$this->load->model('checkout/order');
|
||||
$this->load->model('account/order');
|
||||
|
||||
$data = $this->model_checkout_order->getOrder($order_id);
|
||||
$data['products'] = $this->model_account_order->getOrderProducts($order_id);
|
||||
|
||||
if (!isset($data['fromApi'])) {
|
||||
$this->load->model('setting/setting');
|
||||
$status = $this->model_setting_setting->getSetting('retailcrm');
|
||||
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
|
||||
|
||||
$this->load->model('retailcrm/order');
|
||||
$this->model_retailcrm_order->sendToCrm($data, $data['order_id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate
|
||||
*
|
||||
@ -213,9 +305,9 @@ class ControllerModuleRetailcrm extends Controller
|
||||
}
|
||||
|
||||
if (!$this->_error) {
|
||||
return TRUE;
|
||||
return true;
|
||||
} else {
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// Heading Goes here:
|
||||
$_['heading_title'] = 'RetailCRM';
|
||||
$_['retailcrm_title'] = 'RetailCRM';
|
||||
|
||||
// Text
|
||||
$_['text_module'] = 'Modules';
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// Heading Goes here:
|
||||
$_['heading_title'] = 'RetailCRM';
|
||||
$_['retailcrm_title'] = 'RetailCRM';
|
||||
|
||||
// Text
|
||||
$_['text_module'] = 'Модули';
|
||||
|
@ -86,7 +86,7 @@ class ModelRetailcrmOrder extends Model {
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($order_data['order_status_id'])) {
|
||||
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
||||
$order['status'] = $settings['retailcrm_status'][$order_data['order_status_id']];
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ class ModelRetailcrmOrder extends Model {
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($order_data['order_status_id'])) {
|
||||
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
||||
$order['status'] = $settings['retailcrm_status'][$order_data['order_status_id']];
|
||||
}
|
||||
|
||||
|
110
admin/view/template/module/retailcrm.2.x.tpl
Normal file
110
admin/view/template/module/retailcrm.2.x.tpl
Normal file
@ -0,0 +1,110 @@
|
||||
<?php echo $header; ?>
|
||||
<?php echo $column_left;?>
|
||||
|
||||
<div id="content">
|
||||
<div class="page-header">
|
||||
<div class="container-fluid">
|
||||
<div class="pull-right">
|
||||
<button type="submit" form="form-retailcrm" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
|
||||
<a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
|
||||
<h1><?php echo $heading_title; ?></h1>
|
||||
<ul class="breadcrumb">
|
||||
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
|
||||
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<?php if ($error_warning) : ?>
|
||||
<div class="alert alert-danger">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($saved_settings['retailcrm_url'])): ?>
|
||||
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<?php echo $text_notice; ?>
|
||||
<a href="<?php echo $saved_settings['retailcrm_url']; ?>/admin/settings#t-main"><?php echo $saved_settings['retailcrm_url']; ?>/admin/settings#t-main</a>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<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">
|
||||
|
||||
<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>
|
||||
|
||||
<?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_dict_settings; ?></h3>
|
||||
|
||||
<h4><?php echo $retailcrm_dict_delivery; ?></h4>
|
||||
<?php foreach ($delivery['opencart'] as $key => $value): ?>
|
||||
<div class="retailcrm_unit">
|
||||
<select id="retailcrm_delivery_<?php echo $key; ?>" name="retailcrm_delivery[<?php echo $key; ?>]" >
|
||||
<?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_delivery_<?php echo $key; ?>"><?php echo $value; ?></label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<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; ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo $footer; ?>
|
40
catalog/controller/module/retailcrm.php
Normal file
40
catalog/controller/module/retailcrm.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class ControllerModule
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
||||
*/
|
||||
class ControllerModuleRetailcrm extends Controller
|
||||
{
|
||||
/**
|
||||
* Create order on event
|
||||
*
|
||||
* @param int $order_id order identificator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function order_create($order_id)
|
||||
{
|
||||
$this->load->model('checkout/order');
|
||||
$this->load->model('account/order');
|
||||
|
||||
$data = $this->model_checkout_order->getOrder($order_id);
|
||||
$data['products'] = $this->model_account_order->getOrderProducts($order_id);
|
||||
|
||||
if (!isset($data['fromApi'])) {
|
||||
$this->load->model('setting/setting');
|
||||
$status = $this->model_setting_setting->getSetting('retailcrm');
|
||||
if ($data['order_status_id'] > 0) {
|
||||
$data['order_status'] = $status['retailcrm_status'][$data['order_status_id']];
|
||||
}
|
||||
|
||||
$this->load->model('retailcrm/order');
|
||||
$this->model_retailcrm_order->sendToCrm($data, $data['order_id']);
|
||||
}
|
||||
}
|
||||
}
|
@ -44,11 +44,14 @@ class ModelRetailcrmOrder extends Model {
|
||||
$order['customerComment'] = $order_data['comment'];
|
||||
|
||||
$deliveryCost = 0;
|
||||
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $order_data['order_total'] ;
|
||||
$altTotals = isset($order_data['order_total']) ? $order_data['order_total'] : "";
|
||||
$orderTotals = isset($order_data['totals']) ? $order_data['totals'] : $altTotals ;
|
||||
|
||||
foreach ($orderTotals as $totals) {
|
||||
if ($totals['code'] == 'shipping') {
|
||||
$deliveryCost = $totals['value'];
|
||||
if (!empty($orderTotals)) {
|
||||
foreach ($orderTotals as $totals) {
|
||||
if ($totals['code'] == 'shipping') {
|
||||
$deliveryCost = $totals['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +89,7 @@ class ModelRetailcrmOrder extends Model {
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($order_data['order_status_id'])) {
|
||||
if (isset($order_data['order_status_id']) && $order_data['order_status_id'] > 0) {
|
||||
$order['status'] = $settings['retailcrm_status'][$order_data['order_status_id']];
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,6 @@ $registry->set('request', $request);
|
||||
$response = new Response();
|
||||
$response->addHeader('Content-Type: text/html; charset=utf-8');
|
||||
$registry->set('response', $response);
|
||||
$cache = new Cache();
|
||||
$registry->set('cache', $cache);
|
||||
$session = new Session();
|
||||
$registry->set('session', $session);
|
||||
$languages = array();
|
||||
|
Loading…
Reference in New Issue
Block a user