Skip to content
Snippets Groups Projects
Verified Commit fd582fda authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT set VAL status in res_letterbox only if all attachments is processed (external signatory book)

parent 9312cff3
No related branches found
No related tags found
No related merge requests found
...@@ -195,8 +195,6 @@ function Bt_createAttachment($aArgs = []) ...@@ -195,8 +195,6 @@ function Bt_createAttachment($aArgs = [])
curl_setopt_array($curl, $opts); curl_setopt_array($curl, $opts);
$rawResponse = curl_exec($curl); $rawResponse = curl_exec($curl);
$GLOBALS['db']->query("UPDATE res_letterbox SET status = ? WHERE res_id = ?", [$aArgs['validatedStatus'], $aArgs['res_id_master']]);
return json_decode($rawResponse, true); return json_decode($rawResponse, true);
} }
...@@ -237,7 +235,6 @@ function Bt_processVisaWorkflow($aArgs = []) ...@@ -237,7 +235,6 @@ function Bt_processVisaWorkflow($aArgs = [])
$nbVisaWorkflow = $visaWorkflow->rowCount(); $nbVisaWorkflow = $visaWorkflow->rowCount();
if ($nbVisaWorkflow > 0) { if ($nbVisaWorkflow > 0) {
$signatureRequestedFound = false;
while ($listInstance = $visaWorkflow->fetchObject()) { while ($listInstance = $visaWorkflow->fetchObject()) {
$GLOBALS['db']->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP WHERE listinstance_id = ?", [$listInstance->listinstance_id]); $GLOBALS['db']->query("UPDATE listinstance SET process_date = CURRENT_TIMESTAMP WHERE listinstance_id = ?", [$listInstance->listinstance_id]);
$nbUserProcess++; $nbUserProcess++;
...@@ -256,8 +253,10 @@ function Bt_processVisaWorkflow($aArgs = []) ...@@ -256,8 +253,10 @@ function Bt_processVisaWorkflow($aArgs = [])
$mailStatus = 'EVIS'; $mailStatus = 'EVIS';
} }
$GLOBALS['db']->query('UPDATE res_letterbox SET status = ? WHERE res_id = ? ', [$mailStatus, $aArgs['res_id_master']]); Bt_validatedMail(['status' => $mailStatus, 'resId' => $aArgs['res_id_master']]);
} }
} else {
Bt_validatedMail(['status' => $aArgs['validatedStatus'], 'resId' => $aArgs['res_id_master']]);
} }
} }
...@@ -268,3 +267,15 @@ function Bt_getVisaWorkflow($aArgs = []) ...@@ -268,3 +267,15 @@ function Bt_getVisaWorkflow($aArgs = [])
return $stmt; return $stmt;
} }
function Bt_validatedMail($aArgs = [])
{
$req = "SELECT count(1) as nbresult FROM res_view_attachments WHERE res_id_master = ? AND status = ?";
$stmt = $GLOBALS['db']->query($req, array($aArgs['resId'], 'FRZ'));
$reqResult = $stmt->fetchObject();
var_dump($reqResult->nbresult);
if ($reqResult->nbresult == 0) {
var_dump('a');
$GLOBALS['db']->query('UPDATE res_letterbox SET status = ? WHERE res_id = ? ', [$aArgs['status'], $aArgs['resId']]);
}
}
...@@ -256,12 +256,11 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) { ...@@ -256,12 +256,11 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
'dest_contact_id' => $value->dest_contact_id, 'dest_contact_id' => $value->dest_contact_id,
'dest_address_id' => $value->dest_address_id, 'dest_address_id' => $value->dest_address_id,
'dest_user' => $value->dest_user, 'dest_user' => $value->dest_user,
'typist' => $value->typist, 'typist' => $value->typist
'validatedStatus' => $validatedStatus
]); ]);
$GLOBALS['db']->query("UPDATE res_version_attachments set status = 'TRA' WHERE res_id = ?", [$resId]); $GLOBALS['db']->query("UPDATE res_version_attachments set status = 'TRA' WHERE res_id = ?", [$resId]);
Bt_processVisaWorkflow(['res_id_master' => $value->res_id_master]); Bt_processVisaWorkflow(['res_id_master' => $value->res_id_master, 'validatedStatus' => $validatedStatus]);
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_version_attachments) a été validée dans le parapheur externe'; $historyInfo = 'La signature de la pièce jointe '.$resId.' (res_version_attachments) a été validée dans le parapheur externe';
Bt_history([ Bt_history([
...@@ -302,12 +301,11 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) { ...@@ -302,12 +301,11 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
'dest_user' => $value->dest_user, 'dest_user' => $value->dest_user,
'typist' => $value->typist, 'typist' => $value->typist,
'format' => $value->format, 'format' => $value->format,
'encodedFile' => $value->encodedFile, 'encodedFile' => $value->encodedFile
'validatedStatus' => $validatedStatus
]); ]);
$GLOBALS['db']->query("UPDATE res_attachments SET status = 'TRA' WHERE res_id = ?", [$resId]); $GLOBALS['db']->query("UPDATE res_attachments SET status = 'TRA' WHERE res_id = ?", [$resId]);
Bt_processVisaWorkflow(['res_id_master' => $value->res_id_master]); Bt_processVisaWorkflow(['res_id_master' => $value->res_id_master, 'validatedStatus' => $validatedStatus]);
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_attachments) a été validée dans le parapheur externe'; $historyInfo = 'La signature de la pièce jointe '.$resId.' (res_attachments) a été validée dans le parapheur externe';
Bt_history([ Bt_history([
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment