git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3441 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
0af86f618c
commit
0ac8127653
10 changed files with 365 additions and 73 deletions
19
trunk/.idea/dataSources.xml
generated
Normal file
19
trunk/.idea/dataSources.xml
generated
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="sterntours" uuid="9aaa169a-f6e1-4dca-aa3b-b544a852f49e">
|
||||||
|
<driver-ref>mysql</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:mysql://localhost:3306/sterntours</jdbc-url>
|
||||||
|
<driver-properties>
|
||||||
|
<property name="autoReconnect" value="true" />
|
||||||
|
<property name="zeroDateTimeBehavior" value="convertToNull" />
|
||||||
|
<property name="tinyInt1isBit" value="false" />
|
||||||
|
<property name="characterEncoding" value="utf8" />
|
||||||
|
<property name="characterSetResults" value="utf8" />
|
||||||
|
<property name="yearIsDateType" value="false" />
|
||||||
|
</driver-properties>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
trunk/.idea/vcs.xml
generated
Normal file
6
trunk/.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
@ -25,46 +25,23 @@
|
||||||
{# @var dayState \AppBundle\Util\CalendarDayState #}
|
{# @var dayState \AppBundle\Util\CalendarDayState #}
|
||||||
{% set dayState = calendar_month['data'][(weekIndex * 7) + dayIndex] %}
|
{% set dayState = calendar_month['data'][(weekIndex * 7) + dayIndex] %}
|
||||||
|
|
||||||
{% set is_past_date = dayState.date is not empty and date(dayState.date) < date('now') %}
|
<td class="{{ dayState.getCssClass }} {% if dayState.isBookable %}active{% endif %}">
|
||||||
|
{% if dayState.isBookable %}
|
||||||
{# Set cell class #}
|
<a href="{{ page.urlPath }}/buchen?pnr={{ dayState.price.id }}&fd={{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar_month['monthNumber'] < 10 ? '0':'' }}{{calendar_month['monthNumber']}}{{calendar_month['year']}}"
|
||||||
|
rel="nofollow" class="table-link"
|
||||||
{% if dayState.isReserved and (not dayState.isReservationBegin and not dayState.isReservationEnd) %}
|
>
|
||||||
{% set cell_class = 'calendar-day-disabled' %}
|
{{ dayState.day }}
|
||||||
{% elseif dayState.day == 0 %}
|
</a>
|
||||||
{% set cell_class = 'calendar-day-non' %}
|
{% elseif dayState.day == 0 %}
|
||||||
{% elseif is_past_date %}
|
|
||||||
{% set cell_class = 'calendar-day-past' %}
|
{% else %}
|
||||||
{% elseif not dayState.isInSeason %}
|
{% if dayState.isPastDate %}
|
||||||
{% set cell_class = 'calendar-day-non' %}
|
<del style="color:#989898;">{{ dayState.day }}</del>
|
||||||
{% elseif dayState.isReservationBegin %}
|
{% else %}
|
||||||
{% set cell_class = 'calendar-day-reservation-begin' %}
|
{{ dayState.day }}
|
||||||
{% elseif dayState.isReservationEnd %}
|
{% endif %}
|
||||||
{% set cell_class = 'calendar-day-reservation-end' %}
|
{% endif %}
|
||||||
{% else %}
|
</td>
|
||||||
{% set cell_class = '' %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<td class="{{ cell_class }}">
|
|
||||||
{% if dayState.isBookable and not is_past_date %}
|
|
||||||
<a href="{{ page.urlPath }}/buchen?pnr={{ dayState.price.id }}&fd={{ dayState.day < 10 ? '0':'' }}{{dayState.day}}{{ calendar_month['monthNumber'] < 10 ? '0':'' }}{{calendar_month['monthNumber']}}{{calendar_month['year']}}"
|
|
||||||
style="color: #80B176;"
|
|
||||||
rel="nofollow"
|
|
||||||
>
|
|
||||||
{{ dayState.day }}
|
|
||||||
</a>
|
|
||||||
{% elseif dayState.day == 0 %}
|
|
||||||
|
|
||||||
{% elseif cell_class == '' %}
|
|
||||||
{{ dayState.day }}
|
|
||||||
{% else %}
|
|
||||||
{% if is_past_date %}
|
|
||||||
<del style="color:#989898;">{{ dayState.day }}</del>
|
|
||||||
{% else %}
|
|
||||||
{{ dayState.day }}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
<div class="scroller-nav-tabs scroller-right-nav-tabs"><i class="glyphicon glyphicon-chevron-right"></i></div>
|
<div class="scroller-nav-tabs scroller-right-nav-tabs"><i class="glyphicon glyphicon-chevron-right"></i></div>
|
||||||
<div class="wrapper-nav-tabs">
|
<div class="wrapper-nav-tabs">
|
||||||
<ul class="nav nav-tabs nav-justified list-nav-tabs">
|
<ul class="nav nav-tabs nav-justified list-nav-tabs">
|
||||||
<li class="active">
|
<li class="">
|
||||||
<a href="#travel-description-content-tab" aria-controls="travel-description-content-tab" role="tab" data-toggle="tab">
|
<a href="#travel-description-content-tab" aria-controls="travel-description-content-tab" role="tab" data-toggle="tab">
|
||||||
Beschreibung
|
Beschreibung
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -71,9 +71,9 @@
|
||||||
Ausstattung
|
Ausstattung
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li class="active">
|
||||||
<a href="#travel-dates-content-tab" aria-controls="travel-dates-content-tab" role="tab" data-toggle="tab">
|
<a href="#travel-dates-content-tab" aria-controls="travel-dates-content-tab" role="tab" data-toggle="tab">
|
||||||
Termine <i class="fa fa-star"></i> Preise
|
Termine <i class="fa fa-star"></i> Preise <i class="fa fa-star"></i> Mieten
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -86,7 +86,7 @@
|
||||||
********* BESCHREIBUNG *********
|
********* BESCHREIBUNG *********
|
||||||
#}
|
#}
|
||||||
|
|
||||||
<div role="tabpanel" class="tab-pane active" id="travel-description-content-tab">
|
<div role="tabpanel" class="tab-pane " id="travel-description-content-tab">
|
||||||
|
|
||||||
<h3>Allgemeines</h3>
|
<h3>Allgemeines</h3>
|
||||||
|
|
||||||
|
|
@ -158,7 +158,7 @@
|
||||||
********* TERMINE UND PREISE *********
|
********* TERMINE UND PREISE *********
|
||||||
#}
|
#}
|
||||||
|
|
||||||
<div role="tabpanel" class="tab-pane" id="travel-dates-content-tab">
|
<div role="tabpanel" class="tab-pane active" id="travel-dates-content-tab">
|
||||||
<h3>Saisons</h3>
|
<h3>Saisons</h3>
|
||||||
<div class="table-responsive" id="no-more-tables">
|
<div class="table-responsive" id="no-more-tables">
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@
|
||||||
|
|
||||||
<h3>Buchung</h3>
|
<h3>Buchung</h3>
|
||||||
|
|
||||||
<p>Bitte klicken Sie einen Anreisetermin, um zur Buchungsmaske zu gelagen.</p>
|
<p>Bitte klicken Sie einen Anreisetermin (grüne Zahl), um zur Buchungsmaske zu gelagen.</p>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.table > tbody > tr > td.calendar-day-non {
|
.table > tbody > tr > td.calendar-day-non {
|
||||||
|
|
@ -223,6 +223,42 @@
|
||||||
.table > tbody > tr > td.calendar-day-past {
|
.table > tbody > tr > td.calendar-day-past {
|
||||||
background-color: rgba(242, 242, 242, 0.5);
|
background-color: rgba(242, 242, 242, 0.5);
|
||||||
}
|
}
|
||||||
|
.table > tbody > tr > td.calendar-light {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.table > tbody > tr > td.calendar-day-disabled-half {
|
||||||
|
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#f0bcbc+49,f2f2f2+50,f0bcbc+51 */
|
||||||
|
background: #f0bcbc; /* Old browsers */
|
||||||
|
background: -moz-linear-gradient(-35deg, #f0bcbc 49%, #f2f2f2 50%, #f0bcbc 51%); /* FF3.6-15 */
|
||||||
|
background: -webkit-linear-gradient(-35deg, #f0bcbc 49%,#f2f2f2 50%,#f0bcbc 51%); /* Chrome10-25,Safari5.1-6 */
|
||||||
|
background: linear-gradient(145deg, #f0bcbc 49%,#f2f2f2 50%,#f0bcbc 51%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0bcbc', endColorstr='#f0bcbc',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
|
||||||
|
}
|
||||||
|
.table > tbody > tr > td.active {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.table > tbody > tr > td.active:hover {
|
||||||
|
background-color: #648859;
|
||||||
|
}
|
||||||
|
.table > tbody > tr > td a {
|
||||||
|
color: #598a58;
|
||||||
|
font-weight: 700;
|
||||||
|
width: 100%;
|
||||||
|
display: block;
|
||||||
|
height: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table > tbody > tr > td:hover a {
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 700;
|
||||||
|
width: 100%;
|
||||||
|
display: block;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
{% include 'default/pages/cms/calendarLodgingProgram.html.twig' %}
|
{% include 'default/pages/cms/calendarLodgingProgram.html.twig' %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{#
|
|
||||||
<div id="booking_form" class="booking_form">
|
<div id="booking_form" class="booking_form">
|
||||||
|
|
||||||
<form class="st-booking-form" method="post" data-toggle="validator">
|
<form class="st-booking-form" method="post" data-toggle="validator">
|
||||||
|
|
@ -265,10 +265,11 @@
|
||||||
|
|
||||||
|
|
||||||
{{ form_rest(form) }}
|
{{ form_rest(form) }}
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div><!-- end contact-form -->
|
</div><!-- end contact-form -->
|
||||||
#}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -144,8 +144,8 @@ class CmsController extends Controller
|
||||||
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
|
||||||
if (count($lodging->getPrices()->toArray()) != 0)
|
if (count($lodging->getPrices()->toArray()) != 0)
|
||||||
{
|
{
|
||||||
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
|
$calendar = $calendarService->calendarAndFillDayStates($paddedCalendar, $lodging);
|
||||||
$calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
// $calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
|
||||||
} else {
|
} else {
|
||||||
$calendar = $paddedCalendar;
|
$calendar = $paddedCalendar;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ class FewoBookingController extends Controller
|
||||||
$fromDate = $calendarService->convertDate($fromDate);
|
$fromDate = $calendarService->convertDate($fromDate);
|
||||||
$fromDateTime = new \DateTime($fromDate);
|
$fromDateTime = new \DateTime($fromDate);
|
||||||
$toDate = '';
|
$toDate = '';
|
||||||
|
|
||||||
$maxPersons = $lodging->getMaximumPersons();
|
$maxPersons = $lodging->getMaximumPersons();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -80,6 +79,7 @@ class FewoBookingController extends Controller
|
||||||
$fewoBookingRequest->setLodging($lodging);
|
$fewoBookingRequest->setLodging($lodging);
|
||||||
$fewoBookingRequest->setPrice($price);
|
$fewoBookingRequest->setPrice($price);
|
||||||
|
|
||||||
|
|
||||||
$allowedToDateStrs = [];
|
$allowedToDateStrs = [];
|
||||||
if (!$lodging->getPrices()->isEmpty())
|
if (!$lodging->getPrices()->isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -522,6 +522,22 @@ class FewoLodging
|
||||||
return $this->prices;
|
return $this->prices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get prices
|
||||||
|
*
|
||||||
|
* @return \Doctrine\Common\Collections\Collection
|
||||||
|
*/
|
||||||
|
public function getPricesFilter($dateFrom, $dateTo)
|
||||||
|
{
|
||||||
|
|
||||||
|
return $this->getPrices()->filter(function(FewoPrice $price) use ($dateFrom, $dateTo) {
|
||||||
|
return ($price->getSeason()->getFromDate() >= $dateFrom && $price->getSeason()->getFromDate() <= $dateTo) ||
|
||||||
|
($price->getSeason()->getToDate() >= $dateFrom && $price->getSeason()->getToDate() <= $dateTo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add image
|
* Add image
|
||||||
*
|
*
|
||||||
|
|
@ -590,6 +606,19 @@ class FewoLodging
|
||||||
return $this->reservations;
|
return $this->reservations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get reservationsFilter
|
||||||
|
*
|
||||||
|
* @return \Doctrine\Common\Collections\Collection
|
||||||
|
*/
|
||||||
|
public function getReservationsFilter($dateFrom, $dateTo)
|
||||||
|
{
|
||||||
|
return $this->getReservations()->filter(function(FewoReservation $reservation) use ($dateFrom, $dateTo) {
|
||||||
|
return ($reservation->getFromDate() >= $dateFrom && $reservation->getFromDate() <= $dateTo) ||
|
||||||
|
($reservation->getToDate() >= $dateFrom && $reservation->getToDate() <= $dateTo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set page
|
* Set page
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class LodgingCalendarService
|
||||||
{
|
{
|
||||||
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
|
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
|
||||||
}
|
}
|
||||||
|
//$months = number of Month to the last season
|
||||||
public function getCalendarWithPadding($months)
|
public function getCalendarWithPadding($months)
|
||||||
{
|
{
|
||||||
$calendar = null;
|
$calendar = null;
|
||||||
|
|
@ -37,6 +37,7 @@ class LodgingCalendarService
|
||||||
|
|
||||||
$yearTurned = false;
|
$yearTurned = false;
|
||||||
$yearsTurned = 0;
|
$yearsTurned = 0;
|
||||||
|
$now = new \DateTime();
|
||||||
|
|
||||||
for($m = $currentMonth; $m < ($currentMonth + $months); $m++)
|
for($m = $currentMonth; $m < ($currentMonth + $months); $m++)
|
||||||
{
|
{
|
||||||
|
|
@ -47,9 +48,7 @@ class LodgingCalendarService
|
||||||
$actualMonth = 12;
|
$actualMonth = 12;
|
||||||
$yearTurned = true;
|
$yearTurned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$actualYear = $currentYear + $yearsTurned;
|
$actualYear = $currentYear + $yearsTurned;
|
||||||
|
|
||||||
if($yearTurned)
|
if($yearTurned)
|
||||||
{
|
{
|
||||||
$yearsTurned = $yearsTurned + 1;
|
$yearsTurned = $yearsTurned + 1;
|
||||||
|
|
@ -68,7 +67,7 @@ class LodgingCalendarService
|
||||||
{
|
{
|
||||||
$actualStartingWeekDay = 7;
|
$actualStartingWeekDay = 7;
|
||||||
}
|
}
|
||||||
|
//first empty days from the last month
|
||||||
for($fwd = 0; $fwd < $actualStartingWeekDay - 1; $fwd++)
|
for($fwd = 0; $fwd < $actualStartingWeekDay - 1; $fwd++)
|
||||||
{
|
{
|
||||||
$day = new CalendarDayState();
|
$day = new CalendarDayState();
|
||||||
|
|
@ -78,25 +77,35 @@ class LodgingCalendarService
|
||||||
$day->setIsReserved(false);
|
$day->setIsReserved(false);
|
||||||
$day->setIsReservationBegin(false);
|
$day->setIsReservationBegin(false);
|
||||||
$day->setIsReservationEnd(false);
|
$day->setIsReservationEnd(false);
|
||||||
|
$day->setIsEmpty(true);
|
||||||
|
$day->setIsPastDate(false);
|
||||||
|
|
||||||
$data[] = $day;
|
$data[] = $day;
|
||||||
}
|
}
|
||||||
|
//days of month
|
||||||
for($d = 1; $d <= $numberDays; $d++)
|
for($d = 1; $d <= $numberDays; $d++)
|
||||||
{
|
{
|
||||||
$day = new CalendarDayState();
|
$day = new CalendarDayState();
|
||||||
$day->setDay($d);
|
$day->setDay($d);
|
||||||
|
$datetime = new \DateTime();
|
||||||
|
$datetime->setTimestamp(mktime(0,0,0, $actualMonth, $d, $actualYear));
|
||||||
|
$day->setDate($datetime);
|
||||||
$day->setIsBookable(false);
|
$day->setIsBookable(false);
|
||||||
$day->setIsInSeason(false);
|
$day->setIsInSeason(false);
|
||||||
$day->setIsReserved(false);
|
$day->setIsReserved(false);
|
||||||
$day->setIsReservationBegin(false);
|
$day->setIsReservationBegin(false);
|
||||||
$day->setIsReservationEnd(false);
|
$day->setIsReservationEnd(false);
|
||||||
|
$day->setIsEmpty(false);
|
||||||
|
if($datetime < $now){
|
||||||
|
$day->setIsPastDate(true);
|
||||||
|
}else{
|
||||||
|
$day->setIsPastDate(false);
|
||||||
|
}
|
||||||
$data[] = $day;
|
$data[] = $day;
|
||||||
}
|
}
|
||||||
|
|
||||||
$startIndex = count($data);
|
$startIndex = count($data);
|
||||||
|
//last empty days from the next month
|
||||||
for($lwd = $startIndex; $lwd < 42; $lwd++)
|
for($lwd = $startIndex; $lwd < 42; $lwd++)
|
||||||
{
|
{
|
||||||
$day = new CalendarDayState();
|
$day = new CalendarDayState();
|
||||||
|
|
@ -106,11 +115,12 @@ class LodgingCalendarService
|
||||||
$day->setIsReserved(false);
|
$day->setIsReserved(false);
|
||||||
$day->setIsReservationBegin(false);
|
$day->setIsReservationBegin(false);
|
||||||
$day->setIsReservationEnd(false);
|
$day->setIsReservationEnd(false);
|
||||||
|
$day->setIsEmpty(true);
|
||||||
|
$day->setIsPastDate(false);
|
||||||
|
|
||||||
$data[] = $day;
|
$data[] = $day;
|
||||||
}
|
}
|
||||||
|
$calendar[$actualYear."-".$actualMonth] = [
|
||||||
$calendar[] = [
|
|
||||||
'numberDays' => $numberDays,
|
'numberDays' => $numberDays,
|
||||||
'monthNumber' => $actualMonth,
|
'monthNumber' => $actualMonth,
|
||||||
'monthName' => utf8_encode(strftime("%B", mktime(0, 0, 0, $actualMonth, 1, $actualYear))),
|
'monthName' => utf8_encode(strftime("%B", mktime(0, 0, 0, $actualMonth, 1, $actualYear))),
|
||||||
|
|
@ -161,7 +171,6 @@ class LodgingCalendarService
|
||||||
|
|
||||||
$numberDays = $this->daysInMonth($actualMonth, $actualYear);
|
$numberDays = $this->daysInMonth($actualMonth, $actualYear);
|
||||||
|
|
||||||
/** @var CalendarDayState[] $data */
|
|
||||||
$data = null;
|
$data = null;
|
||||||
|
|
||||||
// alle Wochentage
|
// alle Wochentage
|
||||||
|
|
@ -257,6 +266,7 @@ class LodgingCalendarService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $calendar
|
* @param $calendar
|
||||||
* @param \DateTime $fromDate
|
* @param \DateTime $fromDate
|
||||||
|
|
@ -296,7 +306,6 @@ class LodgingCalendarService
|
||||||
// anfang und ende innerhalb eines monats
|
// 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;
|
||||||
|
|
@ -348,7 +357,6 @@ class LodgingCalendarService
|
||||||
{
|
{
|
||||||
// erster monat
|
// erster monat
|
||||||
|
|
||||||
/** @var CalendarDayState[] $data */
|
|
||||||
$data = $calendar[$startCalendarIndex]['data'];
|
$data = $calendar[$startCalendarIndex]['data'];
|
||||||
|
|
||||||
$calendar[$startCalendarIndex]['marked'] = 1;
|
$calendar[$startCalendarIndex]['marked'] = 1;
|
||||||
|
|
@ -388,7 +396,6 @@ class LodgingCalendarService
|
||||||
|
|
||||||
// letzter monat
|
// letzter monat
|
||||||
|
|
||||||
/** @var CalendarDayState[] $data */
|
|
||||||
$data = $calendar[$endCalendarIndex]['data'];
|
$data = $calendar[$endCalendarIndex]['data'];
|
||||||
|
|
||||||
$calendar[$endCalendarIndex]['marked'] = 1;
|
$calendar[$endCalendarIndex]['marked'] = 1;
|
||||||
|
|
@ -431,7 +438,6 @@ class LodgingCalendarService
|
||||||
// alle monate dazwischen
|
// 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;
|
||||||
|
|
@ -463,15 +469,14 @@ class LodgingCalendarService
|
||||||
return $calendar;
|
return $calendar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// in der Regel: calendar = pricesCalendar; extensionCalendar = reservationsCalendar
|
// in der Regel: calendar = pricesCalendar; extensionCalendar = reservationsCalendar
|
||||||
private function mergeCalendars($calendar, $extensionCalendar)
|
private function mergeCalendars($calendar, $extensionCalendar)
|
||||||
{
|
{
|
||||||
for($i = 0; $i < count($calendar); $i++)
|
for($i = 0; $i < count($calendar); $i++)
|
||||||
{
|
{
|
||||||
/** @var CalendarDayState[] $calendarData */
|
|
||||||
$calendarData = $calendar[$i]['data'];
|
$calendarData = $calendar[$i]['data'];
|
||||||
|
|
||||||
/** @var CalendarDayState[] $extensionCalendarData */
|
|
||||||
$extensionCalendarData = $extensionCalendar[$i]['data'];
|
$extensionCalendarData = $extensionCalendar[$i]['data'];
|
||||||
|
|
||||||
$endIndex = count($calendarData);
|
$endIndex = count($calendarData);
|
||||||
|
|
@ -492,7 +497,6 @@ class LodgingCalendarService
|
||||||
$calendarData[$j]->setIsReservationEnd(false);
|
$calendarData[$j]->setIsReservationEnd(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var FewoPrice $price */
|
|
||||||
$calendarData[$j]->setIsInSeason(true);
|
$calendarData[$j]->setIsInSeason(true);
|
||||||
$calendarData[$j]->setPrice($price);
|
$calendarData[$j]->setPrice($price);
|
||||||
}
|
}
|
||||||
|
|
@ -576,13 +580,11 @@ class LodgingCalendarService
|
||||||
*/
|
*/
|
||||||
private function filterReservableDays(FewoLodging $lodging, $calendar)
|
private function filterReservableDays(FewoLodging $lodging, $calendar)
|
||||||
{
|
{
|
||||||
/** @var CalendarDayState[] $potentiallyReservableDays */
|
|
||||||
$potentiallyReservableDays = [];
|
$potentiallyReservableDays = [];
|
||||||
|
|
||||||
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++)
|
||||||
|
|
@ -649,6 +651,148 @@ class LodgingCalendarService
|
||||||
return $calendar;
|
return $calendar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function findCalendarDayKey($calendarMonth, $dayNumber){
|
||||||
|
|
||||||
|
foreach ($calendarMonth['data'] as $key => $data) {
|
||||||
|
if($data->getDay() == $dayNumber){
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public function calendarAndFillDayStates($paddedCalendar, FewoLodging $lodging){
|
||||||
|
|
||||||
|
$startMonth = array_values($paddedCalendar)[0]['monthNumber'];
|
||||||
|
$startYear = array_values($paddedCalendar)[0]['year'];
|
||||||
|
$endMonth = array_values($paddedCalendar)[count($paddedCalendar)-1]['monthNumber'];
|
||||||
|
$endYear = array_values($paddedCalendar)[count($paddedCalendar)-1]['year'];
|
||||||
|
$endDay = array_values($paddedCalendar)[count($paddedCalendar)-1]['numberDays'];
|
||||||
|
|
||||||
|
$startDate = new \DateTime(date( "Y-m-d", mktime(0,0,0, $startMonth, 1, $startYear)));
|
||||||
|
$endDate = new \DateTime(date( "Y-m-d", mktime(0,0,0, $endMonth, $endDay, $endYear)));
|
||||||
|
|
||||||
|
|
||||||
|
//reservations in the Calender Time
|
||||||
|
$reservations = $lodging->getReservationsFilter($startDate, $endDate);
|
||||||
|
|
||||||
|
|
||||||
|
foreach($reservations as $reservation)
|
||||||
|
{
|
||||||
|
$setFromIntervall = clone $reservation->getFromDate();
|
||||||
|
$fromDate = $reservation->getFromDate();
|
||||||
|
$toDate = $reservation->getToDate();
|
||||||
|
|
||||||
|
// $diff = $fromDate->diff($toDate);
|
||||||
|
$interval = \DateInterval::createFromDateString('1 day');
|
||||||
|
$period = new \DatePeriod($setFromIntervall->modify('+1 day'), $interval, $toDate);
|
||||||
|
|
||||||
|
//first
|
||||||
|
if(isset($paddedCalendar[$fromDate->format("Y-n")])){
|
||||||
|
$key = $this->findCalendarDayKey($paddedCalendar[$fromDate->format("Y-n")], $fromDate->format("d"));
|
||||||
|
$paddedCalendar[$fromDate->format("Y-n")]['data'][$key]->setIsReservationBegin(true);
|
||||||
|
}
|
||||||
|
//last
|
||||||
|
if(isset($paddedCalendar[$toDate->format("Y-n")])) {
|
||||||
|
$key = $this->findCalendarDayKey($paddedCalendar[$toDate->format("Y-n")], $toDate->format("d"));
|
||||||
|
$paddedCalendar[$toDate->format("Y-n")]['data'][$key]->setIsReservationEnd(true);
|
||||||
|
}
|
||||||
|
//days
|
||||||
|
foreach ($period as $dt) {
|
||||||
|
if(isset($paddedCalendar[$dt->format("Y-n")])) {
|
||||||
|
$key = $this->findCalendarDayKey($paddedCalendar[$dt->format("Y-n")], $dt->format("d"));
|
||||||
|
$paddedCalendar[$dt->format("Y-n")]['data'][$key]->setIsReserved(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$prices = $lodging->getPricesFilter($startDate, $endDate);
|
||||||
|
|
||||||
|
foreach ($prices as $price)
|
||||||
|
{
|
||||||
|
|
||||||
|
/** @var FewoSeason $season */
|
||||||
|
$season = $price->getSeason();
|
||||||
|
$setFromIntervall = clone $season->getFromDate();
|
||||||
|
//$fromDate = $season->getFromDate();
|
||||||
|
$setToIntervall = clone $season->getToDate();
|
||||||
|
//$toDate = $season->getToDate();
|
||||||
|
|
||||||
|
$interval = \DateInterval::createFromDateString('1 day');
|
||||||
|
$period = new \DatePeriod($setFromIntervall, $interval, $setToIntervall->modify('+1 day'));
|
||||||
|
|
||||||
|
//days
|
||||||
|
foreach ($period as $dt) {
|
||||||
|
if(isset($paddedCalendar[$dt->format("Y-n")])) {
|
||||||
|
$key = $this->findCalendarDayKey($paddedCalendar[$dt->format("Y-n")], $dt->format("d"));
|
||||||
|
$currDay = $paddedCalendar[$dt->format("Y-n")]['data'][$key];
|
||||||
|
$currDay->setPrice($price);
|
||||||
|
|
||||||
|
|
||||||
|
if(!$currDay->getIsReserved() && $season->getOnlyWeekday() != null && $season->getOnlyWeekday() == $currDay->getDate()->format('w')){
|
||||||
|
$currDay->setIsBookable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$currDay->getIsReserved() && $season->getOnlyWeekday() == null){
|
||||||
|
$currDay->setIsBookable(true);
|
||||||
|
}
|
||||||
|
if($currDay->getIsReservationBegin() == true && $currDay->getIsReservationEnd() == true){
|
||||||
|
$currDay->setIsBookable(false);
|
||||||
|
}
|
||||||
|
//check for the min sty days.
|
||||||
|
if ($currDay->getIsReservationBegin() == true)
|
||||||
|
{
|
||||||
|
//days
|
||||||
|
$minDays = $season->getMinimumStay();
|
||||||
|
$setMinStayFrom = clone $currDay->getDate();
|
||||||
|
$setMinStayTo = clone $currDay->getDate();
|
||||||
|
|
||||||
|
//$minStayInterval = \DateInterval::createFromDateString('-1 day');
|
||||||
|
// $minStayPeriod = new \DatePeriod($setMinStayTo->modify('+1 day'), $minStayInterval, $setMinStayFrom->modify('-'.($minDays-1).' days'));
|
||||||
|
$setMinStayTo->modify('-'.($minDays).' days');
|
||||||
|
$counter = 0;
|
||||||
|
$last = $minDays;
|
||||||
|
|
||||||
|
for($mSdt = $setMinStayFrom; $mSdt >= $setMinStayTo; $mSdt->modify('-1 day')){
|
||||||
|
|
||||||
|
if(isset($paddedCalendar[$mSdt->format("Y-n")])) {
|
||||||
|
$key = $this->findCalendarDayKey($paddedCalendar[$mSdt->format("Y-n")], $mSdt->format("d"));
|
||||||
|
$checkDay = $paddedCalendar[$mSdt->format("Y-n")]['data'][$key];
|
||||||
|
|
||||||
|
|
||||||
|
if($minDays != $checkDay->getPrice()->getSeason()->getMinimumStay()){
|
||||||
|
|
||||||
|
if($minDays > $checkDay->getPrice()->getSeason()->getMinimumStay()){
|
||||||
|
$last = $counter+$checkDay->getPrice()->getSeason()->getMinimumStay();
|
||||||
|
|
||||||
|
|
||||||
|
$setMinStayTo->modify('-'.($last).' days');
|
||||||
|
}
|
||||||
|
if($minDays < $checkDay->getPrice()->getSeason()->getMinimumStay()){
|
||||||
|
$last = $counter+$checkDay->getPrice()->getSeason()->getMinimumStay();
|
||||||
|
$setMinStayTo->modify('-'.($last).' days');
|
||||||
|
|
||||||
|
}
|
||||||
|
$minDays = $checkDay->getPrice()->getSeason()->getMinimumStay();
|
||||||
|
}
|
||||||
|
$counter++;
|
||||||
|
|
||||||
|
if($counter <= $last) {
|
||||||
|
$checkDay->setIsBookable(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//$season is end
|
||||||
|
}
|
||||||
|
return $paddedCalendar;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @param FewoLodging $lodging
|
* @param FewoLodging $lodging
|
||||||
* @param $calendar
|
* @param $calendar
|
||||||
|
|
@ -662,11 +806,11 @@ class LodgingCalendarService
|
||||||
$reservationsCalendar = $this->getCalendar($lodging);
|
$reservationsCalendar = $this->getCalendar($lodging);
|
||||||
|
|
||||||
$reservations = $lodging->getReservations();
|
$reservations = $lodging->getReservations();
|
||||||
|
|
||||||
$prices = $lodging->getPrices();
|
$prices = $lodging->getPrices();
|
||||||
|
|
||||||
foreach ($prices as $price)
|
foreach ($prices as $price)
|
||||||
{
|
{
|
||||||
/** @var FewoSeason $season */
|
|
||||||
$season = $price->getSeason();
|
$season = $price->getSeason();
|
||||||
$pricesCalendar = $this->markCalendarDays($pricesCalendar, $season->getFromDate(), $season->getToDate(),
|
$pricesCalendar = $this->markCalendarDays($pricesCalendar, $season->getFromDate(), $season->getToDate(),
|
||||||
false, $price);
|
false, $price);
|
||||||
|
|
@ -680,7 +824,6 @@ class LodgingCalendarService
|
||||||
$reservationsCalendar = $this->markCalendarDays($reservationsCalendar, $fromDate, $toDate,
|
$reservationsCalendar = $this->markCalendarDays($reservationsCalendar, $fromDate, $toDate,
|
||||||
true, null, $reservation); //TODO fast fertig
|
true, null, $reservation); //TODO fast fertig
|
||||||
}
|
}
|
||||||
|
|
||||||
$mergedPricesAndReservationsCalendar = $this->mergeCalendars($pricesCalendar, $reservationsCalendar);
|
$mergedPricesAndReservationsCalendar = $this->mergeCalendars($pricesCalendar, $reservationsCalendar);
|
||||||
$actuallyReservableDaysCalendar = $this->filterReservableDays($lodging, $mergedPricesAndReservationsCalendar);
|
$actuallyReservableDaysCalendar = $this->filterReservableDays($lodging, $mergedPricesAndReservationsCalendar);
|
||||||
//$resultCalendar = $this->mergeCalendars($actuallyReservableDaysCalendar, $reservationsCalendar, true);
|
//$resultCalendar = $this->mergeCalendars($actuallyReservableDaysCalendar, $reservationsCalendar, true);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,16 @@ class CalendarDayState
|
||||||
*/
|
*/
|
||||||
private $date = null;
|
private $date = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $isEmpty; //empty day in the month
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $isPastDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
|
@ -200,4 +210,75 @@ class CalendarDayState
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getIsEmpty(): bool
|
||||||
|
{
|
||||||
|
return $this->isEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $isEmpty
|
||||||
|
*/
|
||||||
|
public function setIsEmpty(bool $isEmpty)
|
||||||
|
{
|
||||||
|
$this->isEmpty = $isEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getIsPastDate(): bool
|
||||||
|
{
|
||||||
|
return $this->isPastDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $isPastDate
|
||||||
|
*/
|
||||||
|
public function setIsPastDate(bool $isPastDate)
|
||||||
|
{
|
||||||
|
$this->isPastDate = $isPastDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getCssClass(){
|
||||||
|
$ret = "";
|
||||||
|
if($this->getIsPastDate()){
|
||||||
|
$ret .= 'calendar-light ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getDay() == 0){
|
||||||
|
$ret .= 'calendar-day-non ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getIsReserved()){
|
||||||
|
$ret .= 'calendar-day-disabled ';
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getIsReservationBegin() && $this->getIsReservationEnd()){
|
||||||
|
$ret .= 'calendar-day-disabled-half ';
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getIsReservationBegin()){
|
||||||
|
$ret .= 'calendar-day-reservation-begin ';
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getIsReservationEnd()){
|
||||||
|
$ret .= 'calendar-day-reservation-end ';
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue