Исправлена ошибка при выгрузке заказа через админку, улучшена передача типа доставки, доработан дизайн страницы настроек, добавлена настройка передачи номера заказа

This commit is contained in:
Akolzin Dmitry 2018-07-31 17:17:36 +03:00
parent caa6a03b14
commit d08519f673
10 changed files with 540 additions and 320 deletions

View File

@ -1,3 +1,9 @@
## v.3.1.0
* Переработан дизайн шаблона twig
* Добавлена настройка передачи номера заказа в retailCRM
* Улучшена механика передачи типа доставки в retailCRM
* Исправлена ошибка при выгрузке единичного заказа в админ панели
## v.3.0.5 ## v.3.0.5
* Исправлены ошибки в шаблоне twig * Исправлены ошибки в шаблоне twig
* Добавлена обработка истории изменений при сохранении настроек для установки текущего sinceId, если история в retailCRM пустая * Добавлена обработка истории изменений при сохранении настроек для установки текущего sinceId, если история в retailCRM пустая

View File

@ -1 +1 @@
3.0.5 3.1.0

View File

@ -249,7 +249,9 @@ class ControllerExtensionModuleRetailcrm extends Controller
'text_error_delivery', 'text_error_delivery',
'retailcrm_missing_status', 'retailcrm_missing_status',
'special_price_settings', 'special_price_settings',
'special_price' 'special_price',
'order_number',
'text_order_number'
); );
$_data = &$data; $_data = &$data;
@ -516,7 +518,8 @@ class ControllerExtensionModuleRetailcrm extends Controller
$data['order_status'] = $status[$this->moduleTitle . '_status'][$data['order_status_id']]; $data['order_status'] = $status[$this->moduleTitle . '_status'][$data['order_status_id']];
$this->load->model('extension/retailcrm/order'); $this->load->model('extension/retailcrm/order');
$response = $this->model_extension_retailcrm_order->uploadOrder($data, $this->retailcrm->getApiClient()); $this->model_extension_retailcrm_order->uploadOrder($data, $this->retailcrm->getApiClient());
$response = $this->model_extension_retailcrm_order->getLastResponse();
} }
if (!$response->isSuccessful()) { if (!$response->isSuccessful()) {

View File

@ -66,6 +66,9 @@ $_['retailcrm_dict_custom_fields'] = 'Configure custom fields';
$_['retailcrm_dict_default'] = 'Default'; $_['retailcrm_dict_default'] = 'Default';
$_['retailcrm_missing_status'] = 'Missing orders status'; $_['retailcrm_missing_status'] = 'Missing orders status';
$_['order_number'] = 'Order number';
$_['text_order_number'] = 'Transfer order number to retailCRM';
$_['column_total'] = 'Total'; $_['column_total'] = 'Total';
$_['product_summ'] = 'Amount'; $_['product_summ'] = 'Amount';

View File

@ -66,6 +66,9 @@ $_['retailcrm_dict_custom_fields'] = 'Настройка пользовател
$_['retailcrm_dict_default'] = 'По умолчанию'; $_['retailcrm_dict_default'] = 'По умолчанию';
$_['retailcrm_missing_status'] = 'Статус пропавших заказов'; $_['retailcrm_missing_status'] = 'Статус пропавших заказов';
$_['order_number'] = 'Номер заказа';
$_['text_order_number'] = 'Передавать номер заказа в retailCRM';
$_['column_total'] = 'Итого'; $_['column_total'] = 'Итого';
$_['product_summ'] = 'Сумма'; $_['product_summ'] = 'Сумма';

View File

@ -115,11 +115,29 @@ class ModelExtensionRetailcrmOrder extends Model {
} }
} }
if (!isset($delivery_code) && isset($shippingModule)) {
$deliveries = array_keys($this->settings[$this->moduleTitle . '_delivery']);
$shipping_code = '';
array_walk($deliveries, function($item, $key) use ($shippingModule, &$shipping_code) {
if (strripos($item, $shippingModule) !== false) {
$shipping_code = $item;
}
});
$delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$shipping_code];
}
if (!empty($order_data['payment_iso_code_2'])) { if (!empty($order_data['payment_iso_code_2'])) {
$order['countryIso'] = $order_data['payment_iso_code_2']; $order['countryIso'] = $order_data['payment_iso_code_2'];
} }
if (isset($this->settings[$this->moduleTitle . '_order_number'])
&& $this->settings[$this->moduleTitle . '_order_number'] == 1
) {
$order['number'] = $order_data['order_id']; $order['number'] = $order_data['order_id'];
}
$order['externalId'] = $order_data['order_id']; $order['externalId'] = $order_data['order_id'];
$order['firstName'] = $order_data['firstname']; $order['firstName'] = $order_data['firstname'];
$order['lastName'] = $order_data['lastname']; $order['lastName'] = $order_data['lastname'];

View File

@ -133,6 +133,26 @@
</div> </div>
</fieldset> </fieldset>
<?php endif; ?> <?php endif; ?>
<fieldset>
<legend><?php echo $order_number; ?></legend>
<div class="form-group">
<label class="col-sm-2 control-label" for="retailcrm_order_number"><?php echo $text_order_number; ?></label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="retailcrm_order_number" value="1" <?php if (isset($saved_settings['retailcrm_order_number']) &&
$saved_settings['retailcrm_order_number'] == 1) :
echo 'checked'; endif; ?> />
<?php echo $text_yes; ?>
</label>
<label class="radio-inline">
<input type="radio" name="retailcrm_order_number" value="0" <?php if (!isset($saved_settings['retailcrm_order_number']) ||
$saved_settings['retailcrm_order_number'] == 0) :
echo 'checked'; endif; ?> />
<?php echo $text_no; ?>
</label>
</div>
</div>
</fieldset>
</div> </div>
<div class="tab-pane" id="tab-references"> <div class="tab-pane" id="tab-references">
<fieldset> <fieldset>

View File

@ -1,5 +1,4 @@
{{ header }} {{ column_left }} {{ header }} {{ column_left }}
<div id="content"> <div id="content">
<div class="page-header"> <div class="page-header">
<div class="container-fluid"> <div class="container-fluid">
@ -31,12 +30,10 @@
{{ text_notice }} {{ text_notice }}
<a href="{{ saved_settings.module_retailcrm_url }}/admin/settings#t-main">{{ saved_settings.module_retailcrm_url }}/admin/settings#t-main</a> <a href="{{ saved_settings.module_retailcrm_url }}/admin/settings#t-main">{{ saved_settings.module_retailcrm_url }}/admin/settings#t-main</a>
</div> </div>
{% endif %} {% endif %}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body"> <div class="panel-body">
<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-module"> <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-module" class="form-horizontal">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="#tab-general" data-toggle="tab">{{ general_tab_text }}</a></li> <li class="active"><a href="#tab-general" data-toggle="tab">{{ general_tab_text }}</a></li>
{% 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 %}
@ -48,32 +45,40 @@
<li><a href="#tab-logs" data-toggle="tab">{{ logs_tab_text }}</a></li> <li><a href="#tab-logs" data-toggle="tab">{{ logs_tab_text }}</a></li>
{% endif %} {% endif %}
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane active" id="tab-general"> <div class="tab-pane active" id="tab-general">
<input type="hidden" name="module_retailcrm_status" value="1"> <input type="hidden" name="module_retailcrm_status" value="1">
<fieldset>
<h3>{{ retailcrm_base_settings }}</h3> <legend>{{ retailcrm_base_settings }}</legend>
<div class="retailcrm_unit"> <div class="form-group retailcrm_unit">
<label for="retailcrm_url">{{ retailcrm_apiversion }}</label><br> <label class="col-sm-2 control-label" for="retailcrm_url">{{ retailcrm_apiversion }}</label>
<select name="module_retailcrm_apiversion"> <div class="col-lg-1 col-md-2 col-sm-2">
<select name="module_retailcrm_apiversion" class="form-control">
{% for version in api_versions %} {% for version in api_versions %}
<option value="{{ version }}" {% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion == version %} selected="selected" {% elseif saved_settings.module_retailcrm_apiversion is not defined and default_apiversion == version %} selected="selected" {% endif %}>{{ version }}</option> <option value="{{ version }}" {% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion == version %} selected="selected" {% elseif saved_settings.module_retailcrm_apiversion is not defined and default_apiversion == version %} selected="selected" {% endif %}>{{ version }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="retailcrm_unit">
<label for="retailcrm_url">{{ retailcrm_url }}</label><br>
<input id="retailcrm_url" type="text" name="module_retailcrm_url" value="{% if saved_settings.module_retailcrm_url is defined %}{{ saved_settings.module_retailcrm_url }}{% endif %}">
</div> </div>
<div class="retailcrm_unit"> <div class="form-group retailcrm_unit">
<label for="retailcrm_apikey">{{ retailcrm_apikey }}</label><br> <label class="col-sm-2 control-label" for="retailcrm_url">{{ retailcrm_url }}</label>
<input id="retailcrm_apikey" type="text" name="module_retailcrm_apikey" value="{% if saved_settings.module_retailcrm_apikey is defined %}{{ saved_settings.module_retailcrm_apikey }}{% endif %}"> <div class="col-lg-4 col-md-6 col-sm-10">
<input class="form-control" id="retailcrm_url" type="text" name="module_retailcrm_url" value="{% if saved_settings.module_retailcrm_url is defined %}{{ saved_settings.module_retailcrm_url }}{% endif %}">
</div> </div>
</div>
<h3>{{ retailcrm_countries_settings }}</h3> <div class="form-group retailcrm_unit">
<div class="retailcrm_unit"> <label class="col-sm-2 control-label" for="retailcrm_apikey">{{ retailcrm_apikey }}</label>
<div class="well well-sm" style="height: 150px; overflow: auto; width: 30%;"> <div class="col-lg-4 col-md-6 col-sm-10">
<input class="form-control" id="retailcrm_apikey" type="text" name="module_retailcrm_apikey" value="{% if saved_settings.module_retailcrm_apikey is defined %}{{ saved_settings.module_retailcrm_apikey }}{% endif %}">
</div>
</div>
</fieldset>
<fieldset>
<legend>{{ retailcrm_countries_settings }}</legend>
<div class="form-group retailcrm_unit">
<label class="col-sm-2 control-label"></label>
<div class="col-lg-4 col-md-6 col-sm-10">
<div class="well well-sm" style="height: 150px; overflow: auto;">
{% for country in countries %} {% for country in countries %}
<div class="checkbox"> <div class="checkbox">
<label> <label>
@ -84,24 +89,37 @@
{% endfor %} {% endfor %}
</div> </div>
</div> </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 %}
<div class="warning">{{ retailcrm_error }}</div> <div class="warning">{{ retailcrm_error }}</div>
{% endfor %} {% endfor %}
{% else %} {% else %}
<h3>{{ retailcrm_upload_order }}</h3> <fieldset>
<div class="retailcrm_unit"> <legend>{{ retailcrm_upload_order }}</legend>
<label>{{ text_button_export_order }} № </label><input type="text" name="order_id"> <div class="form-group retailcrm_unit">
<label class="col-sm-2 control-label">{{ text_button_export_order }} № </label>
<div class="col-sm-10">
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6">
<input type="text" name="order_id" class="form-control">
</div>
<div class="col-lg-3 col-md-4 col-sm-6">
<button type="button" id="export_order" data-toggle="tooltip" title="{{ text_button_export_order }}" class="btn btn-success"><i class="fa fa-download"></i></button> <button type="button" id="export_order" data-toggle="tooltip" title="{{ text_button_export_order }}" class="btn btn-success"><i class="fa fa-download"></i></button>
</div> </div>
</div>
</div>
</div>
</fieldset>
{% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion != 'v3' %} {% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion != 'v3' %}
<h3>{{ special_price_settings }}</h3> <fieldset>
<div class="retailcrm_unit"> <legend>{{ special_price_settings }}</legend>
<label>{{ special_price_settings }}</label> <div class="form-group retailcrm_unit">
<select id="module_retailcrm_special" name="module_retailcrm_special"> <label class="col-sm-2 control-label">{{ special_price_settings }}</label>
<div class="col-md-4 col-sm-10">
<select id="module_retailcrm_special" name="module_retailcrm_special" class="form-control">
{% for priceType in priceTypes %} {% for priceType in priceTypes %}
{% if priceType.active == true %} {% if priceType.active == true %}
<option value="{{priceType.code }}" {% if saved_settings.module_retailcrm_special is defined and saved_settings.module_retailcrm_special == priceType.code %} selected="selected" {% endif %}> <option value="{{priceType.code }}" {% if saved_settings.module_retailcrm_special is defined and saved_settings.module_retailcrm_special == priceType.code %} selected="selected" {% endif %}>
@ -111,20 +129,47 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
{% endif %}
</div> </div>
</fieldset>
{% endif %}
<fieldset>
<legend>{{ order_number }}</legend>
<div class="form-group">
<label class="col-sm-2 control-label" class="col-sm-2 control-label" for="module_retailcrm_order_number">{{ text_order_number }}</label>
<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 %} />
{{ 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 %} />
{{ text_no }}
</label>
</div>
</div>
</fieldset>
</div>
<div class="tab-pane" id="tab-references"> <div class="tab-pane" id="tab-references">
<h3>{{ retailcrm_dict_settings }}</h3> <fieldset>
<legend>{{ retailcrm_dict_settings }}</legend>
<h4>{{ retailcrm_dict_delivery }}</h4> <div class="form-group">
<label class="col-sm-2 control-label"> {{ retailcrm_dict_delivery }}</label>
<div class="col-sm-10">
<div class="row">
{% if delivery.opencart is not empty %}
{% for value in delivery.opencart %} {% for value in delivery.opencart %}
<div class="col-sm-12" style="margin-bottom:10px;">
<div class="pm">{{ value.title ~ ':' }}</div> <div class="pm">{{ value.title ~ ':' }}</div>
{% for key, val in value %} {% for key, val in value %}
{% if key != 'title' %} {% if key != 'title' %}
<div class="retailcrm_unit"> <div class="form-group retailcrm_unit">
<div class="col-lg-4 col-md-6 col-sm-6">
<select id="retailcrm_delivery_{{ val.code }}" name="module_retailcrm_delivery[{{ val.code }}]" > <select id="retailcrm_delivery_{{ val.code }}" name="module_retailcrm_delivery[{{ val.code }}]" >
{% for k, v in delivery.retailcrm %} {% for k, v in delivery.retailcrm %}
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_delivery[key] is defined and v.code == saved_settings.module_retailcrm_delivery[key] %} selected="selected" {% endif %}> <option value="{{ v.code }}" {% if saved_settings.module_retailcrm_delivery[key] is defined and v.code == saved_settings.module_retailcrm_delivery[key] %} selected="selected" {% endif %}>
@ -132,53 +177,91 @@
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
<label for="retailcrm_pm_{{ val.code }}">{{ val.title }}</label> </div>
<div class="col-lg-4 col-md-6 col-sm-6">
<label class="col-sm-2 control-label" for="retailcrm_pm_{{ val.code }}">{{ val.title }}</label>
</div>
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div>
{% endfor %} {% endfor %}
{% else %}
<h4>{{ retailcrm_dict_status }}</h4> <div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ text_error_delivery }}
</div>
{% endif %}
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ retailcrm_dict_status }}</label>
<div class="col-sm-10">
{% for status in statuses.opencart %} {% for status in statuses.opencart %}
{% set uid = status.order_status_id %} {% set uid = status.order_status_id %}
<div class="retailcrm_unit"> <div class="row retailcrm_unit">
<select id="retailcrm_status_{{ uid }}" name="module_retailcrm_status[{{ status.order_status_id }}]" > <div class="col-lg-4 col-md-6 col-sm-6">
<select id="retailcrm_status_{{ uid }}" name="module_retailcrm_status[{{ status.order_status_id }}]" class="form-control">
{% for k, v in statuses.retailcrm %} {% for k, v in statuses.retailcrm %}
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_status[uid] is defined and v.code == saved_settings.module_retailcrm_status[uid] %} selected="selected" {% endif %}> <option value="{{ v.code }}" {% if saved_settings.module_retailcrm_status[uid] is defined and v.code == saved_settings.module_retailcrm_status[uid] %} selected="selected" {% endif %}>
{{ v.name }} {{ v.name }}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
<label for="retailcrm_status_{{ status.order_status_id }} ">{{ status.name }}</label> </div>
<div class="col-lg-4 col-md-6 col-sm-6">
<label class="control-label" for="retailcrm_status_{{ status.order_status_id }} ">{{ status.name }}</label>
</div>
</div> </div>
{% endfor %} {% endfor %}
</div>
<h4>{{ retailcrm_dict_payment }}</h4> </div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ retailcrm_dict_payment }}</label>
<div class="col-sm-10">
{% for key, value in payments.opencart %} {% for key, value in payments.opencart %}
<div class="retailcrm_unit"> <div class="row retailcrm_unit">
<select id="retailcrm_payment_{{ key }}" name="module_retailcrm_payment[{{ key }}]" > <div class="col-lg-4 col-md-6 col-sm-6">
<select id="retailcrm_payment_{{ key }}" name="module_retailcrm_payment[{{ key }}]" class="form-control">
{% for k, v in payments.retailcrm %} {% for k, v in payments.retailcrm %}
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_payment[key] is defined and v.code == saved_settings.module_retailcrm_payment[key] %} selected="selected" {% endif %}> <option value="{{ v.code }}" {% if saved_settings.module_retailcrm_payment[key] is defined and v.code == saved_settings.module_retailcrm_payment[key] %} selected="selected" {% endif %}>
{{ v.name }} {{ v.name }}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
<label for="retailcrm_payment_{{ key }}">{{ value }}</label> </div>
<div class="col-lg-4 col-md-6 col-sm-6">
<label class="control-label" for="retailcrm_payment_{{ key }}">{{ value }}</label>
</div>
</div> </div>
{% endfor %} {% endfor %}
<h4>{{ retailcrm_dict_default }}</h4> </div>
<div class="retailcrm_unit"> </div>
<select id="module_retailcrm_default_payment" name="module_retailcrm_default_payment" > <div class="form-group">
<label class="col-sm-2 control-label">{{ retailcrm_dict_default }}</label>
<div class="col-sm-10">
<div class="row">
<div class="retailcrm_unit col-sm-12">
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6">
<select id="module_retailcrm_default_payment" name="module_retailcrm_default_payment" class="form-control">
{% for k, v in payments.opencart %} {% for k, v in payments.opencart %}
<option value="{{ k }}" {% if saved_settings.module_retailcrm_default_payment is defined and k == saved_settings.module_retailcrm_default_payment %} selected="selected" {% endif %}> <option value="{{ k }}" {% if saved_settings.module_retailcrm_default_payment is defined and k == saved_settings.module_retailcrm_default_payment %} selected="selected" {% endif %}>
{{ v }} {{ v }}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
<label for="module_retailcrm_default_payment">{{ text_payment }}</label>
</div> </div>
<div class="retailcrm_unit"> <div class="col-lg-4 col-md-6 col-sm-6">
<select id="module_retailcrm_default_shipping" name="module_retailcrm_default_shipping" > <label class="col-sm-2 control-label" for="module_retailcrm_default_payment">{{ text_payment }}</label>
</div>
</div>
</div>
<div class="retailcrm_unit col-sm-12">
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6">
<select id="module_retailcrm_default_shipping" name="module_retailcrm_default_shipping" class="form-control">
{% for key, value in delivery.opencart %} {% for key, value in delivery.opencart %}
<optgroup label="{{ value.title }}"> <optgroup label="{{ value.title }}">
{% for k, v in value %} {% for k, v in value %}
@ -191,11 +274,21 @@
</optgroup> </optgroup>
{% endfor %} {% endfor %}
</select> </select>
<label for="module_retailcrm_default_shipping">{{ text_shipping }}</label>
</div> </div>
<h4>{{ retailcrm_missing_status }}</h4> <div class="col-lg-4 col-md-6 col-sm-6">
<div class="retailcrm_unit"> <label class="col-sm-2 control-label" for="module_retailcrm_default_shipping">{{ text_shipping }}</label>
<select id="retailcrm_missing_status" name="module_retailcrm_missing_status"> </div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ retailcrm_missing_status }}</label>
<div class="col-sm-10">
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6">
<select id="retailcrm_missing_status" name="module_retailcrm_missing_status" class="form-control">
<option></option> <option></option>
{% for k, v in statuses.retailcrm %} {% for k, v in statuses.retailcrm %}
<option value="{{ k }}" {% if saved_settings.module_retailcrm_missing_status is defined and k == saved_settings.module_retailcrm_missing_status %} selected="selected" {% endif %}> <option value="{{ k }}" {% if saved_settings.module_retailcrm_missing_status is defined and k == saved_settings.module_retailcrm_missing_status %} selected="selected" {% endif %}>
@ -204,61 +297,77 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
</div>
</div>
</div>
</fieldset>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
<div class="tab-pane" id="tab-collector"> <div class="tab-pane" id="tab-collector">
<h3>{{ daemon_collector }}</h3> <fieldset>
<div class="retailcrm_unit"> <legend>{{ daemon_collector }}</legend>
<label for="retailcrm_collector_active" class="col-md-4">{{ text_collector_activity }}</label> <div class="form-group">
<label class="radio-inline"> <label class="col-sm-2 control-label" for="retailcrm_collector_active" class="col-md-4">{{ text_collector_activity }}</label>
<div class="col-sm-10">
<label class="control-label" class="radio-inline">
<input type="radio" name="module_retailcrm_collector_active" value="1" {% if saved_settings.module_retailcrm_collector_active is defined and <input type="radio" name="module_retailcrm_collector_active" value="1" {% if saved_settings.module_retailcrm_collector_active is defined and
saved_settings.module_retailcrm_collector_active == 1 %} {{ 'checked' }} saved_settings.module_retailcrm_collector_active == 1 %} {{ 'checked' }}
{% endif %}> {% endif %}>
{{ text_yes }} {{ text_yes }}
</label> </label>
<label class="radio-inline"> <label class="control-label" class="radio-inline">
<input type="radio" name="module_retailcrm_collector_active" value="0" {% if not saved_settings.module_retailcrm_collector_active or <input type="radio" name="module_retailcrm_collector_active" value="0" {% if not saved_settings.module_retailcrm_collector_active or
saved_settings.module_retailcrm_collector_active == 0 %} {{ 'checked' }} saved_settings.module_retailcrm_collector_active == 0 %} {{ 'checked' }}
{% endif %}> {% endif %}>
{{ text_no }} {{ text_no }}
</label> </label>
</div> </div>
<div class="retailcrm_unit">
<label for="retailcrm_collector" class="col-md-4">{{ collector_site_key }}</label>
<input id="retailcrm_collector_site_key" type="text" name="module_retailcrm_collector[site_key]" value="{% if saved_settings.module_retailcrm_collector.site_key is defined %}{{ saved_settings.module_retailcrm_collector.site_key }}{% endif %}">
</div> </div>
<div class="retailcrm_unit"> <div class="form-group">
<label for="retailcrm_collector" class="col-md-4">{{ text_collector_form_capture }}</label> <label class="col-sm-2 control-label" for="retailcrm_collector" class="col-md-4">{{ collector_site_key }}</label>
<label class="radio-inline"> <div class="col-sm-4">
<input class="form-control" id="retailcrm_collector_site_key" type="text" name="module_retailcrm_collector[site_key]" value="{% if saved_settings.module_retailcrm_collector.site_key is defined %}{{ saved_settings.module_retailcrm_collector.site_key }}{% endif %}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="retailcrm_collector" class="col-md-4">{{ text_collector_form_capture }}</label>
<div class="col-sm-10">
<label class="control-label" class="radio-inline">
<input type="radio" name="module_retailcrm_collector[form_capture]" value="1" {% if saved_settings.module_retailcrm_collector.form_capture is defined and <input type="radio" name="module_retailcrm_collector[form_capture]" value="1" {% if saved_settings.module_retailcrm_collector.form_capture is defined and
saved_settings.module_retailcrm_collector.form_capture == 1 %} {{ 'checked' }} saved_settings.module_retailcrm_collector.form_capture == 1 %} {{ 'checked' }}
{% endif %}> {% endif %}>
{{ text_yes }} {{ text_yes }}
</label> </label>
<label class="radio-inline"> <label class="control-label" class="radio-inline">
<input type="radio" name="module_retailcrm_collector[form_capture]" value="0" {% if saved_settings.module_retailcrm_collector.form_capture is not defined or <input type="radio" name="module_retailcrm_collector[form_capture]" value="0" {% if saved_settings.module_retailcrm_collector.form_capture is not defined or
saved_settings.module_retailcrm_collector.form_capture == 0 %} {{ 'checked' }} saved_settings.module_retailcrm_collector.form_capture == 0 %} {{ 'checked' }}
{% endif %}> {% endif %}>
{{ text_no }} {{ text_no }}
</label> </label>
</div> </div>
<div class="retailcrm_unit">
<label for="module_retailcrm_collector" class="col-md-4">{{ text_collector_period }}</label>
<input id="module_retailcrm_collector_period" type="text" name="module_retailcrm_collector[period]" value="{% if saved_settings.module_retailcrm_collector.period is defined %}{{ saved_settings.module_retailcrm_collector.period }}{% endif %}">
</div> </div>
<div class="retailcrm_unit"> <div class="form-group">
<label for="module_retailcrm_collector" class="col-md-4">{{ text_label_promo }}</label> <label class="col-sm-2 control-label" for="module_retailcrm_collector" class="col-md-4">{{ text_collector_period }}</label>
<input id="module_retailcrm_collector[]" type="text" name="module_retailcrm_collector[label_promo]" value="{% if saved_settings.module_retailcrm_collector.label_promo is defined %}{{ saved_settings.module_retailcrm_collector.label_promo }}{% endif %}"> <div class="col-sm-2">
<input class="form-control" id="module_retailcrm_collector_period" type="text" name="module_retailcrm_collector[period]" value="{% if saved_settings.module_retailcrm_collector.period is defined %}{{ saved_settings.module_retailcrm_collector.period }}{% endif %}">
</div> </div>
<div class="retailcrm_unit">
<label for="module_retailcrm_collector" class="col-md-4">{{ text_label_send }}</label>
<input id="module_retailcrm_collector_label_send" type="text" name="module_retailcrm_collector[label_send]" value="{% if saved_settings.module_retailcrm_collector.label_send is defined %}{{ saved_settings.module_retailcrm_collector.label_send }}{% endif %}">
</div> </div>
<div class="retailcrm_unit"> <div class="form-group">
<label for="module_retailcrm_collector" class="col-md-4">{{ collector_custom_text }}</label> <label class="col-sm-2 control-label" for="module_retailcrm_collector" class="col-md-4">{{ text_label_promo }}</label>
<div class="col-sm-4">
<input class="form-control" id="module_retailcrm_collector[]" type="text" name="module_retailcrm_collector[label_promo]" value="{% if saved_settings.module_retailcrm_collector.label_promo is defined %}{{ saved_settings.module_retailcrm_collector.label_promo }}{% endif %}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="module_retailcrm_collector" class="col-md-4">{{ text_label_send }}</label>
<div class="col-sm-4">
<input class="form-control" id="module_retailcrm_collector_label_send" type="text" name="module_retailcrm_collector[label_send]" value="{% if saved_settings.module_retailcrm_collector.label_send is defined %}{{ saved_settings.module_retailcrm_collector.label_send }}{% endif %}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="module_retailcrm_collector" class="col-md-4">{{ collector_custom_text }}</label>
<div class="col-sm-10">
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="module_retailcrm_collector[custom_form]" value="1" {% if saved_settings.module_retailcrm_collector.custom_form is defined and <input type="radio" name="module_retailcrm_collector[custom_form]" value="1" {% if saved_settings.module_retailcrm_collector.custom_form is defined and
saved_settings.module_retailcrm_collector.custom_form == 1 %} {{ 'checked' }} saved_settings.module_retailcrm_collector.custom_form == 1 %} {{ 'checked' }}
@ -272,23 +381,33 @@
{{ text_no }} {{ text_no }}
</label> </label>
</div> </div>
</div>
{% for field, label in collectorFields %} {% for field, label in collectorFields %}
<div class="retailcrm_unit"> <div class="form-group">
<label for="retailcrm_collector" class="col-md-4">{{ label }}</label> <label class="col-sm-2 control-label" for="retailcrm_collector">{{ label }}</label>
<div class="col-md-8"> <div class="col-sm-10">
<input id="module_retailcrm_collector" type="text" name="module_retailcrm_collector[custom][{{ field }}]" value="{% if saved_settings.module_retailcrm_collector.custom[field] is defined %} {{ saved_settings.module_retailcrm_collector.custom[field] }} {% endif %}"> <div class="row">
<input type="checkbox" name="module_retailcrm_collector[require][{{ field }}_require]" value="1" {% if saved_settings.module_retailcrm_collector.require[field ~'_require'] %} checked {% endif %}> <div class="col-md-4 col-sm-6">
<label for="retailcrm_collector">{{ text_require }}</label> <input class="form-control" id="module_retailcrm_collector" type="text" name="module_retailcrm_collector[custom][{{ field }}]" value="{% if saved_settings.module_retailcrm_collector.custom[field] is defined %} {{ saved_settings.module_retailcrm_collector.custom[field] }} {% endif %}">
</div>
<div class="col-md-8 col-sm-6" style="margin-top: 8px;">
<input input style="margin-top: 0; vertical-align: middle;" type="checkbox" name="module_retailcrm_collector[require][{{ field }}_require]" value="1" {% if saved_settings.module_retailcrm_collector.require[field ~'_require'] %} checked {% endif %}>
<label style="margin-bottom: 0; vertical-align: middle; margin-left: 5px;" for="retailcrm_collector">{{ text_require }}</label>
</div>
</div>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</fieldset>
</div> </div>
{% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion == 'v5' and customFields is defined %} {% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion == 'v5' and customFields is defined %}
<div class="tab-pane" id="tab-custom_fields"> <div class="tab-pane" id="tab-custom_fields">
<h4>{{ retailcrm_dict_custom_fields }}</h4> <fieldset>
<legend>{{ retailcrm_dict_custom_fields }}</legend>
{% if customFields.retailcrm is not empty and customFields.opencart is not empty %} {% if customFields.retailcrm is not empty and customFields.opencart is not empty %}
<div class="retailcrm_unit"> <div class="form-group">
<label for="retailcrm_custom_field_active">{{ text_custom_field_activity }}</label> <label class="col-sm-2 control-label" for="retailcrm_custom_field_active">{{ text_custom_field_activity }}</label>
<div class="col-sm-10">
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="module_retailcrm_custom_field_active" value="1" {% if saved_settings.module_retailcrm_custom_field_active is defined and <input type="radio" name="module_retailcrm_custom_field_active" value="1" {% if saved_settings.module_retailcrm_custom_field_active is defined and
saved_settings.module_retailcrm_custom_field_active == 1 %} saved_settings.module_retailcrm_custom_field_active == 1 %}
@ -302,34 +421,55 @@
{{ text_no }} {{ text_no }}
</label> </label>
</div> </div>
<h4>{{ text_customers_custom_fields }}</h4> </div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ text_customers_custom_fields }}</label>
<div class="col-sm-10">
<div class="row">
{% for customField in customFields.opencart %} {% for customField in customFields.opencart %}
<div class="col-sm-12" style="margin-bottom:5px;">
<div class="row">
{% set fid = 'c_' ~ customField.custom_field_id %} {% set fid = 'c_' ~ customField.custom_field_id %}
<div class="retailcrm_unit"> <div class="col-sm-4">
<select id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" > <select class="form-control" id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" >
{% for v in customFields.retailcrm.customers %} {% for v in customFields.retailcrm.customers %}
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_custom_field[fid] is defined and v.code == saved_settings.module_retailcrm_custom_field[fid] %} selected="selected" {% endif %}> <option value="{{ v.code }}" {% if saved_settings.module_retailcrm_custom_field[fid] is defined and v.code == saved_settings.module_retailcrm_custom_field[fid] %} selected="selected" {% endif %}>
{{ v.name }} {{ v.name }}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
<label for="module_retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label> </div>
<label style="padding-top: 9px;" for="module_retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label>
</div>
</div> </div>
{% endfor %} {% endfor %}
<h4>{{ text_orders_custom_fields }}</h4> </div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{ text_orders_custom_fields }}</label>
<div class="col-sm-10">
<div class="row">
{% for customField in customFields.opencart %} {% for customField in customFields.opencart %}
<div class="col-sm-12" style="margin-bottom:5px;">
<div class="row">
{% set fid = 'o_' ~ customField.custom_field_id %} {% set fid = 'o_' ~ customField.custom_field_id %}
<div class="retailcrm_unit"> <div class="col-sm-4">
<select id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" > <select class="form-control" id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" >
{% for v in customFields.retailcrm.orders %} {% for v in customFields.retailcrm.orders %}
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_custom_field[fid] is defined and v.code == saved_settings.module_retailcrm_custom_field[fid] %} selected="selected" {% endif %}> <option value="{{ v.code }}" {% if saved_settings.module_retailcrm_custom_field[fid] is defined and v.code == saved_settings.module_retailcrm_custom_field[fid] %} selected="selected" {% endif %}>
{{ v.name }} {{ v.name }}
</option> </option>
{% endfor %} {% endfor %}
</select> </select>
<label for="module_retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label> </div>
<label style="padding-top: 9px;" for="module_retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label>
</div>
</div> </div>
{% endfor %} {% endfor %}
</div>
</div>
</div>
{% elseif customFields.retailcrm is empty and customFields.opencart is empty %} {% elseif customFields.retailcrm is empty and customFields.opencart is empty %}
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i> <div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
<button type="button" class="close" data-dismiss="alert">&times;</button> <button type="button" class="close" data-dismiss="alert">&times;</button>
@ -346,35 +486,44 @@
{{ text_error_cf_opencart }} {{ text_error_cf_opencart }}
</div> </div>
{% endif %} {% endif %}
</fieldset>
</div> </div>
{% endif %} {% endif %}
<div class="tab-pane" id="tab-logs"> <div class="tab-pane" id="tab-logs">
<fieldset style="margin-bottom: 30px;">
<legend>Retailcrm API error log</legend>
<div class="retailcrm_unit"> <div class="retailcrm_unit">
<span>Retailcrm API error log</span>
<a onclick="confirm('{{ text_confirm_log }}') ? location.href='{{ clear_retailcrm }}' : false;" data-toggle="tooltip" title="{{ button_clear }}" class="btn btn-danger"><i class="fa fa-eraser"></i></a> <a onclick="confirm('{{ text_confirm_log }}') ? location.href='{{ clear_retailcrm }}' : false;" data-toggle="tooltip" title="{{ button_clear }}" class="btn btn-danger"><i class="fa fa-eraser"></i></a>
</div> </div>
{% if logs.retailcrm_log is defined %} {% if logs.retailcrm_log is defined %}
<div class="panel-body"> <div class="row">
<div class="col-sm-12">
<textarea wrap="off" rows="15" readonly class="form-control">{{ logs.retailcrm_log }}</textarea> <textarea wrap="off" rows="15" readonly class="form-control">{{ logs.retailcrm_log }}</textarea>
</div> </div>
</div>
{% elseif logs.retailcrm_error is defined %} {% elseif logs.retailcrm_error is defined %}
<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ logs.retailcrm_error }} <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ logs.retailcrm_error }}
<button type="button" class="close" data-dismiss="alert">&times;</button> <button type="button" class="close" data-dismiss="alert">&times;</button>
</div> </div>
{% endif %} {% endif %}
</fieldset>
<fieldset>
<legend>Opencart API error log</legend>
<div class="retailcrm_unit"> <div class="retailcrm_unit">
<span>Opencart API error log</span>
<a onclick="confirm('{{ text_confirm_log }}') ? location.href='{{ clear_opencart }}' : false;" data-toggle="tooltip" title="{{ button_clear }}" class="btn btn-danger"><i class="fa fa-eraser"></i></a> <a onclick="confirm('{{ text_confirm_log }}') ? location.href='{{ clear_opencart }}' : false;" data-toggle="tooltip" title="{{ button_clear }}" class="btn btn-danger"><i class="fa fa-eraser"></i></a>
</div> </div>
{% if logs.oc_api_log is defined %} {% if logs.oc_api_log is defined %}
<div class="panel-body"> <div class="row">
<div class="col-sm-12">
<textarea wrap="off" rows="15" readonly class="form-control">{{ logs.oc_api_log }}</textarea> <textarea wrap="off" rows="15" readonly class="form-control">{{ logs.oc_api_log }}</textarea>
</div> </div>
</div>
{% elseif logs.oc_error is defined %} {% elseif logs.oc_error is defined %}
<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ logs.oc_error }} <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ logs.oc_error }}
<button type="button" class="close" data-dismiss="alert">&times;</button> <button type="button" class="close" data-dismiss="alert">&times;</button>
</div> </div>
{% endif %} {% endif %}
</fieldset>
</div> </div>
</div> </div>
</form> </form>
@ -382,7 +531,6 @@
</div> </div>
</div> </div>
</div> </div>
{{ footer }} {{ footer }}
<script type="text/javascript"> <script type="text/javascript">

View File

@ -81,11 +81,29 @@ class ModelExtensionRetailcrmOrder extends Model {
} }
} }
if (!isset($delivery_code) && isset($shippingModule)) {
$deliveries = array_keys($this->settings[$this->moduleTitle . '_delivery']);
$shipping_code = '';
array_walk($deliveries, function($item, $key) use ($shippingModule, &$shipping_code) {
if (strripos($item, $shippingModule) !== false) {
$shipping_code = $item;
}
});
$delivery_code = $this->settings[$this->moduleTitle . '_delivery'][$shipping_code];
}
if (!empty($order_data['payment_iso_code_2'])) { if (!empty($order_data['payment_iso_code_2'])) {
$order['countryIso'] = $order_data['payment_iso_code_2']; $order['countryIso'] = $order_data['payment_iso_code_2'];
} }
if (isset($this->settings[$this->moduleTitle . '_order_number'])
&& $this->settings[$this->moduleTitle . '_order_number'] == 1
) {
$order['number'] = $order_data['order_id']; $order['number'] = $order_data['order_id'];
}
$order['externalId'] = $order_id; $order['externalId'] = $order_id;
$order['firstName'] = $order_data['firstname']; $order['firstName'] = $order_data['firstname'];
$order['lastName'] = $order_data['lastname']; $order['lastName'] = $order_data['lastname'];

View File

@ -34,6 +34,7 @@ class ModelRetailcrmOrderAdminTest extends OpenCartTest
$this->retailcrm->getModuleTitle(), $this->retailcrm->getModuleTitle(),
array( array(
$this->retailcrm->getModuleTitle() . '_apiversion' => 'v5', $this->retailcrm->getModuleTitle() . '_apiversion' => 'v5',
$this->retailcrm->getModuleTitle() . '_order_number' => 1,
$this->retailcrm->getModuleTitle() . '_status' => array( $this->retailcrm->getModuleTitle() . '_status' => array(
1 => 'new' 1 => 'new'
), ),