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

FEAT batch retrieveMailsFromExternalSB

parent f5d2bb10
No related branches found
No related tags found
No related merge requests found
......@@ -160,12 +160,15 @@ function Bt_createAttachment($aArgs = [])
array_push($dataValue, ['column' => 'res_id_master', 'value' => $aArgs['res_id_master'], 'type' => 'integer']);
array_push($dataValue, ['column' => 'title', 'value' => $aArgs['title'], 'type' => 'string']);
array_push($dataValue, ['column' => 'identifier', 'value' => $aArgs['identifier'], 'type' => 'string']);
array_push($dataValue, ['column' => 'type_id', 'value' => $aArgs['type_id'], 'type' => 'integer']);
array_push($dataValue, ['column' => 'type_id', 'value' => 1, 'type' => 'integer']);
array_push($dataValue, ['column' => 'dest_contact_id', 'value' => $aArgs['dest_contact_id'], 'type' => 'integer']);
array_push($dataValue, ['column' => 'dest_address_id', 'value' => $aArgs['dest_address_id'], 'type' => 'integer']);
array_push($dataValue, ['column' => 'dest_user', 'value' => $aArgs['dest_user'], 'type' => 'string']);
array_push($dataValue, ['column' => 'typist', 'value' => $aArgs['typist'], 'type' => 'string']);
array_push($dataValue, ['column' => 'attachment_type', 'value' => 'signed_response', 'type' => 'string']);
array_push($dataValue, ['column' => 'coll_id', 'value' => 'letterbox_coll', 'type' => 'string']);
array_push($dataValue, ['column' => 'relation', 'value' => 1, 'type' => 'integer']);
array_push($dataValue, ['column' => 'in_signature_book','value' => 'true', 'type' => 'bool']);
$allDatas = [
"encodedFile" => $aArgs['encodedFile'],
......@@ -180,10 +183,10 @@ function Bt_createAttachment($aArgs = [])
CURLOPT_URL => $GLOBALS['applicationUrl'] . 'rest/res',
CURLOPT_HTTPHEADER => [
'accept:application/json',
'content-type:application/json'
'content-type:application/json',
'Authorization: Basic ' . base64_encode($GLOBALS['userWS']. ':' .$GLOBALS['passwordWS']),
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => 'Authorization: Basic ' . base64_encode($GLOBALS['userWS']. ':' .$GLOBALS['passwordWS']),
CURLOPT_POSTFIELDS => json_encode($allDatas),
CURLOPT_POST => true
];
......@@ -197,10 +200,10 @@ function Bt_createAttachment($aArgs = [])
function Bt_refusedSignedMail($aArgs = [])
{
$GLOBALS['db']->query("UPDATE ".$aArgs['tableAttachment']." SET status = 'A_TRA' WHERE res_id = ?", [$aArgs['resIdAttachment']]);
$GLOBALS['db']->query("UPDATE res_letterbox SET status = '" . $aArgs['refusedStatus'] . "' WHERE res_id = ?", [$aArgs['resIdMaster']]);
if (!empty($aArgs['noteContent'])) {
$GLOBALS['db']->query("INSERT INTO notes (identifier, tablename, user_id, date_note, note_text, coll_id) VALUES (?, 'res_letterbox', 'superadmin', CURRENT_TIMESTAMP, ?, 'letterbox_coll')",
[$aArgs['resIdMaster'], $aArgs['noteContent']]);
}
$GLOBALS['db']->query("UPDATE ".$aArgs['tableAttachment']." SET status = 'A_TRA' WHERE res_id = ?", [$aArgs['resIdAttachment']]);
$GLOBALS['db']->query("UPDATE res_letterbox SET status = '" . $aArgs['refusedStatus'] . "' WHERE res_id = ?", [$aArgs['resIdMaster']]);
}
......@@ -267,7 +267,6 @@ foreach ($retrievedMails['isVersion'] as $resId => $value) {
foreach ($retrievedMails['noVersion'] as $resId => $value) {
$GLOBALS['logger']->write('Update attachment', 'INFO');
if ($value->status == 'validated') {
$GLOBALS['db']->query("UPDATE res_attachments SET status = 'TRA' WHERE res_id = ?", [$resId]);
Bt_createAttachment([
'res_id_master' => $value->res_id_master,
'title' => $value->title,
......@@ -280,6 +279,7 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
'format' => $value->format,
'encodedFile' => $value->encodedFile,
]);
$GLOBALS['db']->query("UPDATE res_attachments SET status = 'TRA' WHERE res_id = ?", [$resId]);
$GLOBALS['db']->query("UPDATE res_letterbox SET status = '".$validatedStatus."' WHERE res_id = ?", [$value->res_id_master]);
} elseif ($value->status == 'refused') {
Bt_refusedSignedMail(['tableAttachment' => 'res_attachments',
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment