PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.15
VikBooking Hotel Booking Engine & PMS v1.8.15
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 1.7.3 All 36 releases
vikbooking / site / views / search / tmpl / default_compact.php

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

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