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

FEAT #11310 TIME 1:50 retrieve multiple notes from maarchParapheur

parent 2f4bea1f
No related branches found
No related tags found
No related merge requests found
...@@ -140,25 +140,28 @@ function Bt_writeLog($args = []) ...@@ -140,25 +140,28 @@ function Bt_writeLog($args = [])
]); ]);
} }
function Bt_createNote($aArgs = []) function Bt_createNote($aArgs = [])
{ {
if (!empty($aArgs['content'])) { if (!empty($aArgs['notes'])) {
$creatorName = ''; foreach ($aArgs['notes'] as $note) {
if (!empty($aArgs['creatorId'])) { if (!empty(trim($note['content']))) {
$creatorId = $aArgs['creatorId']; $creatorName = '';
} else { if (!empty($note['creatorId'])) {
$users = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ["user_id='superadmin' desc"], 'limit' => 1]); $creatorId = $note['creatorId'];
$creatorId = $users[0]['id']; } else {
} $users = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ["user_id='superadmin' desc"], 'limit' => 1]);
if (!empty($aArgs['creatorName'])) { $creatorId = $users[0]['id'];
$creatorName = $aArgs['creatorName'] . ' (Maarch Parapheur) : '; }
if (!empty($note['creatorName'])) {
$creatorName = $note['creatorName'] . ' (Maarch Parapheur) : ';
}
\Note\models\NoteModel::create([
'resId' => $aArgs['resId'],
'user_id' => $creatorId,
'note_text' => $creatorName . $note['content'],
]);
}
} }
\Note\models\NoteModel::create([
'resId' => $aArgs['resId'],
'user_id' => $creatorId,
'note_text' => $creatorName . $aArgs['content'],
]);
} }
} }
......
...@@ -313,7 +313,7 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) { ...@@ -313,7 +313,7 @@ foreach ($retrievedMails['noVersion'] as $resId => $value) {
$historyInfo = 'La signature de la pièce jointe '.$resId.' (res_attachments) a été refusée dans le parapheur externe' . $additionalHistoryInfo; $historyInfo = 'La signature de la pièce jointe '.$resId.' (res_attachments) a été refusée dans le parapheur externe' . $additionalHistoryInfo;
} }
if (in_array($value['status'], ['validated', 'refused'])) { if (in_array($value['status'], ['validated', 'refused'])) {
Bt_createNote(['creatorId' => $value['noteCreatorId'], 'creatorName' => $value['noteCreatorName'], 'content' => $value['noteContent'], 'resId' => $value['res_id_master']]); Bt_createNote(['notes' => $value['notes'], 'resId' => $value['res_id_master']]);
Bt_history([ Bt_history([
'table_name' => 'res_attachments', 'table_name' => 'res_attachments',
'record_id' => $resId, 'record_id' => $resId,
...@@ -395,7 +395,7 @@ foreach ($retrievedMails['resLetterbox'] as $resId => $value) { ...@@ -395,7 +395,7 @@ foreach ($retrievedMails['resLetterbox'] as $resId => $value) {
'event_type' => 'ACTION#1', 'event_type' => 'ACTION#1',
'event_id' => '1' 'event_id' => '1'
]); ]);
Bt_createNote(['creatorId' => $value['noteCreatorId'], 'creatorName' => $value['noteCreatorName'], 'content' => $value['noteContent'], 'resId' => $resId]); Bt_createNote(['notes' => $value['notes'], 'resId' => $resId]);
\Resource\models\ResModel::update([ \Resource\models\ResModel::update([
'set' => ['status' => $status], 'set' => ['status' => $status],
'postSet' => ['external_id' => "external_id - 'signatureBookId'"], 'postSet' => ['external_id' => "external_id - 'signatureBookId'"],
......
...@@ -87,7 +87,7 @@ class FastParapheurController ...@@ -87,7 +87,7 @@ class FastParapheurController
$signatoryInfo = FastParapheurController::getSignatoryUserInfo(['resId' => $aArgs['idsToRetrieve'][$version][$resId]['res_id_master']]); $signatoryInfo = FastParapheurController::getSignatoryUserInfo(['resId' => $aArgs['idsToRetrieve'][$version][$resId]['res_id_master']]);
$response = FastParapheurController::getRefusalMessage(['config' => $aArgs['config'], 'documentId' => $value['external_id']]); $response = FastParapheurController::getRefusalMessage(['config' => $aArgs['config'], 'documentId' => $value['external_id']]);
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refused'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refused';
$aArgs['idsToRetrieve'][$version][$resId]['noteContent'] = $signatoryInfo['lastname'] . ' ' . $signatoryInfo['firstname'] . ' : ' . $response; $aArgs['idsToRetrieve'][$version][$resId]['notes'][] = ['content' => $signatoryInfo['lastname'] . ' ' . $signatoryInfo['firstname'] . ' : ' . $response];
break; break;
} else { } else {
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'waiting'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'waiting';
......
...@@ -332,7 +332,7 @@ class IParapheurController ...@@ -332,7 +332,7 @@ class IParapheurController
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'validated'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'validated';
$aArgs['idsToRetrieve'][$version][$resId]['format'] = 'pdf'; $aArgs['idsToRetrieve'][$version][$resId]['format'] = 'pdf';
$aArgs['idsToRetrieve'][$version][$resId]['encodedFile'] = $response['b64FileContent']; $aArgs['idsToRetrieve'][$version][$resId]['encodedFile'] = $response['b64FileContent'];
$aArgs['idsToRetrieve'][$version][$resId]['noteContent'] = $noteContent; $aArgs['idsToRetrieve'][$version][$resId]['notes'][] = ['content' => $noteContent];
if ($status == $aArgs['config']['data']['signState']) { if ($status == $aArgs['config']['data']['signState']) {
IParapheurController::processVisaWorkflow(['res_id_master' => $value['res_id_master'], 'res_id' => $value['res_id'], 'processSignatory' => true]); IParapheurController::processVisaWorkflow(['res_id_master' => $value['res_id_master'], 'res_id' => $value['res_id'], 'processSignatory' => true]);
break; break;
...@@ -340,7 +340,7 @@ class IParapheurController ...@@ -340,7 +340,7 @@ class IParapheurController
} elseif ($status == $aArgs['config']['data']['refusedVisa'] || $status == $aArgs['config']['data']['refusedSign']) { } elseif ($status == $aArgs['config']['data']['refusedVisa'] || $status == $aArgs['config']['data']['refusedSign']) {
$noteContent .= $res->nom . ' : ' . $res->annotation . PHP_EOL; $noteContent .= $res->nom . ' : ' . $res->annotation . PHP_EOL;
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refused'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refused';
$aArgs['idsToRetrieve'][$version][$resId]['noteContent'] = $noteContent; $aArgs['idsToRetrieve'][$version][$resId]['notes'][] = ['content' => $noteContent];
break; break;
} else { } else {
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'waiting'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'waiting';
......
...@@ -359,7 +359,7 @@ class IxbusController ...@@ -359,7 +359,7 @@ class IxbusController
if ((string)$etatDossier == $aArgs['config']['data']['ixbusIdEtatRefused']) { if ((string)$etatDossier == $aArgs['config']['data']['ixbusIdEtatRefused']) {
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refused'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refused';
$notes = IxbusController::getDossier(['config' => $aArgs['config'], 'sessionId' => $sessionId['cookie'], 'dossier_id' => $value['external_id']]); $notes = IxbusController::getDossier(['config' => $aArgs['config'], 'sessionId' => $sessionId['cookie'], 'dossier_id' => $value['external_id']]);
$aArgs['idsToRetrieve'][$version][$resId]['noteContent'] = (string)$notes->MotifRefus; $aArgs['idsToRetrieve'][$version][$resId]['notes'][] = ['content' => (string)$notes->MotifRefus];
// Validated // Validated
} elseif ((string)$etatDossier == $aArgs['config']['data']['ixbusIdEtatValidated']) { } elseif ((string)$etatDossier == $aArgs['config']['data']['ixbusIdEtatValidated']) {
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'validated'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'validated';
...@@ -368,7 +368,7 @@ class IxbusController ...@@ -368,7 +368,7 @@ class IxbusController
$aArgs['idsToRetrieve'][$version][$resId]['encodedFile'] = (string)$signedDocument->Fichier; $aArgs['idsToRetrieve'][$version][$resId]['encodedFile'] = (string)$signedDocument->Fichier;
$notes = IxbusController::getAnnotations(['config' => $aArgs['config'], 'sessionId' => $sessionId['cookie'], 'dossier_id' => $value['external_id']]); $notes = IxbusController::getAnnotations(['config' => $aArgs['config'], 'sessionId' => $sessionId['cookie'], 'dossier_id' => $value['external_id']]);
$aArgs['idsToRetrieve'][$version][$resId]['noteContent'] = (string)$notes->Annotation->Texte; $aArgs['idsToRetrieve'][$version][$resId]['notes'][] = ['content' => (string)$notes->Annotation->Texte];
} else { } else {
unset($aArgs['idsToRetrieve'][$version][$resId]); unset($aArgs['idsToRetrieve'][$version][$resId]);
} }
......
...@@ -513,6 +513,9 @@ class MaarchParapheurController ...@@ -513,6 +513,9 @@ class MaarchParapheurController
{ {
$version = $aArgs['version']; $version = $aArgs['version'];
foreach ($aArgs['idsToRetrieve'][$version] as $resId => $value) { foreach ($aArgs['idsToRetrieve'][$version] as $resId => $value) {
if (!is_numeric($value['external_id'])) {
continue;
}
$documentWorkflow = MaarchParapheurController::getDocumentWorkflow(['config' => $aArgs['config'], 'documentId' => $value['external_id']]); $documentWorkflow = MaarchParapheurController::getDocumentWorkflow(['config' => $aArgs['config'], 'documentId' => $value['external_id']]);
if (!is_array($documentWorkflow)) { if (!is_array($documentWorkflow)) {
unset($aArgs['idsToRetrieve'][$version][$resId]); unset($aArgs['idsToRetrieve'][$version][$resId]);
...@@ -533,23 +536,25 @@ class MaarchParapheurController ...@@ -533,23 +536,25 @@ class MaarchParapheurController
} elseif ($state['status'] == 'refused' && $state['mode'] == 'note') { } elseif ($state['status'] == 'refused' && $state['mode'] == 'note') {
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refusedNote'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refusedNote';
} }
if (!empty($state['note'])) { foreach ($state['notes'] as $note) {
$aArgs['idsToRetrieve'][$version][$resId]['noteContent'] = $state['note']; $tmpNote = [];
$tmpNote['content'] = $note['content'];
$userInfos = UserModel::getByExternalId([ $userInfos = UserModel::getByExternalId([
'select' => ['id', 'firstname', 'lastname'], 'select' => ['id', 'firstname', 'lastname'],
'externalId' => $state['noteCreatorId'], 'externalId' => $note['creatorId'],
'externalName' => 'maarchParapheur' 'externalName' => 'maarchParapheur'
]); ]);
if (!empty($userInfos)) { if (!empty($userInfos)) {
$aArgs['idsToRetrieve'][$version][$resId]['noteCreatorId'] = $userInfos['id']; $tmpNote['creatorId'] = $userInfos['id'];
} }
$aArgs['idsToRetrieve'][$version][$resId]['noteCreatorName'] = $state['noteCreatorName']; $tmpNote['creatorName'] = $note['creatorName'];
$aArgs['idsToRetrieve'][$version][$resId]['notes'][] = $tmpNote;
} }
if (!empty($state['signatoryUserId'])) { if (!empty($state['signatoryUserId'])) {
$signatoryUser = UserModel::getByExternalId([ $signatoryUser = UserModel::getByExternalId([
'select' => ['user_id', 'id'], 'select' => ['user_id', 'id'],
'externalId' => $state['signatoryUserId'], 'externalId' => $state['signatoryUserId'],
'externalName' => 'maarchParapheur' 'externalName' => 'maarchParapheur'
]); ]);
if (!empty($signatoryUser['user_id'])) { if (!empty($signatoryUser['user_id'])) {
$aArgs['idsToRetrieve'][$version][$resId]['typist'] = $signatoryUser['user_id']; $aArgs['idsToRetrieve'][$version][$resId]['typist'] = $signatoryUser['user_id'];
...@@ -592,9 +597,17 @@ class MaarchParapheurController ...@@ -592,9 +597,17 @@ class MaarchParapheurController
public static function getState($aArgs) public static function getState($aArgs)
{ {
$state['status'] = 'validated'; $state['status'] = 'validated';
$state['workflowInfo'] = []; $state['workflowInfo'] = [];
$state['notes'] = [];
foreach ($aArgs['workflow'] as $step) { foreach ($aArgs['workflow'] as $step) {
if (!empty($step['note'])) {
$state['notes'][] = [
'content' => $step['note'],
'creatorId' => $step['userId'],
'creatorName' => $step['userDisplay']
];
}
if ($step['status'] == 'VAL' && $step['mode'] == 'sign') { if ($step['status'] == 'VAL' && $step['mode'] == 'sign') {
$state['workflowInfo'][] = $step['userDisplay'] . ' (Signé le ' . $step['processDate'] . ')'; $state['workflowInfo'][] = $step['userDisplay'] . ' (Signé le ' . $step['processDate'] . ')';
$state['signatoryUserId'] = $step['userId']; $state['signatoryUserId'] = $step['userId'];
...@@ -603,11 +616,12 @@ class MaarchParapheurController ...@@ -603,11 +616,12 @@ class MaarchParapheurController
} }
if ($step['status'] == 'REF') { if ($step['status'] == 'REF') {
$state['status'] = 'refused'; $state['status'] = 'refused';
$state['note'] = $step['note'];
$state['noteCreatorId'] = $step['userId'];
$state['noteCreatorName'] = $step['userDisplay'];
$state['workflowInfo'][] = $step['userDisplay'] . ' (Refusé le ' . $step['processDate'] . ')'; $state['workflowInfo'][] = $step['userDisplay'] . ' (Refusé le ' . $step['processDate'] . ')';
break; break;
} elseif ($step['status'] == 'STOP') {
$state['status'] = 'refused';
$state['workflowInfo'][] = $step['userDisplay'] . ' (Interrompu le ' . $step['processDate'] . ')';
break;
} elseif (empty($step['status'])) { } elseif (empty($step['status'])) {
$state['status'] = 'inProgress'; $state['status'] = 'inProgress';
break; break;
......
...@@ -421,7 +421,7 @@ class XParaphController ...@@ -421,7 +421,7 @@ class XParaphController
if ($state['id'] == 'refused') { if ($state['id'] == 'refused') {
$aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refused'; $aArgs['idsToRetrieve'][$version][$resId]['status'] = 'refused';
$aArgs['idsToRetrieve'][$version][$resId]['noteContent'] = $state['note']; $aArgs['idsToRetrieve'][$version][$resId]['notes'][] = ['content' => $state['note']];
$processedFile = XParaphController::getFile(['config' => $aArgs['config'], 'depotId' => $value['external_id'], 'userGeneric' => $userGeneric, 'depotLogin' => $xParaphDepot['login']]); $processedFile = XParaphController::getFile(['config' => $aArgs['config'], 'depotId' => $value['external_id'], 'userGeneric' => $userGeneric, 'depotLogin' => $xParaphDepot['login']]);
if (!empty($processedFile['errors'])) { if (!empty($processedFile['errors'])) {
...@@ -472,7 +472,7 @@ class XParaphController ...@@ -472,7 +472,7 @@ class XParaphController
unlink($tmpPath . $tmpName); unlink($tmpPath . $tmpName);
$aArgs['idsToRetrieve'][$version][$resId]['encodedFile'] = $encodedFile; $aArgs['idsToRetrieve'][$version][$resId]['encodedFile'] = $encodedFile;
$aArgs['idsToRetrieve'][$version][$resId]['noteContent'] = $state['note']; $aArgs['idsToRetrieve'][$version][$resId]['notes'][] = ['content' => $state['note']];
if ($state['id'] == 'validateOnlyVisa') { if ($state['id'] == 'validateOnlyVisa') {
$aArgs['idsToRetrieve'][$version][$resId]['onlyVisa'] = true; $aArgs['idsToRetrieve'][$version][$resId]['onlyVisa'] = true;
} }
......
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