/** * Get the availability data for a hotel */ public function getCalendar() { // hotel_id $hotel_id = $this->getHotelId(); if (!$hotel_id) { throw new Exception(CHClient::string('error_resource_not_found'), 404); } // load search $search = CHClient::getSearch(); // get month start and end dates $default_month = substr($search->start_date, 0, -3); $month_date = $this->app->getUserStateFromRequest('chclient.month', 'month', $default_month, 'string'); // init calendar object $calendar = new stdClass(); $calendar->month = CHLibDate::getMonth($month_date); $calendar->months_list = CHLibDate::getMonthsList(); // get ari from api $request = (object) ['hotel_id' => $hotel_id, 'start_date' => $calendar->month->start, 'end_date' => $calendar->month->end, 'currency' => $search->currency, 'lang' => JFactory::getLanguage()->getTag()]; $api_request = $this->apiRequest('ari_get', $request); // check for errors if ($api_request->errors->errors) { return $api_request; } // finalise calendar object $calendar->ari = $api_request->response; return $calendar; }
/** * 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; }
/** * Constructor */ public function __construct($config = array()) { // init view $this->search = CHClient::getSearch(); // params $this->params = JComponentHelper::getParams('com_chclient'); $app_params = JFactory::getApplication()->getParams(); $this->params->merge($app_params); // init data $this->data = (object) []; // parent construct parent::__construct($config); }
/** * Insert new booking */ function new_booking() { // check CSRF protection JSession::checkToken() or die('Invalid Token'); // get the new booking $model = $this->getModel('Booking'); $booking = $model->newBookig(); // invalid booking request if (!$booking) { $this->setRedirect(clone JUri::getInstance()); return; } $this->setRedirect(CHClient::route('booking')); return; }
/** * Display */ public function display($tpl = null) { // load the app $app = CHClient::getApp(); // check if guest user $this->user = CHClient::getUser(); if (!$this->user) { $this->setLayout('access'); } // my booking error $this->my_booking_error = $app->getUserState('chclient.my_booking_error', false); $app->setUserState('chclient.my_booking_error', null); // prepare document $this->prepareDocument(); // display parent::display($tpl); }
/** * 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; }
/** * Api Request * * @param string $task * @param object $data */ public function apiRequest($task, $data = false) { // build request $request = (object) ['app' => $this->config->data_source_app_id, 'log' => microtime(true) * 100, 'task' => $task, 'data' => $data ? $data : (object) []]; $request->sign = hash('sha256', $this->config->data_source_app_secret . md5(json_encode($request))); // api request $api_request = ['request' => json_encode($request)]; try { $api_results = JHttpFactory::getHttp()->post($this->config->data_source_api_host, $api_request, [], $this->config->data_source_api_timeout); //CHLib::ajaxExit($api_results, 200, true); } catch (Exception $e) { throw new Exception(CHClient::string('error_api_unavailable'), 503); } // check result $result = json_decode($api_results->body); if (is_object($result)) { return $result; } //CHLib::ajaxExit($api_results->body, 200, true); throw new Exception(CHClient::string('error_api_unavailable'), 503); }
/** * Get the hotel data */ public function getHotel($hotel_id = 0) { // check if hotel already loaded if (isset($this->hotel)) { return $this->hotel; } // check hotel $id = $hotel_id ? $hotel_id : $this->getHotelId(); if (!$id && !$hotel_id) { throw new Exception(CHClient::string('error_resource_not_found'), 404); } // get the hotel data form inventory table $data = $this->_db->setQuery("SELECT data FROM `#__chclient_inventory` WHERE id = {$id}")->loadResult(); if (!$data) { if (!$hotel_id) { throw new Exception(CHClient::string('error_resource_not_found'), 404); } else { return false; } } // get the data ready to display $this->hotel = CHInventory::prepare(json_decode($data)); return $this->hotel; }
?> : <?php echo CHClient::numstring($this->promo->maxstay, 'nights'); ?> </li> <?php } ?> <?php if ($this->promo->anticipation) { ?> <li><?php echo CHClient::string('anticipation'); ?> : <?php echo CHClient::numstring($this->promo->anticipation, 'days'); ?> </li> <?php } ?> </ul> </div> </div> </div> </div>
echo $availability_link->toString(); ?> "><i class="uk-icon-check"></i> <?php echo CHClient::numstring(count($search->party), 'select_room'); ?> </a></li> <li class="uk-active"><span><i class="uk-icon-angle-right"></i> <?php echo CHClient::string('upgrade_stay'); ?> </span></li> <li><span><i class="uk-icon-angle-right"></i> <?php echo CHClient::string('your_details'); ?> </span></li> <li><span><i class="uk-icon-angle-right"></i> <?php echo CHClient::string('confirmed_booking'); ?> </span></li> </ul> </div> <!-- search --> <?php if ($config->display_inline_search) { ?> <div id="ch-availability-search" class="uk-hidden"> <?php echo JLayoutHelper::render('chclient_search_horizontal'); ?> </div> <?php
<div class="uk-panel uk-panel-box uk-margin-bottom"> <div class="uk-clearfix"> <div class="uk-float-left"> <span><?php echo CHClient::string('select_month'); ?> </span> </div> <div class="uk-float-right"> <div class="uk-form-select uk-active" data-uk-form-select=""> <i class="uk-icon-calendar"></i> <?php echo CHClient::string('month'); ?> : <span></span> <i class="uk-icon-caret-down"></i> <select data-ch-calendar-selector> <?php foreach ($calendar->months_list as $month) { $selected = $calendar->month->value == $month->value ? 'selected="selected"' : ''; echo '<option ' . $selected . ' value="' . $month->value . '">' . $month->text . '</option>'; } ?> </select> </div> </div>
</div> </div> </form> <div data-ch-send-message class="uk-margin-top"></div> <!-- loader --> <div class="ch-loading" data-ch-send-loading> <div class="ch-loading-spinner"> <div class="ch-loading-bounce1"></div> <div class="ch-loading-bounce2"></div> </div> </div> </div> </div> <div class="uk-modal-footer uk-text-right"> <button type="button" class="uk-button uk-modal-close"><?php echo CHClient::string('close'); ?> </button> <button type="button" data-ch-send-action class="uk-button uk-button-primary"><?php echo CHClient::string('send'); ?> </button> </div> </div> </div> <?php } ?> <!-- -->
<?php if (isset($message->ref) && $message->ref == 'hotel') { ?> <?php /* <li><?= $message->ref_title ?> - <?= isset($message->unit) ? CHClient::sprintf('room_n', $message->unit + 1) . ': ' : '' ?><?= CHClient::string('error_' . $message->code) ?> <!-- error_code <?= $message->code ?> --></li> */ ?> <?php $error = isset($message->extra_info) ? CHClient::sprintf('error_' . $message->code, $message->extra_info) : CHClient::string('error_' . $message->code); ?> <li><?php echo $message->ref_title; ?> - <?php echo $error; ?> <!-- error_code <?php echo $message->code; ?> --></li> <?php } ?> <?php } ?> </ul> <p><?php echo CHClient::string('NO_AVAILABILITY_FOUND_CHANGE'); ?> </p> </div>
<div id="ch-availability-search" class="uk-hidden"> <?php echo JLayoutHelper::render('chclient_search_horizontal'); ?> </div> <?php } ?> <!-- tip --> <?php if ($config->display_book_tip) { ?> <div class="uk-alert uk-alert-success uk-text-center"> <p><?php echo CHClient::string('book_tip'); ?> </p> </div> <?php } ?> <!-- main --> <div class="uk-grid uk-grid-medium"> <div class="uk-width-medium-3-10"><?php echo $this->loadTemplate('sidebar'); ?> </div> <div class="uk-width-medium-7-10"><?php echo $this->loadTemplate('main');
" ><?php echo $n; ?> <?php echo $n ? ' ' . CHLibDisplay::money($room_extra->currency->amount * $n, $currency) : ''; ?> </option> <?php } ?> </select> </p> <!-- <button data-ch-upgrade-button type="button" class="uk-button"><?php echo CHClient::string('add'); ?> </button> --> </div> </div> </div> </div> </div> </div> <?php } ?>
/** * Render month head */ static function monthHead($first, $last, $month, $filter_room, $start_empty_days = 0, $end_empty_days = 0) { $html = []; if (!$filter_room) { $html[] = '<div class="ch-month-cell ch-month-cell-head ch-month-cell-title"></div>'; } for ($i = 0; $i < $start_empty_days; $i++) { $html[] = '<div class="ch-month-cell ch-month-cell-head"></div>'; } foreach ($month->dates as $date) { $day = $date->day; if ($day < $first || $day > $last) { continue; } $html[] = '<div class="ch-month-cell ch-month-cell-head ch-month-cell-day-' . $date->day_week . '">' . CHClient::day($date->day_week) . ' ' . $day . '</div>'; } for ($i = 0; $i < $end_empty_days; $i++) { $html[] = '<div class="ch-month-cell ch-month-cell-head"></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); } }
/** * Api Request * * @param type $data */ public function apiRequest($task, $data = false) { // get front-end config require JPATH_ROOT . '/components/com_chclient/helpers/chclient.php'; $config = CHClient::getConfig(); // build request $request = (object) []; $request->app = $config->data_source_app_id; $request->log = microtime(true) * 100; $request->task = $task; $request->data = $data ? $data : (object) []; $request->sign = hash('sha256', $config->data_source_app_secret . md5(json_encode($request))); // api request $api_request = ['request' => json_encode($request)]; try { $api_results = JHttpFactory::getHttp()->post($config->data_source_api_host, $api_request, [], $config->data_source_api_timeout); } catch (Exception $e) { return false; } // check result $result = json_decode($api_results->body); if (is_object($result)) { return $result; } return false; }
echo CHClient::sprintf('room_n', $i + 1); ?> : <?php echo CHClientDisplay::roomGuests($room->adults, count($room->children)); ?> <?php } ?> </small> </p> <?php } ?> <?php if ($config->display_inline_search) { ?> <p class="uk-margin-small"> <a class="uk-button uk-button-mini" href="#" data-uk-toggle="{target:'#ch-availability-search', animation:'uk-animation-slide-bottom'}"> <i class="uk-icon-sliders"></i> <?php echo CHClient::string('modify'); ?> </a> </p> <?php } ?> </div> </div>
</h4> <?php foreach ($this->rooms->units as $i => $room) { ?> <?php if (count($this->rooms->units) > 1) { ?> <p><strong><?php echo CHClient::sprintf('room_n', $unit + 1); ?> : </strong></p> <?php } ?> <p> <?php $rate_tip = '<strong>' . CHClient::string('cancellation') . '</strong>: ' . $room->rate_cancellation_policy; if ($room->rate_free_cancellation) { $rate_tip .= '<br>' . CHClient::sprintf('free_cancellation_before', CHLibDate::dateToDisplay($room->rate_deadline, false)); } $rate_tip .= '<br><strong>' . CHClient::string('prepayment') . '</strong>: ' . CHClient::string(CHClientDisplay::ratePrepayment($room->rate_conditions)); echo $rate_tip; ?> </p> <?php } ?> <br> </div> </div>
<h3><a href="<?php echo $link; ?> "><?php echo $promo->title; ?> </a></h3> <p> <?php echo $promo->info; ?> <br><a class="uk-button uk-button-mini uk-margin-small" href="<?php echo $link; ?> "><?php echo CHClient::string('more_info'); ?> <i class="uk-icon-angle-right"></i></a> </p> </div> </li> <?php } ?> </ul> </div> <div class="uk-flex uk-flex-center uk-margin">
<?php /** * @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; // load assets CHClient::chassets(); // load engine data $config = CHClient::getConfig(); ?> <!-- loading container --> <div class="ch-loading-container" data-ch-view="search"> <div class="uk-grid"> <div class="uk-width-1-1"> <!-- search --> <?php if ($config->display_inline_search) { ?> <div id="ch-availability-search" class="uk-hidden"> <?php echo JLayoutHelper::render('chclient_search_horizontal'); ?> </div>
</a> </label> <div id="ch-search-promo-toggle" class="uk-form-controls <?php echo $search->promo_code ? '' : 'uk-hidden'; ?> "> <input class="uk-form-width-small" type="text" name="promo_code" id="ch-search-promo_code" value="<?php echo $this->escape($search->promo_code); ?> "> </div> </div> <!-- search button --> <div class="uk-form-row"> <button type="submit" class="uk-button uk-button-large uk-button-primary"><?php echo CHClient::string('search'); ?> </button> </div> </fieldset> <!-- dates & party hidden --> <input type="hidden" data-ch-search-start_date name="start_date" value=""> <input type="hidden" data-ch-search-end_date name="end_date" value=""> <input type="hidden" data-ch-search-party name="party" value=""> </form> </div>
</h4> <a class="uk-button uk-button-primary uk-button-small ch-available-display-active" href="javascript:;" data-ch-reserve data-ch-hotel-title="<?php echo $hotel->title; ?> "><?php echo CHClient::string('reserve'); ?> </a> <a class="uk-button uk-button-disabled uk-button-small ch-available-display-inactive" data-uk-tooltip title="<?php echo CHClient::string('select_rate'); ?> " href="javascript:;"><?php echo CHClient::string('reserve'); ?> </a> <p class="uk-text-small uk-text-muted ch-available-display-active"><?php echo CHClient::string('immediate_confirmation'); ?> </p> </div> </div> <?php } ?> </div> </div> </div>
<?php /** * @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; ?> <div class="uk-alert uk-alert-large uk-alert-danger"> <h2><?php echo CHClient::string('ERRORS_FOUND'); ?> </h2> <ul> <?php foreach ($this->calendar->errors->errors as $error) { ?> <li><?php echo $error->message; ?> </li> <?php } ?> </ul> </div>
</small> </div> </div> <?php if ($currency != $hotel_currency) { ?> <p class="uk-alert"> <?php echo CHClient::string('property_currency'); ?> : <?php echo CHLibDisplay::money($booking->amounts->total, $hotel_currency); ?> <br><small><?php echo CHClient::string('exchange_notice'); ?> : <?php echo CHLibDisplay::money($booking->amounts->total_customer_currency, $currency); ?> = <?php echo CHLibDisplay::money($booking->amounts->total, $hotel_currency); ?> </small> </p> <?php } ?> </div>
<?php /** * @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; // load assets CHClient::chassets(); // load layout $layout = new JLayoutFile('chclient_search', $basePath = JPATH_ROOT . '/components/com_chclient/layouts'); $data['title'] = $module->title; $data['action'] = JRoute::_('index.php?Itemid=' . $params->get('Itemid')); echo $layout->render($data);
<h2><a href="#ch-modal-hotel-<?php echo $hotel->id; ?> " data-uk-modal data-ch-engine-modal-link="1"><?php echo $hotel->title; ?> </a></h2> <p><?php echo $hotel->info; ?> </p> <?php if (!$results) { ?> <p class="ch-text-red"><?php echo CHClient::string('sold_out'); ?> </p> <?php } else { ?> <?php $this->results = $results; echo $this->loadTemplate('rooms'); ?> <?php } ?> </div>
/** * @package CHAdminPro * @copyright Copyright (C) CloudHotelier. All rights reserved. * @license GNU GPLv2 <http://www.gnu.org/licenses/gpl.html> * @author Xavier Pallicer <*****@*****.**> */ defined('_JEXEC') or die; $view = isset($displayData['view']) ? $displayData['view'] : 'booking'; ?> <!DOCTYPE html> <html lang="<?php echo JFactory::getLanguage()->getTag(); ?> "> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>Redirect</title> <script type="text/javascript"> window.onload = function () { window.parent.document.location = '<?php echo CHClient::route($view); ?> '; }; </script> </head> <body> </body> </html>
/** * Method that the user can use to send the voucher to their contacts */ public function emailVoucher() { $layout_html = new JLayoutFile('chclient_alert', JPATH_ROOT . '/components/com_chclient/layouts'); $status = ''; // get the booking $booking = $this->getBooking(); if (!$booking) { $status = 'danger'; } // check the emails $emails = array_map('trim', explode(',', CHLib::input()->getString('emails'))); if (!$emails) { $status = 'danger'; } foreach ($emails as $email) { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $status = 'danger'; } } // return if errors detected if ($status == 'danger') { return $layout_html->render(['status' => $status, 'message' => CHClient::string('error_incorrect_data')]); } // prepare mail $mailer = JFactory::getMailer(); $config = JFactory::getConfig(); $sender = array($config->get('mailfrom'), $config->get('fromname')); // mail content $mailer->setSubject($booking->hotel->title . ' - ' . $booking->voucher); $mailer->IsHTML(true); $mailer->Encoding = 'base64'; $mailer->setBody(CHClientDisplay::renderVoucher($booking)); // send emails foreach ($emails as $notification_email) { if ($notification_email) { $mailer->setSender($sender); $mailer->addRecipient($notification_email); try { $mailer->Send(); } catch (Exception $e) { // log errors } $mailer->ClearAddresses(); } } return $layout_html->render(['status' => 'success', 'message' => CHClient::string('emails_sent')]); }