PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.6
VikBooking Hotel Booking Engine & PMS v1.6.6
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 / search / tmpl / default_compact.php

default_compact.php in VikBooking Hotel Booking Engine & PMS 1.6.6, at site/views/search/tmpl/default_compact.php

619 lines 23.0 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 $document = JFactory::getDocument();
14 $document->addStyleSheet(VBO_SITE_URI.'resources/vikfxgallery.css');
15 JHtml::fetch('script', VBO_SITE_URI.'resources/vikfxgallery.js');
16
17 $vat_included = VikBooking::ivaInclusa();
18 $tax_summary = !$vat_included && VikBooking::showTaxOnSummaryOnly() ? true : false;
19
20 $currencysymb = VikBooking::getCurrencySymb();
21
22 // compose array of rooms available for the requested parties
23 $rooms_res = [];
24 $rooms_units = [];
25 $rooms_parties = [];
26 $gallery_data = [];
27 foreach ($this->res as $indroom => $rooms) {
28 foreach ($rooms as $roomrates) {
29 $idroom = $roomrates[0]['idroom'];
30 if (!isset($rooms_res[$idroom])) {
31 $rooms_res[$idroom] = [];
32 $rooms_units[$idroom] = $roomrates[0]['unitsavail'];
33 }
34 $rooms_res[$idroom][$indroom] = $roomrates;
35 }
36 }
37 ?>
38
39 <div class="vbo-searchresults-compact-wrap">
40 <?php
41 foreach ($rooms_res as $idroom => $room_res) {
42 $rooms_parties[$idroom] = array_keys($room_res);
43 foreach ($room_res as $indroom => $roomrates) {
44 $roominfo = $roomrates[0];
45 // just one loop
46 break;
47 }
48 $has_promotion = isset($roominfo['promotion']);
49 $carats = VikBooking::getRoomCaratOriz($roominfo['idcarat'], $this->vbo_tn);
50
51 // prepare CMS contents depending on platform
52 $roominfo = VBORoomHelper::getInstance()->prepareCMSContents($roominfo, ['smalldesc']);
53
54 $saylastavail = false;
55 $showlastavail = (int)VikBooking::getRoomParam('lastavail', $roominfo['params']);
56 if (!empty($showlastavail) && $showlastavail > 0) {
57 if ($roominfo['unitsavail'] <= $showlastavail) {
58 $saylastavail = true;
59 }
60 }
61 // get the max units this room can have in the drop down
62 $maxunits = 1;
63 if (count($room_res) > 1) {
64 // room is available for multiple room parties. Count how many parties have the same adults/children
65 $parties = $rooms_parties[$idroom];
66 $party_count = [];
67 foreach ($parties as $party) {
68 $party_key = "adults{$this->arrpeople[$party]['adults']}children{$this->arrpeople[$party]['children']}";
69 if (!isset($party_count[$party_key])) {
70 $party_count[$party_key] = 0;
71 }
72 $party_count[$party_key]++;
73 }
74 $maxunits = max($party_count);
75 $maxunits = $maxunits > $roominfo['unitsavail'] ? $roominfo['unitsavail'] : $maxunits;
76 }
77 // gallery
78 if (!empty($roominfo['moreimgs'])) {
79 $gallery_data[$idroom] = [];
80 $moreimages = explode(';;', $roominfo['moreimgs']);
81 $imgcaptions = json_decode($roominfo['imgcaptions'], true);
82 $usecaptions = is_array($imgcaptions);
83 foreach ($moreimages as $iind => $mimg) {
84 if (empty($mimg)) {
85 continue;
86 }
87 $img_alt = $usecaptions && !empty($imgcaptions[$iind]) ? $imgcaptions[$iind] : substr($mimg, 0, strpos($mimg, '.'));
88 array_push($gallery_data[$idroom], [
89 'big' => VBO_SITE_URI . 'resources/uploads/big_' . $mimg,
90 'thumb' => VBO_SITE_URI . 'resources/uploads/thumb_' . $mimg,
91 'alt' => $img_alt,
92 'caption' => $usecaptions && !empty($imgcaptions[$iind]) ? $imgcaptions[$iind] : "",
93 ]);
94 }
95 }
96 //
97 ?>
98 <div class="vbo-room-result-wrap<?php echo $has_promotion ? ' vbo-promotion-price' : ''; ?>">
99 <div class="vbo-room-result-inner">
100 <div class="vbo-room-result-head">
101 <div class="vbo-room-result-head-img">
102 <span><?php echo JText::translate('VBSEARCHRESROOM'); ?></span>
103 </div>
104 <div class="vbo-room-result-head-details">
105 <span><?php echo JText::translate('VBSEARCHRESDETAILS'); ?></span>
106 </div>
107 <div class="vbo-room-result-head-party">
108 <span><?php echo JText::translate('VBOINVTOTGUESTS'); ?></span>
109 </div>
110 <div class="vbo-room-result-head-price">
111 <span><?php echo JText::translate('VBPRICE'); ?></span>
112 </div>
113 <div class="vbo-room-result-head-select">
114 <span><?php echo JText::translate('VBORESERVE'); ?></span>
115 </div>
116 <div class="vbo-room-result-head-bookstatus">
117 <span></span>
118 </div>
119 </div>
120 <div class="vbo-room-result-body">
121 <div class="vbo-room-result-body-img">
122 <div class="vikfx-gallery-container vikfx-compact-gallery-container">
123 <div class="vikfx-gallery-fade-container">
124 <img class="vblistimg" alt="<?php echo htmlspecialchars($roominfo['name']); ?>" id="vbroomimg<?php echo $idroom; ?>" src="<?php echo VBO_SITE_URI; ?>resources/uploads/<?php echo $roominfo['img']; ?>"/>
125 <?php
126 if (isset($gallery_data[$idroom]) && count($gallery_data[$idroom])) {
127 ?>
128 <div class="vikfx-gallery-navigation-controls">
129 <div class="vikfx-gallery-navigation-controls-prevnext">
130 <a href="javascript: void(0);" class="vikfx-gallery-previous-image" id="vikfx-gallery-previous-image<?php echo $idroom; ?>"><?php VikBookingIcons::e('chevron-left'); ?></a>
131 <a href="javascript: void(0);" class="vikfx-gallery-next-image" id="vikfx-gallery-next-image<?php echo $idroom; ?>"><?php VikBookingIcons::e('chevron-right'); ?></a>
132 </div>
133 </div>
134 <?php
135 }
136 ?>
137 </div>
138 <?php
139 if (isset($gallery_data[$idroom]) && count($gallery_data[$idroom])) {
140 ?>
141 <div class="vikfx-gallery" id="vikfx-gallery<?php echo $idroom; ?>">
142 <?php
143 foreach ($gallery_data[$idroom] as $mimg) {
144 ?>
145 <a href="<?php echo $mimg['big']; ?>">
146 <img src="<?php echo $mimg['thumb']; ?>" alt="<?php echo $this->escape($mimg['alt']); ?>" title="<?php echo $this->escape($mimg['caption']); ?>"/>
147 </a>
148 <?php
149 }
150 ?>
151 </div>
152 <?php
153 }
154 ?>
155 </div>
156 </div>
157 <div class="vbo-room-result-body-details">
158 <div class="vbo-room-result-body-rname">
159 <h4><?php echo $roominfo['name']; ?></h4>
160 <?php
161 if ($saylastavail === true) {
162 ?>
163 <span class="vbo-room-result-body-lastavail"><?php echo JText::sprintf('VBLASTUNITSAVAIL', $roominfo['unitsavail']); ?></span>
164 <?php
165 }
166 ?>
167 </div>
168 <div class="vbrowcdescr"><?php echo $roominfo['smalldesc']; ?></div>
169 <?php
170 if (!empty($carats)) {
171 ?>
172 <div class="roomlist_carats">
173 <?php echo $carats; ?>
174 </div>
175 <?php
176 }
177 if ($has_promotion && !empty($roominfo['promotion']['promotxt'])) {
178 ?>
179 <div class="vbo-promotion-block">
180 <div class="vbo-promotion-icon"><?php VikBookingIcons::e('percentage'); ?></div>
181 <div class="vbo-promotion-description">
182 <?php echo $roominfo['promotion']['promotxt']; ?>
183 </div>
184 </div>
185 <?php
186 }
187 ?>
188 </div>
189 <div class="vbo-room-result-body-bookingsolutions">
190 <?php
191 $room_parties_displayed = [];
192 foreach ($room_res as $indroom => $roomrates) {
193 $party_key = "adults{$this->arrpeople[$indroom]['adults']}children{$this->arrpeople[$indroom]['children']}";
194 if (in_array($party_key, $room_parties_displayed)) {
195 // skip this room because the drop down will already display the possibility of booking multiple units of this room
196 continue;
197 }
198 // push the party displayed
199 array_push($room_parties_displayed, $party_key);
200 ?>
201 <div class="vbo-room-result-body-bookingsolution">
202 <div class="vbo-room-result-body-price-party">
203 <?php
204 $totguests = $this->arrpeople[$indroom]['adults'] + $this->arrpeople[$indroom]['children'];
205 if ($this->arrpeople[$indroom]['adults'] > 0) {
206 ?>
207 <div class="vbo-room-result-body-price-party-adults">
208 <?php
209 if ($totguests > 4) {
210 ?>
211 <span><?php VikBookingIcons::e('male'); ?> &times;<?php echo $this->arrpeople[$indroom]['adults']; ?></span>
212 <?php
213 } else {
214 for ($i = 0; $i < $this->arrpeople[$indroom]['adults']; $i++) {
215 VikBookingIcons::e('male');
216 }
217 }
218 ?>
219 </div>
220 <?php
221 }
222 if ($this->arrpeople[$indroom]['children'] > 0) {
223 ?>
224 <div class="vbo-room-result-body-price-party-children">
225 <?php
226 if ($totguests > 4) {
227 ?>
228 <span><?php VikBookingIcons::e('child'); ?> &times;<?php echo $this->arrpeople[$indroom]['children']; ?></span>
229 <?php
230 } else {
231 for ($i = 0; $i < $this->arrpeople[$indroom]['children']; $i++) {
232 VikBookingIcons::e('child');
233 }
234 }
235 ?>
236 </div>
237 <?php
238 }
239 $raw_roomcost = $tax_summary ? $roomrates[0]['cost'] : VikBooking::sayCostPlusIva($roomrates[0]['cost'], $roomrates[0]['idprice']);
240 ?>
241 </div>
242 <div class="vbo-room-result-body-price-amount">
243 <span class="room_cost">
244 <span class="vbo_currency"><?php echo $currencysymb; ?></span>
245 <span class="vbo_price"><?php echo VikBooking::numberFormat($raw_roomcost); ?></span>
246 </span>
247 <?php
248 if (isset($roominfo['promotion']) && isset($roominfo['promotion']['discount'])) {
249 if ($roominfo['promotion']['discount']['pcent']) {
250 /**
251 * Do not make an upper-cent operation, but rather calculate the original price proportionally:
252 * final price : (100 - discount amount) = x : 100
253 *
254 * @since 1.13.5
255 */
256 $prev_amount = $raw_roomcost * 100 / (100 - $roominfo['promotion']['discount']['amount']);
257 } else {
258 $prev_amount = $raw_roomcost + $roominfo['promotion']['discount']['amount'];
259 }
260 if ($prev_amount > 0) {
261 ?>
262 <div class="vbo-room-result-price-before-discount">
263 <span class="room_cost">
264 <span class="vbo_currency"><?php echo $currencysymb; ?></span>
265 <span class="vbo_price"><?php echo VikBooking::numberFormat($prev_amount); ?></span>
266 </span>
267 </div>
268 <?php
269 if ($roominfo['promotion']['discount']['pcent']) {
270 // hide by default the DIV containing the percent of discount
271 ?>
272 <div class="vbo-room-result-price-before-discount-percent" style="display: none;">
273 <span class="room_cost">
274 <span><?php echo '-' . (float)$roominfo['promotion']['discount']['amount'] . ' %'; ?></span>
275 </span>
276 </div>
277 <?php
278 }
279 }
280 }
281 ?>
282 </div>
283 <div class="vbo-room-result-body-price-selection">
284 <select id="vbo-selroom-<?php echo "{$indroom}-{$roomrates[0]['idroom']}"; ?>" class="vbo-selroom-ddown vbo-selroom-room<?php echo $roomrates[0]['idroom']; ?> vbo-selroom-party<?php echo $indroom; ?>" onchange="vboCompactSelRoom(<?php echo $indroom; ?>, <?php echo $roomrates[0]['idroom']; ?>, this.value);">
285 <option value="0">0</option>
286 <?php
287 for ($i = 1; $i <= $maxunits; $i++) {
288 ?>
289 <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
290 <?php
291 }
292 ?>
293 </select>
294 </div>
295 <div class="vbo-room-result-body-bookstatus">
296 <span class="vbo-room-result-body-bookmsg" style="display: none;"></span>
297 <div class="vbo-room-result-body-bookbtn" style="display: none;">
298 <button type="button" class="btn" onclick="vboCompactProceed();"><?php echo JText::translate('VBBOOKNOW'); ?></button>
299 </div>
300 </div>
301 </div>
302 <?php
303 }
304 ?>
305 </div>
306 </div>
307 </div>
308 </div>
309 <?php
310 }
311 ?>
312 </div>
313
314 <script type="text/javascript">
315 var vboNeededBooked = <?php echo $this->roomsnum; ?>;
316 var vboRoomsUnits = <?php echo json_encode($rooms_units); ?>;
317 var vboRoomsParties = <?php echo json_encode($rooms_parties); ?>;
318 var vboPartiesRequested = {};
319 var vboRoomsUnitsPool = {};
320 var vboRoomsAssigned = {};
321 var vboCompactMsg = {
322 missingRoomsPl: "<?php echo addslashes(JText::translate('VBONROOMSMISSINGPL')); ?>",
323 missingRoomsSi: "<?php echo addslashes(JText::translate('VBONROOMSMISSINGSI')); ?>",
324 };
325 function vboCompactCountSelected(idroom) {
326 var totselected = 0;
327 var ddowns = document.getElementsByClassName((idroom ? 'vbo-selroom-room' + idroom : 'vbo-selroom-ddown'));
328 for (var i = 0; i < ddowns.length; i++) {
329 totselected += parseInt(ddowns.item(i).value);
330 }
331 return totselected;
332 }
333 function vboCompactCountBooked() {
334 var totbooked = 0;
335 for (var i = 1; i <= vboNeededBooked; i++) {
336 var inpslot = document.getElementById('roomopt' + i).value;
337 if (inpslot.length && parseInt(inpslot) > 0) {
338 totbooked++;
339 }
340 }
341 return totbooked;
342 }
343 /**
344 * Checks whether a slot is occupied by another room. Returns false or an array with the occupier information.
345 */
346 function vboCompactIsSlotOccupied(indroom, idroom) {
347 var current_val = document.getElementById('roomopt' + indroom).value;
348 if (current_val && current_val.length && (current_val + '') != (idroom + '')) {
349 return [parseInt(indroom), parseInt(current_val)];
350 }
351 return false;
352 }
353 /**
354 * Frees up one slot by updating the necessary objects and input field.
355 */
356 function vboCompactMakeSlotFree(indroom, idroom) {
357 var current_room = document.getElementById('roomopt' + indroom).value;
358 if (!current_room || !current_room.length) {
359 return;
360 }
361 current_room = parseInt(current_room);
362 document.getElementById('roomopt' + indroom).value = '';
363 if (vboPartiesRequested.hasOwnProperty(indroom)) {
364 delete vboPartiesRequested[indroom];
365 }
366 if (vboRoomsAssigned.hasOwnProperty(current_room) && vboRoomsAssigned[current_room].hasOwnProperty(indroom)) {
367 for (var i in vboRoomsAssigned[current_room][indroom]) {
368 if (vboRoomsAssigned[current_room][indroom].hasOwnProperty(i) && vboRoomsAssigned[current_room][indroom][i] == indroom) {
369 vboRoomsAssigned[current_room][indroom].splice(i, 1);
370 break;
371 }
372 }
373 }
374 jQuery('.vbo-selroom-room' + current_room).each(function(k, v) {
375 var elem = jQuery(v);
376 var current_val = parseInt(elem.val());
377 if (current_val > 0 && (elem.hasClass('vbo-selroom-party' + indroom) || (Array.isArray(vboRoomsParties[current_room]) && vboRoomsParties[current_room].includes(indroom)))) {
378 elem.val((current_val - 1));
379 // if some drop downs were previously disabled, turn them back on
380 var roomtotsel = vboCompactCountSelected(current_room);
381 if (roomtotsel < vboRoomsUnits[current_room]) {
382 // other units available for this room-type
383 var container = elem.closest('.vbo-room-result-body-bookingsolutions');
384 container.find('.vbo-room-result-body-bookingsolution').removeClass('vbo-room-result-soldout');
385 container.find('select.vbo-selroom-ddown').prop('disabled', false);
386 }
387 // break loop
388 return false;
389 }
390 });
391 }
392 /**
393 * Disables or enables the parties that can be booked.
394 */
395 function vboCompactUpdateParties() {
396 // always free up the already chosen elements for the now empty parties
397 for (var i = 1; i <= vboNeededBooked; i++) {
398 var inpslot = document.getElementById('roomopt' + i).value;
399 if (!inpslot.length) {
400 // no room for this party, make sure the drop downs are enabled
401 jQuery('.vbo-room-result-alreadychosen-' + i).prop('disabled', false).removeClass('vbo-room-result-alreadychosen-' + i);
402 }
403 }
404 //
405 for (var indparty in vboPartiesRequested) {
406 if (!vboPartiesRequested.hasOwnProperty(indparty) || !vboPartiesRequested[indparty]) {
407 continue;
408 }
409 for (var room in vboRoomsParties) {
410 if (!vboRoomsParties.hasOwnProperty(room) || !vboRoomsParties[room].length) {
411 continue;
412 }
413 var check_indparty = parseInt(indparty);
414 if (vboRoomsParties[room].includes(check_indparty)) {
415 // this room is suitable for this party already chosen
416 var elem = jQuery('#vbo-selroom-' + indparty + '-' + room);
417 if (!elem.length) {
418 continue;
419 }
420 if (elem.val() < 1) {
421 // we can disable this drop down so that no units will be selected
422 elem.prop('disabled', true).addClass('vbo-room-result-alreadychosen-' + indparty);
423 } else if (!elem.closest('.vbo-room-result-body-bookingsolution').hasClass('vbo-room-result-soldout')) {
424 // we can enable this drop down
425 elem.prop('disabled', false);
426 }
427 }
428 }
429 }
430 }
431
432 function vboCompactSelRoom(indroom, idroom, units) {
433 // adjust vars
434 units = parseInt(units);
435
436 // update rooms units counter and assigned for visible drop downs
437 if (!vboRoomsUnitsPool.hasOwnProperty(idroom)) {
438 vboRoomsUnitsPool[idroom] = {};
439 vboRoomsAssigned[idroom] = {};
440 }
441 if (!vboRoomsUnitsPool[idroom].hasOwnProperty(indroom)) {
442 vboRoomsUnitsPool[idroom][indroom] = units;
443 vboRoomsAssigned[idroom][indroom] = new Array;
444 }
445 var adding_units = (vboRoomsUnitsPool[idroom][indroom] <= units);
446 var removing_units = !adding_units ? (vboRoomsUnitsPool[idroom][indroom] - units) : 0;
447 var truly_removing = !adding_units;
448 if (truly_removing && removing_units > 0 && units > 0 && (vboCompactCountBooked() - removing_units + units) == vboNeededBooked) {
449 truly_removing = false;
450 }
451
452 // update units selected for this drop down
453 vboRoomsUnitsPool[idroom][indroom] = units;
454
455 if (adding_units) {
456 // populate fields when adding units
457 var indcounter = 0;
458 var units_added = 0;
459 var slot_occupied = vboCompactIsSlotOccupied(indroom, idroom);
460 if (units === 1 && (vboRoomsParties[idroom].length === 1 || slot_occupied === false)) {
461 // occupy exact party requested for one unit when room not suited for other parties or when slot is free
462 if (slot_occupied !== false) {
463 vboCompactMakeSlotFree(slot_occupied[0], slot_occupied[1]);
464 }
465 indcounter++;
466 units_added++;
467 document.getElementById('roomopt' + indroom).value = idroom;
468 vboPartiesRequested[indroom] = idroom;
469 vboRoomsAssigned[idroom][indroom].push(indroom);
470 }
471
472 // selected more than one unit, or one unit for a room that is suitable for multiple parties
473 for (var i = indcounter; i < units; i++) {
474 // fill all containers valid for this room party until the units requested are reached
475 var indparty = vboRoomsParties[idroom][i];
476 if (!document.getElementById('roomopt' + indparty).value.length) {
477 // populate first available party for this room
478 units_added++;
479 document.getElementById('roomopt' + indparty).value = idroom;
480 vboPartiesRequested[indparty] = idroom;
481 vboRoomsAssigned[idroom][indroom].push(indparty);
482 } else {
483 // find the next available party slot for this room
484 var party_filled = 0;
485 for (var j in vboRoomsParties[idroom]) {
486 if (!vboRoomsParties[idroom].hasOwnProperty(j)) {
487 continue;
488 }
489 var indparty = vboRoomsParties[idroom][j];
490 if (!document.getElementById('roomopt' + indparty).value.length) {
491 // populate available party slot for this room
492 party_filled++;
493 units_added++;
494 document.getElementById('roomopt' + indparty).value = idroom;
495 vboPartiesRequested[indparty] = idroom;
496 vboRoomsAssigned[idroom][indroom].push(indparty);
497 break;
498 }
499 }
500 if (!units_added || !party_filled) {
501 /**
502 * All room-parties that this room can accommodate have been booked.
503 * In case of large room parties, this kind of situations could occur.
504 */
505 var totbooked = vboCompactCountBooked();
506 if (totbooked < vboNeededBooked) {
507 var indparty = totbooked + 1;
508 if (!document.getElementById('roomopt' + indparty).value.length) {
509 // populate next available party for this room
510 units_added++;
511 document.getElementById('roomopt' + indparty).value = idroom;
512 vboPartiesRequested[indparty] = idroom;
513 vboRoomsAssigned[idroom][indroom].push(indparty);
514 }
515 }
516 }
517 }
518 }
519 } else if (truly_removing) {
520 // get the reversed list of parties assigned (use .slice() before .reverse() to avoid referencing)
521 var vbo_room_party_revass = vboRoomsAssigned[idroom][indroom].slice().reverse();
522 // decreasing units from the previous selection
523 for (var i = (removing_units - 1); i >= 0; i--) {
524 // iterate the pool of rooms assigned starting from the first one added (last, but in a reverse order is like the first)
525 if (!vbo_room_party_revass.hasOwnProperty(i)) {
526 continue;
527 }
528 // current-first index added
529 var rmparty = vbo_room_party_revass[i];
530 // unset room booked
531 document.getElementById('roomopt' + rmparty).value = '';
532 for (var rmi in vboRoomsAssigned[idroom][indroom]) {
533 if (!vboRoomsAssigned[idroom][indroom].hasOwnProperty(rmi)) {
534 continue;
535 }
536 if (vboRoomsAssigned[idroom][indroom][rmi] == rmparty) {
537 vboRoomsAssigned[idroom][indroom].splice(rmi, 1);
538 break;
539 }
540 }
541 if (vboPartiesRequested.hasOwnProperty(rmparty)) {
542 delete vboPartiesRequested[rmparty];
543 }
544 }
545 }
546
547 // count rooms selected of this type
548 var roomtotsel = vboCompactCountSelected(idroom);
549 if (roomtotsel >= vboRoomsUnits[idroom]) {
550 // no more units available for this room-type
551 jQuery('.vbo-selroom-room' + idroom).not('#vbo-selroom-' + indroom + '-' + idroom).prop('disabled', true).closest('.vbo-room-result-body-bookingsolution').addClass('vbo-room-result-soldout');
552 } else {
553 // other units available for this room-type
554 jQuery('.vbo-selroom-room' + idroom).prop('disabled', false).closest('.vbo-room-result-body-bookingsolution').removeClass('vbo-room-result-soldout');
555 }
556
557 // count non-empty input fields
558 var totbooked = vboCompactCountBooked();
559
560 if (totbooked >= vboNeededBooked) {
561 // proceed with booking process, all rooms selected
562 document.getElementById('vbsearchmainsbmt').style.display = 'block';
563 jQuery('.vbo-room-result-body-bookmsg, .vbo-room-result-body-bookbtn').hide();
564 // show the book now button only next to the rooms selected
565 for (var i = 1; i <= vboNeededBooked; i++) {
566 var idroomsel = jQuery('#roomopt' + i).val();
567 if (!idroomsel || !idroomsel.length) {
568 continue;
569 }
570 jQuery('.vbo-selroom-room' + idroomsel).each(function(k, v) {
571 var elem = jQuery(v);
572 if (elem.val() > 0) {
573 elem.closest('.vbo-room-result-body-bookingsolution').find('.vbo-room-result-body-bookbtn').fadeIn();
574 }
575 });
576 }
577 } else {
578 // missing rooms to select for booking
579 document.getElementById('vbsearchmainsbmt').style.display = 'none';
580 jQuery('.vbo-room-result-body-bookmsg, .vbo-room-result-body-bookbtn').hide();
581 var missingrooms = vboNeededBooked - totbooked;
582 var missmsg = missingrooms === 1 ? vboCompactMsg.missingRoomsSi : vboCompactMsg.missingRoomsPl;
583 missmsg = missmsg.replace('%d', missingrooms);
584 // display the message only if more rooms can be selected
585 jQuery('.vbo-selroom-ddown').each(function(k, v) {
586 var elem = jQuery(v);
587 if (elem.val() != elem.find('option').last().attr('value') && elem.prop('disabled') === false) {
588 // more units can be selected and drop down not disabled
589 elem.closest('.vbo-room-result-body-bookingsolution').find('.vbo-room-result-body-bookmsg').text(missmsg).show();
590 } else if (totbooked == 0 && elem.val() > 0 && elem.prop('disabled') === false) {
591 // reset units
592 elem.val('0');
593 // display message for this room as well
594 elem.closest('.vbo-room-result-body-bookingsolution').find('.vbo-room-result-body-bookmsg').text(missmsg).show();
595 }
596 });
597 }
598 }
599
600 function vboCompactProceed() {
601 document.getElementById('vbselectroomform').submit();
602 }
603
604 jQuery(function() {
605 <?php
606 foreach ($gallery_data as $idr => $gallery) {
607 ?>
608 window["vikfxgallery<?php echo $idr; ?>"] = jQuery("#vikfx-gallery<?php echo $idr; ?> a").vikFxGallery();
609 jQuery("#vikfx-gallery-previous-image<?php echo $idr; ?>, #vikfx-gallery-next-image<?php echo $idr; ?>, #vbroomimg<?php echo $idr; ?>").click(function() {
610 if (typeof window["vikfxgallery<?php echo $idr; ?>"] !== "undefined") {
611 window["vikfxgallery<?php echo $idr; ?>"].open();
612 }
613 });
614 <?php
615 }
616 ?>
617 });
618 </script>
619