PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.7.2
VikBooking Hotel Booking Engine & PMS v1.7.2
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / site / views / roomdetails / view.html.php

view.html.php in VikBooking Hotel Booking Engine & PMS 1.7.2, at site/views/roomdetails/view.html.php

242 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage com_vikbooking
5 * @author Alessio Gaggii - e4j - Extensionsforjoomla.com
6 * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 * @link https://vikwp.com
9 */
10
11 defined('ABSPATH') or die('No script kiddies please!');
12
13 jimport('joomla.application.component.view');
14
15 class VikbookingViewRoomdetails extends JViewVikBooking {
16 function display($tpl = null) {
17 VikBooking::prepareViewContent();
18 $proomid = VikRequest::getString('roomid', '', 'request');
19 $dbo = JFactory::getDbo();
20 $vbo_tn = VikBooking::getTranslator();
21 $q = "SELECT * FROM `#__vikbooking_rooms` WHERE `id`=".$dbo->quote($proomid)." AND `avail`='1';";
22 $dbo->setQuery($q);
23 $dbo->execute();
24 if ($dbo->getNumRows() == 1) {
25 $room = $dbo->loadAssocList();
26 $vbo_tn->translateContents($room, '#__vikbooking_rooms');
27
28 /**
29 * We calculate the default timestamps for check-in of today and check-out for tomorrow.
30 * Useful to apply the today's rate by default for one night of stay.
31 *
32 * @since 1.13.5
33 */
34 $vbo_df = VikBooking::getDateFormat();
35 $vbo_df = $vbo_df == "%d/%m/%Y" ? 'd/m/Y' : ($vbo_df == "%m/%d/%Y" ? 'm/d/Y' : 'Y/m/d');
36 $hcheckin = 0;
37 $mcheckin = 0;
38 $hcheckout = 0;
39 $mcheckout = 0;
40 $timeopst = VikBooking::getTimeOpenStore();
41 if (is_array($timeopst)) {
42 $opent = VikBooking::getHoursMinutes($timeopst[0]);
43 $closet = VikBooking::getHoursMinutes($timeopst[1]);
44 $hcheckin = $opent[0];
45 $mcheckin = $opent[1];
46 $hcheckout = $closet[0];
47 $mcheckout = $closet[1];
48 }
49 $checkin_today_ts = VikBooking::getDateTimestamp(date($vbo_df), $hcheckin, $mcheckin);
50 $checkout_tomorrow_ts = VikBooking::getDateTimestamp(date($vbo_df, strtotime('tomorrow')), $hcheckout, $mcheckout);
51 //
52 $room[0]['base_cost'] = 0;
53 $room[0]['cost'] = 0;
54 $q = "SELECT * FROM `#__vikbooking_dispcost` WHERE `idroom`=".$dbo->quote($room[0]['id'])." ORDER BY `#__vikbooking_dispcost`.`days` ASC, `#__vikbooking_dispcost`.`cost` ASC";
55 $dbo->setQuery($q, 0, 1);
56 $dbo->execute();
57 if ($dbo->getNumRows()) {
58 $tar = $dbo->loadAssocList();
59 $room[0]['base_cost'] = $tar[0]['cost'] / ($tar[0]['days'] > 1 ? $tar[0]['days'] : 1);
60 /**
61 * We apply the today's rate by default for one night of stay.
62 *
63 * @since 1.13.5
64 */
65 $tar = VikBooking::applySeasonsRoom($tar, $checkin_today_ts, $checkout_tomorrow_ts);
66 //
67 $room[0]['cost'] = $tar[0]['cost'] / ($tar[0]['days'] > 1 ? $tar[0]['days'] : 1);
68 }
69 //
70
71 $actnow = mktime(0, 0, 0, date('m'), 1, date('Y'));
72 $busy = "";
73 $q = "SELECT * FROM `#__vikbooking_busy` WHERE `idroom`='".$room[0]['id']."' AND (`checkin`>=".$actnow." OR `checkout`>=".$actnow.");";
74 $dbo->setQuery($q);
75 $dbo->execute();
76 if ($dbo->getNumRows() > 0) {
77 $busy = $dbo->loadAssocList();
78 }
79 //seasons calendar
80 $seasons_cal = array();
81 $use_seasons_cal = VikBooking::getRoomParam('seasoncal', $room[0]['params']);
82 $seasons_cal_nights = explode(',', VikBooking::getRoomParam('seasoncal_nights', $room[0]['params']));
83 $seasons_cal_nights = VikBooking::filterNightsSeasonsCal($seasons_cal_nights);
84 if (intval($use_seasons_cal) > 0 && count($seasons_cal_nights) > 0) {
85 $q = "SELECT * FROM `#__vikbooking_seasons` WHERE `idrooms` LIKE '%-".$room[0]['id']."-%'".($use_seasons_cal == 2 ? " AND `promo`=0" : ($use_seasons_cal == 3 ? " AND `type`=1 AND `promo`=0" : "")).";";
86 $dbo->setQuery($q);
87 $dbo->execute();
88 if ($dbo->getNumRows() > 0) {
89 $seasons = $dbo->loadAssocList();
90 $vbo_tn->translateContents($seasons, '#__vikbooking_seasons');
91 $q = "SELECT `p`.*,`tp`.`name`,`tp`.`attr`,`tp`.`idiva`,`tp`.`breakfast_included`,`tp`.`free_cancellation`,`tp`.`canc_deadline` FROM `#__vikbooking_dispcost` AS `p` LEFT JOIN `#__vikbooking_prices` `tp` ON `p`.`idprice`=`tp`.`id` WHERE `p`.`days` IN (".implode(',', $seasons_cal_nights).") AND `p`.`idroom`=".$room[0]['id']." ORDER BY `p`.`days` ASC, `p`.`cost` ASC;";
92 $dbo->setQuery($q);
93 $dbo->execute();
94 if ($dbo->getNumRows() > 0) {
95 $tars = $dbo->loadAssocList();
96 $vbo_tn->translateContents($tars, '#__vikbooking_prices', array('id' => 'idprice'));
97 $arrtar = array();
98 foreach ($tars as $tar) {
99 $arrtar[$tar['days']][] = $tar;
100 }
101 //Restrictions
102 $all_restrictions = VikBooking::loadRestrictions(true, array($room[0]['id']));
103 $all_seasons = array();
104 $curtime = time();
105 foreach ($seasons as $sk => $s) {
106 if (empty($s['from']) && empty($s['to'])) {
107 continue;
108 }
109 $now_year = !empty($s['year']) ? $s['year'] : date('Y');
110 list($sfrom, $sto) = VikBooking::getSeasonRangeTs($s['from'], $s['to'], $now_year);
111 if ($sto < $curtime && empty($s['year'])) {
112 $now_year += 1;
113 list($sfrom, $sto) = VikBooking::getSeasonRangeTs($s['from'], $s['to'], $now_year);
114 }
115 if ($sto >= $curtime) {
116 $s['from_ts'] = $sfrom;
117 $s['to_ts'] = $sto;
118 $all_seasons[] = $s;
119 }
120 }
121 if (count($all_seasons) > 0) {
122 $seasons_cal['nights'] = $seasons_cal_nights;
123 $seasons_cal['offseason'] = $arrtar;
124 $all_seasons = VikBooking::sortSeasonsRangeTs($all_seasons);
125 $seasons_cal['seasons'] = $all_seasons;
126 $seasons_cal['season_prices'] = array();
127 $seasons_cal['restrictions'] = array();
128 //calc price changes for each season and for each num-night
129 foreach ($all_seasons as $sk => $s) {
130 $checkin_base_ts = $s['from_ts'];
131 $is_dst = date('I', $checkin_base_ts);
132 foreach ($arrtar as $numnights => $tar) {
133 $checkout_base_ts = $s['to_ts'];
134 for ($i = 1; $i <= $numnights; $i++) {
135 $checkout_base_ts += 86400;
136 $is_now_dst = date('I', $checkout_base_ts);
137 if ($is_dst != $is_now_dst) {
138 if ((int)$is_dst == 1) {
139 $checkout_base_ts += 3600;
140 } else {
141 $checkout_base_ts -= 3600;
142 }
143 $is_dst = $is_now_dst;
144 }
145 }
146 //calc check-in and check-out ts for the two dates
147 $first = VikBooking::getDateTimestamp(date($vbo_df, $checkin_base_ts), $hcheckin, $mcheckin);
148 $second = VikBooking::getDateTimestamp(date($vbo_df, $checkout_base_ts), $hcheckout, $mcheckout);
149 $tar = VikBooking::applySeasonsRoom($tar, $first, $second, $s);
150 $seasons_cal['season_prices'][$sk][$numnights] = $tar;
151 //Restrictions
152 if (count($all_restrictions) > 0) {
153 $season_restr = VikBooking::parseSeasonRestrictions($first, $second, $numnights, $all_restrictions);
154 if (count($season_restr) > 0) {
155 $seasons_cal['restrictions'][$sk][$numnights] = $season_restr;
156 }
157 }
158 }
159 }
160 }
161 }
162 }
163 }
164 //end seasons calendar
165 //promotion min number of nights
166 $ppromo = VikRequest::getInt('promo', 0, 'request');
167 $promo_season = array();
168 if ($ppromo > 0) {
169 $q = "SELECT * FROM `#__vikbooking_seasons` WHERE `id`=".(int)$ppromo." AND `promo`=1;";
170 $dbo->setQuery($q);
171 $dbo->execute();
172 if ($dbo->getNumRows() > 0) {
173 $promo_season = $dbo->loadAssoc();
174 $vbo_tn->translateContents($promo_season, '#__vikbooking_seasons');
175 }
176 }
177
178 // attempt to load the first two "mandatory" checkbox fields
179 $terms_fields = array();
180 $q = "SELECT * FROM `#__vikbooking_custfields` WHERE `type`='checkbox' AND `required`=1 ORDER BY `#__vikbooking_custfields`.`ordering` ASC";
181 $dbo->setQuery($q, 0, 2);
182 $dbo->execute();
183 if ($dbo->getNumRows()) {
184 $terms_fields = $dbo->loadAssocList();
185 $vbo_tn->translateContents($terms_fields, '#__vikbooking_custfields');
186 }
187
188 $custptitle = VikBooking::getRoomParam('custptitle', $room[0]['params']);
189 $custptitlew = VikBooking::getRoomParam('custptitlew', $room[0]['params']);
190 $metakeywords = VikBooking::getRoomParam('metakeywords', $room[0]['params']);
191 $metadescription = VikBooking::getRoomParam('metadescription', $room[0]['params']);
192 $document = JFactory::getDocument();
193 if (!empty($custptitle)) {
194 $ctitlewhere = !empty($custptitlew) ? $custptitlew : 'before';
195 $set_title = $custptitle.' - '.$document->getTitle();
196 if ($ctitlewhere == 'after') {
197 $set_title = $document->getTitle().' - '.$custptitle;
198 } elseif ($ctitlewhere == 'replace') {
199 $set_title = $custptitle;
200 }
201 $document->setTitle($set_title);
202 }
203 if (!empty($metakeywords)) {
204 $document->setMetaData('keywords', $metakeywords);
205 }
206 if (!empty($metadescription)) {
207 $document->setMetaData('description', $metadescription);
208 }
209 //OpenGraph Tags
210 if (!empty($custptitle)) {
211 $document->setMetaData('og:title', $set_title);
212 }
213 if (!empty($room[0]['img'])) {
214 $document->setMetaData('og:image', VBO_SITE_URI.'resources/uploads/'.$room[0]['img']);
215 }
216 if (!empty($room[0]['smalldesc'])) {
217 $document->setMetaData('og:description', strip_tags($room[0]['smalldesc']));
218 }
219 //
220 $this->room = $room[0];
221 $this->busy = $busy;
222 $this->seasons_cal = $seasons_cal;
223 $this->promo_season = $promo_season;
224 $this->terms_fields = $terms_fields;
225 $this->vbo_tn = $vbo_tn;
226 //theme
227 $theme = VikBooking::getTheme();
228 if ($theme != 'default') {
229 $thdir = VBO_SITE_PATH.DS.'themes'.DS.$theme.DS.'roomdetails';
230 if (is_dir($thdir)) {
231 $this->_setPath('template', $thdir.DS);
232 }
233 }
234 //
235 parent::display($tpl);
236 } else {
237 $mainframe = JFactory::getApplication();
238 $mainframe->redirect("index.php?option=com_vikbooking&view=roomslist");
239 }
240 }
241 }
242