/** * Get the hotel data */ public function getPromo() { // determine hotel $hotel_id = $this->getHotelId(); // get the vars @(list($type_id, $slug) = explode('-', CHLib::input()->getString('id'), 2)); @(list($type, $promo_id) = explode(':', $type_id)); // check vars if (!$type || !$slug || !$hotel_id || !$promo_id) { throw new Exception(CHClient::string('error_bad_request'), 404); } // check type if (!in_array($type, ['discount', 'extra', 'pack'])) { throw new Exception(CHClient::string('error_bad_request'), 404); } // get the hotel $hotel = parent::getHotel($hotel_id); if (!$hotel) { throw new Exception(CHClient::string('error_resource_not_found'), 404); } // promo type array $type_array = $type . 's'; $promo = CHLibData::getObjectFromList($hotel->{$type_array}, $promo_id, 'id'); $promo->promo_type = $type; return $promo; }
/** * searchPormoInDiscounts */ private function searchPormoInExtras($id) { foreach ($this->availability->results->search_rooms as $search_room) { foreach ($search_room->available_rooms as $available_room) { $promo = CHLibData::getObjectFromList($available_room->extras, $id, 'extra_id'); if ($promo) { return $promo; } } } return false; }
/** * Get the hotel data */ public function getRoom() { // get the vars $hotel_id = $this->getHotelId(); $id = CHLib::input()->getInt('id'); // check vars if (!$hotel_id || !$id) { throw new Exception(CHClient::string('error_bad_request'), 404); } // get the hotel $hotel = parent::getHotel($hotel_id); if (!$hotel) { throw new Exception(CHClient::string('error_resource_not_found'), 404); } // promo type array $room = CHLibData::getObjectFromList($hotel->rooms, $id, 'id'); return $room; }
* @package CHClient * @copyright Copyright (C) CloudHotelier. All rights reserved. * @license GNU GPLv2 <http://www.gnu.org/licenses/gpl.html> * @author Xavier Pallicer <*****@*****.**> */ defined('_JEXEC') or die; ?> <?php foreach ($this->availability->hotels as $hotel) { ?> <?php $results = CHLibData::getObjectFromList($this->availability->results, $hotel->id, 'hotel_id'); ?> <div class="uk-grid uk-grid-small"> <div class="uk-width-small-3-10"> <div class="ch-ratio ch-ratio-3-2" style="background-image: url(<?php echo $hotel->image->screen; ?> );"> <div class="ch-ratio-content"> <a class="ch-ratio ch-ratio-3-2 ch-image-overlay" href="#ch-modal-hotel-<?php echo $hotel->id; ?> " data-uk-modal data-ch-engine-modal-link="0"> <div class="ch-ratio-content uk-text-center">
} ?> </p> <!-- results --> <div class="ch-upgrade-extras"> <!-- results list --> <div class="uk-grid uk-grid-medium ch-upgrade-extras"> <?php foreach ($this->availability->hotel->extras as $extra) { ?> <?php $room_extra = CHLibData::getObjectFromList($available_extras, $extra->id, 'extra_id'); if (!$room_extra) { continue; } $min = $room_extra->type == 'optional' ? 0 : 1; $max = $room_extra->type == 'optional' ? $room_extra->max_units : 1; ?> <div class="uk-width-medium-1-3"> <div class="ch-upgrade-extra-wrap"> <div class="ch-upgrade-extra uk-position-relative uk-margin-bottom"> <div class="ch-ratio ch-ratio-3-2" style="background-image: url(<?php echo $extra->image->med;
/** * Render month row */ static function monthRow($first, $last, $month, $rooms, $ari, $filter_room = false, $start_empty_days = 0, $end_empty_days = 0) { $html = []; $today_int = CHLibDate::getDate()->format('Ymd'); $currency = isset($ari->currency) ? CHLibDisplay::currencySymbol($ari->currency) : ''; foreach ($rooms as $room) { // check room if ($filter_room && $room->id != $filter_room) { continue; } // prepare available & rates keys $room_ari = isset($ari->ari) ? CHLibData::getObjectFromList($ari->ari, $room->id, 'room_id') : 0; // generate html if (!$filter_room) { $title = '<div class="uk-vertical-align-middle">' . $room->title . '</div>'; $html[] = '<div class="uk-vertical-align ch-month-cell ch-month-cell-row ch-month-cell-title">' . $title . '</div>'; } // empty rows for ($i = 0; $i < $start_empty_days; $i++) { $html[] = '<div class="ch-month-cell ch-month-cell-row"></div>'; } foreach ($month->dates as $date) { // month rows $day = $date->day; if ($day < $first || $day > $last) { continue; } // get day data $date_int = str_replace('-', '', $date->date); $rate = '-'; $aclass = ''; $is_not_in_past = $date_int >= $today_int; if ($room_ari) { $has_availability = isset($room_ari->availability[$day - 1]); $has_rate_and_is_not_zero = isset($room_ari->rates[0]->rate[$day - 1]) && $room_ari->rates[0]->rate[$day - 1] > 0; if ($is_not_in_past && $has_availability && $has_rate_and_is_not_zero) { $rate = CHLibDisplay::money($room_ari->rates[0]->rate[$day - 1], $currency); $available = $room_ari->availability[$day - 1]; $aclass = 'ch-month-cell-span-available-' . ($available ? $available > 2 ? 'ok' : 'low' : 'no'); } } // cells $html[] = '<div class="ch-month-cell ch-month-cell-row ch-month-cell-day-' . $date->day_week . '">'; $html[] = '<small class="uk-text-muted ch-month-cell-span ch-month-cell-span-available ' . $aclass . '">' . $rate . '</small>'; $html[] = '</div>'; } // empty rows for ($i = 0; $i < $end_empty_days; $i++) { $html[] = '<div class="ch-month-cell ch-month-cell-row"></div>'; } } return implode("\n", $html); }
/** * Load selected rooms info * * @return mixed * @throws Exception */ protected function loadRooms() { // get & check selection list($rates, $boards) = CHClient::loadRoomsFromRequest(); // to determine the worst conditions $conditions = []; // get rooms units $this->rooms = (object) []; $this->rooms->total = 0; $this->rooms->currency_total = 0; $this->rooms->conditions = 'pay_at_hotel'; $this->rooms->units = []; $this->rooms->amount = []; $this->rooms->currency_amount = []; foreach ($this->availability->results->search_rooms as $i => $search_room) { // look in the rates to determine the room_id foreach ($search_room->available_rooms as $available_room) { $board = $boards[$i]; $rate = CHLibData::getObjectFromList($available_room->rates, $rates[$i], 'rate_id'); if ($rate) { $room = CHLibData::getObjectFromList($this->availability->hotel->rooms, $available_room->room_id, 'id'); $data = (object) []; $data->id = $available_room->room_id; $data->title = $room->title; $data->info = $room->info; $data->image = $room->image; $data->available = $available_room->available; $data->smoking = $available_room->smoking; $data->bed_preference = $available_room->bed_preference; $data->party = $search_room->party; $data->board = $board; $data->rate_id = $rate->rate_id; $data->rate_master = $rate->master; $data->rate_title = $rate->title; $data->rate_conditions = $rate->conditions; $data->rate_deposit = $rate->deposit; $data->rate_deadline = $rate->deadline; $data->rate_free_cancellation = $rate->free_cancellation; $data->rate_cancellation_policy = $rate->cancellation_policy; if (!isset($rate->currency->amount->{$board})) { throw new Exception(CHClient::string('error_bad_request'), 400); } $data->amount = $rate->amount->{$board}; $data->currency_amount = $rate->currency->amount->{$board}; $data->currency = $rate->currency; $data->discounts = $rate->discounts; foreach ($data->discounts as $discount) { unset($discount->detail); } $this->rooms->units[] = $data; // determine the dominant (worst) conditions $conditions[] = $rate->conditions; $this->rooms->total += $rate->amount->{$board}; $this->rooms->currency_total += $rate->currency->amount->{$board}; break; } } } // get the worst conditions found $this->rooms->conditions = CHClient::worstConditions($conditions); // check rooms units if (count($this->rooms->units) != count($this->availability->results->search_rooms)) { throw new Exception(CHClient::string('error_bad_request'), 400); } }
$search = CHClient::getSearch(); // hotel data $hotel = $this->availability->hotel; // load search rooms $unit = $this->available_unit; $search_rooms = $this->availability->results->search_rooms[$unit]; $party = $search_rooms->party; // preapre rooms arrays $first_unit = true; $this->first_unit = true; $this->first_rate = true; $available_rooms = []; $sold_out_rooms = []; foreach ($this->availability->hotel->rooms as $room) { $this->room = $room; $this->available = CHLibData::getObjectFromList($search_rooms->available_rooms, $room->id, 'room_id'); // the room will be displayed only if it's sold out, the room will be ignored for any other errors if (!$this->available) { $this->sold_out = CHClient::checkRoomSoldOut($unit, $room->id, $this->availability->errors); if (!$this->sold_out) { continue; } $this->first_unit = false; $sold_out_rooms[] = $this->loadTemplate('room'); } else { $this->sold_out = false; $this->first_unit = $first_unit ? true : false; $available_rooms[] = $this->loadTemplate('room'); $first_unit = false; } }
/** * Load selected extras info * * @return mixed * @throws Exception */ private function loadExtras() { // init extras array $this->extras = (object) []; $this->extras->total = 0; $this->extras->currency_total = 0; $this->extras->units = []; $this->extras->amount = []; $this->extras->currency_amount = []; // get & check selection $rooms_extras = CHClient::loadExtrasFromRequest(); if (!$rooms_extras) { return; } // load extras info foreach ($this->rooms->units as $i => $room) { // check extras are selected for the room $this->extras->units[$i] = []; $this->extras->amount[$i] = 0; $this->extras->currency_amount[$i] = 0; if (!isset($rooms_extras[$i])) { continue; } // get extras info $extras_data = CHLibData::getObjectFromList($this->availability->results->search_rooms[$i]->available_rooms, $room->id, 'room_id')->extras; foreach ($this->availability->hotel->extras as $extra_info) { // get extra input $input = CHLibData::getObjectFromList($rooms_extras[$i], $extra_info->id, 'id'); if (!$input) { continue; } // create extra object $extra_data = CHLibData::getObjectFromList($extras_data, $extra_info->id, 'extra_id'); $data = (object) []; $data->id = $extra_info->id; $data->title = $extra_info->title; $data->info = $extra_info->info; $data->image = $extra_info->image; $data->units = $input->units; $data->type = $extra_data->type; $data->amount = $extra_data->amount * $input->units; $data->currency_amount = $extra_data->currency->amount * $input->units; $data->data = $extra_data; $this->extras->units[$i][] = $data; $this->extras->amount[$i] += $data->amount; $this->extras->currency_amount[$i] += $data->currency_amount; $this->extras->total += $data->amount; $this->extras->currency_total += $data->currency_amount; } } }