From a619d1a39738aae907bbddb70d3256537c355427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20BOYER?= <t.boyer@si17.lan> Date: Wed, 5 Feb 2025 12:40:27 +0100 Subject: [PATCH] =?UTF-8?q?Bouton=20g=C3=A9n=C3=A9rer=20une=20impression?= =?UTF-8?q?=20+=20Registre=20Public=20+=20Nom=20et=20Service=20Word?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout du nom des éléments dans les Word - Ajout du service dans les Word - Modification du bouton générer une impression pour ne pas apparaitre dans la liste des éléments inactifs ou archivés - Modification de l'indication du registre public dans la visualisation et les PDF générés --- .../Generator/Word/ContractorGenerator.php | 17 ++- .../Generator/Word/MesurementGenerator.php | 15 ++- .../Generator/Word/RequestGenerator.php | 15 ++- .../Generator/Word/ToolGenerator.php | 17 ++- .../Generator/Word/TreatmentGenerator.php | 108 +++++++++++------- .../Generator/Word/ViolationGenerator.php | 19 ++- templates/Registry/Request/list.html.twig | 8 +- templates/Registry/Treatment/list.html.twig | 8 +- templates/Registry/Treatment/pdf.html.twig | 22 ++-- .../Registry/Treatment/pdf_all.html.twig | 22 ++-- templates/Registry/Treatment/show.html.twig | 20 ++-- templates/Registry/Violation/list.html.twig | 8 +- 12 files changed, 181 insertions(+), 98 deletions(-) diff --git a/src/Domain/Reporting/Generator/Word/ContractorGenerator.php b/src/Domain/Reporting/Generator/Word/ContractorGenerator.php index e0545ec5e..2f7307ec6 100644 --- a/src/Domain/Reporting/Generator/Word/ContractorGenerator.php +++ b/src/Domain/Reporting/Generator/Word/ContractorGenerator.php @@ -154,6 +154,21 @@ class ContractorGenerator extends AbstractGenerator implements ImpressionGenerat $section->addTitle($contractor->getName(), 2); $generalInformationsData = [ + [ + 'Nom', + $contractor->getName(), + ], + ]; + + // Ajouter les services si le module est actif + if ($contractor->getCollectivity()->getIsServicesEnabled()) { + $generalInformationsData[] = [ + 'Service', + $contractor->getService(), + ]; + } + + $generalInformationsData = array_merge($generalInformationsData, [ [ 'Agent référent', $contractor->getReferent() ?? $this->parameterBag->get('APP_DEFAULT_REFERENT'), @@ -178,7 +193,7 @@ class ContractorGenerator extends AbstractGenerator implements ImpressionGenerat 'Autres informations', $contractor->getOtherInformations(), ], - ]; + ]); $addressData = [ [ diff --git a/src/Domain/Reporting/Generator/Word/MesurementGenerator.php b/src/Domain/Reporting/Generator/Word/MesurementGenerator.php index 231652b3b..c3f4f722e 100644 --- a/src/Domain/Reporting/Generator/Word/MesurementGenerator.php +++ b/src/Domain/Reporting/Generator/Word/MesurementGenerator.php @@ -314,6 +314,17 @@ class MesurementGenerator extends AbstractGenerator implements ImpressionGenerat 'Nom', $mesurement->getName(), ], + ]; + + // Ajouter les services si le module est actif + if ($mesurement->getCollectivity()->getIsServicesEnabled()) { + $generalInformationsData[] = [ + 'Service', + $mesurement->getService(), + ]; + } + + $generalInformationsData = array_merge($generalInformationsData, [ [ 'Description', $mesurement->getDescription() ? \preg_split('/\R/', $mesurement->getDescription()) : null, @@ -334,7 +345,7 @@ class MesurementGenerator extends AbstractGenerator implements ImpressionGenerat 'Charge', $mesurement->getCharge(), ], - ]; + ]); $applicationData = [ [ @@ -344,7 +355,7 @@ class MesurementGenerator extends AbstractGenerator implements ImpressionGenerat [ 'Échéance', MesurementStatusDictionary::STATUS_NOT_APPLICABLE !== $mesurement->getStatus() - ? ($mesurement->getPlanificationDate() ? $this->getDate($mesurement->getPlanificationDate()) : null) + ? ($mesurement->getPlanificationDate() ? $this->getDate($mesurement->getPlanificationDate(), 'd/m/Y') : null) : 'Non applicable', ], [ diff --git a/src/Domain/Reporting/Generator/Word/RequestGenerator.php b/src/Domain/Reporting/Generator/Word/RequestGenerator.php index d89b73273..fc0e0f843 100644 --- a/src/Domain/Reporting/Generator/Word/RequestGenerator.php +++ b/src/Domain/Reporting/Generator/Word/RequestGenerator.php @@ -121,7 +121,18 @@ class RequestGenerator extends AbstractGenerator implements ImpressionGeneratorI $section->addPageBreak(); } $section->addTitle($request->__toString(), 2); - $requestData = [ + + $requestData = []; + + // Ajouter les services si le module est actif + if ($request->getCollectivity()->getIsServicesEnabled()) { + $requestData[] = [ + 'Service', + $request->getService(), + ]; + } + + $requestData = array_merge($requestData, [ [ 'Objet de la demande', $request->getObject() ? RequestObjectDictionary::getObjects()[$request->getObject()] : null, @@ -150,7 +161,7 @@ class RequestGenerator extends AbstractGenerator implements ImpressionGeneratorI 'Demande légitime', $request->isLegitimateRequest() ? 'Oui' : 'Non', ], - ]; + ]); $applicant = $request->getApplicant(); $applicantData = [ diff --git a/src/Domain/Reporting/Generator/Word/ToolGenerator.php b/src/Domain/Reporting/Generator/Word/ToolGenerator.php index 4c1b2d976..2c583bf02 100644 --- a/src/Domain/Reporting/Generator/Word/ToolGenerator.php +++ b/src/Domain/Reporting/Generator/Word/ToolGenerator.php @@ -116,6 +116,21 @@ class ToolGenerator extends AbstractGenerator implements ImpressionGeneratorInte $section->addTitle($tool->getName(), 2); $generalInformationsData = [ + [ + 'Nom', + $tool->getName(), + ], + ]; + + // Ajouter les services si le module est actif + if ($tool->getCollectivity()->getIsServicesEnabled()) { + $generalInformationsData[] = [ + 'Service', + $tool->getService(), + ]; + } + + $generalInformationsData = array_merge($generalInformationsData, [ [ 'Type', ToolTypeDictionary::getTypes()[$tool->getType()], @@ -140,7 +155,7 @@ class ToolGenerator extends AbstractGenerator implements ImpressionGeneratorInte 'Pays d\'hébergement ou de stockage', $this->translator->trans($tool->getCountryType()), ], - ]; + ]); if (Tool::COUNTRY_FRANCE !== $tool->getCountryType()) { $generalInformationsData[] = [ diff --git a/src/Domain/Reporting/Generator/Word/TreatmentGenerator.php b/src/Domain/Reporting/Generator/Word/TreatmentGenerator.php index 56ca6c962..a9674b9e9 100644 --- a/src/Domain/Reporting/Generator/Word/TreatmentGenerator.php +++ b/src/Domain/Reporting/Generator/Word/TreatmentGenerator.php @@ -220,8 +220,8 @@ class TreatmentGenerator extends AbstractGenerator implements ImpressionGenerato $generalInformationsData = [ [ - 'Registre public', - $treatment->getPublic() ? 'Oui' : 'Non', + 'Nom', + $treatment->getName(), ], ]; @@ -233,14 +233,16 @@ class TreatmentGenerator extends AbstractGenerator implements ImpressionGenerato ]; } - $generalInformationsData[] = [ - 'Finalités', - $treatment->getGoal() ? \preg_split('/\R/', $treatment->getGoal()) : null, - ]; - $generalInformationsData[] = [ - 'En tant que', - !\is_null($treatment->getAuthor()) && array_key_exists($treatment->getAuthor(), TreatmentAuthorDictionary::getAuthors()) ? TreatmentAuthorDictionary::getAuthors()[$treatment->getAuthor()] : $treatment->getAuthor(), - ]; + $generalInformationsData = array_merge($generalInformationsData, [ + [ + 'Finalités', + $treatment->getGoal() ? \preg_split('/\R/', $treatment->getGoal()) : null, + ], + [ + 'En tant que', + !\is_null($treatment->getAuthor()) && array_key_exists($treatment->getAuthor(), TreatmentAuthorDictionary::getAuthors()) ? TreatmentAuthorDictionary::getAuthors()[$treatment->getAuthor()] : $treatment->getAuthor(), + ], + ]); // Ajouter les coordonnées du responsable de traitement si l'auteur est différent du Responsable de Traitement if ('processing_manager' !== $treatment->getAuthor()) { @@ -250,40 +252,49 @@ class TreatmentGenerator extends AbstractGenerator implements ImpressionGenerato ]; } - $generalInformationsData[] = [ - 'Gestionnaire', - $treatment->getManager() ?? $this->parameterBag->get('APP_DEFAULT_REFERENT'), - ]; - $generalInformationsData[] = [ - 'État', - $treatment->isActive() ? 'Actif' : 'Inactif', - ]; - $generalInformationsData[] = [ - 'Base légale', - TreatmentLegalBasisDictionary::getBasis()[$treatment->getLegalBasis()], - ]; - $generalInformationsData[] = [ - 'Justification de la base légale', - $treatment->getLegalBasisJustification() ? \preg_split('/\R/', $treatment->getLegalBasisJustification()) : null, - ]; + $generalInformationsData = array_merge($generalInformationsData, [ + [ + 'Gestionnaire', + $treatment->getManager() ?? $this->parameterBag->get('APP_DEFAULT_REFERENT'), + ], + [ + 'État', + $treatment->isActive() ? 'Actif' : 'Inactif', + ], + [ + 'Base légale', + TreatmentLegalBasisDictionary::getBasis()[$treatment->getLegalBasis()], + ], + [ + 'Justification de la base légale', + $treatment->getLegalBasisJustification() ? \preg_split('/\R/', $treatment->getLegalBasisJustification()) : null, + ], + ]); // Ajouter le consentement demandé et son format si la base légale est "consent" if ('consent' === $treatment->getLegalBasis()) { - $generalInformationsData[] = [ - 'Consentement demandé', - $treatment->getConsentRequest() ? 'Oui' : 'Non', - ]; - - $generalInformationsData[] = [ - 'Format de la demande du consentement', - $treatment->getConsentRequestFormat(), - ]; + $generalInformationsData = array_merge($generalInformationsData, [ + [ + 'Consentement demandé', + $treatment->getConsentRequest() ? 'Oui' : 'Non', + ], + [ + 'Format de la demande du consentement', + $treatment->getConsentRequestFormat(), + ], + ]); } - $generalInformationsData[] = [ - 'Observations', - $treatment->getObservation() ? \preg_split('/\R/', $treatment->getObservation()) : null, - ]; + $generalInformationsData = array_merge($generalInformationsData, [ + [ + 'Observations', + $treatment->getObservation() ? \preg_split('/\R/', $treatment->getObservation()) : null, + ], + [ + 'Registre public', + $treatment->getPublic() ? 'Oui' : 'Non', + ], + ]); $detailsData = [ [ @@ -312,10 +323,19 @@ class TreatmentGenerator extends AbstractGenerator implements ImpressionGenerato return TreatmentCollectingMethodDictionary::getMethods()[$cm]; }, $treatment->getCollectingMethod())) : '', ], - [ - 'Mentions légales apposées', - $treatment->getLegalMentions() ? 'Oui' : 'Non', - ], + ]; + + // Ajouter l'autre moyen de collecte si le champ n'est pas vide + if (!empty($treatment->getOtherCollectingMethod())) { + $detailsData[] = [ + 'Autre moyen de collecte', + $treatment->getOtherCollectingMethod(), + ]; + } + + $detailsData[] = [ + 'Mentions légales apposées', + $treatment->getLegalMentions() ? 'Oui' : 'Non', ]; // "Durée de conservation" @@ -553,7 +573,7 @@ class TreatmentGenerator extends AbstractGenerator implements ImpressionGenerato $cell->addText($item->getName()); $cell = $treatmentAnnexListTable->addCell(2000); $cell->addText($item->getManager()); - $cell = $treatmentAnnexListTable->addCell(1500); + $cell = $treatmentAnnexListTable->addCell(1500); $support = $item->isPaperProcessing() ? 'Papier, ' : ''; $support = $item->getCollectivity() && $item->getCollectivity()->isHasModuleTools() ? $item->getToolsString() : $item->getSoftware(); diff --git a/src/Domain/Reporting/Generator/Word/ViolationGenerator.php b/src/Domain/Reporting/Generator/Word/ViolationGenerator.php index d0009a673..06591a066 100644 --- a/src/Domain/Reporting/Generator/Word/ViolationGenerator.php +++ b/src/Domain/Reporting/Generator/Word/ViolationGenerator.php @@ -177,12 +177,23 @@ class ViolationGenerator extends AbstractGenerator implements ImpressionGenerato $cellDate = $this->getDate($violation->getDate(), 'd/m/Y'); - $natures = join(', ', array_map(function ($n) { return ViolationNatureDictionary::getNatures()[$n] ?? $n; }, (array) $violation->getViolationNatures())); - $generalInformationData = [ + $generalInformationsData = [ [ 'Date de la violation', $cellDate, ], + ]; + + // Ajouter les services si le module est actif + if ($violation->getCollectivity()->getIsServicesEnabled()) { + $generalInformationsData[] = [ + 'Service', + $violation->getService(), + ]; + } + + $natures = join(', ', array_map(function ($n) { return ViolationNatureDictionary::getNatures()[$n] ?? $n; }, (array) $violation->getViolationNatures())); + $generalInformationsData = array_merge($generalInformationsData, [ [ 'Violation en cours', $violation->isInProgress() ? 'Oui' : 'Non', @@ -215,7 +226,7 @@ class ViolationGenerator extends AbstractGenerator implements ImpressionGenerato 'Nombre approximatif de personnes concernées par la violation', $violation->getNbAffectedPersons(), ], - ]; + ]); $consequenceData = [ [ @@ -268,7 +279,7 @@ class ViolationGenerator extends AbstractGenerator implements ImpressionGenerato ]; $section->addTitle('Informations sur la violation', 3); - $this->addTable($section, $generalInformationData, false, self::TABLE_ORIENTATION_VERTICAL); + $this->addTable($section, $generalInformationsData, false, self::TABLE_ORIENTATION_VERTICAL); $section->addTitle('Conséquences de la violation', 3); $this->addTable($section, $consequenceData, false, self::TABLE_ORIENTATION_VERTICAL); diff --git a/templates/Registry/Request/list.html.twig b/templates/Registry/Request/list.html.twig index deea71f66..b1f8bcd1d 100644 --- a/templates/Registry/Request/list.html.twig +++ b/templates/Registry/Request/list.html.twig @@ -40,16 +40,16 @@ {{ 'registry.request.action.new'|trans }} </a> {% endif %} - <a href="{{ path('registry_request_report') }}" class="btn btn-default"> - <i aria-hidden="true" class="fa fa-clipboard-list"></i> - {{ 'global.action.report'|trans }} - </a> {% if app.request.query.get('archive') == 'true' %} <a href="{{ path('registry_request_list', {'archive' : 'false'}) }}" class="btn btn-default"> <i aria-hidden="true" class="fa fa-archive"></i> {{ 'registry.request.action.not_archived'|trans }} </a> {% else %} + <a href="{{ path('registry_request_report') }}" class="btn btn-default"> + <i aria-hidden="true" class="fa fa-clipboard-list"></i> + {{ 'global.action.report'|trans }} + </a> <a href="{{ path('registry_request_list', {'archive' : 'true'}) }}" class="btn btn-default"> <i aria-hidden="true" class="fa fa-archive"></i> {{ 'registry.request.action.archived'|trans }} diff --git a/templates/Registry/Treatment/list.html.twig b/templates/Registry/Treatment/list.html.twig index 8325de3d9..b1bcc8ce8 100644 --- a/templates/Registry/Treatment/list.html.twig +++ b/templates/Registry/Treatment/list.html.twig @@ -39,16 +39,16 @@ {{ 'registry.treatment.action.new'|trans }} </a> {% endif %} - <a href="{{ path('registry_treatment_report') }}" class="btn btn-default"> - <i aria-hidden="true" class="fa fa-clipboard-list"></i> - {{ 'global.action.report'|trans }} - </a> {% if app.request.query.get('active') == 'false' %} <a href="{{ path('registry_treatment_list', {'active' : 'true'}) }}" class="btn btn-default"> <i aria-hidden="true" class="fa fa-list"></i> {{ 'registry.treatment.action.active'|trans }} </a> {% else %} + <a href="{{ path('registry_treatment_report') }}" class="btn btn-default"> + <i aria-hidden="true" class="fa fa-clipboard-list"></i> + {{ 'global.action.report'|trans }} + </a> <a href="{{ path('registry_treatment_list', {'active' : 'false'}) }}" class="btn btn-default"> <i aria-hidden="true" class="fa fa-list"></i> {{ 'registry.treatment.action.inactive'|trans }} diff --git a/templates/Registry/Treatment/pdf.html.twig b/templates/Registry/Treatment/pdf.html.twig index 3b685ee4a..7b75994af 100644 --- a/templates/Registry/Treatment/pdf.html.twig +++ b/templates/Registry/Treatment/pdf.html.twig @@ -40,16 +40,6 @@ <div class="box-body no-padding"> <table class="table"> <tbody> - <tr> - <td><strong>{{ 'registry.treatment.label.public_registry'|trans }}</strong></td> - <td> - {% if object.public == true %} - <span class="badge bg-green">{{ 'global.label.yes'|trans }}</span> - {% else %} - <span class="badge bg-yellow">{{ 'global.label.no'|trans }}</span> - {% endif %} - </td> - </tr> <tr> <td><strong>{{ 'registry.treatment.label.name'|trans }}</strong></td> <td>{{ object.name }}</td> @@ -116,6 +106,16 @@ <td><strong>{{ 'registry.treatment.label.observation'|trans }}</strong></td> <td>{{ object.observation|nl2br }}</td> </tr> + <tr> + <td><strong>{{ 'registry.treatment.label.public_registry'|trans }}</strong></td> + <td> + {% if object.public == true %} + <span class="badge bg-green">{{ 'global.label.yes'|trans }}</span> + {% else %} + <span class="badge bg-yellow">{{ 'global.label.no'|trans }}</span> + {% endif %} + </td> + </tr> </tbody> </table> </div> @@ -472,7 +472,7 @@ </ul> </td> </tr> - {% if object.otherCollectingMethod is not null %} + {% if object.otherCollectingMethod is not null %} <tr> <td><strong>{{ 'registry.treatment.label.otherCollectingMethod'|trans }}</strong></td> <td>{{ object.otherCollectingMethod }}</td> diff --git a/templates/Registry/Treatment/pdf_all.html.twig b/templates/Registry/Treatment/pdf_all.html.twig index 7aa1a6854..1111d07e0 100644 --- a/templates/Registry/Treatment/pdf_all.html.twig +++ b/templates/Registry/Treatment/pdf_all.html.twig @@ -42,16 +42,6 @@ <div class="box-body no-padding"> <table class="table"> <tbody> - <tr> - <td><strong>{{ 'registry.treatment.label.public_registry'|trans }}</strong></td> - <td> - {% if object.public == true %} - <span class="badge bg-green">{{ 'global.label.yes'|trans }}</span> - {% else %} - <span class="badge bg-yellow">{{ 'global.label.no'|trans }}</span> - {% endif %} - </td> - </tr> <tr> <td><strong>{{ 'registry.treatment.label.name'|trans }}</strong></td> <td>{{ object.name }}</td> @@ -118,6 +108,16 @@ <td><strong>{{ 'registry.treatment.label.observation'|trans }}</strong></td> <td>{{ object.observation|nl2br }}</td> </tr> + <tr> + <td><strong>{{ 'registry.treatment.label.public_registry'|trans }}</strong></td> + <td> + {% if object.public == true %} + <span class="badge bg-green">{{ 'global.label.yes'|trans }}</span> + {% else %} + <span class="badge bg-yellow">{{ 'global.label.no'|trans }}</span> + {% endif %} + </td> + </tr> </tbody> </table> </div> @@ -474,7 +474,7 @@ </ul> </td> </tr> - {% if object.otherCollectingMethod is not null %} + {% if object.otherCollectingMethod is not null %} <tr> <td><strong>{{ 'registry.treatment.label.otherCollectingMethod'|trans }}</strong></td> <td>{{ object.otherCollectingMethod }}</td> diff --git a/templates/Registry/Treatment/show.html.twig b/templates/Registry/Treatment/show.html.twig index 65c09ada4..4034bf72c 100644 --- a/templates/Registry/Treatment/show.html.twig +++ b/templates/Registry/Treatment/show.html.twig @@ -78,16 +78,6 @@ <div class="box-body no-padding"> <table role="presentation" class="table"> <tbody> - <tr> - <td><strong>{{ 'registry.treatment.label.public_registry'|trans }}</strong></td> - <td> - {% if object.public == true %} - <span class="badge bg-green">{{ 'global.label.yes'|trans }}</span> - {% else %} - <span class="badge bg-yellow">{{ 'global.label.no'|trans }}</span> - {% endif %} - </td> - </tr> <tr> <td><strong>{{ 'registry.treatment.label.name'|trans }}</strong></td> <td>{{ object.name }}</td> @@ -154,6 +144,16 @@ <td><strong>{{ 'registry.treatment.label.observation'|trans }}</strong></td> <td>{{ object.observation|nl2br }}</td> </tr> + <tr> + <td><strong>{{ 'registry.treatment.label.public_registry'|trans }}</strong></td> + <td> + {% if object.public == true %} + <span class="badge bg-green">{{ 'global.label.yes'|trans }}</span> + {% else %} + <span class="badge bg-yellow">{{ 'global.label.no'|trans }}</span> + {% endif %} + </td> + </tr> </tbody> </table> </div> diff --git a/templates/Registry/Violation/list.html.twig b/templates/Registry/Violation/list.html.twig index 4de2d4c09..56326f9bb 100644 --- a/templates/Registry/Violation/list.html.twig +++ b/templates/Registry/Violation/list.html.twig @@ -40,16 +40,16 @@ {{ 'registry.violation.action.new'|trans }} </a> {% endif %} - <a href="{{ path('registry_violation_report') }}" class="btn btn-default"> - <i aria-hidden="true" class="fa fa-clipboard-list"></i> - {{ 'global.action.report'|trans }} - </a> {% if app.request.query.get('archive') == 'true' %} <a href="{{ path('registry_violation_list', {'archive' : 'false'}) }}" class="btn btn-default"> <i aria-hidden="true" class="fa fa-archive"></i> {{ 'registry.violation.action.not_archived'|trans }} </a> {% else %} + <a href="{{ path('registry_violation_report') }}" class="btn btn-default"> + <i aria-hidden="true" class="fa fa-clipboard-list"></i> + {{ 'global.action.report'|trans }} + </a> <a href="{{ path('registry_violation_list', {'archive' : 'true'}) }}" class="btn btn-default"> <i aria-hidden="true" class="fa fa-archive"></i> {{ 'registry.violation.action.archived'|trans }} -- GitLab