/** * Display */ public function display($tpl = null) { // load app $this->app = CHClient::getApp(); // get the booking info $this->booking = $this->get('Booking'); // no booking found if (!$this->booking) { $this->setLayout('errors'); parent::display($tpl); return; } // processing booking if ($this->booking->booking_status >= 40) { return $this->displayProcessing(); } // new booking analytics tracking $this->new_booking = false; if ($this->app->getUserState('chclient.new_booking', false)) { $this->new_booking = (object) ['booking_id' => $this->booking->booking_id, 'hotel' => $this->booking->hotel->title, 'total' => $this->booking->amounts->total, 'currency' => $this->booking->currency]; $this->new_booking->rooms = []; foreach ($this->booking->rooms as $room) { $new_booking_room = (object) ['title' => $room->title, 'reference' => $room->reference, 'total' => $room->amounts->total]; $this->new_booking->rooms[] = $new_booking_room; } $this->app->setUserState('chclient.new_booking', null); } // determine free cancellation $this->data = (object) []; $this->data->free_cancellation = 1; $this->data->deadline = ''; $deadline = 00; foreach ($this->booking->rooms as $room) { $rate_deadline = CHLIbdate::sqlToInt($room->rate->deadline); if ($rate_deadline > $deadline) { $this->data->deadline = $room->rate->deadline; } if (!in_array($room->rate->conditions, ['pay_at_hotel', 'deposit_refundable', 'prepay_refundable'])) { $this->data->free_cancellation = 0; } } if ($this->data->free_cancellation) { $this->data->free_cancellation = CHLibDate::isGreater($this->data->deadline, CHLibDate::dateToSql(false)); } // print voucher ? if ($this->booking && CHLib::input()->get('print')) { return $this->printVoucher(); } // set document title $this->document->setTitle(CHClient::string('your_booking') . ' - ' . $this->booking->booking_id); // display parent::display($tpl); }
/** * Determine free cancellation * @param type $conditions * @param type $deadline */ public static function freeCancellation($conditions, $deadline) { if (!in_array($conditions, ['pay_at_hotel', 'deposit_refundable', 'prepay_refundable'])) { return false; } return CHLibDate::isGreater(CHLibDate::sqlToInt($deadline), CHLibDate::dateToSql(false)); }
</div> </div> <hr> <?php foreach ($booking->rooms as $room) { ?> <?php $stay = $room->amounts->room + $room->amounts->board; $amount_stay = $room->amounts->amount_room + $room->amounts->amount_board; $discounts = $room->amounts->discounts_room + $room->amounts->discounts_board; $deadline = CHLibDate::isGreater($room->rate->deadline, CHLibDate::dateToSql(false, true)); ?> <div class="uk-grid uk-grid-medium"> <div class="uk-width-small-2-10"> <img class="uk-thumbnail" src="<?php echo $room->image->med; ?> " alt="<?php echo $room->title; ?> "> </div> <div class="uk-width-small-8-10">