From 3bb0bb53a7d2b7771e96de7219aa37a2eb549c66 Mon Sep 17 00:00:00 2001 From: uli Date: Fri, 27 Oct 2017 09:47:23 +0000 Subject: [PATCH] #1352 git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3356 f459cee4-fb09-11de-96c3-f9c5f16c3c76 --- .../admin/lodgingsEditCalendar.html.twig | 107 ++++-------- .../cms/calendarLodgingProgram.html.twig | 152 +++++++----------- .../pages/cms/fewoTravelProgram.html.twig | 8 +- trunk/app/config/services.yml | 2 +- .../AppBundle/Controller/AdminController.php | 4 +- .../AppBundle/Controller/CmsController.php | 2 +- .../assets/less/includes/travel.less | 55 ++++--- .../assets/less/theme_variables.less | 5 +- .../AppBundle/Resources/public/css/custom.css | 89 +++++++--- .../LodgingCalendarService.php} | 141 ++++++---------- trunk/src/AppBundle/Util/CalendarDayState.php | 41 +++-- 11 files changed, 276 insertions(+), 330 deletions(-) rename trunk/src/AppBundle/{Util/LodgingCalendarUtil.php => Service/LodgingCalendarService.php} (80%) diff --git a/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig b/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig index 184316ff..d9a56281 100644 --- a/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig +++ b/trunk/app/Resources/views/default/admin/lodgingsEditCalendar.html.twig @@ -22,83 +22,42 @@ {% for dayIndex in 0..6 %} {# @var dayState \AppBundle\Util\CalendarDayState #} {% set dayState = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex] %} - {% if dayState.isBookable or dayState.isReserved %} - {% if dayState.isBookable %} - - - {{ dayState.day }} - - - {% elseif dayState.isReserved %} - {% if dayState.isReservationBegin %} - {# @var prevState \AppBundle\Util\CalendarDayState #} - {% set prevState = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex - 1)] %} - {% if prevState.day == 0 or prevState.isReservationEnd %} - - - {{ dayState.day }} - - - {% else %} - - - {{ dayState.day }} - - - {% endif %} - {% elseif dayState.isReservationEnd %} - {# @var nextState \AppBundle\Util\CalendarDayState #} - {% set nextState = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex + 1)] %} - {% if nextState.isReservationBegin %} - - - {{ dayState.day }} - - - {% else %} - - - {{ dayState.day }} - - - {% endif %} - {% else %} - - - {{ dayState.day }} - - - {% endif %} - {% endif %} + + {% 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 %} - {% if dayState.day == 0 %} - - - - - {% else %} - {{ dayState.day }} - {% endif %} + {% set cell_class = '' %} {% endif %} + + + + {% if dayState.isReserved and not dayState.isReservationEnd %} + + {{ dayState.day }} + + {% elseif dayState.isBookable and not is_past_date %} + + {{ dayState.day }} + + {% elseif dayState.day == 0 %} + - + {% else %} + {{ dayState.day }} + {% endif %} + {% endfor %} + {% endfor %} diff --git a/trunk/app/Resources/views/default/pages/cms/calendarLodgingProgram.html.twig b/trunk/app/Resources/views/default/pages/cms/calendarLodgingProgram.html.twig index f8210089..93c48f44 100644 --- a/trunk/app/Resources/views/default/pages/cms/calendarLodgingProgram.html.twig +++ b/trunk/app/Resources/views/default/pages/cms/calendarLodgingProgram.html.twig @@ -1,97 +1,65 @@ -{% for monthIndex in 0..11 %} - {% if monthIndex is even %} - - {% else %} -
- {% endif %} - - - - - - - - - - - - - - - - {% for weekIndex in 0..5 %} - - {% for dayIndex in 0..6 %} - {# @var dayState \AppBundle\Util\CalendarDayState #} - {% set dayState = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex] %} - {% if dayState.isBookable or dayState.isReserved %} - {% if dayState.isBookable %} - - {% elseif dayState.isReserved %} - {% if dayState.isReservationBegin %} - {# @var prevState \AppBundle\Util\CalendarDayState #} - {% set prevState = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex - 1)] %} - {% if prevState.day == 0 or prevState.isReservationEnd %} - - {% else %} - - {% endif %} +
+ {% for monthIndex in 0..11 %} +
+
- {{ calendar[monthIndex]['monthName'] }} {{ calendar[monthIndex]['year'] }} -
MoDiMiDoFrSaSo
- - {{ dayState.day }} - - - {{ dayState.day }} - - {{ dayState.day }} -
+ + + + + + + + + + + + + + + + {% for weekIndex in 0..5 %} + + {% for dayIndex in 0..6 %} + {# @var dayState \AppBundle\Util\CalendarDayState #} + {% set dayState = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex] %} + + {% set is_past_date = dayState.date is not empty and date(dayState.date) < date('now') %} + + {# Set cell class #} + {% if is_past_date or + (dayState.isReserved and not dayState.isReservationBegin and not dayState.isReservationEnd) or + not dayState.isInSeason + %} + {% set cell_class = 'calendar-day-disabled' %} + {% elseif dayState.isReservationBegin %} + {% set cell_class = 'calendar-day-reservation-begin' %} {% elseif dayState.isReservationEnd %} - {# @var nextState \AppBundle\Util\CalendarDayState #} - {% set nextState = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex + 1)] %} - {% if nextState.isReservationBegin %} - + {% set cell_class = 'calendar-day-reservation-end' %} + {% else %} + {% set cell_class = '' %} + {% endif %} + + + {{ dayState.day }} {% endif %} - {% else %} - - {% endif %} - {% endif %} - {% else %} - {% if dayState.day == 0 %} - - {% else %} - {% if dayState.isInSeason and not(dayState.isBookable) and not(dayState.isReserved) %} - - {% else %} - - {% endif %} - {% endif %} - {% endif %} + {% endfor %} + {% endfor %} - - {% endfor %} - -
+ {{ calendar[monthIndex]['monthName'] }} {{ calendar[monthIndex]['year'] }} +
MoDiMiDoFrSaSo
- {{ dayState.day }} - + {% if dayState.isBookable and not is_past_date %} + + {{ dayState.day }} + + {% elseif dayState.day == 0 %} + - {% else %} - - - {{ dayState.day }} - - - {{ dayState.day }} - - - - {{ dayState.day }} - - {{ dayState.day }} -
-{% endfor %} + + + + {% endfor %} + \ No newline at end of file diff --git a/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig b/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig index d60addfa..5c271d16 100644 --- a/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig +++ b/trunk/app/Resources/views/default/pages/cms/fewoTravelProgram.html.twig @@ -205,13 +205,17 @@ {% endfor %} -

Buchung

- {% include 'default/pages/cms/calendarLodgingProgram.html.twig' %} {% else %} Momentan sind für dieses Programm keine Termine verfügbar. {% endif %} +

Buchung

+ +

Bitte klicken Sie einen Anreisetermin, um zur Buchungsmaske zu gelagen.

+ + {% include 'default/pages/cms/calendarLodgingProgram.html.twig' %} + diff --git a/trunk/app/config/services.yml b/trunk/app/config/services.yml index c5b5adfb..e38d26f7 100644 --- a/trunk/app/config/services.yml +++ b/trunk/app/config/services.yml @@ -71,6 +71,6 @@ services: - { name: doctrine.event_listener, event: preRemove } app.lodging_calendar_util: - class: AppBundle\Util\LodgingCalendarUtil + class: AppBundle\Service\LodgingCalendarService arguments: - '@doctrine.orm.entity_manager' \ No newline at end of file diff --git a/trunk/src/AppBundle/Controller/AdminController.php b/trunk/src/AppBundle/Controller/AdminController.php index a1dcced2..60141336 100644 --- a/trunk/src/AppBundle/Controller/AdminController.php +++ b/trunk/src/AppBundle/Controller/AdminController.php @@ -168,7 +168,7 @@ class AdminController extends Controller $calendar = $calendarUtil->getCalendar(); if (count($lodging->getPrices()->toArray()) != 0) { - $calendar = $calendarUtil->markCalendarDaysWithReservations($lodging, $calendar); + $calendar = $calendarUtil->getCalendarWithReservations($lodging); $calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar); } else { $calendar = $paddedCalendar; @@ -238,7 +238,7 @@ class AdminController extends Controller $calendar = $calendarUtil->getCalendar(); if (count($lodging->getPrices()->toArray()) != 0) { - $calendar = $calendarUtil->markCalendarDaysWithReservations($lodging, $calendar); + $calendar = $calendarUtil->getCalendarWithReservations($lodging); $calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar); } else { $calendar = $paddedCalendar; diff --git a/trunk/src/AppBundle/Controller/CmsController.php b/trunk/src/AppBundle/Controller/CmsController.php index ad91c79f..4dab1fc5 100644 --- a/trunk/src/AppBundle/Controller/CmsController.php +++ b/trunk/src/AppBundle/Controller/CmsController.php @@ -134,7 +134,7 @@ class CmsController extends Controller $calendar = $calendarUtil->getCalendar(); if (count($lodging->getPrices()->toArray()) != 0) { - $calendar = $calendarUtil->markCalendarDaysWithReservations($lodging, $calendar); + $calendar = $calendarUtil->getCalendarWithReservations($lodging); $calendar = $calendarUtil->mergeWithPaddedCalendar($calendar, $paddedCalendar); } else { $calendar = $paddedCalendar; diff --git a/trunk/src/AppBundle/Resources/assets/less/includes/travel.less b/trunk/src/AppBundle/Resources/assets/less/includes/travel.less index 2aba90e8..3f73052d 100644 --- a/trunk/src/AppBundle/Resources/assets/less/includes/travel.less +++ b/trunk/src/AppBundle/Resources/assets/less/includes/travel.less @@ -508,40 +508,39 @@ color:#ffffff !important; } -.calendarEven{ - float: left; - width: 50%; +.table > tbody > tr > .calendar-day-disabled { + background-color: darkgrey; +} +.table > tbody > tr > .admin-calendar-day-reservation { + background-color: @background-red; +} +.table > tbody > tr > .admin-calendar-day-free { + background-color: @background-green; } -.calendarOdd{ - float: left; - width: 50%; +.calendar-day-dual-state(@color-a, @color-b) { + background-color: @color-b; + background: -moz-linear-gradient(to bottom right, @color-a 0%, @color-a 49%, @color-b 50%, @color-b 100%); /* ff3.6+ */ + background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, @color-a), color-stop(49%, @color-a), color-stop(50%, @color-b), color-stop(100%, @color-b)); /* safari4+,chrome */ + background: -webkit-linear-gradient(to bottom right, @color-a 0%, @color-a 49%, @color-b 50%, @color-b 100%); /* safari5.1+,chrome10+ */ + background: -o-linear-gradient(to bottom right, @color-a 0%, @color-a 49%, @color-b 50%, @color-b 100%); /* opera 11.10+ */ + background: -ms-linear-gradient(to bottom right, @color-a 0%, @color-a 49%, @color-b 50%, @color-b 100%); /* ie10+ */ + background: linear-gradient(to bottom right, @color-a 0%, @color-a 49%, @color-b 50%, @color-b 100%); /* w3c */ + //filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='@color-b', endColorstr='@color-a',GradientType=1 ); /* ie6-9 */ } -.calendarGradientTravelBegin { - background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, darkgrey), color-stop(52%, darkgrey), color-stop(100%, darkgrey)); - background: -moz-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, darkgrey), color-stop(52%, darkgrey), color-stop(100%, darkgrey)); - background: -o-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, darkgrey), color-stop(52%, darkgrey), color-stop(100%, darkgrey)); - background: gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, darkgrey), color-stop(52%, darkgrey), color-stop(100%, darkgrey)); +.table > tbody > tr > .calendar-day-reservation-begin { + .calendar-day-dual-state(#f2f2f2, darkgrey); } -.calendarGradientTravelEnd { - background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, darkgray), color-stop(52%, darkgray), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); - background: -moz-gradient(linear, left top, right bottom, color-stop(1%, darkgray), color-stop(52%, darkgray), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); - background: -o-gradient(linear, left top, right bottom, color-stop(1%, darkgray), color-stop(52%, darkgray), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); - background: gradient(linear, left top, right bottom, color-stop(1%, darkgray), color-stop(52%, darkgray), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); - } - -.calendarGradientAdminBegin { - background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, red), color-stop(52%, red), color-stop(100%, red)); - background: -moz-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, red), color-stop(52%, red), color-stop(100%, red)); - background: -o-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, red), color-stop(52%, red), color-stop(100%, red)); - background: gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, red), color-stop(52%, red), color-stop(100%, red)); +.table > tbody > tr > .calendar-day-reservation-end { + .calendar-day-dual-state(darkgrey, #f2f2f2); } -.calendarGradientAdminEnd { - background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, red), color-stop(52%, red), color-stop(52%, green), color-stop(52%, green), color-stop(100%, green)); - background: -moz-gradient(linear, left top, right bottom, color-stop(1%, red), color-stop(52%, red), color-stop(52%, green), color-stop(52%, green), color-stop(100%, green)); - background: -o-gradient(linear, left top, right bottom, color-stop(1%, red), color-stop(52%, red), color-stop(52%, green), color-stop(52%, green), color-stop(100%, green)); - background: gradient(linear, left top, right bottom, color-stop(1%, red), color-stop(52%, red), color-stop(52%, green), color-stop(52%, green), color-stop(100%, green)); +.table > tbody > tr > .admin-calendar-day-reservation-begin { + .calendar-day-dual-state(@background-green, @background-red); +} + +.table > tbody > tr > .admin-calendar-day-reservation-end { + .calendar-day-dual-state(@background-red, @background-green); } diff --git a/trunk/src/AppBundle/Resources/assets/less/theme_variables.less b/trunk/src/AppBundle/Resources/assets/less/theme_variables.less index 78729dce..17077b97 100755 --- a/trunk/src/AppBundle/Resources/assets/less/theme_variables.less +++ b/trunk/src/AppBundle/Resources/assets/less/theme_variables.less @@ -33,4 +33,7 @@ @font-size-def-h5: @font-size-alternative-base; @font-size-def-h6: ceil((@font-size-alternative-base * 0.85)); -@btn-color-all: #648859; \ No newline at end of file +@background-green: #648859; +@background-red: #d9534f; + +@btn-color-all: @background-green; \ No newline at end of file diff --git a/trunk/src/AppBundle/Resources/public/css/custom.css b/trunk/src/AppBundle/Resources/public/css/custom.css index fed598de..4667f2d2 100644 --- a/trunk/src/AppBundle/Resources/public/css/custom.css +++ b/trunk/src/AppBundle/Resources/public/css/custom.css @@ -1057,37 +1057,74 @@ a[id^="video_"]:before, .widget .sidebar-price .btn { color: #ffffff !important; } -.calendarEven { - float: left; - width: 50%; +.table > tbody > tr > .calendar-day-disabled { + background-color: darkgrey; } -.calendarOdd { - float: left; - width: 50%; +.table > tbody > tr > .admin-calendar-day-reservation { + background-color: #d9534f; } -.calendarGradientTravelBegin { - background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(100%, #a9a9a9)); - background: -moz-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(100%, #a9a9a9)); - background: -o-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(100%, #a9a9a9)); - background: gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(100%, #a9a9a9)); +.table > tbody > tr > .admin-calendar-day-free { + background-color: #648859; } -.calendarGradientTravelEnd { - background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); - background: -moz-gradient(linear, left top, right bottom, color-stop(1%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); - background: -o-gradient(linear, left top, right bottom, color-stop(1%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); - background: gradient(linear, left top, right bottom, color-stop(1%, #a9a9a9), color-stop(52%, #a9a9a9), color-stop(52%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(100%, #f2f2f2)); +.table > tbody > tr > .calendar-day-reservation-begin { + background-color: #a9a9a9; + background: -moz-linear-gradient(to bottom right, #f2f2f2 0%, #f2f2f2 49%, #a9a9a9 50%, #a9a9a9 100%); + /* ff3.6+ */ + background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #f2f2f2), color-stop(49%, #f2f2f2), color-stop(50%, #a9a9a9), color-stop(100%, #a9a9a9)); + /* safari4+,chrome */ + background: -webkit-linear-gradient(to bottom right, #f2f2f2 0%, #f2f2f2 49%, #a9a9a9 50%, #a9a9a9 100%); + /* safari5.1+,chrome10+ */ + background: -o-linear-gradient(to bottom right, #f2f2f2 0%, #f2f2f2 49%, #a9a9a9 50%, #a9a9a9 100%); + /* opera 11.10+ */ + background: -ms-linear-gradient(to bottom right, #f2f2f2 0%, #f2f2f2 49%, #a9a9a9 50%, #a9a9a9 100%); + /* ie10+ */ + background: linear-gradient(to bottom right, #f2f2f2 0%, #f2f2f2 49%, #a9a9a9 50%, #a9a9a9 100%); + /* w3c */ } -.calendarGradientAdminBegin { - background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, #ff0000), color-stop(52%, #ff0000), color-stop(100%, #ff0000)); - background: -moz-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, #ff0000), color-stop(52%, #ff0000), color-stop(100%, #ff0000)); - background: -o-gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, #ff0000), color-stop(52%, #ff0000), color-stop(100%, #ff0000)); - background: gradient(linear, left top, right bottom, color-stop(1%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, #ff0000), color-stop(52%, #ff0000), color-stop(100%, #ff0000)); +.table > tbody > tr > .calendar-day-reservation-end { + background-color: #f2f2f2; + background: -moz-linear-gradient(to bottom right, #a9a9a9 0%, #a9a9a9 49%, #f2f2f2 50%, #f2f2f2 100%); + /* ff3.6+ */ + background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #a9a9a9), color-stop(49%, #a9a9a9), color-stop(50%, #f2f2f2), color-stop(100%, #f2f2f2)); + /* safari4+,chrome */ + background: -webkit-linear-gradient(to bottom right, #a9a9a9 0%, #a9a9a9 49%, #f2f2f2 50%, #f2f2f2 100%); + /* safari5.1+,chrome10+ */ + background: -o-linear-gradient(to bottom right, #a9a9a9 0%, #a9a9a9 49%, #f2f2f2 50%, #f2f2f2 100%); + /* opera 11.10+ */ + background: -ms-linear-gradient(to bottom right, #a9a9a9 0%, #a9a9a9 49%, #f2f2f2 50%, #f2f2f2 100%); + /* ie10+ */ + background: linear-gradient(to bottom right, #a9a9a9 0%, #a9a9a9 49%, #f2f2f2 50%, #f2f2f2 100%); + /* w3c */ } -.calendarGradientAdminEnd { - background: -webkit-gradient(linear, left top, right bottom, color-stop(1%, #ff0000), color-stop(52%, #ff0000), color-stop(52%, #008000), color-stop(52%, #008000), color-stop(100%, #008000)); - background: -moz-gradient(linear, left top, right bottom, color-stop(1%, #ff0000), color-stop(52%, #ff0000), color-stop(52%, #008000), color-stop(52%, #008000), color-stop(100%, #008000)); - background: -o-gradient(linear, left top, right bottom, color-stop(1%, #ff0000), color-stop(52%, #ff0000), color-stop(52%, #008000), color-stop(52%, #008000), color-stop(100%, #008000)); - background: gradient(linear, left top, right bottom, color-stop(1%, #ff0000), color-stop(52%, #ff0000), color-stop(52%, #008000), color-stop(52%, #008000), color-stop(100%, #008000)); +.table > tbody > tr > .admin-calendar-day-reservation-begin { + background-color: #d9534f; + background: -moz-linear-gradient(to bottom right, #648859 0%, #648859 49%, #d9534f 50%, #d9534f 100%); + /* ff3.6+ */ + background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #648859), color-stop(49%, #648859), color-stop(50%, #d9534f), color-stop(100%, #d9534f)); + /* safari4+,chrome */ + background: -webkit-linear-gradient(to bottom right, #648859 0%, #648859 49%, #d9534f 50%, #d9534f 100%); + /* safari5.1+,chrome10+ */ + background: -o-linear-gradient(to bottom right, #648859 0%, #648859 49%, #d9534f 50%, #d9534f 100%); + /* opera 11.10+ */ + background: -ms-linear-gradient(to bottom right, #648859 0%, #648859 49%, #d9534f 50%, #d9534f 100%); + /* ie10+ */ + background: linear-gradient(to bottom right, #648859 0%, #648859 49%, #d9534f 50%, #d9534f 100%); + /* w3c */ +} +.table > tbody > tr > .admin-calendar-day-reservation-end { + background-color: #648859; + background: -moz-linear-gradient(to bottom right, #d9534f 0%, #d9534f 49%, #648859 50%, #648859 100%); + /* ff3.6+ */ + background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #d9534f), color-stop(49%, #d9534f), color-stop(50%, #648859), color-stop(100%, #648859)); + /* safari4+,chrome */ + background: -webkit-linear-gradient(to bottom right, #d9534f 0%, #d9534f 49%, #648859 50%, #648859 100%); + /* safari5.1+,chrome10+ */ + background: -o-linear-gradient(to bottom right, #d9534f 0%, #d9534f 49%, #648859 50%, #648859 100%); + /* opera 11.10+ */ + background: -ms-linear-gradient(to bottom right, #d9534f 0%, #d9534f 49%, #648859 50%, #648859 100%); + /* ie10+ */ + background: linear-gradient(to bottom right, #d9534f 0%, #d9534f 49%, #648859 50%, #648859 100%); + /* w3c */ } /* 7) SHORTCODES diff --git a/trunk/src/AppBundle/Util/LodgingCalendarUtil.php b/trunk/src/AppBundle/Service/LodgingCalendarService.php similarity index 80% rename from trunk/src/AppBundle/Util/LodgingCalendarUtil.php rename to trunk/src/AppBundle/Service/LodgingCalendarService.php index 1d4e85f5..0b7e7d16 100644 --- a/trunk/src/AppBundle/Util/LodgingCalendarUtil.php +++ b/trunk/src/AppBundle/Service/LodgingCalendarService.php @@ -1,6 +1,6 @@ setIsReserved(false); $day->setIsReservationBegin(false); $day->setIsReservationEnd(false); + $datetime = new \DateTime(); + $datetime->setTimestamp(mktime(0,0,0, $actualMonth, $d, $actualCurrentYear)); + $day->setDate($datetime); $data[] = $day; } @@ -299,7 +302,7 @@ class LodgingCalendarUtil $data[$i]->setIsReserved(false); $data[$i]->setPrice($price); $data[$i]->setIsInSeason(true); - $data[$i]->setIsBookable(true); + $data[$i]->setIsBookable(false); } } $calendar[$startCalendarIndex]['data'] = $data; @@ -341,7 +344,7 @@ class LodgingCalendarUtil $data[$i]->setIsReserved(false); $data[$i]->setPrice($price); $data[$i]->setIsInSeason(true); - $data[$i]->setIsBookable(true); + $data[$i]->setIsBookable(false); } } $calendar[$startCalendarIndex]['data'] = $data; @@ -366,7 +369,7 @@ class LodgingCalendarUtil $data[$i]->setIsReservationEnd(true); $data[$i]->setReservation($reservation); $data[$i]->setIsInSeason(true); - $data[$i]->setIsBookable(false); // todo, hier evtl direkt true + $data[$i]->setIsBookable(false); //$data[$i]->setIsBookable(true); } else @@ -382,7 +385,7 @@ class LodgingCalendarUtil $data[$i]->setIsReserved(false); $data[$i]->setPrice($price); $data[$i]->setIsInSeason(true); - $data[$i]->setIsBookable(true); + $data[$i]->setIsBookable(false); } } $calendar[$endCalendarIndex]['data'] = $data; @@ -412,7 +415,7 @@ class LodgingCalendarUtil $data[$j]->setIsReserved(false); $data[$j]->setPrice($price); $data[$j]->setIsInSeason(true); - $data[$j]->setIsBookable(true); + $data[$j]->setIsBookable(false); } } $calendar[$i]['data'] = $data; @@ -435,10 +438,6 @@ class LodgingCalendarUtil for($j = 0; $j < $endIndex; $j++) { - //$mergedPricesAndReservationsCalendar = $this->mergeCalendarsNew($pricesCalendar, $reservationsCalendar, false); - //$actuallyReservableDaysCalendar = $this->filterReservableDays($lodging, $mergedPricesAndReservationsCalendar); - //$resultCalendar = $this->mergeCalendars($actuallyReservableDaysCalendar, $reservationsCalendar, true); - if ($withFromTo) { if ($extensionCalendarData[$j]->getIsInSeason()) @@ -489,13 +488,13 @@ class LodgingCalendarUtil // erste runde $pricesCalendar merge mit $reservationsCalendar $price = $calendarData[$j]->getPrice(); + $isInSeason = $calendarData[$j]->getIsInSeason(); $reservation = $calendarData[$j]->getReservation(); $calendarData[$j] = $extensionCalendarData[$j]; if ($calendarData[$j]->getIsReservationEnd() && $extensionCalendarData[$j]->getIsReservationBegin()) { $calendarData[$j]->setReservation($reservation); - $calendarData[$j]->setIsReservationBegin(false); $calendarData[$j]->setIsReservationEnd(false); } @@ -581,88 +580,50 @@ class LodgingCalendarUtil /** * @param FewoLodging $lodging * @param $calendar - * @return array|null + * @return array|null calendars */ private function filterReservableDays(FewoLodging $lodging, $calendar) { - $priceRepo = $this->em->getRepository('AppBundle:FewoPrice'); - - $today = new \DateTime(); - $seasons = $lodging->getSeasons(); - $prices = $lodging->getPrices(); - $cleanCalendar = $this->getCalendar(); - $potentiallyReservableDays = []; - $actuallyReservableDays = []; - $lastReservablePriceId = 0; $priceId = 0; + /** @var FewoPrice $lastReservablePrice */ + $lastReservablePrice = null; - for($currMonthIndex = 0; $currMonthIndex < count($calendar); $currMonthIndex++) + for ($currMonthIndex = 0; $currMonthIndex < count($calendar); $currMonthIndex++) { $currMonth = $calendar[$currMonthIndex]; /** @var CalendarDayState[] $data */ $data = $currMonth['data']; - for($currDayIndex = 0; $currDayIndex < count($data); $currDayIndex++) + for ($currDayIndex = 0; $currDayIndex < count($data); $currDayIndex++) { - //$currDay = explode(',', $data[$currDayIndex]); $currDay = $data[$currDayIndex]; - if ($currDay->getIsBookable() || $currDay->getIsReserved()) + if ($currDay->getPrice() !== $lastReservablePrice && !$currDay->getIsInSeason()) { - if ($currDay->getIsBookable()) - { - $price = $currDay->getPrice(); - $priceId = $price->getId(); - - if ($lastReservablePriceId == 0) - { - $lastReservablePriceId = $priceId; - } - - if($lastReservablePriceId != $priceId) - { - $lastPrice = $priceRepo->find($lastReservablePriceId); - /** @var FewoSeason $season */ - $season = $lastPrice->getSeason(); - - $actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay()); - $this->processRest($actuallyReservableDays, $lastPrice, $cleanCalendar); //todo - - $lastReservablePriceId = $priceId; - $potentiallyReservableDays = []; - $actuallyReservableDays = []; - } - - $currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay->getDay())); - $potentiallyReservableDays[] = $currentDayDate; - } - elseif ($currDay->getIsReserved() && $currDay->getIsReservationBegin()) - { - $currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay->getDay())); - $potentiallyReservableDays[] = $currentDayDate; - } + $actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, + $lastReservablePrice->getSeason()->getMinimumStay()); + $this->processRest($actuallyReservableDays, $lastReservablePrice, $calendar); + $potentiallyReservableDays = []; } - else + if ($currDay->getIsInSeason() && (!$currDay->getIsReserved() || $currDay->getIsReservationBegin() || + $currDay->getIsReservationEnd())) { - if($lastReservablePriceId == $priceId && $lastReservablePriceId != 0) - { - $lastPrice = $priceRepo->find($lastReservablePriceId); - /** @var FewoSeason $season */ - $season = $lastPrice->getSeason(); - - $actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay()); - $this->processRest($actuallyReservableDays, $lastPrice, $cleanCalendar); //todo - - $lastReservablePriceId = $priceId; - $potentiallyReservableDays = []; - $actuallyReservableDays = []; - } - + $currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-". + $currMonth['monthNumber']."-".$currDay->getDay())); + $potentiallyReservableDays[] = $currentDayDate; } + + $lastReservablePrice = $currDay->getIsInSeason() ? $currDay->getPrice() : null; } } - return $cleanCalendar; + if ($lastReservablePrice !== null) + { + $actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, + $lastReservablePrice->getSeason()->getMinimumStay()); + $this->processRest($actuallyReservableDays, $lastReservablePrice, $calendar); + } + return $calendar; } @@ -739,12 +700,12 @@ class LodgingCalendarUtil if (in_array($currentDate, $actuallyReservableDays)) { - $data[$currDayIndex]->setIsInSeason(true); - $data[$currDayIndex]->setIsReserved(false); // todo ? + //$data[$currDayIndex]->setIsInSeason(true); + //$data[$currDayIndex]->setIsReserved(false); // todo ? $data[$currDayIndex]->setIsBookable(true); - $data[$currDayIndex]->setIsReservationBegin(false); - $data[$currDayIndex]->setIsReservationEnd(false); // todo ? - $data[$currDayIndex]->setPrice($price); + //$data[$currDayIndex]->setIsReservationBegin(false); + //$data[$currDayIndex]->setIsReservationEnd(false); // todo ? + //$data[$currDayIndex]->setPrice($price); $currMonth['marked'] = 1; } @@ -761,28 +722,23 @@ class LodgingCalendarUtil * @param $calendar * @return mixed */ - public function markCalendarDaysWithReservations(FewoLodging $lodging, $calendar) + public function getCalendarWithReservations(FewoLodging $lodging) { $today = new \DateTime(); - $pricesCalendar = $calendar; - $reservationsCalendar = $calendar; + $pricesCalendar = $this->getCalendar(); + $reservationsCalendar = $this->getCalendar(); $reservations = $lodging->getReservations(); $prices = $lodging->getPrices(); $lodgingId = $lodging->getId(); - foreach($prices as $price) + foreach ($prices as $price) { /** @var FewoSeason $season */ $season = $price->getSeason(); - $fromDate = $season->getFromDate(); - $toDate = $season->getToDate(); - - if(!($toDate < $today)) - { - $pricesCalendar = $this->markCalendarDays($pricesCalendar, $fromDate, $toDate, false, $price, null); //TODO fast fertig - } + $pricesCalendar = $this->markCalendarDays($pricesCalendar, $season->getFromDate(), $season->getToDate(), + false, $price); } foreach($reservations as $reservation) @@ -797,9 +753,10 @@ class LodgingCalendarUtil $mergedPricesAndReservationsCalendar = $this->mergeCalendars($pricesCalendar, $reservationsCalendar, false); $actuallyReservableDaysCalendar = $this->filterReservableDays($lodging, $mergedPricesAndReservationsCalendar); - $resultCalendar = $this->mergeCalendars($actuallyReservableDaysCalendar, $reservationsCalendar, true); + //$resultCalendar = $this->mergeCalendars($actuallyReservableDaysCalendar, $reservationsCalendar, true); - return $resultCalendar; + return $actuallyReservableDaysCalendar; + //return $resultCalendar; } diff --git a/trunk/src/AppBundle/Util/CalendarDayState.php b/trunk/src/AppBundle/Util/CalendarDayState.php index f1e64bc6..e6aa1351 100644 --- a/trunk/src/AppBundle/Util/CalendarDayState.php +++ b/trunk/src/AppBundle/Util/CalendarDayState.php @@ -17,12 +17,12 @@ class CalendarDayState private $day; /** - * @var FewoPrice + * @var FewoPrice|null */ private $price; // der preis / die saison /** - * @var FewoReservation + * @var FewoReservation|null */ private $reservation; // die reservierung //todo wenns vorteile bringt, ne zweite speichern @@ -49,7 +49,12 @@ class CalendarDayState /** * @var bool */ - private $isReservationEnd; // ist es das ende einer reservierung? + private $isReservationEnd; + + /** + * @var \DateTime|null + */ + private $date = null; /** * @return int @@ -68,33 +73,33 @@ class CalendarDayState } /** - * @return FewoPrice + * @return FewoPrice|null */ - public function getPrice(): FewoPrice + public function getPrice() { return $this->price; } /** - * @param FewoPrice $price + * @param FewoPrice|null $price */ - public function setPrice(FewoPrice $price) + public function setPrice($price) { $this->price = $price; } /** - * @return FewoReservation + * @return FewoReservation|null */ - public function getReservation(): FewoReservation + public function getReservation() { return $this->reservation; } /** - * @param FewoReservation $reservation + * @param FewoReservation|null $reservation */ - public function setReservation(FewoReservation $reservation) + public function setReservation($reservation) { $this->reservation = $reservation; } @@ -179,6 +184,20 @@ class CalendarDayState $this->isReservationEnd = $isReservationEnd; } + /** + * @return \DateTime|null + */ + public function getDate() + { + return $this->date; + } + /** + * @param \DateTime|null $date + */ + public function setDate($date) + { + $this->date = $date; + } }