Merge pull request #143 from iyzoer/master

History fix, orders history setting
This commit is contained in:
Alex Lushpai 2019-03-20 09:44:43 +03:00 committed by GitHub
commit 41ac83aeff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 120 additions and 51 deletions

View File

@ -1,3 +1,7 @@
## v.3.3.0
* Добавена настройка записи истории изменения заказов в Opencart
* Устранен баг с вызовом события редактирования заказа при выгрузке истории изменений из retailCRM
## v.3.2.4 ## v.3.2.4
* Добавлена возможность передачи акционных цен для нескольких групп пользователей * Добавлена возможность передачи акционных цен для нескольких групп пользователей
* Добавлена передача нулевой цены для неустановленных акционных цен * Добавлена передача нулевой цены для неустановленных акционных цен

View File

@ -1 +1 @@
3.2.4 3.3.0

View File

@ -304,7 +304,9 @@ class ControllerExtensionModuleRetailcrm extends Controller
'order_number', 'order_number',
'text_order_number', 'text_order_number',
'text_currency', 'text_currency',
'text_currency_label' 'text_currency_label',
'status_changes',
'text_status_changes'
); );
$_data = &$data; $_data = &$data;

View File

@ -1,8 +1,8 @@
<?php <?php
// Heading Goes here: // Heading Goes here:
$_['heading_title'] = 'Retailcrm'; $_['heading_title'] = 'retailCRM';
$_['retailcrm_title'] = 'Retailcrm'; $_['retailcrm_title'] = 'retailCRM';
// Text // Text
$_['text_module'] = 'Modules'; $_['text_module'] = 'Modules';
@ -70,6 +70,8 @@ $_['order_number'] = 'Order number';
$_['text_order_number'] = 'Upload the order number to retailCRM'; $_['text_order_number'] = 'Upload the order number to retailCRM';
$_['text_currency'] = 'Currency setting'; $_['text_currency'] = 'Currency setting';
$_['text_currency_label'] = 'Currency in ICML'; $_['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'; $_['column_total'] = 'Total';
$_['product_summ'] = 'Sum'; $_['product_summ'] = 'Sum';

View File

@ -1,8 +1,8 @@
<?php <?php
// Heading Goes here: // Heading Goes here:
$_['heading_title'] = 'retailcrm'; $_['heading_title'] = 'retailCRM';
$_['retailcrm_title'] = 'retailcrm'; $_['retailcrm_title'] = 'retailCRM';
// Text // Text
$_['text_module'] = 'Módulos'; $_['text_module'] = 'Módulos';
@ -70,6 +70,8 @@ $_['order_number'] = 'Número de pedido';
$_['text_order_number'] = 'Transferir número de pedido a retailCRM'; $_['text_order_number'] = 'Transferir número de pedido a retailCRM';
$_['text_currency'] = 'Ajustes de moneda'; $_['text_currency'] = 'Ajustes de moneda';
$_['text_currency_label'] = 'Moneda en ICML'; $_['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'; $_['column_total'] = 'Total';
$_['product_summ'] = 'Importe'; $_['product_summ'] = 'Importe';

View File

@ -1,8 +1,8 @@
<?php <?php
// Heading Goes here: // Heading Goes here:
$_['heading_title'] = 'Retailcrm'; $_['heading_title'] = 'retailCRM';
$_['retailcrm_title'] = 'Retailcrm'; $_['retailcrm_title'] = 'retailCRM';
// Text // Text
$_['text_module'] = 'Модули'; $_['text_module'] = 'Модули';
@ -70,6 +70,8 @@ $_['order_number'] = 'Номер заказа';
$_['text_order_number'] = 'Передавать номер заказа в retailCRM'; $_['text_order_number'] = 'Передавать номер заказа в retailCRM';
$_['text_currency'] = 'Настройка валюты'; $_['text_currency'] = 'Настройка валюты';
$_['text_currency_label'] = 'Валюта в ICML'; $_['text_currency_label'] = 'Валюта в ICML';
$_['status_changes'] = 'История изменений';
$_['text_status_changes'] = 'Фиксировать изменения в истории заказа Opencart';
$_['column_total'] = 'Итого'; $_['column_total'] = 'Итого';
$_['product_summ'] = 'Сумма'; $_['product_summ'] = 'Сумма';

View File

@ -4,6 +4,9 @@ require_once __DIR__ . '/../history.php';
class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory
{ {
/** @var bool */
public static $history_run = false;
protected $createResult; protected $createResult;
protected $settings; protected $settings;
protected $moduleTitle; protected $moduleTitle;
@ -468,7 +471,14 @@ class ModelExtensionRetailcrmHistoryV45 extends ModelExtensionRetailcrmHistory
} }
$this->editOrder($order['externalId'], $data); $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;
}
} }
} }

View File

@ -109,6 +109,26 @@
</div> </div>
</div> </div>
</fieldset> </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 (isset($saved_settings['retailcrm_apikey']) && $saved_settings['retailcrm_apikey'] != '' && isset($saved_settings['retailcrm_url']) && $saved_settings['retailcrm_url'] != ''): ?>
<?php if (!empty($retailcrm_errors)) : ?> <?php if (!empty($retailcrm_errors)) : ?>
<?php foreach($retailcrm_errors as $retailcrm_error): ?> <?php foreach($retailcrm_errors as $retailcrm_error): ?>
@ -510,7 +530,7 @@
<?php endif; ?> <?php endif; ?>
<div class="tab-pane" id="tab-logs"> <div class="tab-pane" id="tab-logs">
<fieldset style="margin-bottom: 30px;"> <fieldset style="margin-bottom: 30px;">
<legend>Retailcrm API error log</legend> <legend>retailCRM API error log</legend>
<div class="retailcrm_unit"> <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> <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> </div>

View File

@ -108,6 +108,28 @@
</div> </div>
</div> </div>
</fieldset> </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 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 %} {% if retailcrm_errors|length %}
{% for retailcrm_error in retailcrm_errors %} {% for retailcrm_error in retailcrm_errors %}
@ -161,16 +183,16 @@
<div class="col-sm-10"> <div class="col-sm-10">
<label class="control-label" class="radio-inline"> <label class="control-label" class="radio-inline">
<input type="radio" name="module_retailcrm_order_number" value="1" <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 %} {% if saved_settings.module_retailcrm_order_number is defined and saved_settings.module_retailcrm_order_number == 1 %}
checked checked
{% endif %} /> {% endif %} />
{{ text_yes }} {{ text_yes }}
</label> </label>
<label class="control-label" class="radio-inline"> <label class="control-label" class="radio-inline">
<input type="radio" name="module_retailcrm_order_number" value="0" <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 %} {% if saved_settings.module_retailcrm_order_number is not defined or saved_settings.module_retailcrm_order_number == 0 %}
checked checked
{% endif %} /> {% endif %} />
{{ text_no }} {{ text_no }}
</label> </label>
</div> </div>

View File

@ -31,6 +31,11 @@ class ControllerExtensionModuleRetailcrm extends Controller {
* @return void * @return void
*/ */
public function order_create($trigger, $data, $order_id = null) { public function order_create($trigger, $data, $order_id = null) {
if (ModelExtensionRetailcrmHistoryV45::$history_run === true) {
return;
}
$this->load->model('checkout/order'); $this->load->model('checkout/order');
$this->load->model('account/order'); $this->load->model('account/order');
$this->load->library('retailcrm/retailcrm'); $this->load->library('retailcrm/retailcrm');