From da2e185204547716192bca411a8b75824ad96009 Mon Sep 17 00:00:00 2001 From: dkorol Date: Wed, 13 Jul 2016 17:42:44 +0300 Subject: [PATCH] removed opencart 1 compatibility --- admin/controller/module/retailcrm.php | 75 +++++--------- admin/model/retailcrm/history.php | 20 +--- admin/view/template/module/retailcrm.1.x.tpl | 99 ------------------- .../{retailcrm.2.x.tpl => retailcrm.tpl} | 0 vqmod/xml/retailcrm_create_order.xml | 47 --------- 5 files changed, 29 insertions(+), 212 deletions(-) delete mode 100644 admin/view/template/module/retailcrm.1.x.tpl rename admin/view/template/module/{retailcrm.2.x.tpl => retailcrm.tpl} (100%) delete mode 100644 vqmod/xml/retailcrm_create_order.xml diff --git a/admin/controller/module/retailcrm.php b/admin/controller/module/retailcrm.php index 85e4bd4..d9c845b 100644 --- a/admin/controller/module/retailcrm.php +++ b/admin/controller/module/retailcrm.php @@ -28,23 +28,21 @@ class ControllerModuleRetailcrm extends Controller $this->model_setting_setting ->editSetting('retailcrm', array('retailcrm_status' => 1)); - if (version_compare(VERSION, '2.0.1.0', '>')) { - $this->load->model('extension/event'); + $this->load->model('extension/event'); - $this->model_extension_event - ->addEvent( - 'retailcrm', - 'post.order.add', - 'module/retailcrm/order_create' - ); + $this->model_extension_event + ->addEvent( + 'retailcrm', + 'post.order.add', + 'module/retailcrm/order_create' + ); - $this->model_extension_event - ->addEvent( - 'retailcrm', - 'post.order.history.add', - 'module/retailcrm/order_edit' - ); - } + $this->model_extension_event + ->addEvent( + 'retailcrm', + 'post.order.history.add', + 'module/retailcrm/order_edit' + ); } /** @@ -58,10 +56,8 @@ class ControllerModuleRetailcrm extends Controller $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'); - } + $this->load->model('extension/event'); + $this->model_extension_event->deleteEvent('retailcrm'); } /** @@ -73,9 +69,7 @@ class ControllerModuleRetailcrm extends Controller { $this->load->model('setting/setting'); - if (version_compare(VERSION, '2.0.1.0', '>')) { - $this->load->model('extension/module'); - } + $this->load->model('extension/module'); $this->load->model('retailcrm/references'); $this->load->language('module/retailcrm'); $this->document->setTitle($this->language->get('heading_title')); @@ -93,11 +87,7 @@ class ControllerModuleRetailcrm extends Controller 'SSL' ); - if (version_compare(VERSION, '2.0.1.0', '<')) { - $this->redirect($redirect); - } else { - $this->response->redirect($redirect); - } + $this->response->redirect($redirect); } $text_strings = array( @@ -117,13 +107,8 @@ class ControllerModuleRetailcrm extends Controller 'retailcrm_dict_payment', ); - 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->load->model('extension/extension'); + $_data = &$data; foreach ($text_strings as $text) { $_data[$text] = $this->language->get($text); @@ -225,23 +210,13 @@ class ControllerModuleRetailcrm extends Controller $this->load->model('design/layout'); $_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', - ); + $_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()); - } 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->load->view('module/retailcrm.2.x.tpl', $_data) - ); - } + $this->response->setOutput( + $this->load->view('module/retailcrm.tpl', $_data) + ); } /** diff --git a/admin/model/retailcrm/history.php b/admin/model/retailcrm/history.php index aaed8f9..3e203c6 100644 --- a/admin/model/retailcrm/history.php +++ b/admin/model/retailcrm/history.php @@ -10,9 +10,7 @@ class ModelRetailcrmHistory extends Model { $this->load->model('setting/setting'); $this->load->model('setting/store'); - if(version_compare(VERSION, '2.0.0', '>=')) { - $this->load->model('user/api'); - } + $this->load->model('user/api'); $this->load->model('sale/order'); if (version_compare(VERSION, '2.1.0.0', '>=')) { $this->load->model('customer/customer'); @@ -37,9 +35,7 @@ class ModelRetailcrmHistory extends Model return false; } - if(version_compare(VERSION, '2.0.0', '>=')) { - $this->opencartApiClient = new OpencartApiClient($this->registry); - } + $this->opencartApiClient = new OpencartApiClient($this->registry); $crm = new RetailcrmProxy( $settings['retailcrm_url'], @@ -247,11 +243,7 @@ class ModelRetailcrmHistory extends Model $data['order_status_id'] = $tmpOrder['order_status_id']; } - if(version_compare(VERSION, '2.0.0', '>=')) { - $this->opencartApiClient->editOrder($order['externalId'], $data); - } else { - $this->model_sale_order->editOrder($order['externalId'], $data); - } + $this->opencartApiClient->editOrder($order['externalId'], $data); } } @@ -442,11 +434,7 @@ class ModelRetailcrmHistory extends Model $data['fromApi'] = true; $data['order_status_id'] = 1; - if(version_compare(VERSION, '2.0.0', '>=')) { - $this->opencartApiClient->addOrder($data); - } else { - $this->model_sale_order->addOrder($data); - } + $this->opencartApiClient->addOrder($data); $last = $this->model_sale_order->getOrders($data = array('order' => 'DESC', 'limit' => 1, 'start' => 0)); diff --git a/admin/view/template/module/retailcrm.1.x.tpl b/admin/view/template/module/retailcrm.1.x.tpl deleted file mode 100644 index 53e4841..0000000 --- a/admin/view/template/module/retailcrm.1.x.tpl +++ /dev/null @@ -1,99 +0,0 @@ - - -
- - -
- - - - - -
-
-

-
-
-
-
- - -

-
-
- -
-
-
- -
- - - - - -
- - -

- -

- $value): ?> -
- - -
- - -

- - -
- - -
- - -

- $value): ?> -
- - -
- - - - - -
-
-
-
- - - diff --git a/admin/view/template/module/retailcrm.2.x.tpl b/admin/view/template/module/retailcrm.tpl similarity index 100% rename from admin/view/template/module/retailcrm.2.x.tpl rename to admin/view/template/module/retailcrm.tpl diff --git a/vqmod/xml/retailcrm_create_order.xml b/vqmod/xml/retailcrm_create_order.xml deleted file mode 100644 index 371345e..0000000 --- a/vqmod/xml/retailcrm_create_order.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - Send order to RetailCRM when it created - 1.5.x - 2.3.x - retailcrm.ru - - - - cart->clear()]]> - load->model('account/order'); - $this->load->model('checkout/order'); - $this->load->model('retailcrm/order'); - - $order = $this->model_checkout_order->getOrder($this->session->data['order_id']); - $order['products'] = $this->model_account_order->getOrderProducts($this->session->data['order_id']); - $order['order_total'] = $this->model_account_order->getOrderTotals($this->session->data['order_id']); - - $this->model_retailcrm_order->sendToCrm($order, $this->session->data['order_id']); - ]]> - - - - - - db->query("UPDATE `" . DB_PREFIX . "order` SET total = '" . (float)$total . "', affiliate_id = '" . (int)$affiliate_id . "', commission = '" . (float)$commission . "' WHERE order_id = '" . (int)$order_id . "'");]]> - 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); - } - } - ]]> - - -