From 2dd04ad57c8129c4fb23114fade5f041b5eb2ac8 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Thu, 12 Dec 2019 11:32:01 +0100 Subject: [PATCH] FEAT #12510 TIME 0:30 send to maarch parapheur with new contact --- .../models/AttachmentModelAbstract.php | 39 ------------------- .../contact/controllers/ContactController.php | 4 +- .../controllers/MaarchParapheurController.php | 26 +++++++------ 3 files changed, 16 insertions(+), 53 deletions(-) diff --git a/src/app/attachment/models/AttachmentModelAbstract.php b/src/app/attachment/models/AttachmentModelAbstract.php index c81333b2201..a2550dfd52a 100755 --- a/src/app/attachment/models/AttachmentModelAbstract.php +++ b/src/app/attachment/models/AttachmentModelAbstract.php @@ -59,45 +59,6 @@ abstract class AttachmentModelAbstract return $attachment[0]; } - public static function getAttachmentToSend(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['ids']); - ValidatorModel::arrayType($aArgs, ['select', 'orderBy', 'ids']); - - $aAttachments = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['max(relation) as relation', 'res_id_master', 'title', 'res_id', 'identifier', 'dest_address_id'] : $aArgs['select'], - 'table' => ['res_attachments'], - 'where' => ['res_id_master in (?)', 'status not in (?)', 'attachment_type not in (?)', 'in_send_attach = TRUE'], - 'data' => [$aArgs['ids'], ['OBS', 'DEL', 'TMP', 'FRZ'], 'print_folder'], - 'groupBy' => ['res_id_master', 'title', 'res_id', 'identifier', 'dest_address_id'], - 'order_by' => empty($aArgs['orderBy']) ? [] : $aArgs['orderBy'] - ]); - - return $aAttachments; - } - - public static function getListByResIdMaster(array $aArgs) - { - ValidatorModel::notEmpty($aArgs, ['resId', 'login']); - ValidatorModel::intVal($aArgs, ['resId', 'limit']); - ValidatorModel::stringType($aArgs, ['login']); - ValidatorModel::arrayType($aArgs, ['excludeAttachmentTypes']); - - $aAttachments = DatabaseModel::select([ - 'select' => [ - 'res_id', 'identifier', 'title', 'creation_date', 'modification_date', 'validation_date as return_date', 'effective_date as real_return_date', - 'relation', 'status', 'attachment_type', 'in_signature_book', 'in_send_attach' - ], - 'table' => ['res_attachments'], - 'where' => ['res_id_master = ?', 'res_attachments.status not in (?)', 'attachment_type not in (?)', '((res_attachments.status = ? AND typist = ?) OR res_attachments.status != ?)'], - 'data' => [$aArgs['resId'], ['OBS', 'DEL'], $aArgs['excludeAttachmentTypes'], 'TMP', $aArgs['login'], 'TMP'], - 'order_by' => empty($aArgs['orderBy']) ? [] : $aArgs['orderBy'], - 'limit' => empty($aArgs['limit']) ? null : $aArgs['limit'] - ]); - - return $aAttachments; - } - public static function create(array $args) { ValidatorModel::notEmpty($args, ['format', 'typist', 'creation_date', 'docserver_id', 'path', 'filename', 'fingerprint', 'filesize', 'status', 'relation']); diff --git a/src/app/contact/controllers/ContactController.php b/src/app/contact/controllers/ContactController.php index 709d46b60f9..31e67f04095 100755 --- a/src/app/contact/controllers/ContactController.php +++ b/src/app/contact/controllers/ContactController.php @@ -696,9 +696,7 @@ class ContactController $contactToDisplay = ContactController::getFormattedContactWithAddress(['contact' => $contactRaw]); } - $contactToDisplay = $contactToDisplay['contact']['otherInfo']; - - $contact = $contactToDisplay; + $contact = $contactToDisplay['contact']['otherInfo']; } elseif ($resourceContact['type'] == 'user') { $contact = UserModel::getLabelledUserById(['id' => $resourceContact['item_id']]); } elseif ($resourceContact['type'] == 'entity') { diff --git a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php index b5e2d26bcc6..1a02e1c8b77 100755 --- a/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php +++ b/src/app/external/externalSignatoryBook/controllers/MaarchParapheurController.php @@ -15,6 +15,7 @@ namespace ExternalSignatoryBook\controllers; use Attachment\models\AttachmentModel; +use Contact\controllers\ContactController; use Convert\controllers\ConvertPdfController; use Docserver\models\DocserverModel; use Entity\models\EntityModel; @@ -76,10 +77,11 @@ class MaarchParapheurController $arrivedMailMainfilePath = $docserverMainInfo['path_template'] . str_replace('#', '/', $adrMainInfo['path']) . $adrMainInfo['filename']; $mainResource = ResModel::getOnView([ - 'select' => ['process_limit_date', 'status', 'category_id', 'alt_identifier', 'subject', 'priority', 'contact_firstname', 'contact_lastname', 'contact_society', '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'], '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']; @@ -131,12 +133,6 @@ class MaarchParapheurController 'data' => ['entity_id', $tmpIds], 'orderBy' => ['listinstance_id'] ]); - } elseif ($unit['unit'] == 'senderRecipientInformations') { - $data['senderRecipient'] = ResModel::get([ - 'select' => ['category_id', 'address_id', 'exp_user_id', 'dest_user_id', 'is_multicontacts', 'res_id'], - 'where' => ['res_id in (?)'], - 'data' => [$tmpIds] - ]); } } @@ -246,8 +242,12 @@ class MaarchParapheurController if (!empty($senderPrimaryEntity['entity_label'])) { $metadata[_INITIATOR_ENTITY] = $senderPrimaryEntity['entity_label']; } - $contact = trim($mainResource[0]['contact_firstname'] . ' ' . $mainResource[0]['contact_lastname'] . ' ' . $mainResource[0]['contact_society']); - if (!empty($contact)) { + if (!empty($recipients)) { + if (count($recipients) > 1) { + $contact = count($recipients) . ' ' . _RECIPIENTS; + } else { + $contact = $contact[0]; + } $metadata[_RECIPIENTS] = $contact; } @@ -281,8 +281,12 @@ class MaarchParapheurController if (!empty($senderPrimaryEntity['entity_label'])) { $metadata[_INITIATOR_ENTITY] = $senderPrimaryEntity['entity_label']; } - $contact = trim($mainResource[0]['contact_firstname'] . ' ' . $mainResource[0]['contact_lastname'] . ' ' . $mainResource[0]['contact_society']); - if (!empty($contact)) { + if (!empty($recipients)) { + if (count($recipients) > 1) { + $contact = count($recipients) . ' ' . _RECIPIENTS; + } else { + $contact = $contact[0]; + } $metadata[_RECIPIENTS] = $contact; } -- GitLab