v3.2.4 Добавлена возможность передачи фкционных цен нескольких групп пользователей

This commit is contained in:
Sergey 2019-02-27 16:05:35 +03:00
parent 24c6de76ec
commit 6443e10330
7 changed files with 394 additions and 328 deletions

View File

@ -1,3 +1,6 @@
## v.3.2.4
* Изменена передача типов цен с учетом групп пользователей на сайте
## v.3.2.2
* Убрана генерация externalId покупателя при заказе без регистрации на сайте.

View File

@ -1 +1 @@
3.2.2
3.2.4

View File

@ -119,6 +119,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
$this->load->model('setting/setting');
$this->load->model('extension/retailcrm/references');
$this->load->model('localisation/currency');
$this->load->model('customer/customer_group');
$this->load->language('extension/module/retailcrm');
$this->document->setTitle($this->language->get('heading_title'));
$this->document->addStyle('/admin/view/stylesheet/retailcrm.css');
@ -344,6 +345,7 @@ class ControllerExtensionModuleRetailcrm extends Controller
if ($apiVersion != 'v3') {
$_data['priceTypes'] = $this->model_extension_retailcrm_references
->getPriceTypes();
$_data['customerGroups'] = $this->model_customer_customer_group->getCustomerGroups();
}
}

View File

@ -9,7 +9,7 @@ class ModelExtensionRetailcrmPrices extends Model
/**
* Constructor
*
*
* @param Registry $registry
*/
public function __construct($registry)
@ -18,6 +18,7 @@ class ModelExtensionRetailcrmPrices extends Model
$this->load->library('retailcrm/retailcrm');
$this->load->model('catalog/option');
$this->load->model('setting/setting');
$this->load->model('customer/customer_group');
$this->moduleTitle = $this->retailcrm->getModuleTitle();
$this->settings = $this->model_setting_setting->getSetting($this->moduleTitle);
@ -25,9 +26,9 @@ class ModelExtensionRetailcrmPrices extends Model
/**
* Upload prices to CRM
*
*
* @param array $products
* @param \RetailcrmProxy $retailcrmApiClient
* @param RetailcrmProxy $retailcrmApiClient
* @return mixed bool | array
*/
public function uploadPrices($products, $retailcrmApiClient)
@ -44,14 +45,15 @@ class ModelExtensionRetailcrmPrices extends Model
$retailcrmApiClient->storePricesUpload($priceUpload);
}
return $pricesUpload;
}
/**
* Get prices
*
*
* @param array $products
*
*
* @return mixed
*/
protected function getPrices($products, $retailcrmApiClient)
@ -59,9 +61,7 @@ class ModelExtensionRetailcrmPrices extends Model
$prices = array();
$site = $this->getSite($retailcrmApiClient);
if (!isset($this->settings[$this->moduleTitle . '_special'])
|| $this->settings[$this->moduleTitle . '_apiversion'] == 'v3'
) {
if ($this->settings[$this->moduleTitle . '_apiversion'] == 'v3') {
return false;
}
@ -72,12 +72,14 @@ class ModelExtensionRetailcrmPrices extends Model
continue;
}
$productPrice = array();
if (is_array($specials) && count($specials)) {
$productPrice = $this->getSpecialPrice($specials);
}
if (!$productPrice) {
continue;
}
if (empty($productPrice)) {
continue;
}
$offers = $this->retailcrm->getOffers($product);
@ -109,17 +111,23 @@ class ModelExtensionRetailcrmPrices extends Model
}
$offerId = implode('_', $offerId);
$price = array();
foreach($productPrice as $k => $v) {
if (isset($this->settings[$this->moduleTitle . '_special_' . $k])) {
$price[] = array(
'code' => $this->settings[$this->moduleTitle . '_special_' . $k],
'price' => $v + $optionsValues['price']
);
}
}
$prices[] = array(
'externalId' => $offerId ? $product['product_id'] . '#' . $offerId : $product['product_id'],
'site' => $site,
'prices' => array(
array(
'code' => $this->settings[$this->moduleTitle . '_special'],
'price' => $productPrice + $optionsValues['price']
)
)
'prices' => $price
);
}
}
@ -128,26 +136,32 @@ class ModelExtensionRetailcrmPrices extends Model
/**
* Get actual special
*
*
* @param array $specials
*
* @return float $productPrice
*
* @return array $productPrice
*/
private function getSpecialPrice($specials)
{
$date = date('Y-m-d');
$always = '0000-00-00';
$productPrice = 0;
$productPrice = array();
foreach ($specials as $special) {
if (($special['date_start'] == $always && $special['date_end'] == $always)
|| ($special['date_start'] <= $date && $special['date_end'] >= $date)
) {
if ((isset($priority) && $priority > $special['priority'])
|| !isset($priority)
) {
$productPrice = $special['price'];
$priority = $special['priority'];
if ((isset($groupId) && $groupId == $special['customer_group_id']) || !isset($groupId)) {
if ((isset($priority) && $priority > $special['priority'])
|| !isset($priority)
) {
$productPrice[$special['customer_group_id']] = $special['price'];
$priority = $special['priority'];
$groupId = $special['customer_group_id'];
}
} else {
$productPrice[$special['customer_group_id']] = $special['price'];
$groupId = $special['customer_group_id'];
}
}
}
@ -157,10 +171,10 @@ class ModelExtensionRetailcrmPrices extends Model
/**
* Get data option
*
*
* @param int $optionId
* @param int $optionValueId
*
*
* @return array
*/
private function getOptionData($optionId, $optionValueId) {

View File

@ -5,7 +5,7 @@
<div class="pull-right">
<?php if ($export_file) : ?>
<button type="button" id="export" data-toggle="tooltip" title="<?php echo $text_button_export; ?>" class="btn btn-success"><i class="fa fa-download"></i></button>
<?php endif; ?>
<?php endif; ?>
<button type="button" id="icml" data-toggle="tooltip" title="<?php echo $text_button_catalog; ?>" class="btn btn-success"><i class="fa fa-file-text-o"></i></button>
<button type="submit" form="form-retailcrm" data-toggle="tooltip" title="<?php echo $button_save; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
<a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a>
@ -73,7 +73,7 @@
<input id="retailcrm_apikey" type="text" name="retailcrm_apikey" value="<?php if (isset($saved_settings['retailcrm_apikey'])): echo $saved_settings['retailcrm_apikey']; endif;?>" class="form-control" />
</div>
</div>
</fieldset>
</fieldset>
<fieldset>
<legend><?php echo $retailcrm_countries_settings; ?></legend>
<div class="form-group retailcrm_unit">
@ -90,7 +90,7 @@
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend><?php echo $text_currency; ?></legend>
@ -101,7 +101,7 @@
<?php foreach ($currencies as $currency) :?>
<?php if ($currency['status']) :?>
<option value="<?php echo $currency['code']; ?>" <?php if(isset($saved_settings['retailcrm_currency']) && $saved_settings['retailcrm_currency'] == $currency['code']):?>selected="selected"<?php endif;?>>
<?php echo $currency['title']; ?>
<?php echo $currency['title']; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
@ -122,7 +122,7 @@
<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" />
<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" class="btn btn-success"><i class="fa fa-download"></i> <?php echo $text_button_export_order; ?></button>
@ -135,19 +135,24 @@
<fieldset>
<legend><?php echo $special_price_settings; ?></legend>
<div class="form-group retailcrm_unit">
<label class="col-sm-2 control-label"><?php echo $special_price_settings; ?></label>
<div class="col-md-4 col-sm-10">
<select id="retailcrm_special" name="retailcrm_special" class="form-control">
<?php foreach ($priceTypes as $priceType) :?>
<?php if ($priceType['active'] == true) :?>
<option value="<?php echo $priceType['code']; ?>" <?php if(isset($saved_settings['retailcrm_special']) && $saved_settings['retailcrm_special'] == $priceType['code']):?>selected="selected"<?php endif;?>>
<?php echo $priceType['name']; ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<?php foreach ($customerGroups as $customerGroup) :?>
<?php $cid = $customerGroup['customer_group_id']?>
<div class="row retailcrm_unit">
<label class="col-sm-2 control-label" style="text-align:right!important;" for="opencart_customer_group_<?php echo $customerGroup['customer_group_id']; ?>"><?php echo $customerGroup['name']; ?></label>
<div class="col-md-4 col-sm-10">
<select id="retailcrm_special_<?php echo $uid; ?>" name="retailcrm_special_<?php echo $uid; ?>" class="form-control">
<?php foreach ($priceTypes as $k => $priceType): ?>
<?php if ($priceType['active'] == true) :?>
<option value="<?php echo $priceType['code'];?>" <?php if(isset($saved_settings['retailcrm_special_' . $cid]) && $priceType['code'] == $saved_settings['retailcrm_special_' . $cid]):?>selected="selected"<?php endif;?>>
<?php echo $priceType['name'];?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</fieldset>
<?php endif; ?>
<fieldset>
@ -189,7 +194,7 @@
<select id="retailcrm_delivery_<?php echo $val['code']; ?>" name="retailcrm_delivery[<?php echo $val['code']; ?>]" class="form-control">
<?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'];?>
<?php echo $v['name'];?>
</option>
<?php endforeach; ?>
</select>
@ -220,7 +225,7 @@
<select id="retailcrm_status_<?php echo $uid; ?>" name="retailcrm_status[<?php echo $uid; ?>]" class="form-control">
<?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'];?>
<?php echo $v['name'];?>
</option>
<?php endforeach; ?>
</select>
@ -241,7 +246,7 @@
<select id="retailcrm_payment_<?php echo $key; ?>" name="retailcrm_payment[<?php echo $key; ?>]" class="form-control">
<?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'];?>
<?php echo $v['name'];?>
</option>
<?php endforeach; ?>
</select>
@ -256,25 +261,25 @@
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $retailcrm_dict_default; ?></label>
<div class="col-sm-10">
<div class="row">
<div class="row">
<div class="retailcrm_unit col-sm-12">
<div class="row">
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6">
<select id="retailcrm_default_payment" name="retailcrm_default_payment" class="form-control">
<?php foreach ($payments['opencart'] as $k => $v): ?>
<option value="<?php echo $k;?>" <?php if(isset($saved_settings['retailcrm_default_payment']) && $k == $saved_settings['retailcrm_default_payment']):?>selected="selected"<?php endif;?>>
<?php echo $v;?>
<?php echo $v;?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-lg-4 col-md-6 col-sm-6">
<label class="control-label" for="retailcrm_default_payment"><?php echo $text_payment; ?></label>
<label class="control-label" for="retailcrm_default_payment"><?php echo $text_payment; ?></label>
</div>
</div>
</div>
<div class="retailcrm_unit col-sm-12">
<div class="row">
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-6">
<select id="retailcrm_default_shipping" name="retailcrm_default_shipping" class="form-control">
<?php foreach ($delivery['opencart'] as $key => $value): ?>
@ -282,7 +287,7 @@
<?php unset($value['title']); ?>
<?php foreach ($value as $v): ?>
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_default_shipping']) && $v['code'] == $saved_settings['retailcrm_default_shipping']):?>selected="selected"<?php endif;?>>
<?php echo $v['title'];?>
<?php echo $v['title'];?>
</option>
<?php endforeach; ?>
</optgroup>
@ -294,7 +299,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
@ -306,7 +311,7 @@
<option>-- Выберите --</option>
<?php foreach ($statuses['retailcrm'] as $k => $v): ?>
<option value="<?php echo $k;?>" <?php if(isset($saved_settings['retailcrm_missing_status']) && $k == $saved_settings['retailcrm_missing_status']):?>selected="selected"<?php endif;?>>
<?php echo $v['name'];?>
<?php echo $v['name'];?>
</option>
<?php endforeach; ?>
</select>
@ -325,13 +330,13 @@
<label class="col-sm-2 control-label" for="retailcrm_collector_active"><?php echo $text_collector_activity; ?></label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="retailcrm_collector_active" value="1" <?php if (isset($saved_settings['retailcrm_collector_active']) &&
<input type="radio" name="retailcrm_collector_active" value="1" <?php if (isset($saved_settings['retailcrm_collector_active']) &&
$saved_settings['retailcrm_collector_active'] == 1) :
echo 'checked'; endif; ?> />
<?php echo $text_yes; ?>
</label>
<label class="radio-inline">
<input type="radio" name="retailcrm_collector_active" value="0" <?php if (!isset($saved_settings['retailcrm_collector_active']) ||
<input type="radio" name="retailcrm_collector_active" value="0" <?php if (!isset($saved_settings['retailcrm_collector_active']) ||
$saved_settings['retailcrm_collector_active'] == 0) :
echo 'checked'; endif; ?> />
<?php echo $text_no; ?>
@ -348,17 +353,17 @@
<label class="col-sm-2 control-label" for="retailcrm_collector"><?php echo $text_collector_form_capture; ?></label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="retailcrm_collector[form_capture]" value="1" <?php if (isset($saved_settings['retailcrm_collector']['form_capture']) &&
<input type="radio" name="retailcrm_collector[form_capture]" value="1" <?php if (isset($saved_settings['retailcrm_collector']['form_capture']) &&
$saved_settings['retailcrm_collector']['form_capture'] == 1) :
echo 'checked'; endif; ?>>
<?php echo $text_yes; ?>
</label>
<label class="radio-inline">
<input type="radio" name="retailcrm_collector[form_capture]" value="0" <?php if (!isset($saved_settings['retailcrm_collector']['form_capture']) ||
<input type="radio" name="retailcrm_collector[form_capture]" value="0" <?php if (!isset($saved_settings['retailcrm_collector']['form_capture']) ||
$saved_settings['retailcrm_collector']['form_capture'] == 0) :
echo 'checked'; endif; ?>>
<?php echo $text_no; ?>
</label>
</label>
</div>
</div>
<div class="form-group">
@ -383,13 +388,13 @@
<label class="col-sm-2 control-label" for="retailcrm_collector"><?php echo $collector_custom_text; ?></label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="retailcrm_collector[custom_form]" value="1" <?php if (isset($saved_settings['retailcrm_collector']['custom_form']) &&
<input type="radio" name="retailcrm_collector[custom_form]" value="1" <?php if (isset($saved_settings['retailcrm_collector']['custom_form']) &&
$saved_settings['retailcrm_collector']['custom_form'] == 1) :
echo 'checked'; endif; ?>>
<?php echo $text_yes; ?>
</label>
<label class="radio-inline">
<input type="radio" name="retailcrm_collector[custom_form]" value="0" <?php if (!isset($saved_settings['retailcrm_collector']['custom_form']) ||
<input type="radio" name="retailcrm_collector[custom_form]" value="0" <?php if (!isset($saved_settings['retailcrm_collector']['custom_form']) ||
$saved_settings['retailcrm_collector']['custom_form'] == 0) :
echo 'checked'; endif; ?>>
<?php echo $text_no; ?>
@ -418,24 +423,24 @@
<div class="tab-pane" id="tab-custom_fields">
<fieldset>
<legend><?php echo $retailcrm_dict_custom_fields; ?></legend>
<?php if ($customFields['retailcrm'] && $customFields['opencart']) : ?>
<?php if ($customFields['retailcrm'] && $customFields['opencart']) : ?>
<div class="form-group">
<label class="col-sm-2 control-label" for="retailcrm_custom_field_active"><?php echo $text_custom_field_activity; ?></label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="retailcrm_custom_field_active" value="1" <?php if (isset($saved_settings['retailcrm_custom_field_active']) &&
<input type="radio" name="retailcrm_custom_field_active" value="1" <?php if (isset($saved_settings['retailcrm_custom_field_active']) &&
$saved_settings['retailcrm_custom_field_active'] == 1) :
echo 'checked'; endif; ?> />
<?php echo $text_yes; ?>
</label>
<label class="radio-inline">
<input type="radio" name="retailcrm_custom_field_active" value="0" <?php if (!isset($saved_settings['retailcrm_custom_field_active']) ||
<input type="radio" name="retailcrm_custom_field_active" value="0" <?php if (!isset($saved_settings['retailcrm_custom_field_active']) ||
$saved_settings['retailcrm_custom_field_active'] == 0) :
echo 'checked'; endif; ?> />
<?php echo $text_no; ?>
</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $text_customers_custom_fields; ?></label>
<div class="col-sm-10">
@ -448,7 +453,7 @@
<select id="retailcrm_custom_field_<?php echo $fid; ?>" name="retailcrm_custom_field[<?php echo $fid; ?>]" class="form-control">
<?php foreach ($customFields['retailcrm']['customers'] as $v): ?>
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_custom_field'][$fid]) && $v['code'] == $saved_settings['retailcrm_custom_field'][$fid]):?>selected="selected"<?php endif;?>>
<?php echo $v['name'];?>
<?php echo $v['name'];?>
</option>
<?php endforeach; ?>
</select>
@ -458,10 +463,10 @@
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $text_orders_custom_fields; ?></label>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $text_orders_custom_fields; ?></label>
<div class="col-sm-10">
<div class="row">
<?php foreach ($customFields['opencart'] as $customField) : ?>
@ -472,7 +477,7 @@
<select id="retailcrm_custom_field_<?php echo $fid; ?>" name="retailcrm_custom_field[<?php echo $fid; ?>]" class="form-control">
<?php foreach ($customFields['retailcrm']['orders'] as $v): ?>
<option value="<?php echo $v['code'];?>" <?php if(isset($saved_settings['retailcrm_custom_field'][$fid]) && $v['code'] == $saved_settings['retailcrm_custom_field'][$fid]):?>selected="selected"<?php endif;?>>
<?php echo $v['name'];?>
<?php echo $v['name'];?>
</option>
<?php endforeach; ?>
</select>
@ -482,8 +487,8 @@
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
<?php elseif (!$customFields['retailcrm'] && !$customFields['opencart']) : ?>
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
<button type="button" class="close" data-dismiss="alert">&times;</button>
@ -526,18 +531,18 @@
<div class="retailcrm_unit">
<a onclick="confirm('<?php echo $text_confirm_log; ?>') ? location.href='<?php echo $clear_opencart; ?>' : 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>
<?php if (isset($logs['oc_api_log'])) : ?>
<div class="row">
<div class="col-sm-12">
<textarea wrap="off" rows="15" readonly class="form-control"><?php echo $logs['oc_api_log']; ?></textarea>
</div>
</div>
<?php elseif (isset($logs['oc_error'])) : ?>
<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> <?php echo $logs['oc_error']; ?>
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
<?php endif; ?>
</fieldset>
<?php if (isset($logs['oc_api_log'])) : ?>
<div class="row">
<div class="col-sm-12">
<textarea wrap="off" rows="15" readonly class="form-control"><?php echo $logs['oc_api_log']; ?></textarea>
</div>
</div>
<?php elseif (isset($logs['oc_error'])) : ?>
<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> <?php echo $logs['oc_error']; ?>
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
<?php endif; ?>
</fieldset>
</div>
</div>
</form>
@ -548,70 +553,70 @@
<?php echo $footer; ?>
<script type="text/javascript">
var token = '<?php echo $token; ?>';
$('#icml').on('click', function() {
$.ajax({
url: '<?php echo $catalog; ?>' + 'admin/index.php?route=extension/module/retailcrm/icml&token=' + token,
beforeSend: function() {
$('#icml').button('loading');
},
complete: function() {
$('.alert-success').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> <?php echo $text_success_catalog; ?></div>');
$('#icml').button('reset');
},
error: function(){
alert('error');
}
});
var token = '<?php echo $token; ?>';
$('#icml').on('click', function() {
$.ajax({
url: '<?php echo $catalog; ?>' + 'admin/index.php?route=extension/module/retailcrm/icml&token=' + token,
beforeSend: function() {
$('#icml').button('loading');
},
complete: function() {
$('.alert-success').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> <?php echo $text_success_catalog; ?></div>');
$('#icml').button('reset');
},
error: function(){
alert('error');
}
});
});
$('#export').on('click', function() {
$.ajax({
url: '<?php echo $catalog; ?>' + 'admin/index.php?route=extension/module/retailcrm/export&token=' + token,
beforeSend: function() {
$('#export').button('loading');
},
complete: function() {
$('.alert-success').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> <?php echo $text_success_export; ?></div>');
$('#export').button('reset');
},
error: function(){
alert('error');
}
});
$('#export').on('click', function() {
$.ajax({
url: '<?php echo $catalog; ?>' + 'admin/index.php?route=extension/module/retailcrm/export&token=' + token,
beforeSend: function() {
$('#export').button('loading');
},
complete: function() {
$('.alert-success').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> <?php echo $text_success_export; ?></div>');
$('#export').button('reset');
},
error: function(){
alert('error');
}
});
});
$('#export_order').on('click', function() {
var order_id = $('input[name=\'order_id\']').val();
if (order_id && order_id > 0) {
$.ajax({
url: '<?php echo $catalog; ?>' + 'admin/index.php?route=extension/module/retailcrm/exportOrder&token=' + token + '&order_id=' + order_id,
beforeSend: function() {
$('#export_order').button('loading');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
},
success: function(data, textStatus, jqXHR) {
response = JSON.parse(jqXHR['responseText']);
if (response['status_code'] == '400') {
$('.alert-danger').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i><?php echo $text_error_order; ?>' + response['error_msg'] + '</div>');
$('#export_order').button('reset');
} else {
$('.alert-success').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i><?php echo $text_success_export_order; ?></div>');
$('#export_order').button('reset');
$('input[name=\'order_id\']').val('');
}
}
});
} else {
$('#export_order').on('click', function() {
var order_id = $('input[name=\'order_id\']').val();
if (order_id && order_id > 0) {
$.ajax({
url: '<?php echo $catalog; ?>' + 'admin/index.php?route=extension/module/retailcrm/exportOrder&token=' + token + '&order_id=' + order_id,
beforeSend: function() {
$('#export_order').button('loading');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
},
success: function(data, textStatus, jqXHR) {
response = JSON.parse(jqXHR['responseText']);
if (response['status_code'] == '400') {
$('.alert-danger').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $text_error_order_id; ?></div>');
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i><?php echo $text_error_order; ?>' + response['error_msg'] + '</div>');
$('#export_order').button('reset');
} else {
$('.alert-success').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i><?php echo $text_success_export_order; ?></div>');
$('#export_order').button('reset');
$('input[name=\'order_id\']').val('');
}
}
});
});
} else {
$('.alert-danger').remove();
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $text_error_order_id; ?></div>');
$('#export_order').button('reset');
}
});
</script>

View File

@ -3,33 +3,33 @@
<div class="page-header">
<div class="container-fluid">
<div class="pull-right">
{% if export_file %}
<button type="button" id="export" data-toggle="tooltip" title="{{ text_button_export }}" class="btn btn-success"><i class="fa fa-download"></i></button>
{% endif %}
{% if export_file %}
<button type="button" id="export" data-toggle="tooltip" title="{{ text_button_export }}" class="btn btn-success"><i class="fa fa-download"></i></button>
{% endif %}
<button type="button" id="icml" data-toggle="tooltip" title="{{ text_button_catalog }}" class="btn btn-success"><i class="fa fa-file-text-o"></i></button>
<button type="submit" form="form-module" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button>
<a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
<h1>{{ heading_title }}</h1>
<ul class="breadcrumb">
{% for breadcrumb in breadcrumbs %}
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
{% endfor %}
</ul>
</div>
</div>
<div class="container-fluid">
{% if error_warning %}
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<i class="fa fa-exclamation-circle"></i> {{ error_warning }}
</div>
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<i class="fa fa-exclamation-circle"></i> {{ error_warning }}
</div>
{% endif %}
{% if saved_settings.module_retailcrm_url is defined %}
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ text_notice }}
<a href="{{ saved_settings.module_retailcrm_url }}/admin/settings#t-main">{{ saved_settings.module_retailcrm_url }}/admin/settings#t-main</a>
</div>
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ text_notice }}
<a href="{{ saved_settings.module_retailcrm_url }}/admin/settings#t-main">{{ saved_settings.module_retailcrm_url }}/admin/settings#t-main</a>
</div>
{% endif %}
<div class="panel panel-default">
<div class="panel-body">
@ -37,13 +37,13 @@
<ul class="nav nav-tabs">
<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 %}
<li><a href="#tab-references" data-toggle="tab">{{ references_tab_text }}</a></li>
<li><a href="#tab-collector" data-toggle="tab">{{ collector_tab_text }}</a></li>
{% if saved_settings.module_retailcrm_apiversion == 'v5' %}
<li><a href="#tab-custom_fields" data-toggle="tab"> {{ custom_fields_tab_text }} </a></li>
<li><a href="#tab-references" data-toggle="tab">{{ references_tab_text }}</a></li>
<li><a href="#tab-collector" data-toggle="tab">{{ collector_tab_text }}</a></li>
{% if saved_settings.module_retailcrm_apiversion == 'v5' %}
<li><a href="#tab-custom_fields" data-toggle="tab"> {{ custom_fields_tab_text }} </a></li>
{% endif %}
<li><a href="#tab-logs" data-toggle="tab">{{ logs_tab_text }}</a></li>
{% endif %}
<li><a href="#tab-logs" data-toggle="tab">{{ logs_tab_text }}</a></li>
{% endif %}
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
@ -79,14 +79,14 @@
<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 %}
<div class="checkbox">
<label>
<input type="checkbox" name="module_retailcrm_country[]" value="{{ country.country_id }}" {% if saved_settings.module_retailcrm_country is defined and country.country_id in saved_settings.module_retailcrm_country %} {{ 'checked' }} {% endif %}">
{{ country.name }}
</label>
</div>
{% endfor %}
{% for country in countries %}
<div class="checkbox">
<label>
<input type="checkbox" name="module_retailcrm_country[]" value="{{ country.country_id }}" {% if saved_settings.module_retailcrm_country is defined and country.country_id in saved_settings.module_retailcrm_country %} {{ 'checked' }} {% endif %}">
{{ country.name }}
</label>
</div>
{% endfor %}
</div>
</div>
</div>
@ -110,8 +110,8 @@
</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 %}
<div class="warning">{{ retailcrm_error }}</div>
{% for retailcrm_error in retailcrm_errors %}
<div class="warning">{{ retailcrm_error }}</div>
{% endfor %}
{% else %}
<fieldset>
@ -131,23 +131,28 @@
</div>
</fieldset>
{% if saved_settings.module_retailcrm_apiversion is defined and saved_settings.module_retailcrm_apiversion != 'v3' %}
<fieldset>
<legend>{{ special_price_settings }}</legend>
<div class="form-group retailcrm_unit">
<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 %}
{% 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 %}>
{{ priceType.name }}
</option>
{% endif %}
{% endfor %}
</select>
<fieldset>
<legend>{{ special_price_settings }}</legend>
<div class="form-group retailcrm_unit">
{% for customerGroup in customerGroups %}
{% set cud = customerGroup.customer_group_id %}
<div class="row retailcrm_unit">
<label class="col-sm-2 control-label" for="opencart_customer_group_{{ cud }}">{{ customerGroup.name }}</label>
<div class="col-md-4 col-sm-10">
<select id="module_retailcrm_special_{{ cud }}" name="module_retailcrm_special_{{ cud }}" class="form-control">
{% for priceType in priceTypes %}
{% if priceType.active == true %}
<option value ="{{ priceType.code }}" {% if saved_settings['module_retailcrm_special_'~cud] is defined and priceType.code == saved_settings['module_retailcrm_special_'~cud] %} selected="selected" {% endif %}>
{{ priceType.name }}
</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
{% endfor %}
</div>
</div>
</fieldset>
</fieldset>
{% endif %}
<fieldset>
<legend>{{ order_number }}</legend>
@ -156,16 +161,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>
@ -179,36 +184,36 @@
<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 %}
<div class="col-sm-12" style="margin-bottom:10px;">
<div class="pm">{{ value.title ~ ':' }}</div>
{% for key, val in value %}
{% if key != 'title' %}
<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 }}]" class="form-control">
{% 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 %}>
{{ v.name }}
</option>
{% endfor %}
</select>
</div>
<div class="col-lg-4 col-md-6 col-sm-6">
<label class="control-label" for="retailcrm_pm_{{ val.code }}">{{ val.title }}</label>
</div>
{% if delivery.opencart is not empty %}
{% for value in delivery.opencart %}
<div class="col-sm-12" style="margin-bottom:10px;">
<div class="pm">{{ value.title ~ ':' }}</div>
{% for key, val in value %}
{% if key != 'title' %}
<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 }}]" class="form-control">
{% 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 %}>
{{ v.name }}
</option>
{% endfor %}
</select>
</div>
<div class="col-lg-4 col-md-6 col-sm-6">
<label class="control-label" for="retailcrm_pm_{{ val.code }}">{{ val.title }}</label>
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endfor %}
{% endfor %}
{% else %}
<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>
{% endfor %}
{% else %}
<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 %}
{% endif %}
</div>
</div>
</div>
@ -216,21 +221,21 @@
<label class="col-sm-2 control-label">{{ retailcrm_dict_status }}</label>
<div class="col-sm-10">
{% for status in statuses.opencart %}
{% set uid = status.order_status_id %}
<div class="row retailcrm_unit">
<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 %}
<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 }}
</option>
{% endfor %}
</select>
{% set uid = status.order_status_id %}
<div class="row retailcrm_unit">
<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 %}
<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 }}
</option>
{% endfor %}
</select>
</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 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>
{% endfor %}
</div>
</div>
@ -238,20 +243,20 @@
<label class="col-sm-2 control-label">{{ retailcrm_dict_payment }}</label>
<div class="col-sm-10">
{% for key, value in payments.opencart %}
<div class="row retailcrm_unit">
<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 %}
<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 }}
</option>
{% endfor %}
</select>
<div class="row retailcrm_unit">
<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 %}
<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 }}
</option>
{% endfor %}
</select>
</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 class="col-lg-4 col-md-6 col-sm-6">
<label class="control-label" for="retailcrm_payment_{{ key }}">{{ value }}</label>
</div>
</div>
{% endfor %}
</div>
</div>
@ -264,9 +269,9 @@
<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 %}
<option value="{{ k }}" {% if saved_settings.module_retailcrm_default_payment is defined and k == saved_settings.module_retailcrm_default_payment %} selected="selected" {% endif %}>
{{ v }}
</option>
<option value="{{ k }}" {% if saved_settings.module_retailcrm_default_payment is defined and k == saved_settings.module_retailcrm_default_payment %} selected="selected" {% endif %}>
{{ v }}
</option>
{% endfor %}
</select>
</div>
@ -280,15 +285,15 @@
<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 %}
<optgroup label="{{ value.title }}">
{% for k, v in value %}
{% if k != 'title' %}
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_default_shipping is defined and v.code == saved_settings.module_retailcrm_default_shipping %} selected="selected" {% endif %}>
{{ v.title }}
</option>
{% endif %}
{% endfor %}
</optgroup>
<optgroup label="{{ value.title }}">
{% for k, v in value %}
{% if k != 'title' %}
<option value="{{ v.code }}" {% if saved_settings.module_retailcrm_default_shipping is defined and v.code == saved_settings.module_retailcrm_default_shipping %} selected="selected" {% endif %}>
{{ v.title }}
</option>
{% endif %}
{% endfor %}
</optgroup>
{% endfor %}
</select>
</div>
@ -308,9 +313,9 @@
<select id="retailcrm_missing_status" name="module_retailcrm_missing_status" class="form-control">
<option></option>
{% 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 %}>
{{ v.name }}
</option>
<option value="{{ k }}" {% if saved_settings.module_retailcrm_missing_status is defined and k == saved_settings.module_retailcrm_missing_status %} selected="selected" {% endif %}>
{{ v.name }}
</option>
{% endfor %}
</select>
</div>
@ -325,17 +330,17 @@
<fieldset>
<legend>{{ daemon_collector }}</legend>
<div class="form-group">
<label class="col-sm-2 control-label" for="retailcrm_collector_active" class="col-md-4">{{ text_collector_activity }}</label>
<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
saved_settings.module_retailcrm_collector_active == 1 %} {{ 'checked' }}
saved_settings.module_retailcrm_collector_active == 1 %} {{ 'checked' }}
{% endif %}>
{{ text_yes }}
</label>
<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
saved_settings.module_retailcrm_collector_active == 0 %} {{ 'checked' }}
saved_settings.module_retailcrm_collector_active == 0 %} {{ 'checked' }}
{% endif %}>
{{ text_no }}
</label>
@ -352,13 +357,13 @@
<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
saved_settings.module_retailcrm_collector.form_capture == 1 %} {{ 'checked' }}
saved_settings.module_retailcrm_collector.form_capture == 1 %} {{ 'checked' }}
{% endif %}>
{{ text_yes }}
</label>
<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
saved_settings.module_retailcrm_collector.form_capture == 0 %} {{ 'checked' }}
saved_settings.module_retailcrm_collector.form_capture == 0 %} {{ 'checked' }}
{% endif %}>
{{ text_no }}
</label>
@ -383,37 +388,37 @@
</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>
<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">
<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' }}
{% endif %}>
{{ text_yes }}
</label>
<label class="radio-inline">
<input type="radio" name="module_retailcrm_collector[custom_form]" value="0" {% if saved_settings.module_retailcrm_collector.custom_form is not defined or
saved_settings.module_retailcrm_collector.custom_form == 0 %} {{ 'checked' }}
saved_settings.module_retailcrm_collector.custom_form == 0 %} {{ 'checked' }}
{% endif %}>
{{ text_no }}
</label>
</div>
</div>
{% for field, label in collectorFields %}
<div class="form-group">
<label class="col-sm-2 control-label" for="retailcrm_collector">{{ label }}</label>
<div class="col-sm-10">
<div class="row">
<div class="col-md-4 col-sm-6">
<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 class="form-group">
<label class="col-sm-2 control-label" for="retailcrm_collector">{{ label }}</label>
<div class="col-sm-10">
<div class="row">
<div class="col-md-4 col-sm-6">
<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>
{% endfor %}
</fieldset>
</div>
@ -427,14 +432,14 @@
<div class="col-sm-10">
<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
saved_settings.module_retailcrm_custom_field_active == 1 %}
checked {% endif %} >
saved_settings.module_retailcrm_custom_field_active == 1 %}
checked {% endif %} >
{{ text_yes }}
</label>
<label class="radio-inline">
<input type="radio" name="module_retailcrm_custom_field_active" value="0" {% if saved_settings.module_retailcrm_custom_field_active is not defined or
saved_settings.module_retailcrm_custom_field_active == 0 %}
checked {% endif %} >
saved_settings.module_retailcrm_custom_field_active == 0 %}
checked {% endif %} >
{{ text_no }}
</label>
</div>
@ -444,21 +449,21 @@
<div class="col-sm-10">
<div class="row">
{% for customField in customFields.opencart %}
<div class="col-sm-12" style="margin-bottom:5px;">
<div class="row">
{% set fid = 'c_' ~ customField.custom_field_id %}
<div class="col-sm-4">
<select class="form-control" id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" >
{% 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 %}>
{{ v.name }}
</option>
{% endfor %}
</select>
<div class="col-sm-12" style="margin-bottom:5px;">
<div class="row">
{% set fid = 'c_' ~ customField.custom_field_id %}
<div class="col-sm-4">
<select class="form-control" id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" >
{% 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 %}>
{{ v.name }}
</option>
{% endfor %}
</select>
</div>
<label style="padding-top: 9px;" 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>
{% endfor %}
</div>
</div>
@ -468,21 +473,21 @@
<div class="col-sm-10">
<div class="row">
{% for customField in customFields.opencart %}
<div class="col-sm-12" style="margin-bottom:5px;">
<div class="row">
{% set fid = 'o_' ~ customField.custom_field_id %}
<div class="col-sm-4">
<select class="form-control" id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" >
{% 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 %}>
{{ v.name }}
</option>
{% endfor %}
</select>
<div class="col-sm-12" style="margin-bottom:5px;">
<div class="row">
{% set fid = 'o_' ~ customField.custom_field_id %}
<div class="col-sm-4">
<select class="form-control" id="module_retailcrm_custom_field_{{ fid }}" name="module_retailcrm_custom_field[{{ fid }}]" >
{% 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 %}>
{{ v.name }}
</option>
{% endfor %}
</select>
</div>
<label style="padding-top: 9px;" 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>
{% endfor %}
</div>
</div>
@ -513,11 +518,11 @@
<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>
{% if logs.retailcrm_log is defined %}
<div class="row">
<div class="col-sm-12">
<textarea wrap="off" rows="15" readonly class="form-control">{{ logs.retailcrm_log }}</textarea>
<div class="row">
<div class="col-sm-12">
<textarea wrap="off" rows="15" readonly class="form-control">{{ logs.retailcrm_log }}</textarea>
</div>
</div>
</div>
{% elseif logs.retailcrm_error is defined %}
<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>
@ -530,11 +535,11 @@
<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>
{% if logs.oc_api_log is defined %}
<div class="row">
<div class="col-sm-12">
<textarea wrap="off" rows="15" readonly class="form-control">{{ logs.oc_api_log }}</textarea>
<div class="row">
<div class="col-sm-12">
<textarea wrap="off" rows="15" readonly class="form-control">{{ logs.oc_api_log }}</textarea>
</div>
</div>
</div>
{% elseif logs.oc_error is defined %}
<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>

View File

@ -17,7 +17,8 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest
->disableOriginalConstructor()
->setMethods(array(
'storePricesUpload',
'sitesList'
'sitesList',
'isSuccessful'
))
->getMock();
@ -28,13 +29,23 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest
$this->retailcrm->getModuleTitle(),
array(
$this->retailcrm->getModuleTitle() . '_apiversion' => 'v5',
$this->retailcrm->getModuleTitle() . '_special' => 'special'
$this->retailcrm->getModuleTitle() . '_special_1' => 'special1',
$this->retailcrm->getModuleTitle() . '_special_2' => 'special2'
)
);
}
public function testUploadPrices()
{
$response = new \RetailcrmApiResponse(
201,
json_encode(
$this->sites()
)
);
$this->apiClientMock->expects($this->any())->method('sitesList')->willReturn($response);
$productModel = $this->loadModel('catalog/product');
$products = $productModel->getProducts();
$prices = $this->pricesModel->uploadPrices($products, $this->apiClientMock);
@ -48,4 +59,30 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest
$this->assertArrayHasKey('prices', $price);
$this->assertInternalType('array', $price['prices']);
}
private function sites(){
return array(
"success"=> true,
"sites"=> array(
"BitrixMod"=> array(
"name"=> "site",
"url"=> "http://site.ru",
"code"=> "site",
"defaultForCrm"=> false,
"ymlUrl"=> "http://site.ru/retailcrm.xml",
"loadFromYml"=> false,
"catalogUpdatedAt"=> "2019-02-08 13:30:37",
"catalogLoadingAt"=> "2019-02-11 09:12:18",
"contragent"=> array(
"contragentType"=> "legal-entity",
"legalName"=> "code",
"code"=> "code",
"countryIso"=> "RU",
"vatRate"=> "",
),
"countryIso"=> "",
)
),
);
}
}