From e8d8a57b4b7a7357dcbc86aa209044d0ab8a6bcf Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 20 Sep 2021 15:23:54 +0200 Subject: [PATCH] rdv: rdv -> activity: pass calendar data to new activity controller --- .../Controller/ActivityController.php | 18 +++++++++++++++++ .../views/Activity/selectType.html.twig | 7 ++++++- .../Controller/CalendarController.php | 20 ++++++++++++++++++- .../Resources/views/Calendar/show.html.twig | 12 +++++++++-- .../translations/messages.fr.yml | 3 ++- 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 0988eedfe..2ede8737f 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -139,6 +139,12 @@ class ActivityController extends AbstractController ]; } + if ($request->query->has('activityData')) { + $activityData = $request->query->get('activityData'); + } else { + $activityData = []; + } + if ($view === null) { throw $this->createNotFoundException('Template not found'); } @@ -147,6 +153,7 @@ class ActivityController extends AbstractController 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, 'data' => $data, + 'activityData' => $activityData ]); } @@ -166,10 +173,21 @@ class ActivityController extends AbstractController $activityType = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class) ->find($activityType_id); + + if ($request->query->has('activityData')) { + $activityData = $request->query->get('activityData'); + dump($activityData); + } + if (!$activityType instanceof \Chill\ActivityBundle\Entity\ActivityType || !$activityType->isActive()) { $params = $this->buildParamsToUrl($person, $accompanyingPeriod); + + if (NULL !== $activityData) { + $params['activityData'] = $activityData; + } + return $this->redirectToRoute('chill_activity_activity_select_type', $params); } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig index 996d95b0f..4120d8285 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/selectType.html.twig @@ -18,7 +18,12 @@ {% set accompanying_course_id = accompanyingCourse.id %} {% endif %} - +
{{ activityType.name|localize_translatable_string }} diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 467c8eed2..103887d36 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -215,10 +215,28 @@ class CalendarController extends AbstractController throw $this->createNotFoundException('Template not found'); } + $personsId = []; + foreach ($entity->getPersons() as $p) { + array_push($personsId, $p->getId()); + } + + $professionalsId = []; + foreach ($entity->getProfessionals() as $p) { + array_push($professionalsId, $p->getId()); + } + + $activityData = [ + 'personsId' => $personsId, + 'professionalsId' => $professionalsId, + 'date' => $entity->getStartDate()->format('Y-m-d'), + 'durationTime' => $entity->getEndDate()->diff($entity->getStartDate())->format("%H:%M") + ]; + return $this->render($view, [ 'accompanyingCourse' => $accompanyingPeriod, 'entity' => $entity, - 'user' => $user + 'user' => $user, + 'activityData' => $activityData //'delete_form' => $deleteForm->createView(), ]); } diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig index 971abe67d..e8830a33d 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig @@ -65,13 +65,21 @@