diff --git a/src/app/action/controllers/ActionMethodController.php b/src/app/action/controllers/ActionMethodController.php index cde80cd3ba410de2ddf517a64d03ca3dac693621..45e513384db764502f58bdaab8048a80f8354fb5 100644 --- a/src/app/action/controllers/ActionMethodController.php +++ b/src/app/action/controllers/ActionMethodController.php @@ -290,11 +290,12 @@ class ActionMethodController $processingUserInfo = MaarchParapheurController::getUserById(['config' => $config, 'id' => $args['data']['processingUser']]); $sendedInfo = MaarchParapheurController::sendDatas([ - 'config' => $config, - 'resIdMaster' => $args['resId'], - 'processingUser' => $args['data']['processingUser'], - 'objectSent' => 'mail', - 'userId' => $GLOBALS['userId'] + 'config' => $config, + 'resIdMaster' => $args['resId'], + 'processingUser' => $args['data']['processingUser'], + 'objectSent' => 'mail', + 'userId' => $GLOBALS['userId'], + 'note' => $args['note'] ?? null ]); if (!empty($sendedInfo['error'])) { return ['errors' => [$sendedInfo['error']]]; diff --git a/src/app/action/controllers/ExternalSignatoryBookTrait.php b/src/app/action/controllers/ExternalSignatoryBookTrait.php index 2406adc0bcb6682888d8390d0d8886eca2e38971..2ee4146b0f47ed749996ef6f28df9a627f6df366 100644 --- a/src/app/action/controllers/ExternalSignatoryBookTrait.php +++ b/src/app/action/controllers/ExternalSignatoryBookTrait.php @@ -63,6 +63,7 @@ trait ExternalSignatoryBookTrait 'objectSent' => 'attachment', 'userId' => $GLOBALS['userId'], 'steps' => $args['data']['steps'], + 'note' => $args['note'] ?? null ]); if (!empty($sendedInfo['error'])) { return ['errors' => [$sendedInfo['error']]]; diff --git a/src/app/action/controllers/PreProcessActionController.php b/src/app/action/controllers/PreProcessActionController.php index 1ebe09dad54a2689d42a30885be5d6b85e686d7a..9307722510be4a1326d110acc3477ae24f719503 100755 --- a/src/app/action/controllers/PreProcessActionController.php +++ b/src/app/action/controllers/PreProcessActionController.php @@ -419,9 +419,11 @@ class PreProcessActionController 'select' => ['destination'], 'resId' => $data['resources'][0] ]); - $destination = EntityModel::getByEntityId(['entityId' => $resDestination['destination'], 'select' => ['id']]); + if (!empty($resDestination['destination'])) { + $destination = EntityModel::getByEntityId(['entityId' => $resDestination['destination'], 'select' => ['id']]); + $additionalsInfos['destinationId'] = $destination['id']; + } - $additionalsInfos['destinationId'] = $destination['id']; } else { $additionalsInfos['destinationId'] = ''; } diff --git a/src/app/attachment/controllers/AttachmentController.php b/src/app/attachment/controllers/AttachmentController.php index adeba2945c955fc1c9399443bdcabfba15f6d4bd..5c0b571625768e038cc74e2e7a1af7027f5f52fd 100755 --- a/src/app/attachment/controllers/AttachmentController.php +++ b/src/app/attachment/controllers/AttachmentController.php @@ -882,9 +882,9 @@ class AttachmentController return ['errors' => 'Body recipientType is empty or not in [user, contact]']; } if ($body['recipientType'] == 'user') { - $recipient = UserModel::getById(['id' => $body['destUserId'], 'select' => [1], 'noDeleted' => true]); + $recipient = UserModel::getById(['id' => $body['recipientId'], 'select' => [1], 'noDeleted' => true]); } elseif ($body['recipientType'] == 'contact') { - $recipient = ContactModel::getById(['id' => $body['contactId'], 'select' => [1]]); + $recipient = ContactModel::getById(['id' => $body['recipientId'], 'select' => [1]]); } if (empty($recipient)) { return ['errors' => 'Body recipientId does not exist']; diff --git a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php index 0348537cbd81abf2b07bd9e235986e0f97b417b7..7ac85f6b20184d8a741e533a15faf54c2b8f0bf7 100755 --- a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php +++ b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php @@ -67,26 +67,27 @@ class MaarchParapheurController { $attachmentToFreeze = []; - $adrMainInfo = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resIdMaster'], 'collId' => 'letterbox_coll']); - if (empty($adrMainInfo['docserver_id'])) { - return ['error' => 'Document ' . $aArgs['resIdMaster'] . ' is not converted in pdf']; - } - $docserverMainInfo = DocserverModel::getByDocserverId(['docserverId' => $adrMainInfo['docserver_id']]); - if (empty($docserverMainInfo['path_template'])) { - return ['error' => 'Docserver does not exist ' . $adrMainInfo['docserver_id']]; - } - $arrivedMailMainfilePath = $docserverMainInfo['path_template'] . str_replace('#', '/', $adrMainInfo['path']) . $adrMainInfo['filename']; - $mainResource = ResModel::getOnView([ - 'select' => ['process_limit_date', 'status', 'category_id', 'alt_identifier', 'subject', 'priority', 'res_id', 'admission_date', 'creation_date', 'doc_date', 'initiator', 'typist', 'type_label', 'destination'], + 'select' => ['process_limit_date', 'status', 'category_id', 'alt_identifier', 'subject', 'priority', 'res_id', 'admission_date', 'creation_date', 'doc_date', 'initiator', 'typist', 'type_label', 'destination', 'filename'], 'where' => ['res_id = ?'], 'data' => [$aArgs['resIdMaster']] ]); - $recipients = ContactController::getFormattedContacts(['resId' => $mainResource[0]['res_id'], 'mode' => 'recipient']); - if (empty($mainResource)) { return ['error' => 'Mail does not exist']; } + if (!empty($mainResource[0]['filename'])) { + $adrMainInfo = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resIdMaster'], 'collId' => 'letterbox_coll']); + if (empty($adrMainInfo['docserver_id'])) { + return ['error' => 'Document ' . $aArgs['resIdMaster'] . ' is not converted in pdf']; + } + $docserverMainInfo = DocserverModel::getByDocserverId(['docserverId' => $adrMainInfo['docserver_id']]); + if (empty($docserverMainInfo['path_template'])) { + return ['error' => 'Docserver does not exist ' . $adrMainInfo['docserver_id']]; + } + $arrivedMailMainfilePath = $docserverMainInfo['path_template'] . str_replace('#', '/', $adrMainInfo['path']) . $adrMainInfo['filename']; + } + $recipients = ContactController::getFormattedContacts(['resId' => $mainResource[0]['res_id'], 'mode' => 'recipient']); + $units = []; $units[] = ['unit' => 'primaryInformations']; @@ -149,7 +150,11 @@ class MaarchParapheurController $concatPdf->setPrintHeader(false); if ($aArgs['objectSent'] == 'mail') { - foreach ([$filename, $arrivedMailMainfilePath] as $file) { + $filesToConcat = [$filename]; + if (!empty($arrivedMailMainfilePath)) { + $filesToConcat[] = $arrivedMailMainfilePath; + } + foreach ($filesToConcat as $file) { $pageCount = $concatPdf->setSourceFile($file); for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) { $pageId = $concatPdf->ImportPage($pageNo); @@ -251,17 +256,22 @@ class MaarchParapheurController } $metadata[_RECIPIENTS] = $contact; } - + $bodyData = [ - 'title' => $value['title'], - 'reference' => $value['identifier'], - 'encodedDocument' => $encodedZipDocument, - 'sender' => trim($sender['firstname'] . ' ' .$sender['lastname']), - 'deadline' => $processLimitDate, - 'attachments' => $attachmentsData, - 'workflow' => $workflow, - 'metadata' => $metadata + 'title' => $value['title'], + 'reference' => $value['identifier'], + 'encodedDocument' => $encodedZipDocument, + 'sender' => trim($sender['firstname'] . ' ' .$sender['lastname']), + 'deadline' => $processLimitDate, + 'attachments' => $attachmentsData, + 'workflow' => $workflow, + 'metadata' => $metadata ]; + if (!empty($aArgs['note'])) { + $noteCreationDate = new \DateTime(); + $noteCreationDate = $noteCreationDate->format('Y-m-d'); + $bodyData['notes'] = ['creator' => trim($sender['firstname'] . ' ' .$sender['lastname']), 'creationDate' => $noteCreationDate, 'value' => $aArgs['note']]; + } $response = CurlModel::exec([ 'url' => rtrim($aArgs['config']['data']['url'], '/') . '/rest/documents', @@ -301,6 +311,11 @@ class MaarchParapheurController 'workflow' => $workflow, 'metadata' => $metadata ]; + if (!empty($aArgs['note'])) { + $noteCreationDate = new \DateTime(); + $noteCreationDate = $noteCreationDate->format('Y-m-d'); + $bodyData['notes'] = ['creator' => trim($sender['firstname'] . ' ' .$sender['lastname']), 'creationDate' => $noteCreationDate, 'value' => $aArgs['note']]; + } $response = CurlModel::exec([ 'url' => rtrim($aArgs['config']['data']['url'], '/') . '/rest/documents', diff --git a/src/frontend/app/actions/send-external-signatory-book-action/maarch-paraph/maarch-paraph.component.ts b/src/frontend/app/actions/send-external-signatory-book-action/maarch-paraph/maarch-paraph.component.ts index 98a073e96131b1a0526b34fd02a4c59c79b75fa4..7e2a2f7aad04ce81ae7c641370e66b6a27a0a597 100644 --- a/src/frontend/app/actions/send-external-signatory-book-action/maarch-paraph/maarch-paraph.component.ts +++ b/src/frontend/app/actions/send-external-signatory-book-action/maarch-paraph/maarch-paraph.component.ts @@ -33,7 +33,7 @@ export class MaarchParaphComponent implements OnInit { constructor(public http: HttpClient, private notify: NotificationService) { } ngOnInit(): void { - if (this.additionalsInfos.destinationId !== '') { + if (typeof this.additionalsInfos.destinationId !== "undefined" && this.additionalsInfos.destinationId !== '') { setTimeout(() => { this.appVisaWorkflow.loadListModel(this.additionalsInfos.destinationId); }, 0);