diff --git a/visa/trunk/visa_workflow.php b/visa/trunk/visa_workflow.php index 9089315591246259a9583a12da3bce60fad00443..3ab79e89fee9235d300c8b1dd1ce2eb82ef70fa2 100644 --- a/visa/trunk/visa_workflow.php +++ b/visa/trunk/visa_workflow.php @@ -39,14 +39,14 @@ $confirm = true; * $etapes array Contains only one etap, the status modification */ -$error_visa_workflow = false; +// $error_visa_workflow = false; -$db = new Database(); -$stmt = $db->query("SELECT listinstance_id from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and process_date ISNULL", array($_POST['values'], 'letterbox_coll', 'VISA_CIRCUIT')); +// $db = new Database(); +// $stmt = $db->query("SELECT listinstance_id from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and process_date ISNULL", array($_POST['values'], 'letterbox_coll', 'VISA_CIRCUIT')); -if ($stmt->rowCount() < 2) { - $error_visa_workflow = true; -} +// if ($stmt->rowCount() < 2) { +// $error_visa_workflow = true; +// } $etapes = array('empty_error'); @@ -55,36 +55,46 @@ require_once "modules/visa/class/class_modules_tools.php"; function manage_empty_error($arr_id, $history, $id_action, $label_action, $status) { $db = new Database(); - $_SESSION['action_error'] = ''; $result = ''; - $coll_id = $_SESSION['current_basket']['coll_id']; - $res_id = $arr_id[0]; - require_once("core/class/class_security.php"); - $sec = new security(); - $table = $sec->retrieve_table_from_coll($coll_id); - $circuit_visa = new visa(); - $sequence = $circuit_visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT'); - $stepDetails = array(); - $stepDetails = $circuit_visa->getStepDetails($res_id, $coll_id, 'VISA_CIRCUIT', $sequence); - $message = ''; - //enables to process the visa if i am not the item_id - if ($stepDetails['item_id'] <> $_SESSION['user']['UserId']) { - $stmt = $db->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP " - . " WHERE listinstance_id = ? AND item_mode = ? AND res_id = ? AND item_id = ? AND difflist_type = ?" - , array($stepDetails['listinstance_id'], $stepDetails['item_mode'], $res_id, $stepDetails['item_id'], 'VISA_CIRCUIT')); - $message = _VISA_BY . " " . $_SESSION['user']['UserId'] - . " " . _INSTEAD_OF . " " . $stepDetails['item_id']; - } else { - $stmt = $db->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP " - . " WHERE listinstance_id = ? AND item_mode = ? AND res_id = ? AND item_id = ? AND difflist_type = ?" - , array($stepDetails['listinstance_id'], $stepDetails['item_mode'], $res_id, $_SESSION['user']['UserId'], 'VISA_CIRCUIT')); + if (!empty($_SESSION['stockCheckbox'])) { + $arr_id = $_SESSION['stockCheckbox']; } - if ($circuit_visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT') == $circuit_visa->nbVisa($res_id, $coll_id)) { - $mailStatus = 'ESIG'; - $db->query("UPDATE res_letterbox SET status = ? WHERE res_id = ? ", [$mailStatus, $res_id]); + for ($i=0; $i<count($arr_id);$i++) { + $_SESSION['action_error'] = ''; + $coll_id = $_SESSION['current_basket']['coll_id']; + $res_id = $arr_id[$i]; + require_once("core/class/class_security.php"); + $sec = new security(); + require_once("core/class/class_history.php"); + $history = new history(); + $table = $sec->retrieve_table_from_coll($coll_id); + $circuit_visa = new visa(); + $sequence = $circuit_visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT'); + $stepDetails = array(); + $stepDetails = $circuit_visa->getStepDetails($res_id, $coll_id, 'VISA_CIRCUIT', $sequence); + $message = ''; + + //enables to process the visa if i am not the item_id + if ($stepDetails['item_id'] <> $_SESSION['user']['UserId']) { + $stmt = $db->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP " + . " WHERE listinstance_id = ? AND item_mode = ? AND res_id = ? AND item_id = ? AND difflist_type = ?" + , array($stepDetails['listinstance_id'], $stepDetails['item_mode'], $res_id, $stepDetails['item_id'], 'VISA_CIRCUIT')); + $message = _VISA_BY . " " . $_SESSION['user']['UserId'] + . " " . _INSTEAD_OF . " " . $stepDetails['item_id']; + } else { + $stmt = $db->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP " + . " WHERE listinstance_id = ? AND item_mode = ? AND res_id = ? AND item_id = ? AND difflist_type = ?" + , array($stepDetails['listinstance_id'], $stepDetails['item_mode'], $res_id, $_SESSION['user']['UserId'], 'VISA_CIRCUIT')); + } + + if ($circuit_visa->getCurrentStep($res_id, $coll_id, 'VISA_CIRCUIT') == $circuit_visa->nbVisa($res_id, $coll_id)) { + $mailStatus = 'ESIG'; + $db->query("UPDATE res_letterbox SET status = ? WHERE res_id = ? ", [$mailStatus, $res_id]); + } + $result .= $arr_id[$i] . '#'; } - return array('result' => $res_id.'#', 'history_msg' => $message); + return array('result' => $result, 'history_msg' => ''); }