| 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 |
$pcategories = VikRequest::getString('categories', '', 'request'); |
| 14 |
$pitemid = VikRequest::getInt('Itemid', '', 'request'); |
| 15 |
$vbdateformat = VikBooking::getDateFormat(); |
| 16 |
if ($vbdateformat == "%d/%m/%Y") { |
| 17 |
$df = 'd/m/Y'; |
| 18 |
} elseif ($vbdateformat == "%m/%d/%Y") { |
| 19 |
$df = 'm/d/Y'; |
| 20 |
} else { |
| 21 |
$df = 'Y/m/d'; |
| 22 |
} |
| 23 |
$sugg_units = (int)VikBooking::showSearchSuggestions(); |
| 24 |
$datesep = VikBooking::getDateSeparator(); |
| 25 |
$timeopst = VikBooking::getTimeOpenStore(); |
| 26 |
if (is_array($timeopst)) { |
| 27 |
$opent = VikBooking::getHoursMinutes($timeopst[0]); |
| 28 |
$closet = VikBooking::getHoursMinutes($timeopst[1]); |
| 29 |
$hcheckin = $opent[0]; |
| 30 |
$mcheckin = $opent[1]; |
| 31 |
$hcheckout = $closet[0]; |
| 32 |
$mcheckout = $closet[1]; |
| 33 |
} else { |
| 34 |
$hcheckin = 0; |
| 35 |
$mcheckin = 0; |
| 36 |
$hcheckout = 0; |
| 37 |
$mcheckout = 0; |
| 38 |
} |
| 39 |
|
| 40 |
$map_months = array( |
| 41 |
JText::translate('VBMONTHONE'), |
| 42 |
JText::translate('VBMONTHTWO'), |
| 43 |
JText::translate('VBMONTHTHREE'), |
| 44 |
JText::translate('VBMONTHFOUR'), |
| 45 |
JText::translate('VBMONTHFIVE'), |
| 46 |
JText::translate('VBMONTHSIX'), |
| 47 |
JText::translate('VBMONTHSEVEN'), |
| 48 |
JText::translate('VBMONTHEIGHT'), |
| 49 |
JText::translate('VBMONTHNINE'), |
| 50 |
JText::translate('VBMONTHTEN'), |
| 51 |
JText::translate('VBMONTHELEVEN'), |
| 52 |
JText::translate('VBMONTHTWELVE') |
| 53 |
); |
| 54 |
|
| 55 |
$map_short_wday = array( |
| 56 |
JText::translate('VBSUN'), |
| 57 |
JText::translate('VBMON'), |
| 58 |
JText::translate('VBTUE'), |
| 59 |
JText::translate('VBWED'), |
| 60 |
JText::translate('VBTHU'), |
| 61 |
JText::translate('VBFRI'), |
| 62 |
JText::translate('VBSAT') |
| 63 |
); |
| 64 |
$map_long_wday = array( |
| 65 |
JText::translate('VBWEEKDAYZERO'), |
| 66 |
JText::translate('VBWEEKDAYONE'), |
| 67 |
JText::translate('VBWEEKDAYTWO'), |
| 68 |
JText::translate('VBWEEKDAYTHREE'), |
| 69 |
JText::translate('VBWEEKDAYFOUR'), |
| 70 |
JText::translate('VBWEEKDAYFIVE'), |
| 71 |
JText::translate('VBWEEKDAYSIX') |
| 72 |
); |
| 73 |
|
| 74 |
if ($this->code == 1 && count($this->suggestions) && count($this->solutions) && count($this->split_stay_solutions)) { |
| 75 |
// parse split stay solutions first |
| 76 |
?> |
| 77 |
<div id="vbo-splitstay-suggestions-container-<?php echo $this->code; ?>" class="vbo-search-suggestions-container vbo-splitstay-suggestions-container"> |
| 78 |
<h4><?php echo JText::translate('VBO_SPLIT_STAY_SOLS'); ?></h4> |
| 79 |
<p class="vbo-search-suggestions-intro"><?php echo JText::translate('VBO_SPLIT_STAY_SOLS_DESCR'); ?></p> |
| 80 |
<div class="vbo-booking-solutions vbo-splitstay-solutions"> |
| 81 |
<?php |
| 82 |
// limits and general values |
| 83 |
$max_splitstay_suggs = 4; |
| 84 |
$splitstay_suggested = 0; |
| 85 |
$orig_checkin_info = getdate($this->checkin); |
| 86 |
$orig_checkout_info = getdate($this->checkout); |
| 87 |
$main_adults = 0; |
| 88 |
$main_children = 0; |
| 89 |
foreach ($this->party as $guests) { |
| 90 |
if (isset($guests['adults'])) { |
| 91 |
$main_adults = (int)$guests['adults']; |
| 92 |
} |
| 93 |
if (isset($guests['children'])) { |
| 94 |
$main_children = (int)$guests['children']; |
| 95 |
} |
| 96 |
break; |
| 97 |
} |
| 98 |
|
| 99 |
// loop throuh all split stay solutions available |
| 100 |
foreach ($this->split_stay_solutions as $split_stay_sol) { |
| 101 |
// count rooms in this split stay solutions |
| 102 |
$sol_tot_rooms = count($split_stay_sol); |
| 103 |
// build book now URI for this split stay solution |
| 104 |
$split_stay_url_data = [ |
| 105 |
'option' => 'com_vikbooking', |
| 106 |
'task' => 'showprc', |
| 107 |
'roomsnum' => $sol_tot_rooms, |
| 108 |
'roomopt' => [], |
| 109 |
'adults' => [], |
| 110 |
'children' => [], |
| 111 |
'split_stay' => [], |
| 112 |
'days' => $this->nights, |
| 113 |
'checkin' => $this->checkin, |
| 114 |
'checkout' => $this->checkout, |
| 115 |
'categories' => (!empty($pcategories) ? $pcategories : null), |
| 116 |
'Itemid' => (!empty($pitemid) ? $pitemid : null), |
| 117 |
]; |
| 118 |
?> |
| 119 |
<div class="vbo-booking-solution vbo-splitstay-solution"> |
| 120 |
<div class="vbo-booking-solution-dates"> |
| 121 |
<span class="vbo-booking-solution-checkin"> |
| 122 |
<span class="vbo-booking-solution-date-lbl"><?php echo JText::sprintf('VBOBOOKSOLSUGGCKIN', $map_long_wday[$orig_checkin_info['wday']]); ?></span> |
| 123 |
<span class="vbo-booking-solution-date-dt"><?php echo date(str_replace("/", $datesep, $df), $orig_checkin_info[0]); ?></span> |
| 124 |
</span> |
| 125 |
<span class="vbo-booking-solution-checkout"> |
| 126 |
<span class="vbo-booking-solution-date-lbl"><?php echo JText::sprintf('VBOBOOKSOLSUGGCKOUT', $map_long_wday[$orig_checkout_info['wday']]); ?></span> |
| 127 |
<span class="vbo-booking-solution-date-dt"><?php echo date(str_replace("/", $datesep, $df), $orig_checkout_info[0]); ?></span> |
| 128 |
</span> |
| 129 |
</div> |
| 130 |
<div class="vbo-booking-solution-rooms"> |
| 131 |
<div class="vbo-booking-solution-totrooms"><?php echo $sol_tot_rooms . ' ' . ($sol_tot_rooms > 1 ? JText::translate('VBSEARCHRESROOMS') : JText::translate('VBSEARCHRESROOM')); ?></div> |
| 132 |
<?php |
| 133 |
foreach ($split_stay_sol as $split_stay) { |
| 134 |
// get stay dates info |
| 135 |
$split_checkin_info = getdate(strtotime($split_stay['checkin'])); |
| 136 |
$split_checkout_info = getdate(strtotime($split_stay['checkout'])); |
| 137 |
// push split stay data to URL |
| 138 |
$split_stay_copy = $split_stay; |
| 139 |
unset($split_stay_copy['room_name']); |
| 140 |
$split_stay_url_data['split_stay'][] = $split_stay_copy; |
| 141 |
// push additional URL values |
| 142 |
$split_stay_url_data['roomopt'][] = $split_stay['idroom']; |
| 143 |
$split_stay_url_data['adults'][] = $main_adults; |
| 144 |
$split_stay_url_data['children'][] = $main_children; |
| 145 |
?> |
| 146 |
<div class="vbo-booking-solution-room vbo-splitstay-solution-room"> |
| 147 |
<div class="vbo-booking-solution-rname"> |
| 148 |
<span><?php echo $split_stay['room_name']; ?></span> |
| 149 |
</div> |
| 150 |
<div class="vbo-splitstay-solution-details"> |
| 151 |
<span class="vbo-splitstay-solution-nights"><?php VikBookingIcons::e('moon'); ?> <?php echo $split_stay['nights'] . ' ' . ($split_stay['nights'] > 1 ? JText::translate('VBDAYS') : JText::translate('VBDAY')); ?></span> |
| 152 |
<span class="vbo-splitstay-solution-checkin"><?php VikBookingIcons::e('plane-arrival'); ?> <?php echo $map_short_wday[$split_checkin_info['wday']] . ', ' . date(str_replace("/", $datesep, $df), $split_checkin_info[0]); ?></span> |
| 153 |
<span class="vbo-splitstay-solution-checkout"><?php VikBookingIcons::e('plane-departure'); ?> <?php echo $map_short_wday[$split_checkout_info['wday']] . ', ' . date(str_replace("/", $datesep, $df), $split_checkout_info[0]); ?></span> |
| 154 |
</div> |
| 155 |
</div> |
| 156 |
<?php |
| 157 |
} |
| 158 |
?> |
| 159 |
</div> |
| 160 |
<div class="vbo-booking-solution-book vbselectr"> |
| 161 |
<a class="btn vbo-pref-color-btn" href="<?php echo JRoute::rewrite('index.php?' . http_build_query($split_stay_url_data)); ?>"><?php echo JText::translate('VBBOOKNOW'); ?></a> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
<?php |
| 165 |
$splitstay_suggested++; |
| 166 |
if ($splitstay_suggested >= $max_splitstay_suggs) { |
| 167 |
break; |
| 168 |
} |
| 169 |
} |
| 170 |
?> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
<?php |
| 174 |
} |
| 175 |
|
| 176 |
if (count($this->suggestions)) { |
| 177 |
$sug_from_ts_info = getdate($this->sug_from_ts); |
| 178 |
$begin_month = $sug_from_ts_info['mon']; |
| 179 |
$sug_calendars = array(); |
| 180 |
while ($sug_from_ts_info[0] <= $this->sug_to_ts) { |
| 181 |
$calkey = $sug_from_ts_info['mon'].'_'.$sug_from_ts_info['year']; |
| 182 |
if (!isset($sug_calendars[$calkey])) { |
| 183 |
$sug_calendars[$calkey] = array(); |
| 184 |
} |
| 185 |
array_push($sug_calendars[$calkey], $sug_from_ts_info); |
| 186 |
$sug_from_ts_info = getdate(mktime(0, 0, 0, $sug_from_ts_info['mon'], ($sug_from_ts_info['mday'] + 1), $sug_from_ts_info['year'])); |
| 187 |
} |
| 188 |
$todays_arr = array(); |
| 189 |
foreach ($sug_calendars as $daycal) { |
| 190 |
$todays_arr[] = count($daycal); |
| 191 |
} |
| 192 |
$max_day_cells = max($todays_arr); |
| 193 |
?> |
| 194 |
<div id="vbo-search-suggestions-container-<?php echo $this->code; ?>" class="vbo-search-suggestions-container"> |
| 195 |
<h4><?php echo JText::translate('VBOSEARCHSUGGAVNEAR'); ?></h4> |
| 196 |
<p class="vbo-search-suggestions-intro"><?php echo JText::translate('VBOSEARCHSUGGINTROCODE' . ($this->code === 1 ? '1' : '2')); ?></p> |
| 197 |
<div class="vbo-search-suggestions-av table-responsive"> |
| 198 |
<table class="table"> |
| 199 |
<tbody> |
| 200 |
<?php |
| 201 |
foreach ($sug_calendars as $calkey => $caldays) { |
| 202 |
$monparts = explode('_', $calkey); |
| 203 |
?> |
| 204 |
<tr class="vbo-search-suggestions-month-days"> |
| 205 |
<td class="vbo-search-suggestions-av-mon vbo-pref-color-text" rowspan="2"><?php echo $map_months[((int)$monparts[0] - 1)].' '.$monparts[1]; ?></td> |
| 206 |
<?php |
| 207 |
$days_counter = 0; |
| 208 |
foreach ($caldays as $calday) { |
| 209 |
?> |
| 210 |
<td class="vbo-search-suggestions-month-day<?php echo in_array($calday[0], $this->nights_requested) ? ' vbo-search-suggestions-month-day-requested' : ''; ?>" data-day="<?php echo date('Y-m-d', $calday[0]); ?>"> |
| 211 |
<span class="vbo-suggestion-daynumber"><?php echo $calday['mday']; ?></span> |
| 212 |
<span class="vbo-suggestion-weekday"><?php echo $map_short_wday[(int)$calday['wday']]; ?></span> |
| 213 |
</td> |
| 214 |
<?php |
| 215 |
$days_counter++; |
| 216 |
} |
| 217 |
if ($days_counter < $max_day_cells) { |
| 218 |
while ($days_counter < $max_day_cells) { |
| 219 |
?> |
| 220 |
<td></td> |
| 221 |
<?php |
| 222 |
$days_counter++; |
| 223 |
} |
| 224 |
} |
| 225 |
?> |
| 226 |
</tr> |
| 227 |
<tr class="vbo-search-suggestions-av-days"> |
| 228 |
<?php |
| 229 |
$days_counter = 0; |
| 230 |
foreach ($caldays as $calday) { |
| 231 |
$keyday = date('Y-m-d', $calday[0]); |
| 232 |
$dayclass = isset($this->suggestions[$keyday]) ? 'vbo-suggestion-free' : 'vbo-suggestion-busy'; |
| 233 |
$daycont = 0; |
| 234 |
if (isset($this->suggestions[$keyday])) { |
| 235 |
foreach ($this->suggestions[$keyday] as $rr) { |
| 236 |
$daycont += $rr['units_left']; |
| 237 |
} |
| 238 |
} |
| 239 |
$sayday = $map_long_wday[(int)$calday['wday']].', '.$calday['mday'].' '.$map_months[((int)$monparts[0] - 1)].' '.$monparts[1]; |
| 240 |
?> |
| 241 |
<td class="vbo-search-suggestions-av-day <?php echo $dayclass; ?>" data-keyday="<?php echo $keyday; ?>" data-sayday="<?php echo $sayday; ?>"><?php echo $sugg_units == 1 || $daycont < 1 ? $daycont : ' '; ?></td> |
| 242 |
<?php |
| 243 |
$days_counter++; |
| 244 |
} |
| 245 |
if ($days_counter < $max_day_cells) { |
| 246 |
while ($days_counter < $max_day_cells) { |
| 247 |
?> |
| 248 |
<td></td> |
| 249 |
<?php |
| 250 |
$days_counter++; |
| 251 |
} |
| 252 |
} |
| 253 |
?> |
| 254 |
</tr> |
| 255 |
<tr class="vbo-search-suggestions-av-daysel" style="display: none;"> |
| 256 |
<td class="vbo-search-suggestions-av-daysel-cont" data-keyday="" colspan="<?php echo ($max_day_cells + 1); ?>"></td> |
| 257 |
</tr> |
| 258 |
<?php |
| 259 |
} |
| 260 |
?> |
| 261 |
</tbody> |
| 262 |
</table> |
| 263 |
</div> |
| 264 |
<?php |
| 265 |
if ($this->code == 1 && count($this->solutions)) { |
| 266 |
// (error code 1) closest bookings solutions with availability |
| 267 |
?> |
| 268 |
<div class="vbo-search-solutions-container"> |
| 269 |
<h4><?php echo JText::sprintf('VBOBOOKSOLSUGGNIGHTS', $this->nights.' '.($this->nights > 1 ? JText::translate('VBSEARCHRESNIGHTS') : JText::translate('VBSEARCHRESNIGHT'))); ?></h4> |
| 270 |
<div class="vbo-search-solutions"> |
| 271 |
<?php |
| 272 |
$max_suggestions = 4; |
| 273 |
$sug_count = 0; |
| 274 |
foreach ($this->solutions as $keyday => $solution) { |
| 275 |
$day_info = getdate($keyday); |
| 276 |
$out_info = getdate(mktime(0, 0, 0, $day_info['mon'], ($day_info['mday'] + $this->nights), $day_info['year'])); |
| 277 |
$aduchild_str = ''; |
| 278 |
foreach ($this->party as $gp) { |
| 279 |
$aduchild_str .= '&adults[]='.$gp['adults'].'&children[]='.$gp['children']; |
| 280 |
} |
| 281 |
$nights_suggested = array(date('Y-m-d', $day_info[0])); |
| 282 |
for ($n = 1; $n < $this->nights; $n++) { |
| 283 |
$nights_suggested[] = date('Y-m-d', mktime(0, 0, 0, $day_info['mon'], ($day_info['mday'] + $n), $day_info['year'])); |
| 284 |
} |
| 285 |
?> |
| 286 |
<div class="vbo-search-solution" data-daysol="<?php echo implode(';', $nights_suggested); ?>"> |
| 287 |
<div class="vbo-search-solution-dates"> |
| 288 |
<span class="vbo-search-solution-checkin"> |
| 289 |
<span class="vbo-search-solution-date-lbl"><?php echo JText::sprintf('VBOBOOKSOLSUGGCKIN', $map_long_wday[(int)$day_info['wday']]); ?></span> |
| 290 |
<span class="vbo-search-solution-date-dt"><?php echo date(str_replace("/", $datesep, $df), $day_info[0]); ?></span> |
| 291 |
</span> |
| 292 |
<span class="vbo-search-solution-checkout"> |
| 293 |
<span class="vbo-search-solution-date-lbl"><?php echo JText::sprintf('VBOBOOKSOLSUGGCKOUT', $map_long_wday[(int)$out_info['wday']]); ?></span> |
| 294 |
<span class="vbo-search-solution-date-dt"><?php echo date(str_replace("/", $datesep, $df), $out_info[0]); ?></span> |
| 295 |
</span> |
| 296 |
</div> |
| 297 |
<div class="vbo-search-solution-book vbselectr"> |
| 298 |
<a href="<?php echo JRoute::rewrite('index.php?option=com_vikbooking&task=search&checkindate='.date($df, $day_info[0]).'&checkinh='.$hcheckin.'&checkinm='.$mcheckin.'&checkoutdate='.date($df, $out_info[0]).'&checkouth='.$hcheckout.'&checkoutm='.$mcheckout.'&roomsnum='.count($this->party).$aduchild_str.(!empty($pcategories) ? '&categories='.$pcategories : '').(!empty($pitemid) ? '&Itemid='.$pitemid : '')); ?>" class="btn vbo-pref-color-btn"><?php echo JText::translate('VBOBOOKSOLSEARCHROOMS'); ?></a> |
| 299 |
</div> |
| 300 |
</div> |
| 301 |
<?php |
| 302 |
$sug_count++; |
| 303 |
if ($sug_count >= $max_suggestions) { |
| 304 |
break; |
| 305 |
} |
| 306 |
} |
| 307 |
?> |
| 308 |
</div> |
| 309 |
</div> |
| 310 |
<?php |
| 311 |
} elseif ($this->code == 1 && !count($this->solutions)) { |
| 312 |
//if error code = 1 and count(solutions) = 0, it probably means that the party requested cannot be satisfied in the suggested dates. |
| 313 |
//we display a message like: "...try to select a different number of rooms and guests" |
| 314 |
?> |
| 315 |
<div class="vbo-search-solutions-container"> |
| 316 |
<p class="vbo-search-no-solutions"><?php echo JText::translate('VBOSEARCHNOSOLUTIONS'); ?></p> |
| 317 |
</div> |
| 318 |
<?php |
| 319 |
} |
| 320 |
|
| 321 |
if (($this->code == 2 || $this->code == 3) && count($this->booking_solutions)) { |
| 322 |
//(error codes 2/3) other combinations of party for booking |
| 323 |
$guests_strarr = array(); |
| 324 |
if ($this->party_guests['adults'] > 0) { |
| 325 |
$guests_strarr[] = $this->party_guests['adults'].' '.($this->party_guests['adults'] > 1 ? JText::translate('VBSEARCHRESADULTS') : JText::translate('VBSEARCHRESADULT')); |
| 326 |
} |
| 327 |
if ($this->party_guests['children'] > 0) { |
| 328 |
$guests_strarr[] = $this->party_guests['children'].' '.($this->party_guests['children'] > 1 ? JText::translate('VBSEARCHRESCHILDREN') : JText::translate('VBSEARCHRESCHILD')); |
| 329 |
} |
| 330 |
?> |
| 331 |
<div class="vbo-booking-solutions-container"> |
| 332 |
<h4><?php echo JText::sprintf('VBOBOOKSOLSUGGPARTY', implode(', ', $guests_strarr)); ?></h4> |
| 333 |
<div class="vbo-booking-solutions"> |
| 334 |
<?php |
| 335 |
$max_suggestions = 4; |
| 336 |
$sug_count = 0; |
| 337 |
foreach ($this->booking_solutions as $keyday => $solution) { |
| 338 |
$day_info = getdate($keyday); |
| 339 |
$out_info = getdate(mktime(0, 0, 0, $day_info['mon'], ($day_info['mday'] + $this->nights), $day_info['year'])); |
| 340 |
$sol_checkints = mktime($hcheckin, $mcheckin, 0, $day_info['mon'], $day_info['mday'], $day_info['year']); |
| 341 |
$sol_checkoutts = mktime($hcheckout, $mcheckout, 0, $out_info['mon'], $out_info['mday'], $out_info['year']); |
| 342 |
$sol_tot_rooms = count($solution); |
| 343 |
$aduchild_str = ''; |
| 344 |
$nights_suggested = array(date('Y-m-d', $day_info[0])); |
| 345 |
for ($n = 1; $n < $this->nights; $n++) { |
| 346 |
$nights_suggested[] = date('Y-m-d', mktime(0, 0, 0, $day_info['mon'], ($day_info['mday'] + $n), $day_info['year'])); |
| 347 |
} |
| 348 |
?> |
| 349 |
<div class="vbo-booking-solution" data-daysol="<?php echo implode(';', $nights_suggested); ?>"> |
| 350 |
<div class="vbo-booking-solution-dates"> |
| 351 |
<span class="vbo-booking-solution-checkin"> |
| 352 |
<span class="vbo-booking-solution-date-lbl"><?php echo JText::sprintf('VBOBOOKSOLSUGGCKIN', $map_long_wday[(int)$day_info['wday']]); ?></span> |
| 353 |
<span class="vbo-booking-solution-date-dt"><?php echo date(str_replace("/", $datesep, $df), $day_info[0]); ?></span> |
| 354 |
</span> |
| 355 |
<span class="vbo-booking-solution-checkout"> |
| 356 |
<span class="vbo-booking-solution-date-lbl"><?php echo JText::sprintf('VBOBOOKSOLSUGGCKOUT', $map_long_wday[(int)$out_info['wday']]); ?></span> |
| 357 |
<span class="vbo-booking-solution-date-dt"><?php echo date(str_replace("/", $datesep, $df), $out_info[0]); ?></span> |
| 358 |
</span> |
| 359 |
</div> |
| 360 |
<div class="vbo-booking-solution-rooms"> |
| 361 |
<div class="vbo-booking-solution-totrooms"><?php echo $sol_tot_rooms.' '.($sol_tot_rooms > 1 ? JText::translate('VBSEARCHRESROOMS') : JText::translate('VBSEARCHRESROOM')); ?></div> |
| 362 |
<?php |
| 363 |
foreach ($solution as $roomsol) { |
| 364 |
$room_guests_strarr = array(); |
| 365 |
if ($roomsol['guests_allocation']['adults'] > 0) { |
| 366 |
$room_guests_strarr[] = $roomsol['guests_allocation']['adults'].' '.($roomsol['guests_allocation']['adults'] > 1 ? JText::translate('VBSEARCHRESADULTS') : JText::translate('VBSEARCHRESADULT')); |
| 367 |
} |
| 368 |
if ($roomsol['guests_allocation']['children'] > 0) { |
| 369 |
$room_guests_strarr[] = $roomsol['guests_allocation']['children'].' '.($roomsol['guests_allocation']['children'] > 1 ? JText::translate('VBSEARCHRESCHILDREN') : JText::translate('VBSEARCHRESCHILD')); |
| 370 |
} |
| 371 |
$aduchild_str .= '&adults[]='.$roomsol['guests_allocation']['adults'].'&children[]='.$roomsol['guests_allocation']['children']; |
| 372 |
?> |
| 373 |
<div class="vbo-booking-solution-room"> |
| 374 |
<span class="vbo-booking-solution-rname"> |
| 375 |
<a href="<?php echo JRoute::rewrite('index.php?option=com_vikbooking&view=searchdetails&roomid='.$roomsol['id'].'&checkin='.$sol_checkints.'&checkout='.$sol_checkoutts.'&adults='.$roomsol['guests_allocation']['adults'].'&children='.$roomsol['guests_allocation']['children'].'&tmpl=component'.(!empty($pitemid) ? '&Itemid='.$pitemid : '')); ?>" class="vbmodalframe" target="_blank"><?php echo $roomsol['name']; ?></a> |
| 376 |
</span> |
| 377 |
<span class="vbo-booking-solution-guests"><?php echo implode(', ', $room_guests_strarr); ?></span> |
| 378 |
</div> |
| 379 |
<?php |
| 380 |
} |
| 381 |
?> |
| 382 |
</div> |
| 383 |
<div class="vbo-booking-solution-book vbselectr"> |
| 384 |
<a class="btn vbo-pref-color-btn" href="<?php echo JRoute::rewrite('index.php?option=com_vikbooking&task=search&suggestion='.$this->code.'&checkindate='.date($df, $day_info[0]).'&checkinh='.$hcheckin.'&checkinm='.$mcheckin.'&checkoutdate='.date($df, $out_info[0]).'&checkouth='.$hcheckout.'&checkoutm='.$mcheckout.'&roomsnum='.$sol_tot_rooms.$aduchild_str.(!empty($pcategories) ? '&categories='.$pcategories : '').(!empty($pitemid) ? '&Itemid='.$pitemid : '')); ?>"><?php echo JText::translate('VBBOOKNOW'); ?></a> |
| 385 |
</div> |
| 386 |
</div> |
| 387 |
<?php |
| 388 |
$sug_count++; |
| 389 |
if ($sug_count >= $max_suggestions) { |
| 390 |
break; |
| 391 |
} |
| 392 |
} |
| 393 |
?> |
| 394 |
</div> |
| 395 |
</div> |
| 396 |
<?php |
| 397 |
} elseif (($this->code == 2 || $this->code == 3) && !count($this->booking_solutions)) { |
| 398 |
//if error code = 2/3 and count(booking_solutions) = 0, it probably means that there are no rates, or no rooms to fit this number of nights and guests |
| 399 |
?> |
| 400 |
<div class="vbo-booking-solutions-container"> |
| 401 |
<p class="vbo-search-no-solutions"><?php echo JText::translate('VBOSEARCHNOBOOKSOLUTIONS'); ?></p> |
| 402 |
</div> |
| 403 |
<?php |
| 404 |
} |
| 405 |
?> |
| 406 |
</div> |
| 407 |
<script type="text/javascript"> |
| 408 |
jQuery('#vbo-search-suggestions-container-<?php echo $this->code; ?>').find(".vbo-search-solution, .vbo-booking-solution").hover(function() { |
| 409 |
var daysol = jQuery(this).attr("data-daysol").split(";"); |
| 410 |
if (!daysol.length) { |
| 411 |
return; |
| 412 |
} |
| 413 |
for (var i = 0; i < daysol.length; i++) { |
| 414 |
var avday = jQuery('#vbo-search-suggestions-container-<?php echo $this->code; ?>').find("td.vbo-search-suggestions-month-day[data-day='"+daysol[i]+"']"); |
| 415 |
if (avday && avday.length) { |
| 416 |
avday.addClass("vbo-search-suggestions-month-day-highlighted"); |
| 417 |
} |
| 418 |
} |
| 419 |
}, function() { |
| 420 |
jQuery('#vbo-search-suggestions-container-<?php echo $this->code; ?>').find("td.vbo-search-suggestions-month-day-highlighted").removeClass("vbo-search-suggestions-month-day-highlighted"); |
| 421 |
}); |
| 422 |
|
| 423 |
jQuery(".vbmodalframe").fancybox({ |
| 424 |
"helpers": { |
| 425 |
"overlay": { |
| 426 |
"locked": false |
| 427 |
} |
| 428 |
}, |
| 429 |
"width": "70%", |
| 430 |
"height": "60%", |
| 431 |
"autoScale": true, |
| 432 |
"transitionIn": "none", |
| 433 |
"transitionOut": "none", |
| 434 |
"padding": 0, |
| 435 |
"fitToView" : true, |
| 436 |
"autoSize" : false, |
| 437 |
"type": "iframe" |
| 438 |
}); |
| 439 |
|
| 440 |
/** |
| 441 |
* We allow multiple requests to be made on this View, one for each error code. |
| 442 |
* For this reason, all JS functions should be restricted to the current error code. |
| 443 |
* |
| 444 |
* @since 1.3.6 |
| 445 |
*/ |
| 446 |
var vbo_suggestions_<?php echo $this->code; ?> = <?php echo json_encode($this->suggestions); ?>; |
| 447 |
|
| 448 |
jQuery('#vbo-search-suggestions-container-<?php echo $this->code; ?>').find(".vbo-suggestion-free").click(function() { |
| 449 |
var vbo_suggestions = vbo_suggestions_<?php echo $this->code; ?>; |
| 450 |
var keyday = jQuery(this).attr('data-keyday'); |
| 451 |
var sayday = jQuery(this).attr('data-sayday'); |
| 452 |
var trshow = jQuery(this).parent("tr").next(".vbo-search-suggestions-av-daysel"); |
| 453 |
if (!trshow || !trshow.length) { |
| 454 |
return; |
| 455 |
} |
| 456 |
var daycont = ''; |
| 457 |
var tdcont = trshow.find(".vbo-search-suggestions-av-daysel-cont"); |
| 458 |
if (trshow.is(":visible") && tdcont.attr('data-keyday') == keyday) { |
| 459 |
jQuery(this).removeClass("vbo-suggestion-selected"); |
| 460 |
trshow.fadeOut(400, function() { |
| 461 |
tdcont.html(daycont); |
| 462 |
}); |
| 463 |
return; |
| 464 |
} |
| 465 |
|
| 466 |
if (vbo_suggestions.hasOwnProperty(keyday)) { |
| 467 |
jQuery('#vbo-search-suggestions-container-<?php echo $this->code; ?>').find(".vbo-suggestion-free.vbo-suggestion-selected").removeClass("vbo-suggestion-selected"); |
| 468 |
jQuery(this).addClass("vbo-suggestion-selected"); |
| 469 |
daycont += '<h5>'+sayday+'</h5>'; |
| 470 |
daycont += '<div class="vbo-search-suggestions-dayrooms">'; |
| 471 |
for (var rid in vbo_suggestions[keyday]) { |
| 472 |
var paramshowpeople = parseInt(JSON.parse(vbo_suggestions[keyday][rid]['params'])['maxminpeople']); |
| 473 |
daycont += '<div class="vbo-search-suggestions-dayroom">'; |
| 474 |
daycont += '<div class="vbo-search-suggestions-dayroom-name">'+vbo_suggestions[keyday][rid]['name']+'</div>'; |
| 475 |
<?php |
| 476 |
if ($sugg_units == 1) : |
| 477 |
?> |
| 478 |
daycont += '<div class="vbo-search-suggestions-dayroom-units">x'+vbo_suggestions[keyday][rid]['units_left']+'</div>'; |
| 479 |
<?php |
| 480 |
endif; |
| 481 |
?> |
| 482 |
daycont += '<div class="vbo-search-suggestions-dayroom-guests">'; |
| 483 |
if (paramshowpeople > 0) { |
| 484 |
var maxadustr = (vbo_suggestions[keyday][rid]['fromadult'] != vbo_suggestions[keyday][rid]['toadult'] ? vbo_suggestions[keyday][rid]['fromadult']+' - '+vbo_suggestions[keyday][rid]['toadult'] : vbo_suggestions[keyday][rid]['toadult']); |
| 485 |
var maxchistr = (vbo_suggestions[keyday][rid]['fromchild'] != vbo_suggestions[keyday][rid]['tochild'] ? vbo_suggestions[keyday][rid]['fromchild']+' - '+vbo_suggestions[keyday][rid]['tochild'] : vbo_suggestions[keyday][rid]['tochild']); |
| 486 |
var maxtotstr = (vbo_suggestions[keyday][rid]['mintotpeople'] != vbo_suggestions[keyday][rid]['totpeople'] ? vbo_suggestions[keyday][rid]['mintotpeople']+' - '+vbo_suggestions[keyday][rid]['totpeople'] : vbo_suggestions[keyday][rid]['totpeople']); |
| 487 |
daycont += '<div class="vbmaxminpeopleroom">'; |
| 488 |
if (paramshowpeople == 1) { |
| 489 |
daycont += '<div class="vbmaxadultsdet"><span class="vbmaximgdet"><?php VikBookingIcons::e('male'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBFORMADULTS')); ?></span><span class="vbmaxnumberdet">'+maxadustr+'</span></div>'; |
| 490 |
} else if (paramshowpeople == 2) { |
| 491 |
daycont += '<div class="vbmaxchildrendet"><span class="vbmaximgdet"><?php VikBookingIcons::e('child'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBFORMCHILDREN')); ?></span><span class="vbmaxnumberdet">'+maxchistr+'</span></div>'; |
| 492 |
} else if (paramshowpeople == 3) { |
| 493 |
daycont += '<div class="vbmaxadultsdet"><span class="vbmaximgdet"><?php VikBookingIcons::e('male'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBFORMADULTS')); ?></span><span class="vbmaxnumberdet">'+maxadustr+'</span></div>'; |
| 494 |
daycont += '<div class="vbmaxtotdet"><span class="vbmaximgdet"><?php VikBookingIcons::e('users'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBMAXTOTPEOPLE')); ?></span><span class="vbmaxnumberdet">'+maxtotstr+'</span></div>'; |
| 495 |
} else if (paramshowpeople == 4) { |
| 496 |
daycont += '<div class="vbmaxchildrendet"><span class="vbmaximgdet"><?php VikBookingIcons::e('child'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBFORMCHILDREN')); ?></span><span class="vbmaxnumberdet">'+maxchistr+'</span></div>'; |
| 497 |
daycont += '<div class="vbmaxtotdet"><span class="vbmaximgdet"><?php VikBookingIcons::e('users'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBMAXTOTPEOPLE')); ?></span><span class="vbmaxnumberdet">'+maxtotstr+'</span></div>'; |
| 498 |
} else if (paramshowpeople == 5) { |
| 499 |
daycont += '<div class="vbmaxadultsdet"><span class="vbmaximgdet"><?php VikBookingIcons::e('male'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBFORMADULTS')); ?></span><span class="vbmaxnumberdet">'+maxadustr+'</span></div>'; |
| 500 |
daycont += '<div class="vbmaxchildrendet"><span class="vbmaximgdet"><?php VikBookingIcons::e('child'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBFORMCHILDREN')); ?></span><span class="vbmaxnumberdet">'+maxchistr+'</span></div>'; |
| 501 |
daycont += '<div class="vbmaxtotdet"><span class="vbmaximgdet"><?php VikBookingIcons::e('users'); ?></span><span class="vbmaxlabeldet"><?php echo addslashes(JText::translate('VBMAXTOTPEOPLE')); ?></span><span class="vbmaxnumberdet">'+maxtotstr+'</span></div>'; |
| 502 |
} |
| 503 |
daycont += '</div>'; |
| 504 |
} |
| 505 |
daycont += '</div>'; |
| 506 |
daycont += '</div>'; |
| 507 |
} |
| 508 |
daycont += '</div>'; |
| 509 |
tdcont.attr('data-keyday', keyday); |
| 510 |
tdcont.html(daycont); |
| 511 |
trshow.fadeIn(); |
| 512 |
} |
| 513 |
}); |
| 514 |
</script> |
| 515 |
<?php |
| 516 |
} |
| 517 |
|