diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 65037c005..293cbeae6 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -119,6 +119,11 @@ class CalendarController extends AbstractController public function cancelAction(Calendar $calendar, Request $request): Response { + // Add voter + // Deal with sms being sent or not + // Communicate cancellation with the remote calendar. + + $this->denyAccessUnlessGranted(CalendarVoter::EDIT, $calendar); [$person, $accompanyingPeriod] = [$calendar->getPerson(), $calendar->getAccompanyingPeriod()]; @@ -139,10 +144,11 @@ class CalendarController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $this->em->persist($calendar); + + $calendar->setStatus($calendar::STATUS_CANCELED); $this->em->flush(); - $this->addFlash('success', $this->translator->trans('calender.calendar item has been canceled!')); + $this->addFlash('success', $this->translator->trans('chill_calendar.calendar_canceled')); return new RedirectResponse($redirectRoute); } diff --git a/src/Bundle/ChillCalendarBundle/Form/CancelType.php b/src/Bundle/ChillCalendarBundle/Form/CancelType.php index f3a45968a..6b63344f2 100644 --- a/src/Bundle/ChillCalendarBundle/Form/CancelType.php +++ b/src/Bundle/ChillCalendarBundle/Form/CancelType.php @@ -27,13 +27,13 @@ class CancelType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $builder->add('cancelReason', EntityType::class, array( + $builder->add('cancelReason', EntityType::class, [ 'class' => CancelReason::class, - 'required' => false, + 'required' => true, 'choice_label' => function (CancelReason $cancelReason) { return $this->translatableStringHelper->localize($cancelReason->getName()); }, - )); + ]); } public function configureOptions(OptionsResolver $resolver) diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig index 10841bf9f..cc378d3cb 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/cancelCalendarByAccompanyingCourse.html.twig @@ -6,17 +6,24 @@ {% block content %} - {{ form(form) }} + {{ form_start(form) }} + + {{ form_row(form.cancelReason) }}
+ {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index e35a46d97..527fabb12 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -45,6 +45,7 @@ crud: chill_calendar: cancel_calendar_item: Annuler rendez-vous + calendar_canceled: Le rendez-vous a été annulé Document: Document d'un rendez-vous form: The main user is mandatory. He will organize the appointment.: L'utilisateur principal est obligatoire. Il est l'organisateur de l'événement.