diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index cc4e36e..12bdbab 100755 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -349,23 +349,32 @@ public function productVersionCreation(Request $request): Response #[Route('admin/archive/{entityType}/{id}', name: 'archive_entity')] public function archiveEntity(Request $request, string $entityType, int $id): Response { - $originUrl = $request->headers->get('referer'); - $user = $this->getUser()->getUsername(); - $commentary = $request->request->get('archivingCommentary'); + if ($this->getUser() !== null && $this->authChecker->isGranted('ROLE_ADMIN') == false) { + $this->addFlash('danger', 'Vous n\'avez pas les droits pour effectuer cette action'); + return $this->redirectToRoute('app_base'); + } else { - $this->logger->info($user . ' archived entity: ' . $entityType . ' ' . $id . ' ' . 'commentaire: ' . $commentary . ' full request: ' . json_encode($request->getContent())); + $originUrl = $request->headers->get('referer'); + $user = $this->getUser()->getUsername(); + $commentary = $request->request->get('archivingCommentary'); - $result = $this->entityDeletionService->archivedEntity($entityType, $id, $commentary, $user); + if ($entityType == "efnc" && $commentary == null) { + $this->addFlash('danger', 'Un commentaire est requis pour archiver une EFNC'); + return $this->redirect($originUrl); + } - if ($result == false) { - $this->addFlash('danger', 'L\'élément n\'a pas pu être archivé'); - return $this->redirect($originUrl); - } else { - $this->addFlash('success', 'L\'élément a bien été archivé'); - if ($entityType == "efnc") { - return $this->redirectToRoute('app_base', []); - } else { + $result = $this->entityDeletionService->archivedEntity($entityType, $id, $commentary, $user); + + if ($result == false) { + $this->addFlash('danger', 'L\'élément n\'a pas pu être archivé'); return $this->redirect($originUrl); + } else { + $this->addFlash('success', 'L\'élément a bien été archivé'); + if ($entityType == "efnc") { + return $this->redirectToRoute('app_base', []); + } else { + return $this->redirect($originUrl); + } } } } diff --git a/src/Controller/EFNCController.php b/src/Controller/EFNCController.php index 51f7d77..7b456fb 100755 --- a/src/Controller/EFNCController.php +++ b/src/Controller/EFNCController.php @@ -27,8 +27,9 @@ public function formCreation(Request $request): Response { $efnc = new EFNC(); $imcome = new ImmediateConservatoryMeasures(); - $riskWeighting = new RiskWeighting(); $product = new Product(); + $riskWeighting = new RiskWeighting(); + $efnc->getImmediateConservatoryMeasures()->add($imcome); $efnc->getProduct($product); $efnc->getRiskWeighting($riskWeighting); diff --git a/templates/services/efnc/creation/form_creation.html.twig b/templates/services/efnc/creation/form_creation.html.twig index 6147262..c78ae38 100755 --- a/templates/services/efnc/creation/form_creation.html.twig +++ b/templates/services/efnc/creation/form_creation.html.twig @@ -5,21 +5,30 @@ {% block body %} -

- Création de la Fiche de Non-Conformité : +

+ + Création de la Fiche de Non-Conformité : +

-
-
-
+
+
+
{{ form_start(form1, { attr: { id: 'formCreationForm', method: 'POST', enctype: 'multipart/form-data' }, action: path('app_form_creation') }) }} -
+

- Enregistrement de la Non-Conformité: + + Enregistrement de la Non-Conformité: +

{% set fields = [ 'Creator', 'DetectionDate', 'DetectionTime', 'Team','UAP', @@ -30,55 +39,134 @@ {{ form_row(form1[field]) }} {% endfor %}

- Description du Probléme : + + Description du Probléme : +

{% set problemDetails = ['AnomalyType', 'Quantity', 'QuantityToBlock', 'DetailedDescription'] %} {% for detail in problemDetails %} {{ form_row(form1[detail]) }} {% endfor %} - -
- - -
+ - -
- - -
+
+ + +
+
+ +
+ + +

- Mesures Conservatoire Immediates: + + Mesures Conservatoire Immediates: +

-
+
{% for imcomeFormEntry in form1.immediateConservatoryMeasures %} -
- {{ form_widget(imcomeFormEntry, {'attr': {'class': 'row'}}) }} +
+ {{ form_widget(imcomeFormEntry, {'attr': {'class': 'row'}} + ) }}
{% endfor %}
- -
- + +
+
- diff --git a/templates/services/efnc/modification/form_modification.html.twig b/templates/services/efnc/modification/form_modification.html.twig index 22274f5..aa27e9d 100755 --- a/templates/services/efnc/modification/form_modification.html.twig +++ b/templates/services/efnc/modification/form_modification.html.twig @@ -190,74 +190,77 @@ {% endif %}
{{ form_end(form1) }} - {% if EFNC.archived is null and EFNC.status is null %} + {% if is_granted('ROLE_ADMIN') %} -
+ {% 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 + + {% elseif EFNC.archived is same as(true) and EFNC.status is null %} +
+ Archivage effectué par - {{ EFNC.Archiver|capitalize|split('.')|first }} - {{ EFNC.Archiver|upper|split('.')|last }} + {{ EFNC.Archiver|capitalize|split('.')|first }} + {{ EFNC.Archiver|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 + avec le commentaire suivant : + {{ EFNC.archivingCommentary }} +
+ {% elseif EFNC.archived is same as(true) and EFNC.status is not null %} +
+ Cloture effectué par - {{ EFNC.Closer|capitalize|split('.')|first }} - {{ EFNC.Closer|upper|split('.')|last }} -
+ {{ EFNC.Closer|capitalize|split('.')|first }} + {{ EFNC.Closer|upper|split('.')|last }} +
+ {% endif %} {% endif %}