diff --git a/src/Controller/Back/SignalementController.php b/src/Controller/Back/SignalementController.php index 58b0d0e40..0c138dfb2 100755 --- a/src/Controller/Back/SignalementController.php +++ b/src/Controller/Back/SignalementController.php @@ -88,7 +88,11 @@ public function viewSignalement( } } $isClosedForMe = $isClosedForMe ?? Signalement::STATUS_CLOSED === $signalement->getStatut(); - $clotureForm = $this->createForm(ClotureType::class); + $clotureForm = $this->createForm(type: ClotureType::class, options: [ + 'is_admin_territory' => $this->isGranted('ROLE_ADMIN_TERRITORY'), + 'is_accepted' => $isAccepted, + 'is_affected' => $isAffected, + ]); $clotureForm->handleRequest($request); $eventParams = []; if ($clotureForm->isSubmitted() && $clotureForm->isValid()) { diff --git a/src/Form/ClotureType.php b/src/Form/ClotureType.php index 8c0f3fcc0..5b0f9b610 100755 --- a/src/Form/ClotureType.php +++ b/src/Form/ClotureType.php @@ -13,6 +13,14 @@ class ClotureType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { + $clotureType = 'partner'; + if ($options['is_admin_territory']) { + $clotureType = 'all'; + if ($options['is_affected'] && $options['is_accepted']) { + $clotureType = 'partner'; + } + } + $builder ->add('motif', EnumType::class, [ 'class' => MotifCloture::class, @@ -31,7 +39,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'class' => 'fr-hint-text', ], ]) - ->add('type', HiddenType::class); + ->add('type', HiddenType::class, ['data' => $clotureType]); } public function configureOptions(OptionsResolver $resolver): void @@ -39,6 +47,9 @@ public function configureOptions(OptionsResolver $resolver): void $resolver->setDefaults([ 'data_class' => null, 'allow_extra_fields' => true, + 'is_admin_territory' => false, + 'is_affected' => false, + 'is_accepted' => false, 'attr' => [ 'id' => 'cloture_form', ], diff --git a/templates/_partials/_modal_cloture.html.twig b/templates/_partials/_modal_cloture.html.twig index e3f58d7e6..b52311814 100755 --- a/templates/_partials/_modal_cloture.html.twig +++ b/templates/_partials/_modal_cloture.html.twig @@ -16,6 +16,7 @@ {{ form_label(clotureForm.motif) }} {{ form_help(clotureForm.motif) }} {{ form_widget(clotureForm.motif) }} + {{ form_widget(clotureForm.type) }}

Précisez le contexte et les raisons de la clôture (10 caractères @@ -66,23 +67,30 @@ {% if is_granted('ROLE_ADMIN_TERRITORY') %}

  • {% if isAffected and isAccepted %}
  • -
  • {% endif %} {% else %}
  • -
  • {% endif %} @@ -97,4 +105,4 @@
    - \ No newline at end of file +