예제 #1
0
 /**
  * displayProcessing
  */
 private function displayProcessing()
 {
     // load config
     $this->config = CHClient::getConfig();
     // submit confirmation method
     $this->submit_confirm = false;
     if ($this->app->getUserState('chclient.submit_confirm', false)) {
         $this->submit_confirm = true;
         $this->app->setUserState('chclient.submit_confirm', null);
         $this->loadConfirmationMethod();
     }
     // load needed data
     $this->data->special_conditions = false;
     $this->data->worst_conditions = false;
     $conditions_array = [];
     foreach ($this->booking->rooms as $room) {
         $conditions_array[] = $room->rate->conditions;
         $room->special_conditions = false;
         $room->free_cancellation = CHClient::freeCancellation($room->rate->conditions, $room->rate->deadline);
         $room->non_refundable = in_array($room->rate->conditions, ['deposit_non_refundable', 'prepay_non_refundable']);
         if (!$room->free_cancellation && !$room->non_refundable) {
             $room->special_conditions = true;
             $this->data->special_conditions = true;
         }
     }
     $this->data->worst_conditions = CHClient::worstConditions($conditions_array);
     // display
     $this->setLayout('processing');
     parent::display();
     return;
 }
예제 #2
0
 /**
  * Constructor
  */
 public function __construct($config = array())
 {
     // get app & config
     $this->app = CHClient::getApp();
     $this->config = CHClient::getConfig();
     $this->search = CHClient::getSearch();
     // construct
     parent::__construct($config);
 }
<?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 engine data
$config = CHClient::getConfig();
// get the data
$booking = $this->booking;
$hotel = $booking->hotel;
// get currency display
$currency = CHLibDisplay::currencySymbol($booking->customer->currency);
$hotel_currency = CHLibDisplay::currencySymbol($booking->currency);
$conversion = $booking->customer->currency_conversion;
?>

<!-- summary -->
<div data-uk-sticky="{boundary: true, top: 10, media: 640}">

	<div class="uk-panel uk-panel-box">

		<?php 
if (count($booking->rooms) < 3 && $config->display_book_hotel_info) {
    ?>
			<div class="ch-ratio ch-ratio-3-2" style="background-image: url(<?php 
    echo $hotel->image->med;
    ?>
예제 #4
0
 /**
  * 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;
 }
예제 #5
0
 /**
  * Instert a new booking
  */
 public function newBookig()
 {
     // init post validation
     $valid = true;
     $app = CHClient::getApp();
     $config = CHClient::getConfig();
     $post = CHLib::input()->post;
     // build the new booking request
     $request = (object) [];
     $request->hotel_id = $post->getUint('hotel_id');
     // required string fields
     foreach (['start_date', 'end_date', 'first_name', 'last_name', 'email', 'phone'] as $field) {
         $request->{$field} = $post->getString($field);
         if (strlen($request->{$field}) <= 2) {
             $valid = false;
             $errors[] = $field;
         }
     }
     // not required strings
     foreach (['country', 'promo_code', 'checkin_time', 'requests', 'confirm', 'lang', 'currency'] as $field) {
         $request->{$field} = $post->getString($field);
     }
     // bool fields
     $request->pay_full = $post->get('pay_full') ? 1 : 0;
     $request->newsletter = $post->get('newsletter') ? 1 : 0;
     // collect card info
     // @todo server validation
     if ($config->confirm_card_hosted) {
         // set confirmation method for api request
         $request->confirm = 'card_hosted';
         // init card object
         $card = (object) [];
         $card->type = $post->get('card_type');
         $card->cvc = $post->get('card_cvc');
         $card->expiration_date = $post->get('card_expiration_month') . '/' . $post->get('card_expiration_year');
         // split card number details for security
         $card_number = (int) str_replace(' ', '', $post->getString('card_number'));
         $request->card_number = substr($card_number, 0, -4) . '****';
         $card->number = '**** **** **** ' . substr($card_number, -4);
     }
     // invalid data, try again
     if (!$valid) {
         $app->setUserState('chclient.booking_request', $request);
         $app->setUserState('chclient.booking_errors', $errors);
         return false;
     }
     // attach rooms array
     $request->rooms = [];
     $party = CHClient::loadParty($post->get('party'));
     list($rates, $boards) = CHClient::loadRoomsFromRequest($post->get('rooms'));
     $extras = CHClient::loadExtrasFromRequest($post->get('extras'));
     foreach ($party as $i => $r_party) {
         $room = (object) ['party' => $r_party];
         $room->rate = $rates[$i];
         $room->board = $boards[$i];
         $room->extras = isset($extras[$i]) ? $extras[$i] : [];
         $room->guest = (object) ['name' => $post->getString('guest_' . $i), 'bed' => $post->get('bed_' . $i), 'smoking' => $post->get('smoking_' . $i)];
         $request->rooms[] = $room;
     }
     // attach app object
     $user = JFactory::getUser();
     $request->app = (object) [];
     $request->app->app_id = $config->data_source_app_id;
     $request->app->user_id = $user->guest ? null : $user->id;
     $request->app->user_ip = CHLib::getIp();
     // attach tracking object
     $request->tracking = json_decode($app->getUserState('plg_racking.tracking', 'null'));
     // init request
     $api_request = $this->apiRequest('booking_add', $request);
     // check for errors
     if ($api_request->errors->errors) {
         $app->setUserState('chclient.api_errors', $api_request->errors);
         return false;
     }
     // load booking
     $booking = $api_request->response;
     // confirmed & pending bookings (1x, 2x)
     if ($booking->booking_status < 30) {
         // send notification
         CHClientBooking::emailNotification($booking, $card);
     } else {
         // set booking confirm submit
         $app->setUserState('chclient.submit_confirm', true);
     }
     // set new booking state (for analytics tracking)
     $app->setUserState('chclient.new_booking', true);
     // set booking data state for late use in booking view
     $app->setUserState('chclient.booking', $booking);
     return true;
 }