本文整理汇总了PHP中JHotelUtil::getAvailabilityCalendar方法的典型用法代码示例。如果您正苦于以下问题:PHP JHotelUtil::getAvailabilityCalendar方法的具体用法?PHP JHotelUtil::getAvailabilityCalendar怎么用?PHP JHotelUtil::getAvailabilityCalendar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JHotelUtil
的用法示例。
在下文中一共展示了JHotelUtil::getAvailabilityCalendar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOffersCalendar
//.........这里部分代码省略.........
//add extra person cost - if it is the case
if ($adults > $offer->base_adults) {
$dayPrice += ($adults - $offer->base_adults) * $extraPersonPrice;
}
//for single use
//if the price is per person apply single supplement , if is for room apply discount
if ($adults == 1 && $children == 0) {
if (!$isExtraNight) {
if ($offer->price_type == 1) {
$dayPrice = $dayPrice + $offer->single_balancing;
//dmp("add balancing: ".$offer->single_balancing." -> ".$dayPrice);
} else {
$dayPrice = $dayPrice - $offer->single_balancing;
}
} else {
if ($offer->price_type_day == 1) {
if ($offer->price_type == 1) {
$dayPrice = $dayPrice + $offer->single_balancing / $offer->offer_min_nights;
} else {
$dayPrice = $dayPrice - $offer->single_balancing / $offer->offer_min_nights;
}
}
}
}
//check if offer is available on stay period
if (!(strtotime($offer->offer_datas) <= $d && $d <= strtotime($offer->offer_datae))) {
$available = false;
}
//get the minimum availability in the selected period
if (count($roomRateDetails)) {
foreach ($roomRateDetails as $roomRateDetail) {
//get room availability - if rate details are set default settings are ignored
if ($roomRateDetail->date == $dayString) {
$offer->nrRoomsAvailable = $roomRateDetail->availability;
}
}
}
$totalNumberRoomsReserved = 0;
if (isset($bookings[$offer->room_id][$dayString])) {
$totalNumberRoomsReserved = $bookings[$offer->room_id][$dayString];
}
if (isset($temporaryReservedRooms[$offer->room_id]) && (strtotime($temporaryReservedRooms["datas"]) <= $d && $d < strtotime($temporaryReservedRooms["datae"]))) {
$totalNumberRoomsReserved += $temporaryReservedRooms[$offer->room_id];
}
//calculate maximum number of bookings per stay interval
if ($offer->nrRoomsAvailable <= $totalNumberRoomsReserved) {
$available = false;
}
if ($offer_max_nights > 0) {
if (count($offerRateDetails)) {
foreach ($offerRateDetails as $offerRateDetail) {
//set single use price
if ($offerRateDetail->date == $dayString && $adults == 1 && $children == 0) {
$dayPrice = $offerRateDetail->single_use_price;
}
}
}
}
//check if hotel is available
if (!$hotelAvailability[$dayString]) {
$available = false;
}
if (strtotime($startDate) == $d) {
$firstDayPrice = $dayPrice;
}
if ($isExtraNight) {
$extraNightPrice += $dayPrice;
}
//dmp("DP: ".$dayPrice);
$totalPrice += $dayPrice;
$offer_max_nights--;
$d = strtotime(date('Y-m-d', $d) . ' + 1 day ');
}
}
//dmp("T: ".$totalPrice);
//dmp($offer->nrRoomsAvailable);
//dmp($offer->bookings);
//average price per offer
$offer->offer_average_price = round($totalPrice / $nrDays, 2);
$offer->pers_total_price = round($totalPrice / ($adults + $children), 2);
$price = $offer->offer_average_price;
if (JRequest::getVar('show_price_per_person') == 1) {
$price = $offer->pers_total_price;
}
if ($offer->price_type_day == 1) {
$price = $firstDayPrice / ($adults + $children);
$price += $extraNightPrice / ($adults + $children);
}
$roomsInfo[] = array("price" => JHotelUtil::fmt($price, 2), "isAvailable" => $available);
$index++;
}
//dmp($roomsInfo);
$id = $offer->offer_id . $offer->room_id;
$hotelId = $offer->hotel_id;
$offersCalendar[$id] = JHotelUtil::getAvailabilityCalendar($hotelId, $month, $year, $roomsInfo, $nrDays, $id);
}
}
//dmp($offersCalendar);
return $offersCalendar;
}
示例2: getExcursionCalendar
static function getExcursionCalendar($excursions, $nrOfDays, $adults, $children, $month, $year, $bookings, $temporaryReservedExcursions, $hotelAvailability)
{
$excursionsCalendar = array();
$endDay = date('t', mktime(0, 0, 0, $month, 1, $year));
// dmp("D: ".$endDay);
foreach ($excursions as $excursion) {
$excursionsInfo = array();
$index = 1;
$excursionRateDetails = $excursion->excursionRateDetails;
$ignoredDates = explode(",", $excursion->excursionIgnoredDates);
$nrDays = 0;
foreach ($excursion->daily as &$daily) {
$price = $daily["price"];
$available = true;
$totalPrice = 0;
$nrDays = $nrOfDays;
if ($index <= $endDay) {
$startDate = date('Y-m-d', mktime(0, 0, 0, $month, $index, $year));
$nrDays = $nrDays < $excursion->min_days ? $excursion->min_days : $nrDays;
$endDate = date('Y-m-d', mktime(0, 0, 0, $month, $index + $nrDays, $year));
$excursion->nrExcursionsAvailable = $excursion->availability;
$excursion->bookings = 0;
if (array_search($startDate, $ignoredDates)) {
$available = false;
}
$d = strtotime($startDate);
$nr_d = 'excursion_day_' . date("N", $d);
if ($excursion->{$nr_d} == 0) {
$available = false;
}
for ($i = $index; $i < $index + $nrDays; $i++) {
$day = date('Y-m-d', mktime(0, 0, 0, $month, $i, $year));
//check if hotel is available
if ($hotelAvailability != null && !$hotelAvailability[$day]) {
$available = false;
}
foreach ($excursionRateDetails as $excursionRateDetail) {
if ($excursionRateDetail->date == $day) {
$excursion->nrExcursionsAvailable = $excursionRateDetail->availability;
}
}
$totalNumberExcursionsReserved = 0;
if (isset($bookings[$excursion->excursion_id][$day])) {
$totalNumberExcursionsReserved = $bookings[$excursion->excursion_id][$day];
}
if (isset($temporaryReservedExcursions[$excursion->excursion_id]) && (strtotime($temporaryReservedExcursions["datas"]) <= strtotime($day) && strtotime($day) < strtotime($temporaryReservedExcursions["datae"]))) {
$totalNumberExcursionsReserved += $temporaryReservedExcursions[$excursion->excursion_id];
}
//calculate maximum number of bookings per stay interval
if ($excursion->nrExcursionsAvailable <= $totalNumberExcursionsReserved) {
$available = false;
}
if (isset($excursion->daily[$i - 1])) {
$price = $excursion->daily[$i - 1]['price'];
}
//echo $p.' <br/>';
$totalPrice += $price;
}
}
//average price per excursion
$excursion->excursion_average_price = round($totalPrice / $nrDays, 2);
$excursion->pers_total_price = round($totalPrice / $nrDays, 2);
if (JRequest::getVar('show_price_per_person') == 1) {
$price = $excursion->pers_total_price;
} else {
$price = $excursion->excursion_average_price;
}
$excursionsInfo[] = array("price" => JHotelUtil::fmt($price, 2), "isAvailable" => $available);
$id = $excursion->excursion_id + 1000;
$index++;
}
$hotelId = $excursion->hotel_id;
$excursionsCalendar[$id] = JHotelUtil::getAvailabilityCalendar($hotelId, $month, $year, $excursionsInfo, $nrDays, $id);
}
return $excursionsCalendar;
}