#1352 - Anpassungen

git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3355 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
valentin.wacker 2017-10-26 14:14:55 +00:00
parent a2d4159c88
commit 8240ce87f9
9 changed files with 670 additions and 230 deletions

View file

@ -1,100 +1,106 @@
<table class="table"> <table class="table">
{% for month in calendar %} {% for monthIndex in 0..11 %}
<thead>
<thead> <tr>
<th colspan="7">
{{ calendar[monthIndex]['monthName'] }} {{ calendar[monthIndex]['year'] }}
</th>
</tr>
<tr>
<th>Mo</th>
<th>Di</th>
<th>Mi</th>
<th>Do</th>
<th>Fr</th>
<th>Sa</th>
<th>So</th>
</tr>
</thead>
<tbody>
{% for weekIndex in 0..5 %}
<tr> <tr>
<th colspan="7"> {% for dayIndex in 0..6 %}
{{ month['monthName'] }} {{ month['year'] }} {# @var dayState \AppBundle\Util\CalendarDayState #}
</th> {% set dayState = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex] %}
</tr> {% if dayState.isBookable or dayState.isReserved %}
<tr> {% if dayState.isBookable %}
<th>Mo</th> <td style="background-color: green!important;">
<th>Di</th> <a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new/{{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar[monthIndex]['monthNumber'] < 10 ? '0':'' }}{{calendar[monthIndex]['monthNumber']}}{{calendar[monthIndex]['year']}}"
<th>Mi</th> style="color: #5a5a5a;"
<th>Do</th> {#class="btn btn-primary"#}
<th>Fr</th> rel="nofollow"
<th>Sa</th> >
<th>So</th> {{ dayState.day }}
</tr> </a>
</thead> </td>
<tbody> {% elseif dayState.isReserved %}
{% for weekIndex in 0..5 %} {% if dayState.isReservationBegin %}
<tr> {# @var prevState \AppBundle\Util\CalendarDayState #}
{% for dayIndex in 0..6 %} {% set prevState = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex - 1)] %}
{% set day = month['data'][(weekIndex * 7) + dayIndex]|split(',') %} {% if prevState.day == 0 or prevState.isReservationEnd %}
{% if day|length > 1 %} <td style="background-color: red!important;">
{% if day[1] == 'reservable' %} <a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ dayState.reservation.id }}"
<td style="background-color: green!important;"> style="color: #5a5a5a;"
<a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new/{{ day[0] < 10 ? '0':'' }}{{day[0]}}{{ month['monthNumber'] < 10 ? '0':'' }}{{month['monthNumber']}}{{month['year']}}" rel="nofollow"
>
{{ dayState.day }}
</a>
</td>
{% else %}
<td class="calendarGradientAdminBegin">
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ dayState.reservation.id }}"
style="color: #5a5a5a;"
rel="nofollow"
>
{{ dayState.day }}
</a>
</td>
{% endif %}
{% elseif dayState.isReservationEnd %}
{# @var nextState \AppBundle\Util\CalendarDayState #}
{% set nextState = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex + 1)] %}
{% if nextState.isReservationBegin %}
<td style="background-color: red!important;">
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ dayState.reservation.id }}"
style="color: #5a5a5a;"
rel="nofollow"
>
{{ dayState.day }}
</a>
</td>
{% else %}
<td class="calendarGradientAdminEnd">
<a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new/{{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar[monthIndex]['monthNumber'] < 10 ? '0':'' }}{{calendar[monthIndex]['monthNumber']}}{{calendar[monthIndex]['year']}}"
style="color: #5a5a5a;"
rel="nofollow"
>
{{ dayState.day }}
</a>
</td>
{% endif %}
{% else %}
<td style="background-color: red!important;">
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ dayState.reservation.id }}"
style="color: #5a5a5a;" style="color: #5a5a5a;"
{#class="btn btn-primary"#}
rel="nofollow" rel="nofollow"
> >
{{ day[0] }} {{ dayState.day }}
</a> </a>
</td> </td>
{% else %}
{% if day|length > 3%}
<td style="background-color: red!important;">
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ day[1] }}"
style="color: #5a5a5a;"
{#class="btn btn-primary"#}
rel="nofollow"
>
{{ day[0] }}
</a>
</td>
{% elseif day|length > 2 and day[2] == 'from' %}
<td style="
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));
">
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ day[1] }}"
style="color: #5a5a5a;"
rel="nofollow"
>
{{ day[0] }}
</a>
</td>
{% elseif day|length > 2 and day[2] == 'to' %}
<td style="
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));
">
<a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new/{{ day[0] < 10 ? '0':'' }}{{day[0]}}{{ month['monthNumber'] < 10 ? '0':'' }}{{month['monthNumber']}}{{month['year']}}"
style="color: #5a5a5a;"
rel="nofollow"
>
{{ day[0] }}
</a>
</td>
{% else %}
<td style="background-color: red!important;">
<a href="{{ '/admin/fewo/lodgings/' ~ lodging.id ~ '/reservations/' ~ day[1] }}"
style="color: #5a5a5a;"
rel="nofollow"
>
{{ day[0] }}
</a>
</td>
{% endif %}
{% endif %} {% endif %}
{% else %}
<td>
{% if day[0] == 0 %}
-
{% else %}
{{ day[0] }}
{% endif %}
</td>
{% endif %} {% endif %}
{% endfor %} {% else %}
</tr> {% if dayState.day == 0 %}
{% endfor %} <td>
</tbody> -
</td>
{% else %}
<td>{{ dayState.day }}</td>
{% endif %}
{% endif %}
{% endfor %}
</tr>
{% endfor %} {% endfor %}
</table> </tbody>
{% endfor %}
</table>

View file

@ -4,7 +4,7 @@
{% elseif page.travelProgram is not empty and page.travelProgram.previewImage is not empty %} {% elseif page.travelProgram is not empty and page.travelProgram.previewImage is not empty %}
{% set image_url = '/uploads/travel_program/' ~ page.travelProgram.previewImage.fileNameWithExtension %} {% set image_url = '/uploads/travel_program/' ~ page.travelProgram.previewImage.fileNameWithExtension %}
{% set image_alt = page.title %} {% set image_alt = page.title %}
{% elseif page.fewoLodging is not empty and page.fewoLodging.images[0] is not empty %} {% elseif page.fewoLodging is not empty and page.fewoLodging.images is not empty and page.fewoLodging.images[0] is not empty %}
{% set image_url = asset('uploads/images/' ~ page.fewoLodging.images[0].file) %} {% set image_url = asset('uploads/images/' ~ page.fewoLodging.images[0].file) %}
{% set image_alt = page.title %} {% set image_alt = page.title %}
{% else %} {% else %}

View file

@ -24,57 +24,70 @@
{% for weekIndex in 0..5 %} {% for weekIndex in 0..5 %}
<tr> <tr>
{% for dayIndex in 0..6 %} {% for dayIndex in 0..6 %}
{% set day = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex]|split(',') %} {# @var dayState \AppBundle\Util\CalendarDayState #}
{% if day|length > 1 %} {% set dayState = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex] %}
{% if day[1] == 'reservable' %} {% if dayState.isBookable or dayState.isReserved %}
{% if dayState.isBookable %}
<td> <td>
<a href="/fewo/{{ page.slug }}/fewo-buchen?pnr={{ day[2] }}&fd={{ day[0] < 10 ? '0':'' }}{{day[0]}}{{ calendar[monthIndex]['monthNumber'] < 10 ? '0':'' }}{{calendar[monthIndex]['monthNumber']}}{{calendar[monthIndex]['year']}}" <a href="/fewo/{{ page.slug }}/fewo-buchen?pnr={{ dayState.price.id }}&fd={{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar[monthIndex]['monthNumber'] < 10 ? '0':'' }}{{calendar[monthIndex]['monthNumber']}}{{calendar[monthIndex]['year']}}"
style="color: #5a5a5a;" style="color: #5a5a5a;"
rel="nofollow" rel="nofollow"
> >
{{ day[0] }} {{ dayState.day }}
</a> </a>
</td> </td>
{% else %} {% elseif dayState.isReserved %}
{% if day|length > 3%} {% if dayState.isReservationBegin %}
<td style="background-color: darkgray!important;"> {# @var prevState \AppBundle\Util\CalendarDayState #}
<del>{{ day[0] }}</del> {% set prevState = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex - 1)] %}
</td> {% if prevState.day == 0 or prevState.isReservationEnd %}
{% elseif day|length > 2 and day[2] == 'from' %} <td style="background-color: darkgray!important;">
<td style=" <del>{{ dayState.day }}</del>
background: darkgray!important; </td>
"> {% else %}
<del>{{ day[0] }}</del> <td class="calendarGradientTravelBegin">
</td> <del>{{ dayState.day }}</del>
{% elseif day|length > 2 and day[2] == 'to' %} </td>
{% set nextDay = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex + 1)]|split(',') %} {% endif %}
<td class="calendarGradient"> {% elseif dayState.isReservationEnd %}
<a href="/fewo/{{ page.slug }}/fewo-buchen?pnr={{ nextDay[2] }}&fd={{ day[0] < 10 ? '0':'' }}{{day[0]}}{{ calendar[monthIndex]['monthNumber'] < 10 ? '0':'' }}{{calendar[monthIndex]['monthNumber']}}{{calendar[monthIndex]['year']}}" {# @var nextState \AppBundle\Util\CalendarDayState #}
style="color: white;" {% set nextState = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex + 1)] %}
rel="nofollow" {% if nextState.isReservationBegin %}
> <td style="background-color: darkgray!important;">
<del>{{ day[0] }}</del> <del>{{ dayState.day }}</del>
</a> </td>
</td> {% else %}
<td class="calendarGradientTravelEnd">
<a href="/fewo/{{ page.slug }}/fewo-buchen?pnr={{ dayState.price.id }}&fd={{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar[monthIndex]['monthNumber'] < 10 ? '0':'' }}{{calendar[monthIndex]['monthNumber']}}{{calendar[monthIndex]['year']}}"
style="color: white;"
rel="nofollow"
>
<del>{{ dayState.day }}</del>
</a>
</td>
{% endif %}
{% else %} {% else %}
<td style="background-color: darkgray!important;"> <td style="background-color: darkgray!important;">
<del>{{ day[0] }}</del> <del>{{ dayState.day }}</del>
</td> </td>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% else %} {% else %}
{% if dayState.day == 0 %}
{% if day[0] == 0 %}
<td> <td>
- -
</td> </td>
{% else %} {% else %}
<td style="background-color: darkgray!important"> {% if dayState.isInSeason and not(dayState.isBookable) and not(dayState.isReserved) %}
<del>{{ day[0] }}</del> <td>
</td> <del>{{ dayState.day }}</del>
</td>
{% else %}
<td style="background-color: darkgray!important">
<del>{{ dayState.day }}</del>
</td>
{% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</tr> </tr>

View file

@ -164,7 +164,6 @@ class AdminController extends Controller
$lodging = $fewoLodgingRepo->find($lodgingId); $lodging = $fewoLodgingRepo->find($lodgingId);
$reservations = $calendarUtil->getReservations($lodging); $reservations = $calendarUtil->getReservations($lodging);
$paddedCalendar = $calendarUtil->getCalendarWithPadding(); $paddedCalendar = $calendarUtil->getCalendarWithPadding();
$calendar = $calendarUtil->getCalendar(); $calendar = $calendarUtil->getCalendar();
if (count($lodging->getPrices()->toArray()) != 0) if (count($lodging->getPrices()->toArray()) != 0)
@ -220,6 +219,8 @@ class AdminController extends Controller
return $this->redirect('/admin/fewo/lodgings'); return $this->redirect('/admin/fewo/lodgings');
} }
// todo, WEG
/** /**
* @Route("/admin/fewo/lodgings/{lodgingId}/program", requirements={"lodgingId": "\d+"}) * @Route("/admin/fewo/lodgings/{lodgingId}/program", requirements={"lodgingId": "\d+"})
*/ */
@ -243,6 +244,7 @@ class AdminController extends Controller
$calendar = $paddedCalendar; $calendar = $paddedCalendar;
} }
return $this->render('default/pages/cms/fewoTravelProgram.html.twig', [ return $this->render('default/pages/cms/fewoTravelProgram.html.twig', [
'fewo_lodging' => $lodging, 'fewo_lodging' => $lodging,
'calendar' => $calendar 'calendar' => $calendar

View file

@ -518,9 +518,30 @@
width: 50%; width: 50%;
} }
.calendarGradient{ .calendarGradientTravelBegin {
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: -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%, 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%, #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%, 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%, #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%, 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%, #f2f2f2), color-stop(52%, #f2f2f2), color-stop(52%, darkgrey), color-stop(52%, darkgrey), color-stop(100%, 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));
}
.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));
}

View file

@ -1065,12 +1065,30 @@ a[id^="video_"]:before,
float: left; float: left;
width: 50%; width: 50%;
} }
.calendarGradient { .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));
}
.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: -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: -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: -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)); 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));
} }
.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));
}
.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));
}
/* /*
7) SHORTCODES 7) SHORTCODES
=============================================================== ===============================================================

View file

@ -0,0 +1,184 @@
<?php
namespace AppBundle\Util;
use AppBundle\Entity\FewoLodging;
use AppBundle\Entity\FewoPrice;
use AppBundle\Entity\FewoReservation;
use AppBundle\Entity\FewoSeason;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManager;
class CalendarDayState
{
/**
* @var int
*/
private $day;
/**
* @var FewoPrice
*/
private $price; // der preis / die saison
/**
* @var FewoReservation
*/
private $reservation; // die reservierung //todo wenns vorteile bringt, ne zweite speichern
/**
* @var bool
*/
private $isInSeason; // liegt innerhalb einer saison?;
/**
* @var bool
*/
private $isReserved; // ist reserviert?;
/**
* @var bool
*/
private $isBookable; // ist buchbar? nur wenn isReserved = false und isInSeason = true
/**
* @var bool
*/
private $isReservationBegin; // ist es der anfang einer reservierung?
/**
* @var bool
*/
private $isReservationEnd; // ist es das ende einer reservierung?
/**
* @return int
*/
public function getDay(): int
{
return $this->day;
}
/**
* @param int $day
*/
public function setDay(int $day)
{
$this->day = $day;
}
/**
* @return FewoPrice
*/
public function getPrice(): FewoPrice
{
return $this->price;
}
/**
* @param FewoPrice $price
*/
public function setPrice(FewoPrice $price)
{
$this->price = $price;
}
/**
* @return FewoReservation
*/
public function getReservation(): FewoReservation
{
return $this->reservation;
}
/**
* @param FewoReservation $reservation
*/
public function setReservation(FewoReservation $reservation)
{
$this->reservation = $reservation;
}
/**
* @return bool
*/
public function getIsInSeason(): bool
{
return $this->isInSeason;
}
/**
* @param bool $isInSeason
*/
public function setIsInSeason(bool $isInSeason)
{
$this->isInSeason = $isInSeason;
}
/**
* @return bool
*/
public function getIsReserved(): bool
{
return $this->isReserved;
}
/**
* @param bool $isReserved
*/
public function setIsReserved(bool $isReserved)
{
$this->isReserved = $isReserved;
}
/**
* @return bool
*/
public function getIsBookable(): bool
{
return $this->isBookable;
}
/**
* @param bool $isBookable
*/
public function setIsBookable(bool $isBookable)
{
$this->isBookable = $isBookable;
}
/**
* @return bool
*/
public function getIsReservationBegin(): bool
{
return $this->isReservationBegin;
}
/**
* @param bool $isReservationBegin
*/
public function setIsReservationBegin(bool $isReservationBegin)
{
$this->isReservationBegin = $isReservationBegin;
}
/**
* @return bool
*/
public function getIsReservationEnd(): bool
{
return $this->isReservationEnd;
}
/**
* @param bool $isReservationEnd
*/
public function setIsReservationEnd(bool $isReservationEnd)
{
$this->isReservationEnd = $isReservationEnd;
}
}

View file

@ -8,6 +8,7 @@ use AppBundle\Entity\FewoReservation;
use AppBundle\Entity\FewoSeason; use AppBundle\Entity\FewoSeason;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use AppBundle\Util\CalendarDayState;
class LodgingCalendarUtil class LodgingCalendarUtil
{ {
@ -62,19 +63,43 @@ class LodgingCalendarUtil
for($fwd = 0; $fwd < $actualStartingWeekDay - 1; $fwd++) for($fwd = 0; $fwd < $actualStartingWeekDay - 1; $fwd++)
{ {
$data[] = 0; $day = new CalendarDayState();
$day->setDay(0);
$day->setIsBookable(false);
$day->setIsInSeason(false);
$day->setIsReserved(false);
$day->setIsReservationBegin(false);
$day->setIsReservationEnd(false);
$data[] = $day;
} }
for($d = 1; $d <= $numberDays; $d++) for($d = 1; $d <= $numberDays; $d++)
{ {
$data[] = $d; $day = new CalendarDayState();
$day->setDay($d);
$day->setIsBookable(false);
$day->setIsInSeason(false);
$day->setIsReserved(false);
$day->setIsReservationBegin(false);
$day->setIsReservationEnd(false);
$data[] = $day;
} }
$startIndex = count($data); $startIndex = count($data);
for($lwd = $startIndex; $lwd < 42; $lwd++) for($lwd = $startIndex; $lwd < 42; $lwd++)
{ {
$data[] = 0; $day = new CalendarDayState();
$day->setDay(0);
$day->setIsBookable(false);
$day->setIsInSeason(false);
$day->setIsReserved(false);
$day->setIsReservationBegin(false);
$day->setIsReservationEnd(false);
$data[] = $day;
} }
$calendar[] = [ $calendar[] = [
@ -119,12 +144,23 @@ class LodgingCalendarUtil
$weekDay = $weekDays[$date['wday']]; $weekDay = $weekDays[$date['wday']];
$numberDays = $this->daysInMonth($actualMonth, $actualCurrentYear); $numberDays = $this->daysInMonth($actualMonth, $actualCurrentYear);
/** @var CalendarDayState[] $data */
$data = null; $data = null;
// alle Wochentage // alle Wochentage
for($d = 1; $d <= $numberDays; $d++) for($d = 1; $d <= $numberDays; $d++)
{ {
$data[] = $d; // standard-vorbelegung
$day = new CalendarDayState();
$day->setDay($d);
$day->setIsBookable(false);
$day->setIsInSeason(false);
$day->setIsReserved(false);
$day->setIsReservationBegin(false);
$day->setIsReservationEnd(false);
$data[] = $day;
} }
$calendar[] = [ $calendar[] = [
@ -141,6 +177,7 @@ class LodgingCalendarUtil
return $calendar; return $calendar;
} }
/** /**
* @param FewoLodging $lodging * @param FewoLodging $lodging
* @return array|null * @return array|null
@ -190,7 +227,9 @@ class LodgingCalendarUtil
* @param $appendix * @param $appendix
* @return mixed * @return mixed
*/ */
private function markCalendarDays($calendar, \DateTime $fromDate, \DateTime $toDate, $appendix, $reservationMode = false) private function markCalendarDays($calendar, \DateTime $fromDate, \DateTime $toDate,
$reservationMode = false,
FewoPrice $price = null, FewoReservation $reservation = null)
{ {
$startDay = $fromDate->format('j'); $startDay = $fromDate->format('j');
$startMonth = $fromDate->format('n'); $startMonth = $fromDate->format('n');
@ -215,8 +254,10 @@ class LodgingCalendarUtil
$endCalendarIndex = $this->getMonthIndex($calendar, $endMonth); $endCalendarIndex = $this->getMonthIndex($calendar, $endMonth);
// anfang und ende innerhalb eines monats
if($startCalendarIndex == $endCalendarIndex) if($startCalendarIndex == $endCalendarIndex)
{ {
/** @var CalendarDayState[] $data */
$data = $calendar[$startCalendarIndex]['data']; $data = $calendar[$startCalendarIndex]['data'];
$calendar[$startCalendarIndex]['marked'] = 1; $calendar[$startCalendarIndex]['marked'] = 1;
@ -224,50 +265,90 @@ class LodgingCalendarUtil
$startIndex = $startDay - 1; $startIndex = $startDay - 1;
$endIndex = $endDay - 1; $endIndex = $endDay - 1;
$firstDay = explode(',', $data[$startIndex]); for ($i = $startIndex; $i <= $endIndex; $i++)
if(count($firstDay) > 1 && $reservationMode == false)
$startIndex = $startIndex + 1;
for($i = $startIndex; $i <= $endIndex; $i++)
{ {
if ($reservationMode)
if($i == $startIndex && $reservationMode)
{ {
$data[$i] = $data[$i].$appendix.",from"; if ($i == $startIndex)
} elseif($i == $endIndex && $reservationMode) { {
$data[$i] = $data[$i].$appendix.",to"; $data[$i]->setIsReserved(true);
} else { $data[$i]->setIsReservationBegin(true);
$data[$i] = $data[$i].$appendix; $data[$i]->setReservation($reservation);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(false);
}
elseif ($i == $endIndex)
{
$data[$i]->setIsReserved(true);
$data[$i]->setIsReservationEnd(true);
$data[$i]->setReservation($reservation);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(false);
//$data[$i]->setIsBookable(true);
}
else
{
$data[$i]->setIsReserved(true);
$data[$i]->setReservation($reservation);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(false);
}
}
else
{
$data[$i]->setIsReserved(false);
$data[$i]->setPrice($price);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(true);
} }
} }
$calendar[$startCalendarIndex]['data'] = $data; $calendar[$startCalendarIndex]['data'] = $data;
} }
else else
{ {
// erster monat
/** @var CalendarDayState[] $data */
$data = $calendar[$startCalendarIndex]['data']; $data = $calendar[$startCalendarIndex]['data'];
$calendar[$startCalendarIndex]['marked'] = 1; $calendar[$startCalendarIndex]['marked'] = 1;
$startIndex = $startDay - 1; $startIndex = $startDay - 1;
$firstDay = explode(',', $data[$startIndex]);
if(count($firstDay) > 1 && $reservationMode == false)
$startIndex = $startIndex + 1;
$endIndex = count($data) - 1; $endIndex = count($data) - 1;
for($i = $startIndex; $i <= $endIndex; $i++) for($i = $startIndex; $i <= $endIndex; $i++)
{ {
if($i == $startIndex && $reservationMode) if ($reservationMode)
{ {
$data[$i] = $data[$i].$appendix.",from"; if ($i == $startIndex)
} else { {
$data[$i] = $data[$i].$appendix; $data[$i]->setIsReserved(true);
$data[$i]->setIsReservationBegin(true);
$data[$i]->setReservation($reservation);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(false);
}
else
{
$data[$i]->setIsReserved(true);
$data[$i]->setReservation($reservation);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(false);
}
}
else
{
$data[$i]->setIsReserved(false);
$data[$i]->setPrice($price);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(true);
} }
} }
$calendar[$startCalendarIndex]['data'] = $data; $calendar[$startCalendarIndex]['data'] = $data;
// letzter monat
/** @var CalendarDayState[] $data */
$data = $calendar[$endCalendarIndex]['data']; $data = $calendar[$endCalendarIndex]['data'];
$calendar[$endCalendarIndex]['marked'] = 1; $calendar[$endCalendarIndex]['marked'] = 1;
@ -276,17 +357,41 @@ class LodgingCalendarUtil
$endIndex = $endDay - 1; $endIndex = $endDay - 1;
for($i = $startIndex; $i <= $endIndex; $i++) for($i = $startIndex; $i <= $endIndex; $i++)
{ {
if($i == $endIndex && $reservationMode)
if ($reservationMode)
{ {
$data[$i] = $data[$i].$appendix.",to"; if ($i == $endIndex)
} else { {
$data[$i] = $data[$i].$appendix; $data[$i]->setIsReserved(true);
$data[$i]->setIsReservationEnd(true);
$data[$i]->setReservation($reservation);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(false); // todo, hier evtl direkt true
//$data[$i]->setIsBookable(true);
}
else
{
$data[$i]->setIsReserved(true);
$data[$i]->setReservation($reservation);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(false);
}
}
else
{
$data[$i]->setIsReserved(false);
$data[$i]->setPrice($price);
$data[$i]->setIsInSeason(true);
$data[$i]->setIsBookable(true);
} }
} }
$calendar[$endCalendarIndex]['data'] = $data; $calendar[$endCalendarIndex]['data'] = $data;
// alle monate dazwischen
for($i = $startCalendarIndex + 1; $i < $endCalendarIndex; $i++) for($i = $startCalendarIndex + 1; $i < $endCalendarIndex; $i++)
{ {
/** @var CalendarDayState[] $data */
$data = $calendar[$i]['data']; $data = $calendar[$i]['data'];
$calendar[$i]['marked'] = 1; $calendar[$i]['marked'] = 1;
@ -295,7 +400,20 @@ class LodgingCalendarUtil
$endIndex = count($data) - 1; $endIndex = count($data) - 1;
for($j = $startIndex; $j <= $endIndex; $j++) for($j = $startIndex; $j <= $endIndex; $j++)
{ {
$data[$j] = $data[$j].$appendix; if ($reservationMode)
{
$data[$j]->setIsReserved(true);
$data[$j]->setReservation($reservation);
$data[$j]->setIsInSeason(true);
$data[$j]->setIsBookable(false);
}
else
{
$data[$j]->setIsReserved(false);
$data[$j]->setPrice($price);
$data[$j]->setIsInSeason(true);
$data[$j]->setIsBookable(true);
}
} }
$calendar[$i]['data'] = $data; $calendar[$i]['data'] = $data;
} }
@ -307,42 +425,107 @@ class LodgingCalendarUtil
{ {
for($i = 0; $i < 12; $i++) for($i = 0; $i < 12; $i++)
{ {
if($calendar[$i]['marked'] == 1 && $extensionCalendar[$i]['marked'] == 1) /** @var CalendarDayState[] $calendarData */
$calendarData = $calendar[$i]['data'];
/** @var CalendarDayState[] $extensionCalendarData */
$extensionCalendarData = $extensionCalendar[$i]['data'];
$endIndex = count($calendarData);
for($j = 0; $j < $endIndex; $j++)
{ {
$calendarData = $calendar[$i]['data']; //$mergedPricesAndReservationsCalendar = $this->mergeCalendarsNew($pricesCalendar, $reservationsCalendar, false);
$extensionCalendarData = $extensionCalendar[$i]['data']; //$actuallyReservableDaysCalendar = $this->filterReservableDays($lodging, $mergedPricesAndReservationsCalendar);
//$resultCalendar = $this->mergeCalendars($actuallyReservableDaysCalendar, $reservationsCalendar, true);
$endIndex = count($calendarData); if ($withFromTo)
for($j = 0; $j < $endIndex; $j++)
{ {
if(strlen($extensionCalendarData[$j]) > 2) if ($extensionCalendarData[$j]->getIsInSeason())
{ {
if($withFromTo) //$calendarData[$j] = $extensionCalendarData[$j];
{ $price = $extensionCalendarData[$j]->getPrice();
$calDay = explode(',', $calendarData[$j]); $calendarData[$j]->setIsInSeason(true);
$extCalDay = explode(',', $extensionCalendarData[$j]); $calendarData[$j]->setPrice($price);
if(count ($calDay) > 1 && $calDay[1] == "reservable" && count($extCalDay) > 2 && $extCalDay[2] == 'to')
{
$calendarData[$j] = $extensionCalendarData[$j].",reservable".','.$calDay[2];
}
else
$calendarData[$j] = $extensionCalendarData[$j];
}
else
{
$calendarData[$j] = $extensionCalendarData[$j];
}
} }
} }
$calendar[$i]['data'] = $calendarData;
if ($extensionCalendarData[$j]->getIsReserved())
{
// braucht man das überhaupt noch?
if ($withFromTo)
{
// zweite runde $actuallyReservableDaysCalendar merge mit $reservationsCalendar
if (!($calendarData[$j]->getIsBookable() && $extensionCalendarData[$j]->getIsReservationEnd()))
{
//$calendarData[$j] = $extensionCalendarData[$j];
$price = $calendarData[$j]->getPrice();
//$calendarData[$j] = $extensionCalendarData[$j];// todo
$calendarData[$j]->setIsBookable(false);
$calendarData[$j]->setIsReserved(true);
$calendarData[$j]->setReservation($extensionCalendarData[$j]->getReservation());
$calendarData[$j]->setIsReservationBegin($extensionCalendarData[$j]->getIsReservationBegin());
$calendarData[$j]->setIsReservationEnd($extensionCalendarData[$j]->getIsReservationEnd());
if ($calendarData[$j]->getIsReservationEnd() && $extensionCalendarData[$j]->getIsReservationBegin())
{
$calendarData[$j]->setIsReservationBegin(false);
$calendarData[$j]->setIsReservationEnd(false);
}
$calendarData[$j]->setIsInSeason(true);
$calendarData[$j]->setPrice($price);
}
}
else
{
// erste runde $pricesCalendar merge mit $reservationsCalendar
$price = $calendarData[$j]->getPrice();
$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);
}
/** @var FewoPrice $price */
$calendarData[$j]->setIsInSeason(true);
$calendarData[$j]->setPrice($price);
}
}
}
$calendar[$i]['data'] = $calendarData;
}
return $calendar;
}
/** @var CalendarDayState[] $calendarMonth */
private function findCalendarDayIndexInMonth($dayNumber, $calendarMonth)
{
$result = 0;
for ($i = 0; $i < count($calendarMonth); $i++)
{
if ($calendarMonth[$i]->getDay() == $dayNumber)
{
$result = $i;
break;
} }
} }
return $result;
return $calendar;
} }
public function mergeWithPaddedCalendar($calendar, $paddedCalendar) public function mergeWithPaddedCalendar($calendar, $paddedCalendar)
@ -351,7 +534,10 @@ class LodgingCalendarUtil
{ {
$calendarDataCurrMonth = $calendar[$i]['data']; $calendarDataCurrMonth = $calendar[$i]['data'];
$paddedCalendarDataCurrMonth = $paddedCalendar[$i]['data']; $paddedCalendarDataCurrMonth = $paddedCalendar[$i]['data'];
$startIndex = array_search(1, $paddedCalendarDataCurrMonth);
$startIndex = $this->findCalendarDayIndexInMonth(1, $paddedCalendarDataCurrMonth);
//$startIndex = array_search(1, $paddedCalendarDataCurrMonth);
for($j = 0; $j < count($calendarDataCurrMonth); $j++, $startIndex++) for($j = 0; $j < count($calendarDataCurrMonth); $j++, $startIndex++)
{ {
$paddedCalendarDataCurrMonth[$startIndex] = $calendarDataCurrMonth[$j]; $paddedCalendarDataCurrMonth[$startIndex] = $calendarDataCurrMonth[$j];
@ -361,6 +547,7 @@ class LodgingCalendarUtil
return $paddedCalendar; return $paddedCalendar;
} }
private function isNextDay($current, $next) private function isNextDay($current, $next)
{ {
$result = false; $result = false;
@ -413,69 +600,73 @@ class LodgingCalendarUtil
for($currMonthIndex = 0; $currMonthIndex < count($calendar); $currMonthIndex++) for($currMonthIndex = 0; $currMonthIndex < count($calendar); $currMonthIndex++)
{ {
$currMonth = $calendar[$currMonthIndex]; $currMonth = $calendar[$currMonthIndex];
/** @var CalendarDayState[] $data */
$data = $currMonth['data']; $data = $currMonth['data'];
for($currDayIndex = 0; $currDayIndex < count($data); $currDayIndex++) for($currDayIndex = 0; $currDayIndex < count($data); $currDayIndex++)
{ {
$currDay = explode(',', $data[$currDayIndex]); //$currDay = explode(',', $data[$currDayIndex]);
$currDay = $data[$currDayIndex];
if(count($currDay) > 1) if ($currDay->getIsBookable() || $currDay->getIsReserved())
{ {
if($currDay[1] == "reservable") if ($currDay->getIsBookable())
{ {
$priceId = $currDay[2]; $price = $currDay->getPrice();
$priceId = $price->getId();
if($lastReservablePriceId == 0) if ($lastReservablePriceId == 0)
{
$lastReservablePriceId = $priceId; $lastReservablePriceId = $priceId;
}
if($lastReservablePriceId != $priceId) if($lastReservablePriceId != $priceId)
{ {
$price = $priceRepo->find($lastReservablePriceId); $lastPrice = $priceRepo->find($lastReservablePriceId);
/** @var FewoSeason $season */ /** @var FewoSeason $season */
$season = $price->getSeason(); $season = $lastPrice->getSeason();
$actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay()); $actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay());
$this->processRest($actuallyReservableDays, $lastReservablePriceId, $cleanCalendar); $this->processRest($actuallyReservableDays, $lastPrice, $cleanCalendar); //todo
$lastReservablePriceId = $priceId; $lastReservablePriceId = $priceId;
$potentiallyReservableDays = []; $potentiallyReservableDays = [];
$actuallyReservableDays = []; $actuallyReservableDays = [];
} }
$currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay[0])); $currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay->getDay()));
$potentiallyReservableDays[] = $currentDayDate; $potentiallyReservableDays[] = $currentDayDate;
} }
elseif(count($currDay) > 2 && $currDay[2] == "from") elseif ($currDay->getIsReserved() && $currDay->getIsReservationBegin())
{ {
$currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay[0])); $currentDayDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay->getDay()));
$potentiallyReservableDays[] = $currentDayDate; $potentiallyReservableDays[] = $currentDayDate;
} }
} }
else else
{ {
if($lastReservablePriceId == $priceId && $lastReservablePriceId != 0) if($lastReservablePriceId == $priceId && $lastReservablePriceId != 0)
{ {
$price = $priceRepo->find($lastReservablePriceId); $lastPrice = $priceRepo->find($lastReservablePriceId);
/** @var FewoSeason $season */ /** @var FewoSeason $season */
$season = $price->getSeason(); $season = $lastPrice->getSeason();
$actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay()); $actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay());
$this->processRest($actuallyReservableDays, $lastReservablePriceId, $cleanCalendar); $this->processRest($actuallyReservableDays, $lastPrice, $cleanCalendar); //todo
$lastReservablePriceId = $priceId; $lastReservablePriceId = $priceId;
$potentiallyReservableDays = []; $potentiallyReservableDays = [];
$actuallyReservableDays = []; $actuallyReservableDays = [];
} }
} }
} }
} }
return $cleanCalendar; return $cleanCalendar;
} }
private function processPotentiallyReservableDays($potentiallyReservableDays, $minimumStay) private function processPotentiallyReservableDays($potentiallyReservableDays, $minimumStay)
{ {
$coherentDays = []; $coherentDays = [];
@ -531,35 +722,40 @@ class LodgingCalendarUtil
return $actuallyReservableDays; return $actuallyReservableDays;
} }
private function processRest($actuallyReservableDays, $priceId, &$cleanCalendar)
private function processRest($actuallyReservableDays, FewoPrice $price, &$cleanCalendar)
{ {
for($currMonthIndex = 0; $currMonthIndex < count($cleanCalendar); $currMonthIndex++) for($currMonthIndex = 0; $currMonthIndex < count($cleanCalendar); $currMonthIndex++)
{ {
$currMonth = $cleanCalendar[$currMonthIndex]; $currMonth = $cleanCalendar[$currMonthIndex];
/** @var CalendarDayState[] $data */
$data = $currMonth['data']; $data = $currMonth['data'];
$startIndex = array_search(1, $data); for($currDayIndex = 0; $currDayIndex < count($data); $currDayIndex++)
$endIndex = $startIndex + ($currMonth['numberDays']);
for($currDayIndex = $startIndex; $currDayIndex < $endIndex; $currDayIndex++)
{ {
$currDay = explode(',', $data[$currDayIndex]); $currDay = $data[$currDayIndex];
$currentDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay[0])); $currentDate = date("d.m.Y", strtotime($currMonth['year']."-".$currMonth['monthNumber']."-".$currDay->getDay()));
if(in_array($currentDate, $actuallyReservableDays)) if (in_array($currentDate, $actuallyReservableDays))
{ {
$data[$currDayIndex] = $data[$currDayIndex].",reservable,".$priceId; $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);
$currMonth['marked'] = 1; $currMonth['marked'] = 1;
} }
} }
$currMonth['data'] = $data; $currMonth['data'] = $data;
$cleanCalendar[$currMonthIndex] = $currMonth; $cleanCalendar[$currMonthIndex] = $currMonth;
} }
} }
/** /**
* @param FewoLodging $lodging * @param FewoLodging $lodging
* @param $calendar * @param $calendar
@ -580,17 +776,12 @@ class LodgingCalendarUtil
{ {
/** @var FewoSeason $season */ /** @var FewoSeason $season */
$season = $price->getSeason(); $season = $price->getSeason();
$appendix = ',reservable,'.$price->getId();
$fromDate = $season->getFromDate(); $fromDate = $season->getFromDate();
$toDate = $season->getToDate(); $toDate = $season->getToDate();
if($toDate < $today) if(!($toDate < $today))
{ {
$pricesCalendar = $this->markCalendarDays($pricesCalendar, $fromDate, $toDate, false, $price, null); //TODO fast fertig
}
else
{
$pricesCalendar = $this->markCalendarDays($pricesCalendar, $fromDate, $toDate, $appendix, false);
} }
} }
@ -601,7 +792,7 @@ class LodgingCalendarUtil
$fromDate = $reservation->getFromDate(); $fromDate = $reservation->getFromDate();
$toDate = $reservation->getToDate(); $toDate = $reservation->getToDate();
$reservationsCalendar = $this->markCalendarDays($reservationsCalendar, $fromDate, $toDate, $appendix, true); $reservationsCalendar = $this->markCalendarDays($reservationsCalendar, $fromDate, $toDate, true, null, $reservation); //TODO fast fertig
} }
$mergedPricesAndReservationsCalendar = $this->mergeCalendars($pricesCalendar, $reservationsCalendar, false); $mergedPricesAndReservationsCalendar = $this->mergeCalendars($pricesCalendar, $reservationsCalendar, false);
@ -611,6 +802,7 @@ class LodgingCalendarUtil
return $resultCalendar; return $resultCalendar;
} }
public function convertDate($date) public function convertDate($date)
{ {
$result = substr($date, 0, 2).'.'.substr($date, 2, 2).'.'.substr($date, 4, 4); $result = substr($date, 0, 2).'.'.substr($date, 2, 2).'.'.substr($date, 4, 4);

View file

@ -35,6 +35,10 @@ class FewoReservationValidator extends ConstraintValidator
*/ */
public function validate($reservation, Constraint $constraint) public function validate($reservation, Constraint $constraint)
{ {
$fromDate = $reservation->getFromDate();
$toDate = $reservation->getToDate();
$lodging = $reservation->getLodging(); $lodging = $reservation->getLodging();
$reservations = $lodging->getReservations(); $reservations = $lodging->getReservations();
$seasons = $lodging->getSeasons(); $seasons = $lodging->getSeasons();
@ -57,7 +61,7 @@ class FewoReservationValidator extends ConstraintValidator
$reservationToDate = $reservation->getToDate(); $reservationToDate = $reservation->getToDate();
if($this->alreadyReserved($reservation->getFromDate(), $reservation->getToDate(), $reservationFromDate, $reservationToDate)) if($this->alreadyReserved($fromDate, $toDate, $reservationFromDate, $reservationToDate))
{ {
$alreadyReserved = true; $alreadyReserved = true;
} }