Admin Booking

git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3443 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
adametz 2018-08-14 16:20:27 +00:00
parent e4f09da134
commit 73ed632267
4 changed files with 87 additions and 27 deletions

View file

@ -250,11 +250,15 @@ class AdminController extends Controller
$reservations = $calendarService->getReservations($lodging);
$paddedCalendar = $calendarService->getCalendarWithPadding($calendarService->getMinCalendarEntriesByLodging($lodging));
$calendar = $calendarService->getCalendar($lodging);
// $calendar = $calendarService->getCalendar($lodging);
if (count($lodging->getPrices()->toArray()) != 0)
{
$calendar = $calendarService->calendarAndFillDayStates($paddedCalendar, $lodging);
/*
$calendar = $calendarService->createCalendarAndFillDayStates($lodging);
$calendar = $calendarService->mergeWithPaddedCalendar($calendar, $paddedCalendar);
*/
} else {
$calendar = $paddedCalendar;
}

View file

@ -525,7 +525,23 @@ class LodgingCalendarService
public function mergeWithPaddedCalendar($calendar, $paddedCalendar)
{
for($i = 0; $i < count($paddedCalendar); $i++)
$i = 0;
foreach ($paddedCalendar as $key => $data){
$calendarDataCurrMonth = $calendar[$i]['data'];
$paddedCalendarDataCurrMonth = $paddedCalendar[$key]['data'];
$startIndex = $this->findCalendarDayIndexInMonth(1, $paddedCalendarDataCurrMonth);
//$startIndex = array_search(1, $paddedCalendarDataCurrMonth);
for($j = 0; $j < count($calendarDataCurrMonth); $j++, $startIndex++)
{
$paddedCalendarDataCurrMonth[$startIndex] = $calendarDataCurrMonth[$j];
}
$paddedCalendar[$key]['data'] = $paddedCalendarDataCurrMonth;
$i++;
}
/*for($i = 0; $i < count($paddedCalendar); $i++)
{
$calendarDataCurrMonth = $calendar[$i]['data'];
$paddedCalendarDataCurrMonth = $paddedCalendar[$i]['data'];
@ -538,7 +554,7 @@ class LodgingCalendarService
$paddedCalendarDataCurrMonth[$startIndex] = $calendarDataCurrMonth[$j];
}
$paddedCalendar[$i]['data'] = $paddedCalendarDataCurrMonth;
}
}*/
return $paddedCalendar;
}
@ -691,6 +707,8 @@ class LodgingCalendarService
if(isset($paddedCalendar[$fromDate->format("Y-n")])){
$key = $this->findCalendarDayKey($paddedCalendar[$fromDate->format("Y-n")], $fromDate->format("d"));
$paddedCalendar[$fromDate->format("Y-n")]['data'][$key]->setIsReservationBegin(true);
$paddedCalendar[$fromDate->format("Y-n")]['data'][$key]->setReservation($reservation);
}
//last
if(isset($paddedCalendar[$toDate->format("Y-n")])) {
@ -702,6 +720,8 @@ class LodgingCalendarService
if(isset($paddedCalendar[$dt->format("Y-n")])) {
$key = $this->findCalendarDayKey($paddedCalendar[$dt->format("Y-n")], $dt->format("d"));
$paddedCalendar[$dt->format("Y-n")]['data'][$key]->setIsReserved(true);
$paddedCalendar[$dt->format("Y-n")]['data'][$key]->setReservation($reservation);
}
}
}