opencart-module/admin/view/template/extension/module/retailcrm.twig
2017-10-30 16:49:49 +03:00

401 lines
28 KiB
Twig

{{ header }}{{ column_left }}
<div id="content">
<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 %}
<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>
{% 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>
{% 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>
{% endif %}
<div class="panel panel-default">
<div class="panel-body">
<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-module">
<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>
{% endif %}
{% endif %}
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab-general">
<input type="hidden" name="module_retailcrm_status" value="1">
<h3>{{ retailcrm_base_settings }}</h3>
<div class="retailcrm_unit">
<label for="retailcrm_url">{{ retailcrm_apiversion }}</label><br>
<select name="module_retailcrm_apiversion">
{% 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>
{% endfor %}
</select>
</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 class="retailcrm_unit">
<label for="retailcrm_apikey">{{ retailcrm_apikey }}</label><br>
<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>
<h3>{{ retailcrm_countries_settings }}</h3>
<div class="retailcrm_unit">
<div class="well well-sm" style="height: 150px; overflow: auto; width: 30%;">
{% 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>
{% 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>
{% endfor %}
{% else %}
<h3>{{ retailcrm_upload_order }}</h3>
<div class="retailcrm_unit">
<label>{{ text_button_export_order }} № </label><input type="text" name="order_id">
<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 class="tab-pane" id="tab-references">
<h3>{{ retailcrm_dict_settings }}</h3>
<h4>{{ retailcrm_dict_delivery }}</h4>
{% for value in delivery.opencart %}
<div class="pm">{{ value.title ~ ':' }}</div>
{% for key, val in value %}
{% if key != 'title' %}
<div class="retailcrm_unit">
<select id="retailcrm_delivery_{{ val.code }}" name="module_retailcrm_delivery[{{ val.code }}]" >
{% 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>
<label for="retailcrm_pm_{{ val.code }}">{{ val.title }}</label>
</div>
{% endif %}
{% endfor %}
{% endfor %}
<h4>{{ retailcrm_dict_status }}</h4>
{% for status in statuses.opencart %}
{% set uid = status.order_status_id %}
<div class="retailcrm_unit">
<select id="retailcrm_status_{{ uid }}" name="module_retailcrm_status[{{ status.order_status_id }}]" >
{% 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>
<label for="retailcrm_status_{{ status.order_status_id }} ">{{ status.name }}</label>
</div>
{% endfor %}
<h4>{{ retailcrm_dict_payment }}</h4>
{% for key, value in payments.opencart %}
<div class="retailcrm_unit">
<select id="retailcrm_payment_{{ key }}" name="module_retailcrm_payment[{{ key }}]" >
{% 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>
<label for="retailcrm_payment_{{ key }}">{{ value }}</label>
</div>
{% endfor %}
<h4>{{ retailcrm_dict_default }}</h4>
<div class="retailcrm_unit">
<select id="retailcrm_default_payment" name="retailcrm_default_payment" >
{% for k, v in payments.opencart %}
<option value="{{ k }}" {% if saved_settings.retailcrm_default_payment is defined and k == saved_settings.retailcrm_default_payment %} selected="selected" {% endif %}>
{{ v }}
</option>
{% endfor %}
</select>
<label for="retailcrm_default_payment">{{ text_payment }}</label>
</div>
<div class="retailcrm_unit">
<select id="retailcrm_default_shipping" name="retailcrm_default_shipping" >
{% 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.retailcrm_default_shipping is defined and v.code == saved_settings.retailcrm_default_shipping %} selected="selected" {% endif %}>
{{ v.title }}
</option>
{% endif %}
{% endfor %}
</optgroup>
{% endfor %}
</select>
<label for="retailcrm_default_payment">{{ text_shipping }}</label>
</div>
{% endif %}
{% endif %}
</div>
<div class="tab-pane" id="tab-collector">
<h3>{{ daemon_collector }}</h3>
<div class="retailcrm_unit">
<label for="retailcrm_collector_active" class="col-md-4">{{ text_collector_activity }}</label>
<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' }}
{% endif %}>
{{ text_yes }}
</label>
<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' }}
{% endif %}>
{{ text_no }}
</label>
</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 class="retailcrm_unit">
<label for="retailcrm_collector" class="col-md-4">{{ text_collector_form_capture }}</label>
<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' }}
{% endif %}>
{{ text_yes }}
</label>
<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' }}
{% endif %}>
{{ text_no }}
</label>
</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 class="retailcrm_unit">
<label for="module_retailcrm_collector" class="col-md-4">{{ text_label_promo }}</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>
<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 class="retailcrm_unit">
<label for="module_retailcrm_collector" class="col-md-4">{{ collector_custom_text }}</label>
<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' }}
{% 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' }}
{% endif %}>
{{ text_no }}
</label>
</div>
{% for field, label in collectorFields %}
<div class="retailcrm_unit">
<label for="retailcrm_collector" class="col-md-4">{{ label }}</label>
<div class="col-md-8">
<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 %}">
<input type="checkbox" name="module_retailcrm_collector[require][{{ field }}_require]" value="1" {% if saved_settings.module_retailcrm_collector.require[field ~'_require'] %} checked {% endif %}>
<label for="retailcrm_collector">{{ text_require }}</label>
</div>
</div>
{% endfor %}
</div>
{% 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">
<h4>{{ retailcrm_dict_custom_fields }}</h4>
{% if customFields.retailcrm is not empty and customFields.opencart is not empty %}
<div class="retailcrm_unit">
<label for="retailcrm_custom_field_active">{{ text_custom_field_activity }}</label>
<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 %} >
{{ 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 %} >
{{ text_no }}
</label>
</div>
<h4>{{ text_customers_custom_fields }}</h4>
{% for customField in customFields.opencart %}
{% set fid = 'c_' ~ customField.custom_field_id %}
<div class="retailcrm_unit">
<select 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>
<label for="module_retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label>
</div>
{% endfor %}
<h4>{{ text_orders_custom_fields }}</h4>
{% for customField in customFields.opencart %}
{% set fid = 'o_' ~ customField.custom_field_id %}
<div class="retailcrm_unit">
<select 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>
<label for="module_retailcrm_custom_field_{{ fid }}">{{ customField.name }}</label>
</div>
{% endfor %}
{% elseif customFields.retailcrm is empty and customFields.opencart is empty %}
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ text_error_custom_field }}
</div>
{% elseif customFields.retailcrm is empty %}
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ text_error_cf_retailcrm }}
</div>
{% elseif customFields.opencart is empty %}
<div class="alert alert-info"><i class="fa fa-exclamation-circle"></i>
<button type="button" class="close" data-dismiss="alert">&times;</button>
{{ text_error_cf_opencart }}
</div>
{% endif %}
</div>
{% endif %}
</div>
</form>
</div>
</div>
</div>
</div>
{{ footer }}
<script type="text/javascript">
var token = '{{ user_token }}';
$('#icml').on('click', function() {
$.ajax({
url: '{{ catalog }}' + 'admin/index.php?route=extension/module/retailcrm/icml&user_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> {{ text_success_catalog }}</div>');
$('#icml').button('reset');
},
error: function(){
alert('error');
}
});
});
$('#export').on('click', function() {
$.ajax({
url: '{{ catalog }}' + 'admin/index.php?route=extension/module/retailcrm/export&user_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> {{ 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: '{{ catalog }}' + 'admin/index.php?route=extension/module/retailcrm/exportOrder&user_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>{{ 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>{{ 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> {{ text_error_order_id }}</div>');
$('#export_order').button('reset');
}
});
</script>