diff --git a/admin/controller/extension/module/retailcrm.php b/admin/controller/extension/module/retailcrm.php index 2de9976..47e9068 100644 --- a/admin/controller/extension/module/retailcrm.php +++ b/admin/controller/extension/module/retailcrm.php @@ -127,7 +127,9 @@ class ControllerExtensionModuleRetailcrm extends Controller 'text_button_export_order', 'text_button_catalog', 'text_success_catalog', - 'retailcrm_upload_order' + 'retailcrm_upload_order', + 'text_error_order', + 'text_error_order_id' ); $this->load->model('extension/extension'); @@ -322,9 +324,10 @@ class ControllerExtensionModuleRetailcrm extends Controller $data['order_status'] = $status['retailcrm_status'][$data['order_status_id']]; $this->load->model('extension/retailcrm/order'); - $this->model_extension_retailcrm_order->uploadOrder($data); + $result = $this->model_extension_retailcrm_order->uploadOrder($data); } + echo json_encode($result); } /** diff --git a/admin/language/en-gb/extension/module/retailcrm.php b/admin/language/en-gb/extension/module/retailcrm.php index 266b1bc..9fda572 100644 --- a/admin/language/en-gb/extension/module/retailcrm.php +++ b/admin/language/en-gb/extension/module/retailcrm.php @@ -22,6 +22,9 @@ $_['text_button_export'] = 'Unload all orders and customers'; $_['text_button_export_order'] = 'Unload order'; $_['text_button_catalog'] = 'Unload catalog'; $_['text_success_catalog'] = 'Catalog successfully unloaded'; +$_['text_error_order'] = 'Error! Order is not unloaded!'; +$_['text_error_order_id'] = 'Error! Enter the correct order number!'; + $_['retailcrm_dict_delivery'] = 'Shipment methods'; $_['retailcrm_dict_status'] = 'Order statuses'; diff --git a/admin/language/ru-ru/extension/module/retailcrm.php b/admin/language/ru-ru/extension/module/retailcrm.php index 85bbdd0..9672dd5 100644 --- a/admin/language/ru-ru/extension/module/retailcrm.php +++ b/admin/language/ru-ru/extension/module/retailcrm.php @@ -22,6 +22,8 @@ $_['text_button_export'] = 'Выгрузить все заказы и к $_['text_button_export_order'] = 'Выгрузить заказ'; $_['text_button_catalog'] = 'Выгрузить каталог'; $_['text_success_catalog'] = 'Каталог успешно выгружен'; +$_['text_error_order'] = 'Ошибка! Заказ не выгружен!'; +$_['text_error_order_id'] = 'Ошибка! Введите корректный номер заказа!'; $_['retailcrm_dict_delivery'] = 'Способы доставки'; $_['retailcrm_dict_status'] = 'Статусы'; diff --git a/admin/model/extension/retailcrm/order.php b/admin/model/extension/retailcrm/order.php index 253d31c..5edd1de 100644 --- a/admin/model/extension/retailcrm/order.php +++ b/admin/model/extension/retailcrm/order.php @@ -58,8 +58,10 @@ class ModelExtensionRetailcrmOrder extends Model { unset($customers); - $this->retailcrm->ordersCreate($order); + $result = $this->retailcrm->ordersCreate($order); } + + return $result; } private function process($order_data) { diff --git a/admin/view/template/extension/module/retailcrm.tpl b/admin/view/template/extension/module/retailcrm.tpl index b9c84bc..e5ccc59 100644 --- a/admin/view/template/extension/module/retailcrm.tpl +++ b/admin/view/template/extension/module/retailcrm.tpl @@ -171,20 +171,33 @@ }); $('#export_order').on('click', function() { - $.ajax({ - url: ''+'admin/index.php?route=extension/module/retailcrm/exportOrder&token=' + token + '&order_id=' + $('input[name=\'order_id\']').val(), - beforeSend: function() { - $('#export_order').button('loading'); - }, - complete: function(json) { - $('.alert-success').remove(); - $('#content > .container-fluid').prepend('
'); - $('#export_order').button('reset'); - }, - error: function(xhr, ajaxOptions, thrownError) { - alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); - } - - }); + var order_id = $('input[name=\'order_id\']').val(); + if (order_id && order_id > 0) { + $.ajax({ + url: ''+'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) { + if (jqXHR['responseText'] == 'false') { + $('.alert-success').remove(); + $('#content > .container-fluid').prepend('
'); + $('#export_order').button('reset'); + } else { + $('.alert-success').remove(); + $('#content > .container-fluid').prepend('
'); + $('#export_order').button('reset'); + $('input[name=\'order_id\']').val(''); + } + } + }); + } else { + $('.alert-success').remove(); + $('#content > .container-fluid').prepend('
'); + $('#export_order').button('reset'); + } }); \ No newline at end of file