diff --git a/src/app/resource/controllers/ResourceDataExportController.php b/src/app/resource/controllers/ResourceDataExportController.php index e61513976c51fe843d83963d30e35ee299324ae8..2839fdb9ac7451e0da2edc205dc57e29a28b13c0 100644 --- a/src/app/resource/controllers/ResourceDataExportController.php +++ b/src/app/resource/controllers/ResourceDataExportController.php @@ -30,6 +30,7 @@ use Slim\Http\Request; use Slim\Http\Response; use SrcCore\models\CoreConfigModel; use SrcCore\models\ValidatorModel; +use Status\models\StatusModel; use User\models\UserModel; class ResourceDataExportController @@ -70,7 +71,7 @@ class ResourceDataExportController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } $attachments = AttachmentModel::get([ - 'select' => ['res_id', 'docserver_id', 'res_id_master'], + 'select' => ['*'], 'where' => ['res_id in (?)', 'status not in (?)'], 'data' => [$queryParams['attachments'], ['DEL']], ]); @@ -84,6 +85,8 @@ class ResourceDataExportController return $response->withStatus(400)->withJson(['errors' => 'Attachment not linked to resource']); } + $documentPaths[] = ResourceDataExportController::getAttachmentSeparator(['attachment' => $attachment]); + $path = ResourceDataExportController::getDocumentFilePath(['document' => $attachment, 'collId' => 'attachments_coll']); if (!empty($path['errors'])) { @@ -131,8 +134,7 @@ class ResourceDataExportController return $response->withStatus(400)->withJson(['errors' => 'Acknowledgement Receipt not linked to resource']); } - $separatorPath = ResourceDataExportController::getAcknowledgementReceiptSeparator(['acknowledgementReceipt' => $acknowledgementReceipt]); - $documentPaths[] = $separatorPath; + $documentPaths[] = ResourceDataExportController::getAcknowledgementReceiptSeparator(['acknowledgementReceipt' => $acknowledgementReceipt]); $path = ResourceDataExportController::getDocumentFilePath(['document' => $acknowledgementReceipt]); @@ -281,7 +283,7 @@ class ResourceDataExportController } $tmpDir = CoreConfigModel::getTmpPath(); - $filePathOnTmp = $tmpDir . '/' . 'listNotes_' . $GLOBALS['id'] . '.pdf'; + $filePathOnTmp = $tmpDir . 'listNotes_' . $GLOBALS['id'] . '.pdf'; $pdf->Output($filePathOnTmp, 'F'); return $filePathOnTmp; @@ -340,7 +342,7 @@ class ResourceDataExportController $tmpDir = CoreConfigModel::getTmpPath(); - $filePathOnTmp = $tmpDir . '/' . 'convertedAr_' . $acknowledgementReceipt['id'] . '_SEPARATOR_' . $GLOBALS['id'] . '.pdf'; + $filePathOnTmp = $tmpDir . 'convertedAr_' . $acknowledgementReceipt['id'] . '_SEPARATOR_' . $GLOBALS['id'] . '.pdf'; $pdf->Output($filePathOnTmp, 'F'); return $filePathOnTmp; @@ -360,7 +362,79 @@ class ResourceDataExportController $pdf->writeHTML($contentHtml); $tmpDir = CoreConfigModel::getTmpPath(); - $filePathOnTmp = $tmpDir . '/' . 'convertedAr_' . $acknowledgementReceipt['id'] . '_' . $GLOBALS['id'] . '.pdf'; + $filePathOnTmp = $tmpDir . 'convertedAr_' . $acknowledgementReceipt['id'] . '_' . $GLOBALS['id'] . '.pdf'; + $pdf->Output($filePathOnTmp, 'F'); + + return $filePathOnTmp; + } + + private static function getAttachmentSeparator(array $args) + { + $attachment = $args['attachment']; + + if ($attachment['recipient_type'] == 'user') { + $displayContact = UserModel::getLabelledUserById(['id' => $attachment['recipient_id']]); + } else if ($attachment['recipient_type'] == 'contact') { + $contact = ContactModel::getById([ + 'select' => ['*'], + 'id' => $attachment['recipient_id'] + ]); + $displayContact = ContactController::getFormattedContactWithAddress([ + 'contact' => $contact + ]); + $displayContact = $displayContact['contact']['otherInfo']; + } + + $creator = UserModel::getByLogin(['login' => $attachment['typist']]); + + $status = StatusModel::getById(['id' => $attachment['status'], 'select' => ['label_status']]); + $status = $status['label_status']; + + $attachmentTypes = AttachmentModel::getAttachmentsTypesByXML(); + $attachmentType = $attachmentTypes[$attachment['attachment_type']]['label']; + + $pdf = new Fpdi('P', 'pt'); + $pdf->setPrintHeader(false); + $pdf->AddPage(); + + $dimensions = $pdf->getPageDimensions(); + $widthNoMargins = $dimensions['w'] - $dimensions['rm'] - $dimensions['lm']; + $width = $widthNoMargins / 2; + + $pdf->SetFont('', 'B', 12); + $pdf->Cell($width, 15, _ATTACHMENT, 0, 0, 'L', false); + $pdf->Cell($width, 15, $attachment['identifier'], 0, 1, 'C', false); + + $pdf->SetY($pdf->GetY() + 40); + $pdf->SetFont('', '', 10); + + $pdf->MultiCell($width, 30, '<b>' . _CHRONO_NUMBER . '</b>', 1, 'L', false, 0, '', '', true, 0, true); + $pdf->MultiCell($width, 30, $attachment['identifier'] , 1, 'L', false, 1, '', '', true, 0, true); + + $pdf->MultiCell($width, 30, '<b>' . _SUBJECT . '</b>', 1, 'L', false, 0, '', '', true, 0, true); + $pdf->MultiCell($width, 30, $attachment['title'] . ' ' . $creator['lastname'] , 1, 'L', false, 1, '', '', true, 0, true); + + $pdf->MultiCell($width, 30, '<b>' . _CREATED_BY . '</b>', 1, 'L', false, 0, '', '', true, 0, true); + $pdf->MultiCell($width, 30, $creator['firstname'] . ' ' . $creator['lastname'] , 1, 'L', false, 1, '', '', true, 0, true); + + $pdf->MultiCell($width, 30, '<b>' . _CREATED . '</b>', 1, 'L', false, 0, '', '', true, 0, true); + $pdf->MultiCell($width, 30, $attachment['creation_date'] , 1, 'L', false, 1, '', '', true, 0, true); + + $pdf->MultiCell($width, 30, '<b>' . _FORMAT . '</b>', 1, 'L', false, 0, '', '', true, 0, true); + $pdf->MultiCell($width, 30, $attachment['format'] , 1, 'L', false, 1, '', '', true, 0, true); + + $pdf->MultiCell($width, 30, '<b>' . _STATUS . '</b>', 1, 'L', false, 0, '', '', true, 0, true); + $pdf->MultiCell($width, 30, $status , 1, 'L', false, 1, '', '', true, 0, true); + + $pdf->MultiCell($width, 30, '<b>' . _DOCTYPE . '</b>', 1, 'L', false, 0, '', '', true, 0, true); + $pdf->MultiCell($width, 30, $attachmentType , 1, 'L', false, 1, '', '', true, 0, true); + + $pdf->MultiCell($width, 30, '<b>' . _CONTACT . '</b>', 1, 'L', false, 0, '', '', true, 0, true); + $pdf->MultiCell($width, 30, $displayContact , 1, 'L', false, 1, '', '', true, 0, true); + + + $tmpDir = CoreConfigModel::getTmpPath(); + $filePathOnTmp = $tmpDir . 'attachment_' . $attachment['res_id'] . '_SEPARATOR_' . $GLOBALS['id'] . '.pdf'; $pdf->Output($filePathOnTmp, 'F'); return $filePathOnTmp; diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php index 1b9ee95d940896da18551fdf00eade644d724814..de124757679307ebf50d37bb4e8b297014a3734f 100755 --- a/src/core/lang/lang-en.php +++ b/src/core/lang/lang-en.php @@ -455,4 +455,5 @@ define("_CREATED_BY", "Created by"); define("_SENT_DATE", "Sent "); define("_SENT_TO", "Sent to"); define("_FORMAT", "Format"); +define("_SUBJECT", "Subject"); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index 70c69980f69ca5c484076ac4aa99572b13826ba5..93aea8fdeb8c227cd5571b3036993d89989c1f77 100755 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -454,3 +454,5 @@ define("_CREATED_BY", "Créer par"); define("_SENT_DATE", "Envoyé le"); define("_SENT_TO", "Envoyé à "); define("_FORMAT", "Format"); +define("_SUBJECT", "Objet"); +define("_CONTACT", "Contact"); diff --git a/src/core/lang/lang-nl.php b/src/core/lang/lang-nl.php index 8cf505a387f6d6ade7b9d1c35971ba7c6844a75b..6f385c2756650cb67de2b9927a1f90d0a5a202cb 100755 --- a/src/core/lang/lang-nl.php +++ b/src/core/lang/lang-nl.php @@ -460,3 +460,4 @@ define("_CREATED_BY", "Created by"); //TO TRANSLATE define("_SENT_DATE", "Sent "); //TO TRANSLATE define("_SENT_TO", "Sent to"); //TO TRANSLATE define("_FORMAT", "Format"); //TO TRANSLATE +define("_SUBJECT", "Subject"); //TO TRANSLATE diff --git a/src/frontend/app/list/filters/filters-tool.component.scss b/src/frontend/app/list/filters/filters-tool.component.scss index d0daaf9769c14c781bb064109f2c397dce82955c..1f88c136196e6fe7fe85016221835d270886e370 100644 --- a/src/frontend/app/list/filters/filters-tool.component.scss +++ b/src/frontend/app/list/filters/filters-tool.component.scss @@ -1,5 +1,3 @@ -@import '../../../css/vars.scss'; - .filtersContent { display: flex;