#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">
{% for month in calendar %}
<thead>
{% for monthIndex in 0..11 %}
<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>
<th colspan="7">
{{ month['monthName'] }} {{ month['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>
{% for dayIndex in 0..6 %}
{% set day = month['data'][(weekIndex * 7) + dayIndex]|split(',') %}
{% if day|length > 1 %}
{% if day[1] == 'reservable' %}
<td style="background-color: green!important;">
<a href="/admin/fewo/lodgings/{{ lodging.id }}/reservations/new/{{ day[0] < 10 ? '0':'' }}{{day[0]}}{{ month['monthNumber'] < 10 ? '0':'' }}{{month['monthNumber']}}{{month['year']}}"
{% 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 %}
<td style="background-color: green!important;">
<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;"
{#class="btn btn-primary"#}
rel="nofollow"
>
{{ dayState.day }}
</a>
</td>
{% 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 %}
<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="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;"
{#class="btn btn-primary"#}
rel="nofollow"
>
{{ day[0] }}
{{ dayState.day }}
</a>
</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 %}
{% else %}
<td>
{% if day[0] == 0 %}
-
{% else %}
{{ day[0] }}
{% endif %}
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
{% else %}
{% if dayState.day == 0 %}
<td>
-
</td>
{% else %}
<td>{{ dayState.day }}</td>
{% endif %}
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
{% endfor %}
</table>

View file

@ -4,7 +4,7 @@
{% 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_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_alt = page.title %}
{% else %}

View file

@ -24,57 +24,70 @@
{% for weekIndex in 0..5 %}
<tr>
{% for dayIndex in 0..6 %}
{% set day = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex]|split(',') %}
{% if day|length > 1 %}
{% if day[1] == 'reservable' %}
{# @var dayState \AppBundle\Util\CalendarDayState #}
{% set dayState = calendar[monthIndex]['data'][(weekIndex * 7) + dayIndex] %}
{% if dayState.isBookable or dayState.isReserved %}
{% if dayState.isBookable %}
<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;"
rel="nofollow"
>
{{ day[0] }}
{{ dayState.day }}
</a>
</td>
{% else %}
{% if day|length > 3%}
<td style="background-color: darkgray!important;">
<del>{{ day[0] }}</del>
</td>
{% elseif day|length > 2 and day[2] == 'from' %}
<td style="
background: darkgray!important;
">
<del>{{ day[0] }}</del>
</td>
{% elseif day|length > 2 and day[2] == 'to' %}
{% set nextDay = calendar[monthIndex]['data'][(weekIndex * 7) + (dayIndex + 1)]|split(',') %}
<td class="calendarGradient">
<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']}}"
style="color: white;"
rel="nofollow"
>
<del>{{ day[0] }}</del>
</a>
</td>
{% 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 %}
<td style="background-color: darkgray!important;">
<del>{{ dayState.day }}</del>
</td>
{% else %}
<td class="calendarGradientTravelBegin">
<del>{{ dayState.day }}</del>
</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: darkgray!important;">
<del>{{ dayState.day }}</del>
</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 %}
<td style="background-color: darkgray!important;">
<del>{{ day[0] }}</del>
<del>{{ dayState.day }}</del>
</td>
{% endif %}
{% endif %}
{% else %}
{% if day[0] == 0 %}
{% if dayState.day == 0 %}
<td>
-
</td>
{% else %}
<td style="background-color: darkgray!important">
<del>{{ day[0] }}</del>
</td>
{% if dayState.isInSeason and not(dayState.isBookable) and not(dayState.isReserved) %}
<td>
<del>{{ dayState.day }}</del>
</td>
{% else %}
<td style="background-color: darkgray!important">
<del>{{ dayState.day }}</del>
</td>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</tr>

View file

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

View file

@ -518,9 +518,30 @@
width: 50%;
}
.calendarGradient{
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));
.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));
}
.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;
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: -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));
}
.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
===============================================================

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 Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManager;
use AppBundle\Util\CalendarDayState;
class LodgingCalendarUtil
{
@ -62,19 +63,43 @@ class LodgingCalendarUtil
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++)
{
$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);
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[] = [
@ -119,12 +144,23 @@ class LodgingCalendarUtil
$weekDay = $weekDays[$date['wday']];
$numberDays = $this->daysInMonth($actualMonth, $actualCurrentYear);
/** @var CalendarDayState[] $data */
$data = null;
// alle Wochentage
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[] = [
@ -141,6 +177,7 @@ class LodgingCalendarUtil
return $calendar;
}
/**
* @param FewoLodging $lodging
* @return array|null
@ -190,7 +227,9 @@ class LodgingCalendarUtil
* @param $appendix
* @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');
$startMonth = $fromDate->format('n');
@ -215,8 +254,10 @@ class LodgingCalendarUtil
$endCalendarIndex = $this->getMonthIndex($calendar, $endMonth);
// anfang und ende innerhalb eines monats
if($startCalendarIndex == $endCalendarIndex)
{
/** @var CalendarDayState[] $data */
$data = $calendar[$startCalendarIndex]['data'];
$calendar[$startCalendarIndex]['marked'] = 1;
@ -224,50 +265,90 @@ class LodgingCalendarUtil
$startIndex = $startDay - 1;
$endIndex = $endDay - 1;
$firstDay = explode(',', $data[$startIndex]);
if(count($firstDay) > 1 && $reservationMode == false)
$startIndex = $startIndex + 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";
} elseif($i == $endIndex && $reservationMode) {
$data[$i] = $data[$i].$appendix.",to";
} else {
$data[$i] = $data[$i].$appendix;
if ($i == $startIndex)
{
$data[$i]->setIsReserved(true);
$data[$i]->setIsReservationBegin(true);
$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;
}
else
{
// erster monat
/** @var CalendarDayState[] $data */
$data = $calendar[$startCalendarIndex]['data'];
$calendar[$startCalendarIndex]['marked'] = 1;
$startIndex = $startDay - 1;
$firstDay = explode(',', $data[$startIndex]);
if(count($firstDay) > 1 && $reservationMode == false)
$startIndex = $startIndex + 1;
$endIndex = count($data) - 1;
for($i = $startIndex; $i <= $endIndex; $i++)
{
if($i == $startIndex && $reservationMode)
if ($reservationMode)
{
$data[$i] = $data[$i].$appendix.",from";
} else {
$data[$i] = $data[$i].$appendix;
if ($i == $startIndex)
{
$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;
// letzter monat
/** @var CalendarDayState[] $data */
$data = $calendar[$endCalendarIndex]['data'];
$calendar[$endCalendarIndex]['marked'] = 1;
@ -276,17 +357,41 @@ class LodgingCalendarUtil
$endIndex = $endDay - 1;
for($i = $startIndex; $i <= $endIndex; $i++)
{
if($i == $endIndex && $reservationMode)
if ($reservationMode)
{
$data[$i] = $data[$i].$appendix.",to";
} else {
$data[$i] = $data[$i].$appendix;
if ($i == $endIndex)
{
$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;
// alle monate dazwischen
for($i = $startCalendarIndex + 1; $i < $endCalendarIndex; $i++)
{
/** @var CalendarDayState[] $data */
$data = $calendar[$i]['data'];
$calendar[$i]['marked'] = 1;
@ -295,7 +400,20 @@ class LodgingCalendarUtil
$endIndex = count($data) - 1;
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;
}
@ -307,42 +425,107 @@ class LodgingCalendarUtil
{
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'];
$extensionCalendarData = $extensionCalendar[$i]['data'];
//$mergedPricesAndReservationsCalendar = $this->mergeCalendarsNew($pricesCalendar, $reservationsCalendar, false);
//$actuallyReservableDaysCalendar = $this->filterReservableDays($lodging, $mergedPricesAndReservationsCalendar);
//$resultCalendar = $this->mergeCalendars($actuallyReservableDaysCalendar, $reservationsCalendar, true);
$endIndex = count($calendarData);
for($j = 0; $j < $endIndex; $j++)
if ($withFromTo)
{
if(strlen($extensionCalendarData[$j]) > 2)
if ($extensionCalendarData[$j]->getIsInSeason())
{
if($withFromTo)
{
$calDay = explode(',', $calendarData[$j]);
$extCalDay = explode(',', $extensionCalendarData[$j]);
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];
}
//$calendarData[$j] = $extensionCalendarData[$j];
$price = $extensionCalendarData[$j]->getPrice();
$calendarData[$j]->setIsInSeason(true);
$calendarData[$j]->setPrice($price);
}
}
$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 $calendar;
return $result;
}
public function mergeWithPaddedCalendar($calendar, $paddedCalendar)
@ -351,7 +534,10 @@ class LodgingCalendarUtil
{
$calendarDataCurrMonth = $calendar[$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++)
{
$paddedCalendarDataCurrMonth[$startIndex] = $calendarDataCurrMonth[$j];
@ -361,6 +547,7 @@ class LodgingCalendarUtil
return $paddedCalendar;
}
private function isNextDay($current, $next)
{
$result = false;
@ -413,69 +600,73 @@ class LodgingCalendarUtil
for($currMonthIndex = 0; $currMonthIndex < count($calendar); $currMonthIndex++)
{
$currMonth = $calendar[$currMonthIndex];
/** @var CalendarDayState[] $data */
$data = $currMonth['data'];
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;
}
if($lastReservablePriceId != $priceId)
{
$price = $priceRepo->find($lastReservablePriceId);
$lastPrice = $priceRepo->find($lastReservablePriceId);
/** @var FewoSeason $season */
$season = $price->getSeason();
$season = $lastPrice->getSeason();
$actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay());
$this->processRest($actuallyReservableDays, $lastReservablePriceId, $cleanCalendar);
$this->processRest($actuallyReservableDays, $lastPrice, $cleanCalendar); //todo
$lastReservablePriceId = $priceId;
$potentiallyReservableDays = [];
$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;
}
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;
}
}
else
{
if($lastReservablePriceId == $priceId && $lastReservablePriceId != 0)
{
$price = $priceRepo->find($lastReservablePriceId);
$lastPrice = $priceRepo->find($lastReservablePriceId);
/** @var FewoSeason $season */
$season = $price->getSeason();
$season = $lastPrice->getSeason();
$actuallyReservableDays = $this->processPotentiallyReservableDays($potentiallyReservableDays, $season->getMinimumStay());
$this->processRest($actuallyReservableDays, $lastReservablePriceId, $cleanCalendar);
$this->processRest($actuallyReservableDays, $lastPrice, $cleanCalendar); //todo
$lastReservablePriceId = $priceId;
$potentiallyReservableDays = [];
$actuallyReservableDays = [];
}
}
}
}
return $cleanCalendar;
}
private function processPotentiallyReservableDays($potentiallyReservableDays, $minimumStay)
{
$coherentDays = [];
@ -531,35 +722,40 @@ class LodgingCalendarUtil
return $actuallyReservableDays;
}
private function processRest($actuallyReservableDays, $priceId, &$cleanCalendar)
private function processRest($actuallyReservableDays, FewoPrice $price, &$cleanCalendar)
{
for($currMonthIndex = 0; $currMonthIndex < count($cleanCalendar); $currMonthIndex++)
{
$currMonth = $cleanCalendar[$currMonthIndex];
/** @var CalendarDayState[] $data */
$data = $currMonth['data'];
$startIndex = array_search(1, $data);
$endIndex = $startIndex + ($currMonth['numberDays']);
for($currDayIndex = $startIndex; $currDayIndex < $endIndex; $currDayIndex++)
for($currDayIndex = 0; $currDayIndex < count($data); $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['data'] = $data;
$cleanCalendar[$currMonthIndex] = $currMonth;
}
}
/**
* @param FewoLodging $lodging
* @param $calendar
@ -580,17 +776,12 @@ class LodgingCalendarUtil
{
/** @var FewoSeason $season */
$season = $price->getSeason();
$appendix = ',reservable,'.$price->getId();
$fromDate = $season->getFromDate();
$toDate = $season->getToDate();
if($toDate < $today)
if(!($toDate < $today))
{
}
else
{
$pricesCalendar = $this->markCalendarDays($pricesCalendar, $fromDate, $toDate, $appendix, false);
$pricesCalendar = $this->markCalendarDays($pricesCalendar, $fromDate, $toDate, false, $price, null); //TODO fast fertig
}
}
@ -601,7 +792,7 @@ class LodgingCalendarUtil
$fromDate = $reservation->getFromDate();
$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);
@ -611,6 +802,7 @@ class LodgingCalendarUtil
return $resultCalendar;
}
public function convertDate($date)
{
$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)
{
$fromDate = $reservation->getFromDate();
$toDate = $reservation->getToDate();
$lodging = $reservation->getLodging();
$reservations = $lodging->getReservations();
$seasons = $lodging->getSeasons();
@ -57,7 +61,7 @@ class FewoReservationValidator extends ConstraintValidator
$reservationToDate = $reservation->getToDate();
if($this->alreadyReserved($reservation->getFromDate(), $reservation->getToDate(), $reservationFromDate, $reservationToDate))
if($this->alreadyReserved($fromDate, $toDate, $reservationFromDate, $reservationToDate))
{
$alreadyReserved = true;
}