diff --git a/apps/maarch_entreprise/js/functions.js b/apps/maarch_entreprise/js/functions.js index 3b30887860934622f3ce7785cdee142de387c33f..279c3cdbac43a07f1129b0a643adeb48e1d1ae67 100755 --- a/apps/maarch_entreprise/js/functions.js +++ b/apps/maarch_entreprise/js/functions.js @@ -1595,28 +1595,30 @@ function action_change_status(path_manage_script, mode_req, res_id_values, table { if(res_id_values != '' && (mode_req == 'mass' || mode_req == 'page') && tablename != '' && id_coll != '') - { - new Ajax.Request(path_manage_script, - { - method:'post', - asynchronous : false, - parameters: { values : res_id_values, - mode : mode_req, - req : 'change_status', - table : tablename, - coll_id : id_coll, - new_status : status - }, - onSuccess: function(answer){ - eval('response='+answer.responseText); - if(response.status == 0 ) { + { + + $j.ajax({ + cache : false, + url : path_manage_script, + type : 'POST', + dataType : 'json', + data: { values : res_id_values, + mode : mode_req, + req : 'change_status', + table : tablename, + coll_id : id_coll, + new_status : status, + }, + success: function(answer) { + + setTimeout(function(){ + if(answer.status == 0 ) { actions_status.values = []; // Status changed } else { try{ - //$('frm_error').updateContent(response.error_txt); // update the error div in the modal form - $('frm_error').innerHTML = response.error_txt; - } + $('frm_error').innerHTML = answer.error_txt; + } catch(e){} } if(page != '' && page != NaN && page && page != null ) { @@ -1648,12 +1650,11 @@ function action_change_status(path_manage_script, mode_req, res_id_values, table } do_nothing = false; - }, - onFailure: function(){ - } - }); - } - return true; + }, 200); + } + }); + } + return true; } /***********************************************************************/ diff --git a/core/manage_action.php b/core/manage_action.php index e91c1180d6117650d457d95e489cdf6f1254279c..af48fa8dc9b9dfc5ad34040edf61490cc379f3ad 100644 --- a/core/manage_action.php +++ b/core/manage_action.php @@ -140,8 +140,7 @@ if($_POST['req'] == 'valid_form' && !empty($_POST['action_id']) && isset($_POST[ exit(); } } -elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values'])&& $_POST['values'] != 'none#' && !empty($_POST['new_status']) && !empty($_POST['table'])) -{ +elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values']) && !empty($_POST['new_status']) && !empty($_POST['table'])){ $stmt = $db->query("select id from status where id = ?", array($_POST['new_status'])); $lineStatus = $stmt->fetchObject(); if ($lineStatus->id <> '') { @@ -150,7 +149,7 @@ elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values'])&& $_PO for ($i=0; $i<count($arr_id );$i++) { $arr_id[$i] = str_replace('#', '', $arr_id[$i]); $result .= $arr_id[$i].'#'; - if (trim($_POST['new_status']) <> '') { + if (trim($_POST['new_status']) <> '' && is_numeric($arr_id[$i])) { if ($_POST['table'] == 'folders') { $query_str = "update " . $_POST['table'] . " set status = ? where folders_system_id = ?"; @@ -166,10 +165,10 @@ elseif(trim($_POST['req']) == 'change_status' && !empty($_POST['values'])&& $_PO } } } - echo "{status : 0, error_txt : '".addslashes(_STATUS_UPDATED.' : '.functions::xssafe($_POST['new_status']))."'}"; + echo json_encode(['status' => 0, 'error_txt' => _STATUS_UPDATED.' : '.functions::xssafe($_POST['new_status']) ]); exit(); } else { - echo "{status : 0, error_txt : '".addslashes(_STATUS_NOT_EXISTS.' : '.functions::xssafe($_POST['new_status']))."'}"; + echo json_encode(['status' => 0, 'error_txt' => _STATUS_NOT_EXISTS.' : '.functions::xssafe($_POST['new_status']) ]); exit(); } }