From 5ef7eb6200b8d54afb3b8188e547f9f4ac8307b9 Mon Sep 17 00:00:00 2001 From: SFDKHISSI Date: Fri, 15 Mar 2024 18:01:18 +0100 Subject: [PATCH 1/3] forgot to change the lastmodifier logic for the modification logic and the closure logic --- src/Controller/EFNCController.php | 2 +- src/Service/FormModificationService.php | 3 ++- .../modification/form_modification.html.twig | 22 ++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Controller/EFNCController.php b/src/Controller/EFNCController.php index df53829..0a2b37f 100755 --- a/src/Controller/EFNCController.php +++ b/src/Controller/EFNCController.php @@ -93,7 +93,7 @@ public function formModificationDisplay(int $efncID, Request $request): Response } else if ($request->getMethod() == 'POST') { if ($this->getUser() !== null) { if ($this->authChecker->isGranted('ROLE_ADMIN')) { - $user = $this->getUser(); + $user = $this->getUser()->getUsername(); $form1->handleRequest($request); if ($form1->isValid() && $form1->isSubmitted()) { $result = $this->formModificationService->modifyNCForm( diff --git a/src/Service/FormModificationService.php b/src/Service/FormModificationService.php index 227cfb3..27279cb 100755 --- a/src/Service/FormModificationService.php +++ b/src/Service/FormModificationService.php @@ -50,7 +50,8 @@ public function __construct( public function modifyNCForm( EFNC $efnc, Request $request, - FormInterface $form1 + FormInterface $form1, + string $user = null ) { $now = new \DateTime(); diff --git a/templates/services/efnc/modification/form_modification.html.twig b/templates/services/efnc/modification/form_modification.html.twig index af65351..a24fe9c 100755 --- a/templates/services/efnc/modification/form_modification.html.twig +++ b/templates/services/efnc/modification/form_modification.html.twig @@ -171,18 +171,20 @@ class="d-grid gap-2 d-md-flex justify-content-md-center mt-5 text-white"> Derniere modification effectué par - {{ EFNC.LastModifier.username|capitalize|split('.')|first }} - {{ EFNC.LastModifier.username|upper|split('.')|last }} + {{ EFNC.LastModifier|capitalize|split('.')|first }} + {{ EFNC.LastModifier|upper|split('.')|last }} {% endif %} -
- -
+ {% if EFNC.archived is null and EFNC.status is null %} +
+ +
+ {% endif %} {% endif %} From 832bde419b26bf9500e3e77d0639149ce3e63dcb Mon Sep 17 00:00:00 2001 From: SFDKHISSI Date: Fri, 15 Mar 2024 18:01:38 +0100 Subject: [PATCH 2/3] still need to review different view --- src/Controller/EFNCController.php | 3 ++- src/Service/EntityDeletionService.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controller/EFNCController.php b/src/Controller/EFNCController.php index 0a2b37f..51f7d77 100755 --- a/src/Controller/EFNCController.php +++ b/src/Controller/EFNCController.php @@ -151,7 +151,8 @@ public function closeEntity(Request $request, string $entityType, int $id): Resp if ($this->getUser() !== null) { if ($this->authChecker->isGranted('ROLE_MASTER_ADMIN')) { - $result = $this->entityDeletionService->closeEntity($entityType, $id); // Implement this method in your service + $user = $this->getUser()->getUsername(); + $result = $this->entityDeletionService->closeEntity($entityType, $id, $commentary = null, $user); // Implement this method in your service if ($result == false) { $this->addFlash('danger', 'L\'élément n\'a pas pu être clôturé'); return $this->redirectToRoute('app_base', []); diff --git a/src/Service/EntityDeletionService.php b/src/Service/EntityDeletionService.php index 6c4bb1f..6c5bcd3 100755 --- a/src/Service/EntityDeletionService.php +++ b/src/Service/EntityDeletionService.php @@ -533,7 +533,7 @@ public function unarchiveEntity(string $entityType, int $id): bool } - public function closeEntity(string $entityType, int $id): bool + public function closeEntity(string $entityType, int $id, string $commentary = null, string $user = null): bool { $repository = null; switch ($entityType) { @@ -553,6 +553,7 @@ public function closeEntity(string $entityType, int $id): bool } if ($entityType === 'efnc') { + $entity->setLastModifier($user); $entity->setArchived(true); $entity->setStatus(true); } From 274ae0c0384f8b8ea63d6b95f134c87406854ed2 Mon Sep 17 00:00:00 2001 From: SFDKHISSI Date: Tue, 19 Mar 2024 09:12:30 +0100 Subject: [PATCH 3/3] has been corrected, i need to differentiate between archiver, midifier and closer --- .../modification/form_modification.html.twig | 107 +++++++++++------- 1 file changed, 65 insertions(+), 42 deletions(-) diff --git a/templates/services/efnc/modification/form_modification.html.twig b/templates/services/efnc/modification/form_modification.html.twig index a24fe9c..1d6303a 100755 --- a/templates/services/efnc/modification/form_modification.html.twig +++ b/templates/services/efnc/modification/form_modification.html.twig @@ -177,10 +177,10 @@ {% endif %} {% if EFNC.archived is null and EFNC.status is null %}
+ class="d-grid gap-2 d-md-flex justify-content-md-center mt-3 textwhite">
@@ -190,53 +190,76 @@ {% endif %} {{ form_end(form1) }} -
+ {% if EFNC.archived is null and EFNC.status is null %} + + -
+ class="container mt-2 mb-2" + data-controller="archiving-commentary">
- - + class="row justify-content-md-center"> +
+ + +
-
-
- - {% if is_granted('ROLE_MASTER_ADMIN') %} - + + {% if is_granted('ROLE_MASTER_ADMIN') %} + + Cloturer + + {% endif %} +
+
+ {% elseif EFNC.archived is same as(true) and EFNC.status is null %} +
+ Archivage effectué par + + {{ EFNC.LastModifier|capitalize|split('.')|first }} + {{ EFNC.LastModifier|upper|split('.')|last }} + + avec le commentaire suivant : + {{ EFNC.archivingCommentary }}
- + {% elseif EFNC.archived is same as(true) and EFNC.status is not null %} +
+ Cloture effectué par + + {{ EFNC.LastModifier|capitalize|split('.')|first }} + {{ EFNC.LastModifier|upper|split('.')|last }} +
+ {% endif %} + {% endblock %}