Commit 0fb53ea6 authored by Florian Azizian's avatar Florian Azizian

FIX #10704 TIME 0:15 rm process visa workflow in batch

parent 804a63f8
......@@ -275,47 +275,6 @@ function Bt_refusedSignedMail($aArgs = [])
]);
}
function Bt_processVisaWorkflow($aArgs = [])
{
$visaWorkflow = Bt_getVisaWorkflow(['resId' => $aArgs['res_id_master']]);
$nbVisaWorkflow = $visaWorkflow->rowCount();
if ($nbVisaWorkflow > 0) {
while ($listInstance = $visaWorkflow->fetchObject()) {
$GLOBALS['db']->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP WHERE listinstance_id = ?", [$listInstance->listinstance_id]);
$nbUserProcess++;
// Stop to the first signatory user
if ($listInstance->requested_signature) {
$GLOBALS['db']->query("UPDATE listinstance SET signatory = 'true' WHERE listinstance_id = ?", [$listInstance->listinstance_id]);
break;
}
}
if ($nbUserProcess < $nbVisaWorkflow) {
// Get the next user in workflow
$listInstance = $visaWorkflow->fetchObject();
if ($listInstance->requested_signature) {
$mailStatus = 'ESIG';
} else {
$mailStatus = 'EVIS';
}
Bt_validatedMail(['status' => $mailStatus, 'resId' => $aArgs['res_id_master']]);
} else {
Bt_validatedMail(['status' => $aArgs['validatedStatus'], 'resId' => $aArgs['res_id_master']]);
}
} else {
Bt_validatedMail(['status' => $aArgs['validatedStatus'], 'resId' => $aArgs['res_id_master']]);
}
}
function Bt_getVisaWorkflow($aArgs = [])
{
$req = "SELECT listinstance_id, item_id, requested_signature FROM listinstance WHERE res_id = ? AND difflist_type = 'VISA_CIRCUIT' AND process_date IS NULL ORDER BY listinstance_id ASC";
$stmt = $GLOBALS['db']->query($req, array($aArgs['resId']));
return $stmt;
}
function Bt_validatedMail($aArgs = [])
{
$req = "SELECT count(1) as nbresult FROM res_view_attachments WHERE res_id_master = ? AND status = ?";
......
......@@ -335,8 +335,8 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
} else {
$status = $validatedStatus;
}
Bt_processVisaWorkflow(['res_id_master' => $value->res_id_master, 'validatedStatus' => $status]);
Bt_validatedMail(['status' => $status, 'resId' => $value->res_id_master]);
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_version_attachments) a été validée dans le parapheur externe';
Bt_history([
'table_name' => 'res_version_attachments',
......@@ -439,7 +439,7 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
} else {
$status = $validatedStatus;
}
Bt_processVisaWorkflow(['res_id_master' => $value->res_id_master, 'validatedStatus' => $status]);
Bt_validatedMail(['status' => $status, 'resId' => $value->res_id_master]);
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_attachments) a été validée dans le parapheur externe';
Bt_history([
......@@ -508,7 +508,7 @@ foreach ($retrievedMails['resLetterbox'] as $resId => $value) {
if ($value->status == 'validatedNote') {
$GLOBALS['logger']->write('Document validated', 'INFO');
Bt_processVisaWorkflow(['res_id_master' => $value->res_id, 'validatedStatus' => $validatedStatusAnnot]);
Bt_validatedMail(['status' => $validatedStatusAnnot, 'resId' => $value->res_id]);
Bt_history([
'table_name' => 'res_letterbox',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment