/** * 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; }
/** * 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; }
/** * 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')]); }
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
?> <input type="hidden" name="task" value="my_booking"> <div class="uk-form-row"> <label class="uk-form-label" for="ch-mod_my_booking_email"><?php echo CHClient::string('email'); ?> </label> <div class="uk-form-controls"> <input class="uk-width-1-1 uk-form-large" type="text" name="email" id="ch-mod_my_booking_email" value=""/> </div> </div> <div class="uk-form-row"> <label class="uk-form-label" for="ch-mod_my_booking_voucher"><?php echo CHClient::string('voucher_code'); ?> </label> <div class="uk-form-controls"> <input class="uk-width-1-1 uk-form-large" type="text" name="voucher" id="ch-mod_my_booking_voucher" value=""/> </div> </div> <div class="uk-form-row"> <span class="uk-text-small" data-uk-tooltip title="To find your booking number and voucher code, check your confirmation email.">Where can I find this<br> information?</span> <button class="uk-margin uk-button uk-button-large uk-button-primary uk-width-1-1">Go</button> </div> </form> <p class="uk-margin-top-remove">Can't find your confirmation email?<br> <a href="#"><i class="uk-icon-envelope-o"></i> We'll resend it to you</a></p> </div>
<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>
</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>
]</span> <?php } ?> </p> </div> </div> <hr> <?php } ?> <h2><?php echo CHClient::string('hotel_conditions'); ?> </h2> <?php echo CHLibDisplay::convertMarkdownToHtml($hotel->conditions_text_lang); ?> <hr> <?php echo CHLibDisplay::convertMarkdownToHtml($booking->app->voucher_text_lang);
</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 } ?> <!-- -->
/** * Send notification emails */ public static function emailNotification($booking, $card = false, $cancellation = false) { // prepare mail $mailer = JFactory::getMailer(); $mailer->IsHTML(true); $mailer->Encoding = 'base64'; $config = JFactory::getConfig(); $sender = array($config->get('mailfrom'), $config->get('fromname')); // mail content $subject = $booking->hotel->title . ' - ' . $booking->booking_id; if ($cancellation) { $subject .= ' - ' . CHClient::string('cancellation'); } $mailer->setSubject($subject); $mailer->setBody(CHClientDisplay::renderVoucher($booking)); // voucher notification emails $hotel_notify = array_map('trim', explode(',', $booking->hotel->notify_voucher)); $app_notify = array_map('trim', explode(',', $booking->app->notify_voucher)); $notification_emails = array_values(array_merge($hotel_notify, $app_notify)); // send mails to notification list first if ($notification_emails) { foreach ($notification_emails as $notification_email) { if ($notification_email) { $mailer->setSender($sender); $mailer->addRecipient($notification_email); try { $mailer->Send(); } catch (Exception $e) { // log errors } $mailer->ClearAddresses(); } } } // send mail to guest $mailer->addRecipient($booking->customer->email); $mailer->setSender($sender); try { $mailer->Send(); } catch (Exception $e) { // log errors } $mailer->ClearAddresses(); // send card details email if ($card) { // generate card email $title = $booking->hotel->title . ' - ' . $booking->booking_id . ' - ' . CHClient::string('card_details'); $mailer->setSubject($title); // generate email body $layout_css = new JLayoutFile('chclient_email_css', JPATH_ROOT . '/components/com_chclient/layouts'); $layout_html = new JLayoutFile('chclient_email_card', JPATH_ROOT . '/components/com_chclient/layouts'); $html = $layout_html->render(['booking' => $booking, 'card' => $card, 'title' => $title]); $css = 'a { color:' . $booking->app->color . ';}' . $layout_css->render([]); $body = CHLibEmail::inlineCSS($html, $css); $mailer->setBody($body); // send to card notifications emails $hotel_notify = explode(',', $booking->hotel->notify_card); $app_notify = explode(',', $booking->app->notify_card); $notification_emails = array_values(array_merge($hotel_notify, $app_notify)); if ($notification_emails) { foreach ($notification_emails as $notification_email) { if ($notification_email) { $mailer->setSender($sender); $mailer->addRecipient($notification_email); try { $mailer->Send(); } catch (Exception $e) { // log errors } $mailer->ClearAddresses(); } } } } // execute notify plugins JPluginHelper::importPlugin('chclient'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onNotify', [$booking]); }
/** * 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); } }
<?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 class="uk-float-left"> <ul class="uk-subnav uk-subnav-pill ch-engine-modal-nav" data-uk-switcher="{connect:'#ch-modal-extra-switcher-<?php echo $extra->id; ?> '}"> <li><a href="javascript:;"><i class="uk-icon-photo"></i> <?php echo CHClient::string('photos'); ?> </a></li> <li><a href="javascript:;"><i class="uk-icon-file-text-o"></i> <?php echo CHClient::string('info'); ?> </a></li> </ul> </div> <div class="uk-float-right"> <button type="button" class="uk-button uk-modal-close"><?php echo CHClient::string('close'); ?> </button> </div> </div> </div> </div> <?php }
/** * loadExtrasFromRequest * @param string $extras_input * @return mixed * @throws Exception */ static function loadExtrasFromRequest($extras_input = false) { $extras = explode('-', $extras_input ? $extras_input : CHLib::input()->get('extras')); if (!$extras[0]) { return false; } // get & check extras $rooms_extras = []; foreach ($extras as $extra) { $values = explode('.', $extra); $room = (int) $values[0]; if (!isset($values[0]) || !isset($values[1]) || !isset($values[2]) || !(int) $values[1] || !(int) $values[2]) { throw new Exception(CHClient::string('error_bad_request'), 400); } if (!isset($rooms_extras[$room])) { $rooms_extras[$room] = []; } $rooms_extras[$room][] = (object) ['id' => (int) $values[1], 'units' => (int) $values[2]]; } return $rooms_extras; }
<!-- results --> <div class="ch-available-results"> <!-- list header --> <div data-ch-available-header class=" uk-clearfix uk-panel uk-panel-box ch-available-header"> <div class="ch-available-header-info"><?php echo CHClient::string('available_rooms'); ?> </div> <div class="ch-available-header-rates"><?php echo CHClient::string('select_rate'); ?> </div> <div class="ch-available-header-price"><?php echo CHClient::string('price'); ?> </div> </div> <!-- results list --> <div class="uk-grid uk-grid-medium ch-available-rooms"> <?php foreach ($available_rooms as $available_room) { echo $available_room; } foreach ($sold_out_rooms as $sold_out_room) { echo $sold_out_room; } ?>
?> <li><?php echo CHClient::string('maxstay'); ?> : <?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 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>
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>
<?php } ?> </div> <!-- good to know --> <?php if ($config->display_availability_hotel_conditions) { ?> <h3><?php echo CHClient::string('good_to_know'); ?> </h3> <?php echo $this->availability->hotel->conditions_text_html; } ?> <!-- check if there are extras available to determine next view (upgrade for extras vs book for rooms with no-extras) --> <div class="uk-hidden" data-ch-rooms-with-extras='<?php echo json_encode($this->rooms_with_extras); ?> '></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">
/** * roomParty * @param object $party * @param bool $force * @return string */ static function roomParty($party, $force = false, $ages = true) { $adults = $party->adults; $children = isset($party->children) ? count($party->children) : 0; $babies = isset($party->babies) ? count($party->babies) : 0; $text = CHClient::numstring($adults, 'guests_adult'); if ($children || $force == 'force_children' || $force == 'force_all') { $text .= ', ' . CHClient::numstring($children, 'guests_child'); if ($ages && $children) { $text .= ' (' . implode(',', $party->children) . ' ' . CHClient::string('yo') . ')'; } } if ($babies || $force == 'force_all') { $text .= ', ' . CHClient::numstring($babies, 'guests_baby'); if ($ages && $babies) { $text .= ' (' . implode(',', $party->babies) . ' ' . CHClient::string('yo') . ')'; } } return $text; }
</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>
" ><?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 } ?>
<?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>
<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');
</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>
</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>