From 73ed632267b2f6135e14ea847c099e847459f561 Mon Sep 17 00:00:00 2001 From: adametz Date: Tue, 14 Aug 2018 16:20:27 +0000 Subject: [PATCH] Admin Booking git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3443 f459cee4-fb09-11de-96c3-f9c5f16c3c76 --- .../default/admin/lodgingsEdit.html.twig | 47 +++++++++++++++++++ .../admin/lodgingsEditCalendar.html.twig | 37 +++++---------- .../AppBundle/Controller/AdminController.php | 6 ++- .../Service/LodgingCalendarService.php | 24 +++++++++- 4 files changed, 87 insertions(+), 27 deletions(-) diff --git a/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig b/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig index acac0f91..9b456c41 100644 --- a/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig +++ b/trunk/app/Resources/views/default/admin/lodgingsEdit.html.twig @@ -214,6 +214,53 @@

Verfügbarkeit

+ + + + {% include 'default/admin/lodgingsEditCalendar.html.twig' %}
diff --git a/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig b/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig index 8b016fe5..7975f0a8 100644 --- a/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig +++ b/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig @@ -26,41 +26,29 @@ {% set is_past_date = dayState.date is not empty and date(dayState.date) < date('now') %} {# Set cell class #} - {% if (dayState.isReserved and - not dayState.isReservationBegin and not dayState.isReservationEnd) - %} - {% set cell_class = 'admin-calendar-day-reservation' %} - {% elseif dayState.isReservationBegin %} - {% set cell_class = 'admin-calendar-day-reservation-begin' %} - {% elseif dayState.isReservationEnd %} - {% set cell_class = 'admin-calendar-day-reservation-end' %} - {% elseif dayState.isInSeason %} - {% set cell_class = 'admin-calendar-day-free' %} - {% else %} - {% set cell_class = '' %} - {% endif %} - - - {% if dayState.isReserved and not dayState.isReservationEnd %} - + + {% if dayState.isReserved or dayState.isReservationBegin %} {% if dayState.reservation.id is defined %} - + {{ dayState.day }} {% else %} ID {% endif %} - - + {% elseif dayState.isBookable and not is_past_date %} - + {{ dayState.day }} {% elseif dayState.day == 0 %} - - +   {% else %} - {{ dayState.day }} + {% if dayState.isPastDate %} + {{ dayState.day }} + {% else %} + {{ dayState.day }} + {% endif %} {% endif %} {% endfor %} @@ -69,4 +57,5 @@ {% endfor %} {% endfor %} - \ No newline at end of file + + diff --git a/trunk/src/AppBundle/Controller/AdminController.php b/trunk/src/AppBundle/Controller/AdminController.php index d40e9a33..bb1530b2 100644 --- a/trunk/src/AppBundle/Controller/AdminController.php +++ b/trunk/src/AppBundle/Controller/AdminController.php @@ -250,11 +250,15 @@ class AdminController extends Controller $reservations = $calendarService->getReservations($lodging); $paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging)); - $calendar = $calendarService->getCalendar($lodging); + // $calendar = $calendarService->getCalendar($lodging); if (count($lodging->getPrices()->toArray()) != 0) { + $calendar = $calendarService->calendarAndFillDayStates($paddedCalendar, $lodging); + + /* $calendar = $calendarService->createCalendarAndFillDayStates($lodging); $calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar); + */ } else { $calendar = $paddedCalendar; } diff --git a/trunk/src/AppBundle/Service/LodgingCalendarService.php b/trunk/src/AppBundle/Service/LodgingCalendarService.php index 83efea23..aad931ac 100644 --- a/trunk/src/AppBundle/Service/LodgingCalendarService.php +++ b/trunk/src/AppBundle/Service/LodgingCalendarService.php @@ -525,7 +525,23 @@ class LodgingCalendarService public function mergeWithPaddedCalendar($calendar, $paddedCalendar) { - for($i = 0; $i < count($paddedCalendar); $i++) + $i = 0; + foreach ($paddedCalendar as $key => $data){ + + $calendarDataCurrMonth = $calendar[$i]['data']; + $paddedCalendarDataCurrMonth = $paddedCalendar[$key]['data']; + + $startIndex = $this->findCalendarDayIndexInMonth(1, $paddedCalendarDataCurrMonth); + //$startIndex = array_search(1, $paddedCalendarDataCurrMonth); + + for($j = 0; $j < count($calendarDataCurrMonth); $j++, $startIndex++) + { + $paddedCalendarDataCurrMonth[$startIndex] = $calendarDataCurrMonth[$j]; + } + $paddedCalendar[$key]['data'] = $paddedCalendarDataCurrMonth; + $i++; + } + /*for($i = 0; $i < count($paddedCalendar); $i++) { $calendarDataCurrMonth = $calendar[$i]['data']; $paddedCalendarDataCurrMonth = $paddedCalendar[$i]['data']; @@ -538,7 +554,7 @@ class LodgingCalendarService $paddedCalendarDataCurrMonth[$startIndex] = $calendarDataCurrMonth[$j]; } $paddedCalendar[$i]['data'] = $paddedCalendarDataCurrMonth; - } + }*/ return $paddedCalendar; } @@ -691,6 +707,8 @@ class LodgingCalendarService if(isset($paddedCalendar[$fromDate->format("Y-n")])){ $key = $this->findCalendarDayKey($paddedCalendar[$fromDate->format("Y-n")], $fromDate->format("d")); $paddedCalendar[$fromDate->format("Y-n")]['data'][$key]->setIsReservationBegin(true); + $paddedCalendar[$fromDate->format("Y-n")]['data'][$key]->setReservation($reservation); + } //last if(isset($paddedCalendar[$toDate->format("Y-n")])) { @@ -702,6 +720,8 @@ class LodgingCalendarService if(isset($paddedCalendar[$dt->format("Y-n")])) { $key = $this->findCalendarDayKey($paddedCalendar[$dt->format("Y-n")], $dt->format("d")); $paddedCalendar[$dt->format("Y-n")]['data'][$key]->setIsReserved(true); + $paddedCalendar[$dt->format("Y-n")]['data'][$key]->setReservation($reservation); + } } }