diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php index 16178c5f0..8d9f2fafa 100644 --- a/admin-dev/ajax.php +++ b/admin-dev/ajax.php @@ -152,36 +152,6 @@ if (Tools::isSubmit('submitTrackClickOnHelp')) HelpAccess::trackClick($label, $version); } -if (Tools::isSubmit('saveImportMatchs')) -{ - $match = implode('|', Tools::getValue('type_value')); - Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'import_match` ( - `id_import_match` , - `name` , - `match`, - `skip` - ) - VALUES ( - NULL , - \''.pSQL(Tools::getValue('newImportMatchs')).'\', - \''.pSQL($match).'\', - \''.pSQL(Tools::getValue('skip')).'\' - )'); - - die('{"id" : "'.Db::getInstance()->Insert_ID().'"}'); -} - -if (Tools::isSubmit('deleteImportMatchs')) -{ - Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'import_match` WHERE `id_import_match` = '.(int)Tools::getValue('idImportMatchs')); -} - -if (Tools::isSubmit('loadImportMatchs')) -{ - $return = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'import_match` WHERE `id_import_match` = '.(int)Tools::getValue('idImportMatchs')); - die('{"id" : "'.$return[0]['id_import_match'].'", "matchs" : "'.$return[0]['match'].'", "skip" : "'.$return[0]['skip'].'"}'); -} - if (Tools::isSubmit('toggleScreencast')) { if (Validate::isLoadedObject($context->employee)) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index be5401dc5..f024a3278 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -2490,5 +2490,45 @@ class AdminImportControllerCore extends AdminController { $this->warnings[] = $product_name.(isset($product_id) ? ' (ID '.$product_id.')' : '').' '.Tools::displayError($message); } + + public function ajaxProcessSaveImportMatchs() + { + if ($this->tabAccess['edit'] === '1') + { + $match = implode('|', Tools::getValue('type_value')); + Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'import_match` ( + `id_import_match` , + `name` , + `match`, + `skip` + ) + VALUES ( + NULL , + \''.pSQL(Tools::getValue('newImportMatchs')).'\', + \''.pSQL($match).'\', + \''.pSQL(Tools::getValue('skip')).'\' + )'); + + die('{"id" : "'.Db::getInstance()->Insert_ID().'"}'); + } + } + + public function ajaxProcessLoadImportMatchs() + { + if ($this->tabAccess['edit'] === '1') + { + $return = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'import_match` WHERE `id_import_match` = '.(int)Tools::getValue('idImportMatchs')); + die('{"id" : "'.$return[0]['id_import_match'].'", "matchs" : "'.$return[0]['match'].'", "skip" : "'.$return[0]['skip'].'"}'); + } + } + + public function ajaxProcessDeleteImportMatchs() + { + if ($this->tabAccess['edit'] === '1') + { + Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'import_match` WHERE `id_import_match` = '.(int)Tools::getValue('idImportMatchs')); + die; + } + } } diff --git a/js/adminImport.js b/js/adminImport.js index 5bd115ad6..9042f7966 100644 --- a/js/adminImport.js +++ b/js/adminImport.js @@ -39,11 +39,11 @@ $(document).ready(function(){ }); $.ajax({ type: 'GET', - url: 'ajax.php', + url: 'index.php', async: false, cache: false, dataType : "json", - data: 'ajax=true&saveImportMatchs&skip='+$('input[name=skip]').attr('value')+'&newImportMatchs='+newImportMatchs+matchFields, + data: 'ajax=1&action=saveImportMatchs&skip='+$('input[name=skip]').attr('value')+'&newImportMatchs='+newImportMatchs+matchFields+'&tab=AdminImport&token='+token, success: function(jsonData) { $('#valueImportMatchs').append(''); @@ -64,11 +64,11 @@ $(document).ready(function(){ var idToLoad = $('select#valueImportMatchs option:selected').attr('id'); $.ajax({ type: 'GET', - url: 'ajax.php', + url: 'index.php', async: false, cache: false, dataType : "json", - data: 'ajax=true&loadImportMatchs&idImportMatchs='+idToLoad, + data: 'ajax=1&action=loadImportMatchs&idImportMatchs='+idToLoad+'&tab=AdminImport&token='+token, success: function(jsonData) { var matchs = jsonData.matchs.split('|') @@ -89,11 +89,11 @@ $(document).ready(function(){ var idToDelete = $('select#valueImportMatchs option:selected').attr('id'); $.ajax({ type: 'GET', - url: 'ajax.php', + url: 'index.php', async: false, cache: false, dataType : "json", - data: 'ajax=true&deleteImportMatchs&idImportMatchs='+idToDelete, + data: 'ajax=1&action=deleteImportMatchs&idImportMatchs='+idToDelete+'&tab=AdminImport&token='+token, success: function(jsonData) { $('select#valueImportMatchs option[id=\''+idToDelete+'\']').remove();