person: can reopen an accompanying course

This commit is contained in:
nobohan 2022-01-19 21:46:40 +01:00
parent 9d6afc4bb2
commit d4efe81dbb
6 changed files with 96 additions and 0 deletions

View File

@ -275,4 +275,60 @@ class AccompanyingCourseController extends Controller
'accompanying_period_id' => $period->getId(),
]);
}
/**
* @Route("/{_locale}/parcours/{accompanying_period_id}/open", name="chill_person_accompanying_course_reopen")
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function reOpenAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
{
//$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse);
// $form = $this->createForm(AccompanyingCourseType::class, $accompanyingCourse, [
// 'validation_groups' => [AccompanyingPeriod::STEP_CLOSED],
// ]);
$form = $this->createFormBuilder([])->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$accompanyingCourse->reOpen();
$em->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', [
'form' => $form->createView(),
'accompanyingCourse' => $accompanyingCourse,
]);
}
}

View File

@ -996,6 +996,7 @@ class AccompanyingPeriod implements
{
$this->setClosingDate(null);
$this->setClosingMotive(null);
$this->setStep(AccompanyingPeriod::STEP_CONFIRMED);
}
/**

View File

@ -82,6 +82,15 @@ 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'), [
'route' => 'chill_person_accompanying_course_reopen',
'routeParameters' => [
'accompanying_period_id' => $period->getId(),
], ])
->setExtras(['order' => 99998]);
}
if ($workflow->can($period, 'close')) {
$menu->addChild($this->translator->trans('Close Accompanying Course'), [
'route' => 'chill_person_accompanying_course_close',

View File

@ -1,5 +1,7 @@
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% block title %}{{ 'Close accompanying course'|trans }}{% endblock %}
{% block content %}
<h1>{{ "Close accompanying course"|trans }}</h1>

View File

@ -0,0 +1,27 @@
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
{% block title %}{{ 'Reopen accompanying course'|trans }}{% endblock %}
{% block content %}
<h1>{{ "Reopen accompanying course"|trans }}</h1>
{{ form_start(form) }}
{% set accompanying_course_id = null %}
{% if accompanyingCourse %}
{% set accompanying_course_id = accompanyingCourse.id %}
{% endif %}
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ chill_return_path_or('chill_person_accompanying_course_index', {'accompanying_period_id' : accompanyingCourse.id}) }}" class="btn btn-cancel">
{{ 'Return'|trans }}
</a>
</li>
<li>
<button class="btn btn-update" type="submit">{{ 'Save'|trans }}</button>
</li>
</ul>
{{ form_end(form) }}
{% endblock %}

View File

@ -170,6 +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
'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