// Clean ajax.php

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16081 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rGaillard
2012-06-19 13:20:07 +00:00
parent 8a5ee83850
commit 2efce57799
3 changed files with 46 additions and 36 deletions

View File

@@ -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))

View File

@@ -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;
}
}
}

View File

@@ -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('<option id="'+jsonData.id+'" value="'+matchFields+'" selected="selected">'+newImportMatchs+'</option>');
@@ -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();