mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-25 06:36:06 +03:00
removed opencart 1 compatibility
This commit is contained in:
parent
185d28f2b6
commit
da2e185204
@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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));
|
||||
|
||||
|
@ -1,99 +0,0 @@
|
||||
<?php echo $header; ?>
|
||||
|
||||
<div id="content">
|
||||
<div class="breadcrumb">
|
||||
<?php foreach ($breadcrumbs as $breadcrumb): ?>
|
||||
<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($error_warning) : ?>
|
||||
<div class="warning"><?php echo $error_warning; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($saved_settings['retailcrm_url'])): ?>
|
||||
<div class="success">
|
||||
<?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="box">
|
||||
<div class="heading">
|
||||
<h1><img src="view/image/module.png" alt="" /> <?php echo $heading_title; ?></h1>
|
||||
<div class="buttons"><a onclick="$('#form').submit();" class="button"><span><?php echo $button_save; ?></span></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><span><?php echo $button_cancel; ?></span></a></div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
|
||||
<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>
|
||||
|
||||
|
||||
<?php echo $footer; ?>
|
@ -1,47 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<modification>
|
||||
<id>Send order to RetailCRM when it created</id>
|
||||
<version>1.5.x</version>
|
||||
<vqmver required="true">2.3.x</vqmver>
|
||||
<author>retailcrm.ru</author>
|
||||
|
||||
<file path="catalog/controller/checkout/" name="success.php">
|
||||
<operation error="skip">
|
||||
<search position="before" ><![CDATA[$this->cart->clear()]]></search>
|
||||
<add><![CDATA[
|
||||
$this->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']);
|
||||
]]></add>
|
||||
</operation>
|
||||
</file>
|
||||
|
||||
<file path="admin/model/sale/" name="order.php">
|
||||
<operation error="skip">
|
||||
<search position="after" ><![CDATA[$this->db->query("UPDATE `" . DB_PREFIX . "order` SET total = '" . (float)$total . "', affiliate_id = '" . (int)$affiliate_id . "', commission = '" . (float)$commission . "' WHERE order_id = '" . (int)$order_id . "'");]]></search>
|
||||
<add><![CDATA[
|
||||
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);
|
||||
}
|
||||
}
|
||||
]]></add>
|
||||
</operation>
|
||||
</file>
|
||||
</modification>
|
Loading…
Reference in New Issue
Block a user