diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index ae7c00ce1..4e5fdbe3e 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -282,51 +282,26 @@ class AccompanyingCourseController extends Controller */ public function reOpenAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response { - //$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse); + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse); - // $form = $this->createForm(AccompanyingCourseType::class, $accompanyingCourse, [ - // 'validation_groups' => [AccompanyingPeriod::STEP_CLOSED], - // ]); + if (null === $accompanyingCourse) { + throw $this->createNotFoundException('period not found'); + } $form = $this->createFormBuilder([])->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); - + $accompanyingCourse->reOpen(); - $em->flush(); + $this->getDoctrine()->getManager()->flush(); return $this->redirectToRoute('chill_person_accompanying_course_index', [ 'accompanying_period_id' => $accompanyingCourse->getId(), ]); - - //TODO: delete motif de cloture and date de cloture (NULL) - //TODO: which redirection? - //TODO workflow stuff? - //TODO: error handling - // $workflow = $this->registry->get($accompanyingCourse); - - // if ($workflow->can($accompanyingCourse, 'close')) { - // $workflow->apply($accompanyingCourse, 'close'); - - // $em->flush(); - - // return $this->redirectToRoute('chill_person_accompanying_course_index', [ - // 'accompanying_period_id' => $accompanyingCourse->getId(), - // ]); - // } - // /** @var ConstraintViolationListInterface $errors */ - // $errors = $this->validator->validate($accompanyingCourse, null, [$accompanyingCourse::STEP_CLOSED]); - // $this->addFlash('error', $this->translator->trans('It is not possible to close this course')); - - // foreach ($errors as $e) { - // /** @var ConstraintViolationInterface $e */ - // $this->addFlash('error', $e->getMessage()); - // } } - return $this->render('@ChillPerson/AccompanyingCourse/reopen.html.twig', [ + return $this->render('@ChillPerson/AccompanyingCourse/re_open.html.twig', [ 'form' => $form->createView(), 'accompanyingCourse' => $accompanyingCourse, ]); diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 3b8cca55b..0efbf9ac3 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -83,7 +83,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface $workflow = $this->registry->get($period, 'accompanying_period_lifecycle'); if (null !== $period->getClosingDate()) { - $menu->addChild($this->translator->trans('Re-open Accompanying Course'), [ + $menu->addChild($this->translator->trans('Re-open accompanying course'), [ 'route' => 'chill_person_accompanying_course_reopen', 'routeParameters' => [ 'accompanying_period_id' => $period->getId(), diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/reopen.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/re_open.html.twig similarity index 81% rename from src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/reopen.html.twig rename to src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/re_open.html.twig index 9b50cfbb4..4cf6bfb24 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/reopen.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/re_open.html.twig @@ -1,9 +1,11 @@ {% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} -{% block title %}{{ 'Reopen accompanying course'|trans }}{% endblock %} +{% block title 'Re-Open a period'|trans %} {% block content %} -

{{ "Reopen accompanying course"|trans }}

+

{{ "Re-Open a period"|trans }}

+ +

{{ 'Are you sure you want to re-open this period ?'|trans }}

{{ form_start(form) }} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 38d53a95a..e8474fdfb 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -170,7 +170,7 @@ Update accompanying period: Mettre à jour une période d'accompagnement "Period not opened : form is invalid": "La période n'a pas été ouverte: le formulaire est invalide." 'Closing motive': 'Motif de clôture' Close accompanying course: Clôturer le parcours -Re-open Accompanying Course: Ré-ouvrir le parcours +Re-open accompanying course: Ré-ouvrir le parcours 'Person details': 'Détails de la personne' 'Update details for %name%': 'Modifier détails de %name%' An accompanying period ends: Une periode d'accompagnement se clôture