From 13549332ead898ad14719b6bdee813f65ab3d33d Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Fri, 9 Oct 2020 09:40:35 +0200 Subject: [PATCH] FEAT #15047 TIME 0:20 Begin initSeda --- .../exportSeda/controllers/SedaController.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/app/external/exportSeda/controllers/SedaController.php b/src/app/external/exportSeda/controllers/SedaController.php index 7dfd2fbd854..6941c7e5090 100755 --- a/src/app/external/exportSeda/controllers/SedaController.php +++ b/src/app/external/exportSeda/controllers/SedaController.php @@ -33,7 +33,7 @@ class SedaController return $response->withStatus(400)->withJson(['errors' => 'Route resId is not an integer']); } - $resource = ResModel::getById(['resId' => $aArgs['resId'], 'select' => ['destination', 'type_id', 'subject']]); + $resource = ResModel::getById(['resId' => $aArgs['resId'], 'select' => ['destination', 'type_id', 'subject', 'linked_resources']]); if (empty($resource)) { return $response->withStatus(400)->withJson(['errors' => 'resource does not exists']); } elseif (empty($resource['destination'])) { @@ -98,6 +98,40 @@ class SedaController 'type' => 'email' ]; } + + $return['archiveUnit'][] = [ + 'id' => 'summarySheet_' . $aArgs['resId'], + 'label' => 'Fiche de liaison', + 'type' => 'summarySheet' + ]; + + $attachments = AttachmentModel::get([ + 'select' => ['res_id', 'title'], + 'where' => ['res_id_master = ?', 'status not in (?)', 'attachment_type not in (?)'], + 'data' => [$aArgs['resId'], ['DEL', 'OBS', 'TMP'], ['signed_response']], + 'orderBy' => ['modification_date DESC'] + ]); + foreach ($attachments as $attachment) { + $return['archiveUnit'][] = [ + 'id' => 'attachment_' . $attachment['res_id'], + 'label' => $attachment['title'], + 'type' => 'attachment' + ]; + } + + $linkedResourcesIds = json_decode($resource['linked_resources'], true); + + $linkedResources = []; + if (!empty($linkedResourcesIds)) { + $linkedResources = ResModel::get([ + 'select' => ['res_id', 'alt_identifier'], + 'where' => ['res_id in (?)'], + 'data' => [$linkedResourcesIds] + ]); + $return['additionalData']['linkedResources'] = array_column($linkedResources, 'alt_identifier'); + } + + // TODO Folders return $response->withJson($return); } -- GitLab