mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-25 06:36:06 +03:00
Merge pull request #143 from iyzoer/master
History fix, orders history setting
This commit is contained in:
commit
41ac83aeff
@ -1,3 +1,7 @@
|
||||
## v.3.3.0
|
||||
* Добавена настройка записи истории изменения заказов в Opencart
|
||||
* Устранен баг с вызовом события редактирования заказа при выгрузке истории изменений из retailCRM
|
||||
|
||||
## v.3.2.4
|
||||
* Добавлена возможность передачи акционных цен для нескольких групп пользователей
|
||||
* Добавлена передача нулевой цены для неустановленных акционных цен
|
||||
|
@ -304,7 +304,9 @@ class ControllerExtensionModuleRetailcrm extends Controller
|
||||
'order_number',
|
||||
'text_order_number',
|
||||
'text_currency',
|
||||
'text_currency_label'
|
||||
'text_currency_label',
|
||||
'status_changes',
|
||||
'text_status_changes'
|
||||
);
|
||||
|
||||
$_data = &$data;
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
// Heading Goes here:
|
||||
$_['heading_title'] = 'Retailcrm';
|
||||
$_['retailcrm_title'] = 'Retailcrm';
|
||||
$_['heading_title'] = 'retailCRM';
|
||||
$_['retailcrm_title'] = 'retailCRM';
|
||||
|
||||
// Text
|
||||
$_['text_module'] = 'Modules';
|
||||
@ -56,7 +56,7 @@ $_['text_error_cf_opencart'] = 'There are no custom fields in Opencart';
|
||||
$_['text_error_cf_retailcrm'] = 'There are no custom fields in retailCRM';
|
||||
$_['text_error_save'] = 'Error when saving settings';
|
||||
$_['text_error_log'] = 'Log size is more than 2MB';
|
||||
$_['text_error_delivery'] = 'Delivery types are not found';
|
||||
$_['text_error_delivery'] = 'Delivery types are not found';
|
||||
$_['text_confirm_log'] = 'Are you sure that you want to clear the log?';
|
||||
|
||||
$_['retailcrm_dict_delivery'] = 'Delivery types';
|
||||
@ -70,6 +70,8 @@ $_['order_number'] = 'Order number';
|
||||
$_['text_order_number'] = 'Upload the order number to retailCRM';
|
||||
$_['text_currency'] = 'Currency setting';
|
||||
$_['text_currency_label'] = 'Currency in ICML';
|
||||
$_['status_changes'] = 'History of changes';
|
||||
$_['text_status_changes'] = 'Record changes to the order history of Opencart';
|
||||
|
||||
$_['column_total'] = 'Total';
|
||||
$_['product_summ'] = 'Sum';
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
// Heading Goes here:
|
||||
$_['heading_title'] = 'retailcrm';
|
||||
$_['retailcrm_title'] = 'retailcrm';
|
||||
$_['heading_title'] = 'retailCRM';
|
||||
$_['retailcrm_title'] = 'retailCRM';
|
||||
|
||||
// Text
|
||||
$_['text_module'] = 'Módulos';
|
||||
@ -24,7 +24,7 @@ $_['retailcrm_url'] = 'Dirección del retailCRM';
|
||||
$_['retailcrm_apikey'] = 'Clave de la API del retailCRM';
|
||||
$_['collector_site_key'] = 'Clave de la página web';
|
||||
$_['special_price_settings'] = 'Ajuste de la descarga del precio promocional';
|
||||
$_['special_price'] = 'Tipo de precio en el que se cargará el precio de promoción';
|
||||
$_['special_price'] = 'Tipo de precio en el que se cargará el precio de promoción';
|
||||
|
||||
$_['text_success_export'] = 'Los pedidos y los clientes han sido exportados con éxito';
|
||||
$_['text_success_export_order'] = 'El pedido ha sido exportado con éxito';
|
||||
@ -56,7 +56,7 @@ $_['text_error_cf_opencart'] = 'Faltan campos personalizados en Opencart';
|
||||
$_['text_error_cf_retailcrm'] = 'Faltan campos personalizados en retailCRM';
|
||||
$_['text_error_save'] = 'Error al guardar la configuración';
|
||||
$_['text_error_log'] = 'El Tamaño del registro es más de 2MB';
|
||||
$_['text_error_delivery'] = 'No se encontraron los métodos de envío';
|
||||
$_['text_error_delivery'] = 'No se encontraron los métodos de envío';
|
||||
$_['text_confirm_log'] = '¿Estás seguro de que quieres borrar el registro?';
|
||||
|
||||
$_['retailcrm_dict_delivery'] = 'Métodos de envío';
|
||||
@ -70,6 +70,8 @@ $_['order_number'] = 'Número de pedido';
|
||||
$_['text_order_number'] = 'Transferir número de pedido a retailCRM';
|
||||
$_['text_currency'] = 'Ajustes de moneda';
|
||||
$_['text_currency_label'] = 'Moneda en ICML';
|
||||
$_['status_changes'] = 'Historial de cambios';
|
||||
$_['text_status_changes'] = 'Registrar los cambios en el historial de pedidos de Opencart';
|
||||
|
||||
$_['column_total'] = 'Total';
|
||||
$_['product_summ'] = 'Importe';
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
// Heading Goes here:
|
||||
$_['heading_title'] = 'Retailcrm';
|
||||
$_['retailcrm_title'] = 'Retailcrm';
|
||||
$_['heading_title'] = 'retailCRM';
|
||||
$_['retailcrm_title'] = 'retailCRM';
|
||||
|
||||
// Text
|
||||
$_['text_module'] = 'Модули';
|
||||
@ -24,7 +24,7 @@ $_['retailcrm_url'] = 'Адрес RetailCRM';
|
||||
$_['retailcrm_apikey'] = 'Api ключ RetailCRM';
|
||||
$_['collector_site_key'] = 'Ключ сайта';
|
||||
$_['special_price_settings'] = 'Настройка выгрузки акционной цены';
|
||||
$_['special_price'] = 'Тип цены, в который будет выгружаться цена по акции';
|
||||
$_['special_price'] = 'Тип цены, в который будет выгружаться цена по акции';
|
||||
|
||||
$_['text_success_export'] = 'Заказы и клиенты успешно выгружены';
|
||||
$_['text_success_export_order'] = 'Заказ успешно выгружен';
|
||||
@ -56,7 +56,7 @@ $_['text_error_cf_opencart'] = 'Отсутствуют пользовате
|
||||
$_['text_error_cf_retailcrm'] = 'Отсутствуют пользовательские поля в RetailCRM';
|
||||
$_['text_error_save'] = 'Ошибка сохранения настроек';
|
||||
$_['text_error_log'] = 'Размер лога более 2MB';
|
||||
$_['text_error_delivery'] = 'Не найдены типы доставки';
|
||||
$_['text_error_delivery'] = 'Не найдены типы доставки';
|
||||
$_['text_confirm_log'] = 'Вы уверены, что хотите очистить лог?';
|
||||
|
||||
$_['retailcrm_dict_delivery'] = 'Способы доставки';
|
||||
@ -70,6 +70,8 @@ $_['order_number'] = 'Номер заказа';
|
||||
$_['text_order_number'] = 'Передавать номер заказа в retailCRM';
|
||||
$_['text_currency'] = 'Настройка валюты';
|
||||
$_['text_currency_label'] = 'Валюта в ICML';
|
||||
$_['status_changes'] = 'История изменений';
|
||||
$_['text_status_changes'] = 'Фиксировать изменения в истории заказа Opencart';
|
||||
|
||||
$_['column_total'] = 'Итого';
|
||||
$_['product_summ'] = 'Сумма';
|
||||
|
@ -4,9 +4,9 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
{
|
||||
/**
|
||||
* Create order in OC
|
||||
*
|
||||
*
|
||||
* @param array $order
|
||||
*
|
||||
*
|
||||
* @return int $order_id
|
||||
*/
|
||||
public function addOrder($order)
|
||||
@ -30,10 +30,10 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
|
||||
/**
|
||||
* Edit order in OC
|
||||
*
|
||||
*
|
||||
* @param int $order_id
|
||||
* @param array $order
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editOrder($order_id, $order)
|
||||
@ -57,10 +57,10 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
|
||||
/**
|
||||
* Add order products
|
||||
*
|
||||
*
|
||||
* @param int $order_id
|
||||
* @param array $products
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addOrderProducts($order_id, $products)
|
||||
@ -78,10 +78,10 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
|
||||
/**
|
||||
* Add order totals
|
||||
*
|
||||
*
|
||||
* @param int $order_id
|
||||
* @param array $totals
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addOrderTotals($order_id, $totals)
|
||||
@ -93,7 +93,7 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
|
||||
/**
|
||||
* Get total titles
|
||||
*
|
||||
*
|
||||
* @return string $title
|
||||
*/
|
||||
protected function totalTitles()
|
||||
@ -109,23 +109,23 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
|
||||
/**
|
||||
* Get country by iso code 2
|
||||
*
|
||||
*
|
||||
* @param string $isoCode
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCountryByIsoCode($isoCode)
|
||||
{
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE iso_code_2 = '" . $isoCode . "'");
|
||||
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zone by name
|
||||
*
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getZoneByName($name)
|
||||
@ -137,10 +137,10 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
|
||||
/**
|
||||
* Get currency
|
||||
*
|
||||
*
|
||||
* @param string $code
|
||||
* @param string $field (default = '')
|
||||
*
|
||||
*
|
||||
* @return mixed array | string
|
||||
*/
|
||||
public function getCurrencyByCode($code, $field = '')
|
||||
@ -156,10 +156,10 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
*
|
||||
* @param string $code
|
||||
* @param string $field (default = '')
|
||||
*
|
||||
*
|
||||
* @return mixed array | string
|
||||
*/
|
||||
public function getLanguageByCode($code, $field = '')
|
||||
@ -175,10 +175,10 @@ class ModelExtensionRetailcrmHistory extends Model
|
||||
|
||||
/**
|
||||
* Get product option value
|
||||
*
|
||||
*
|
||||
* @param int $option_value_id
|
||||
* @param string $field
|
||||
*
|
||||
*
|
||||
* @return mixed array | string
|
||||
*/
|
||||
public function getOptionValue($option_value_id, $field = '')
|
||||
|
@ -4,6 +4,9 @@ require_once __DIR__ . '/../history.php';
|
||||
|
||||
class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory
|
||||
{
|
||||
/** @var bool */
|
||||
public static $history_run = false;
|
||||
|
||||
protected $createResult;
|
||||
protected $settings;
|
||||
protected $moduleTitle;
|
||||
@ -32,7 +35,7 @@ class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory
|
||||
$this->load->model('setting/store');
|
||||
$this->load->model('user/api');
|
||||
$this->load->model('sale/order');
|
||||
$this->load->model('customer/customer');
|
||||
$this->load->model('customer/customer');
|
||||
$this->load->model('extension/retailcrm/references');
|
||||
$this->load->model('catalog/product');
|
||||
$this->load->model('catalog/option');
|
||||
@ -162,9 +165,9 @@ class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory
|
||||
}
|
||||
|
||||
$this->model_setting_setting->editSetting(
|
||||
'retailcrm_history',
|
||||
'retailcrm_history',
|
||||
array(
|
||||
'retailcrm_history_orders' => $sinceIdOrders,
|
||||
'retailcrm_history_orders' => $sinceIdOrders,
|
||||
'retailcrm_history_customers' => $sinceIdCustomers,
|
||||
'retailcrm_history_datetime' => $generatedAt
|
||||
)
|
||||
@ -183,13 +186,13 @@ class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory
|
||||
|
||||
/**
|
||||
* Update orders from history
|
||||
*
|
||||
*
|
||||
* @param array $orders
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function updateOrders($orders)
|
||||
{
|
||||
{
|
||||
foreach ($orders as $order) {
|
||||
$ocOrder = $this->model_sale_order->getOrder($order['externalId']);
|
||||
|
||||
@ -468,19 +471,26 @@ class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory
|
||||
}
|
||||
|
||||
$this->editOrder($order['externalId'], $data);
|
||||
$this->opencartApiClient->addHistory($order['externalId'], $data['order_status_id']);
|
||||
|
||||
if (isset($this->settings[$this->moduleTitle . '_status_changes'])
|
||||
&& $this->settings[$this->moduleTitle . '_status_changes']
|
||||
) {
|
||||
static::$history_run = true;
|
||||
$this->opencartApiClient->addHistory($order['externalId'], $data['order_status_id']);
|
||||
static::$history_run = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create orders from history
|
||||
*
|
||||
*
|
||||
* @param array $orders
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function createOrders($orders)
|
||||
{
|
||||
{
|
||||
$customersIdsFix = array();
|
||||
$ordersIdsFix = array();
|
||||
|
||||
|
@ -109,6 +109,26 @@
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><?php echo $status_changes; ?></legend>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="retailcrm_status_changes"><?php echo $text_status_changes; ?></label>
|
||||
<div class="col-sm-10">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_status_changes" value="1" <?php if (isset($saved_settings['retailcrm_status_changes']) &&
|
||||
$saved_settings['retailcrm_status_changes'] == 1) :
|
||||
echo 'checked'; endif; ?> />
|
||||
<?php echo $text_yes; ?>
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="retailcrm_status_changes" value="0" <?php if (!isset($saved_settings['retailcrm_status_changes']) ||
|
||||
$saved_settings['retailcrm_status_changes'] == 0) :
|
||||
echo 'checked'; endif; ?> />
|
||||
<?php echo $text_no; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?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): ?>
|
||||
@ -510,7 +530,7 @@
|
||||
<?php endif; ?>
|
||||
<div class="tab-pane" id="tab-logs">
|
||||
<fieldset style="margin-bottom: 30px;">
|
||||
<legend>Retailcrm API error log</legend>
|
||||
<legend>retailCRM API error log</legend>
|
||||
<div class="retailcrm_unit">
|
||||
<a onclick="confirm('<?php echo $text_confirm_log; ?>') ? location.href='<?php echo $clear_retailcrm; ?>' : false;" data-toggle="tooltip" title="<?php echo $button_clear; ?>" class="btn btn-danger"><i class="fa fa-eraser"></i> <span class="hidden-xs"><?php echo $button_clear; ?></span></a>
|
||||
</div>
|
||||
|
@ -108,6 +108,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{{ status_changes }}</legend>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="module_retailcrm_status_changes">{{ text_status_changes }}</label>
|
||||
<div class="col-sm-10">
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_status_changes" value="1"
|
||||
{% if saved_settings.retailcrm_status_changes is defined and saved_settings.retailcrm_status_changes == 1 %}
|
||||
checked
|
||||
{% endif %} />
|
||||
{{ text_yes }}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_status_changes" value="0"
|
||||
{% if saved_settings.retailcrm_status_changes is not defined or saved_settings.retailcrm_status_changes == 0 %}
|
||||
checked
|
||||
{% endif %} />
|
||||
{{ text_no }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
{% if saved_settings.module_retailcrm_apikey is defined and saved_settings.module_retailcrm_apikey and saved_settings.module_retailcrm_url is defined and saved_settings.module_retailcrm_url %}
|
||||
{% if retailcrm_errors|length %}
|
||||
{% for retailcrm_error in retailcrm_errors %}
|
||||
@ -161,16 +183,16 @@
|
||||
<div class="col-sm-10">
|
||||
<label class="control-label" class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_order_number" value="1"
|
||||
{% if saved_settings.module_retailcrm_order_number is defined and saved_settings.module_retailcrm_order_number == 1 %}
|
||||
checked
|
||||
{% endif %} />
|
||||
{% if saved_settings.module_retailcrm_order_number is defined and saved_settings.module_retailcrm_order_number == 1 %}
|
||||
checked
|
||||
{% endif %} />
|
||||
{{ text_yes }}
|
||||
</label>
|
||||
<label class="control-label" class="radio-inline">
|
||||
<input type="radio" name="module_retailcrm_order_number" value="0"
|
||||
{% if saved_settings.module_retailcrm_order_number is not defined or saved_settings.module_retailcrm_order_number == 0 %}
|
||||
checked
|
||||
{% endif %} />
|
||||
{% if saved_settings.module_retailcrm_order_number is not defined or saved_settings.module_retailcrm_order_number == 0 %}
|
||||
checked
|
||||
{% endif %} />
|
||||
{{ text_no }}
|
||||
</label>
|
||||
</div>
|
||||
@ -623,4 +645,4 @@
|
||||
$('#export_order').button('reset');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
@ -31,6 +31,11 @@ class ControllerExtensionModuleRetailcrm extends Controller {
|
||||
* @return void
|
||||
*/
|
||||
public function order_create($trigger, $data, $order_id = null) {
|
||||
|
||||
if (ModelExtensionRetailcrmHistoryV45::$history_run === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->load->model('checkout/order');
|
||||
$this->load->model('account/order');
|
||||
$this->load->library('retailcrm/retailcrm');
|
||||
|
Loading…
Reference in New Issue
Block a user