PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.9
VikBooking Hotel Booking Engine & PMS v1.6.9
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.9, at site/views/search/tmpl/default_compact.php

657 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 <span class="vbo_currency"><?php echo $currencysymb; ?></span>
248 <span class="vbo_price"><?php echo VikBooking::numberFormat($raw_roomcost); ?></span>
249 </span>
250 <?php
251 if (isset($roominfo['promotion']) && isset($roominfo['promotion']['discount'])) {
252 if ($roominfo['promotion']['discount']['pcent']) {
253 /**
254 * Do not make an upper-cent operation, but rather calculate the original price proportionally:
255 * final price : (100 - discount amount) = x : 100
256 *
257 * @since 1.13.5
258 */
259 $prev_amount = $raw_roomcost * 100 / (100 - $roominfo['promotion']['discount']['amount']);
260 } else {
261 $prev_amount = $raw_roomcost + $roominfo['promotion']['discount']['amount'];
262 }
263 if ($prev_amount > 0) {
264 ?>
265 <div class="vbo-room-result-price-before-discount">
266 <span class="room_cost">
267 <span class="vbo_currency"><?php echo $currencysymb; ?></span>
268 <span class="vbo_price"><?php echo VikBooking::numberFormat($prev_amount); ?></span>
269 </span>
270 </div>
271 <?php
272 if ($roominfo['promotion']['discount']['pcent']) {
273 // hide by default the DIV containing the percent of discount
274 ?>
275 <div class="vbo-room-result-price-before-discount-percent" style="display: none;">
276 <span class="room_cost">
277 <span><?php echo '-' . (float)$roominfo['promotion']['discount']['amount'] . ' %'; ?></span>
278 </span>
279 </div>
280 <?php
281 }
282 }
283 }
284 ?>
285 </div>
286 <div class="vbo-room-result-body-price-selection">
287 <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);">
288 <option value="0">0</option>
289 <?php
290 for ($i = 1; $i <= $maxunits; $i++) {
291 ?>
292 <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
293 <?php
294 }
295 ?>
296 </select>
297 </div>
298 <div class="vbo-room-result-body-bookstatus">
299 <span class="vbo-room-result-body-bookmsg" style="display: none;"></span>
300 <div class="vbo-room-result-body-bookbtn" style="display: none;">
301 <button type="button" class="btn" onclick="vboCompactProceed();"><?php echo JText::translate('VBBOOKNOW'); ?></button>
302 </div>
303 </div>
304 </div>
305 <?php
306 }
307 ?>
308 </div>
309 </div>
310 </div>
311 </div>
312 <?php
313 }
314
315 /**
316 * Normalize the room parties object in case some rooms can also be suited for additional room parties.
317 * This is to avoid situations where the sum of selected room units do not satisfy all room parties.
318 * The configuration setting "Smart Search Type" should be set to "dynamic" to avoid this normalization.
319 *
320 * @see VikBooking::getSmartSearchType() should return "dynamic" NOT "automatic".
321 *
322 * @since 1.16.9 (J) - 1.6.9 (WP)
323 */
324 $all_parties = range(1, $this->roomsnum);
325 foreach ($rooms_parties as $rid => $r_party) {
326 $missing_parties = array_diff($all_parties, $r_party);
327 $fit_parties = array_intersect($r_party, $all_parties);
328 if (!$missing_parties || !$fit_parties) {
329 // this room can satisfy all room parties
330 continue;
331 }
332 // compare equal room parties in terms of guests
333 foreach ($missing_parties as $missing_party) {
334 foreach ($fit_parties as $fit_party) {
335 if ($this->arrpeople[$missing_party] === $this->arrpeople[$fit_party]) {
336 // push this missing party because the guests are identical to a fit party
337 $rooms_parties[$rid][] = $missing_party;
338 break;
339 }
340 }
341 }
342 }
343
344 ?>
345 </div>
346
347 <script type="text/javascript">
348 var vboNeededBooked = <?php echo $this->roomsnum; ?>;
349 var vboRoomsUnits = <?php echo json_encode($rooms_units); ?>;
350 var vboRoomsParties = <?php echo json_encode($rooms_parties); ?>;
351 var vboPartiesRequested = {};
352 var vboRoomsUnitsPool = {};
353 var vboRoomsAssigned = {};
354 var vboCompactMsg = {
355 missingRoomsPl: "<?php echo addslashes(JText::translate('VBONROOMSMISSINGPL')); ?>",
356 missingRoomsSi: "<?php echo addslashes(JText::translate('VBONROOMSMISSINGSI')); ?>",
357 };
358
359 function vboCompactCountSelected(idroom) {
360 var totselected = 0;
361 var ddowns = document.getElementsByClassName((idroom ? 'vbo-selroom-room' + idroom : 'vbo-selroom-ddown'));
362 for (var i = 0; i < ddowns.length; i++) {
363 totselected += parseInt(ddowns.item(i).value);
364 }
365 return totselected;
366 }
367
368 function vboCompactCountBooked() {
369 var totbooked = 0;
370 for (var i = 1; i <= vboNeededBooked; i++) {
371 var inpslot = document.getElementById('roomopt' + i).value;
372 if (inpslot.length && parseInt(inpslot) > 0) {
373 totbooked++;
374 }
375 }
376 return totbooked;
377 }
378
379 /**
380 * Checks whether a slot is occupied by another room. Returns false or an array with the occupier information.
381 */
382 function vboCompactIsSlotOccupied(indroom, idroom) {
383 var current_val = document.getElementById('roomopt' + indroom).value;
384 if (current_val && current_val.length && (current_val + '') != (idroom + '')) {
385 return [parseInt(indroom), parseInt(current_val)];
386 }
387 return false;
388 }
389
390 /**
391 * Frees up one slot by updating the necessary objects and input field.
392 */
393 function vboCompactMakeSlotFree(indroom, idroom) {
394 var current_room = document.getElementById('roomopt' + indroom).value;
395 if (!current_room || !current_room.length) {
396 return;
397 }
398 current_room = parseInt(current_room);
399 document.getElementById('roomopt' + indroom).value = '';
400 if (vboPartiesRequested.hasOwnProperty(indroom)) {
401 delete vboPartiesRequested[indroom];
402 }
403 if (vboRoomsAssigned.hasOwnProperty(current_room) && vboRoomsAssigned[current_room].hasOwnProperty(indroom)) {
404 for (var i in vboRoomsAssigned[current_room][indroom]) {
405 if (vboRoomsAssigned[current_room][indroom].hasOwnProperty(i) && vboRoomsAssigned[current_room][indroom][i] == indroom) {
406 vboRoomsAssigned[current_room][indroom].splice(i, 1);
407 break;
408 }
409 }
410 }
411 jQuery('.vbo-selroom-room' + current_room).each(function(k, v) {
412 var elem = jQuery(v);
413 var current_val = parseInt(elem.val());
414 if (current_val > 0 && (elem.hasClass('vbo-selroom-party' + indroom) || (Array.isArray(vboRoomsParties[current_room]) && vboRoomsParties[current_room].includes(indroom)))) {
415 elem.val((current_val - 1));
416 // if some drop downs were previously disabled, turn them back on
417 var roomtotsel = vboCompactCountSelected(current_room);
418 if (roomtotsel < vboRoomsUnits[current_room]) {
419 // other units available for this room-type
420 var container = elem.closest('.vbo-room-result-body-bookingsolutions');
421 container.find('.vbo-room-result-body-bookingsolution').removeClass('vbo-room-result-soldout');
422 container.find('select.vbo-selroom-ddown').prop('disabled', false);
423 }
424 // break loop
425 return false;
426 }
427 });
428 }
429
430 /**
431 * Disables or enables the parties that can be booked.
432 */
433 function vboCompactUpdateParties() {
434 // always free up the already chosen elements for the now empty parties
435 for (var i = 1; i <= vboNeededBooked; i++) {
436 var inpslot = document.getElementById('roomopt' + i).value;
437 if (!inpslot.length) {
438 // no room for this party, make sure the drop downs are enabled
439 jQuery('.vbo-room-result-alreadychosen-' + i).prop('disabled', false).removeClass('vbo-room-result-alreadychosen-' + i);
440 }
441 }
442 //
443 for (var indparty in vboPartiesRequested) {
444 if (!vboPartiesRequested.hasOwnProperty(indparty) || !vboPartiesRequested[indparty]) {
445 continue;
446 }
447 for (var room in vboRoomsParties) {
448 if (!vboRoomsParties.hasOwnProperty(room) || !vboRoomsParties[room].length) {
449 continue;
450 }
451 var check_indparty = parseInt(indparty);
452 if (vboRoomsParties[room].includes(check_indparty)) {
453 // this room is suitable for this party already chosen
454 var elem = jQuery('#vbo-selroom-' + indparty + '-' + room);
455 if (!elem.length) {
456 continue;
457 }
458 if (elem.val() < 1) {
459 // we can disable this drop down so that no units will be selected
460 elem.prop('disabled', true).addClass('vbo-room-result-alreadychosen-' + indparty);
461 } else if (!elem.closest('.vbo-room-result-body-bookingsolution').hasClass('vbo-room-result-soldout')) {
462 // we can enable this drop down
463 elem.prop('disabled', false);
464 }
465 }
466 }
467 }
468 }
469
470 function vboCompactSelRoom(indroom, idroom, units) {
471 // adjust vars
472 units = parseInt(units);
473
474 // update rooms units counter and assigned for visible drop downs
475 if (!vboRoomsUnitsPool.hasOwnProperty(idroom)) {
476 vboRoomsUnitsPool[idroom] = {};
477 vboRoomsAssigned[idroom] = {};
478 }
479 if (!vboRoomsUnitsPool[idroom].hasOwnProperty(indroom)) {
480 vboRoomsUnitsPool[idroom][indroom] = units;
481 vboRoomsAssigned[idroom][indroom] = new Array;
482 }
483 var adding_units = (vboRoomsUnitsPool[idroom][indroom] <= units);
484 var removing_units = !adding_units ? (vboRoomsUnitsPool[idroom][indroom] - units) : 0;
485 var truly_removing = !adding_units;
486 if (truly_removing && removing_units > 0 && units > 0 && (vboCompactCountBooked() - removing_units + units) == vboNeededBooked) {
487 truly_removing = false;
488 }
489
490 // update units selected for this drop down
491 vboRoomsUnitsPool[idroom][indroom] = units;
492
493 if (adding_units) {
494 // populate fields when adding units
495 var indcounter = 0;
496 var units_added = 0;
497 var slot_occupied = vboCompactIsSlotOccupied(indroom, idroom);
498 if (units === 1 && (vboRoomsParties[idroom].length === 1 || slot_occupied === false)) {
499 // occupy exact party requested for one unit when room not suited for other parties or when slot is free
500 if (slot_occupied !== false) {
501 vboCompactMakeSlotFree(slot_occupied[0], slot_occupied[1]);
502 }
503 indcounter++;
504 units_added++;
505 document.getElementById('roomopt' + indroom).value = idroom;
506 vboPartiesRequested[indroom] = idroom;
507 vboRoomsAssigned[idroom][indroom].push(indroom);
508 }
509
510 // selected more than one unit, or one unit for a room that is suitable for multiple parties
511 for (var i = indcounter; i < units; i++) {
512 // fill all containers valid for this room party until the units requested are reached
513 var indparty = vboRoomsParties[idroom][i];
514 if (!document.getElementById('roomopt' + indparty).value.length) {
515 // populate first available party for this room
516 units_added++;
517 document.getElementById('roomopt' + indparty).value = idroom;
518 vboPartiesRequested[indparty] = idroom;
519 vboRoomsAssigned[idroom][indroom].push(indparty);
520 } else {
521 // find the next available party slot for this room
522 var party_filled = 0;
523 for (var j in vboRoomsParties[idroom]) {
524 if (!vboRoomsParties[idroom].hasOwnProperty(j)) {
525 continue;
526 }
527 var indparty = vboRoomsParties[idroom][j];
528 if (!document.getElementById('roomopt' + indparty).value.length) {
529 // populate available party slot for this room
530 party_filled++;
531 units_added++;
532 document.getElementById('roomopt' + indparty).value = idroom;
533 vboPartiesRequested[indparty] = idroom;
534 vboRoomsAssigned[idroom][indroom].push(indparty);
535 break;
536 }
537 }
538 if (!units_added || !party_filled) {
539 /**
540 * All room-parties that this room can accommodate have been booked.
541 * In case of large room parties, this kind of situations could occur.
542 */
543 var totbooked = vboCompactCountBooked();
544 if (totbooked < vboNeededBooked) {
545 var indparty = totbooked + 1;
546 if (!document.getElementById('roomopt' + indparty).value.length) {
547 // populate next available party for this room
548 units_added++;
549 document.getElementById('roomopt' + indparty).value = idroom;
550 vboPartiesRequested[indparty] = idroom;
551 vboRoomsAssigned[idroom][indroom].push(indparty);
552 }
553 }
554 }
555 }
556 }
557 } else if (truly_removing) {
558 // get the reversed list of parties assigned (use .slice() before .reverse() to avoid referencing)
559 var vbo_room_party_revass = vboRoomsAssigned[idroom][indroom].slice().reverse();
560 // decreasing units from the previous selection
561 for (var i = (removing_units - 1); i >= 0; i--) {
562 // iterate the pool of rooms assigned starting from the first one added (last, but in a reverse order is like the first)
563 if (!vbo_room_party_revass.hasOwnProperty(i)) {
564 continue;
565 }
566 // current-first index added
567 var rmparty = vbo_room_party_revass[i];
568 // unset room booked
569 document.getElementById('roomopt' + rmparty).value = '';
570 for (var rmi in vboRoomsAssigned[idroom][indroom]) {
571 if (!vboRoomsAssigned[idroom][indroom].hasOwnProperty(rmi)) {
572 continue;
573 }
574 if (vboRoomsAssigned[idroom][indroom][rmi] == rmparty) {
575 vboRoomsAssigned[idroom][indroom].splice(rmi, 1);
576 break;
577 }
578 }
579 if (vboPartiesRequested.hasOwnProperty(rmparty)) {
580 delete vboPartiesRequested[rmparty];
581 }
582 }
583 }
584
585 // count rooms selected of this type
586 var roomtotsel = vboCompactCountSelected(idroom);
587 if (roomtotsel >= vboRoomsUnits[idroom]) {
588 // no more units available for this room-type
589 jQuery('.vbo-selroom-room' + idroom).not('#vbo-selroom-' + indroom + '-' + idroom).prop('disabled', true).closest('.vbo-room-result-body-bookingsolution').addClass('vbo-room-result-soldout');
590 } else {
591 // other units available for this room-type
592 jQuery('.vbo-selroom-room' + idroom).prop('disabled', false).closest('.vbo-room-result-body-bookingsolution').removeClass('vbo-room-result-soldout');
593 }
594
595 // count non-empty input fields
596 var totbooked = vboCompactCountBooked();
597
598 if (totbooked >= vboNeededBooked) {
599 // proceed with booking process, all rooms selected
600 document.getElementById('vbsearchmainsbmt').style.display = 'block';
601 jQuery('.vbo-room-result-body-bookmsg, .vbo-room-result-body-bookbtn').hide();
602 // show the book now button only next to the rooms selected
603 for (var i = 1; i <= vboNeededBooked; i++) {
604 var idroomsel = jQuery('#roomopt' + i).val();
605 if (!idroomsel || !idroomsel.length) {
606 continue;
607 }
608 jQuery('.vbo-selroom-room' + idroomsel).each(function(k, v) {
609 var elem = jQuery(v);
610 if (elem.val() > 0) {
611 elem.closest('.vbo-room-result-body-bookingsolution').find('.vbo-room-result-body-bookbtn').fadeIn();
612 }
613 });
614 }
615 } else {
616 // missing rooms to select for booking
617 document.getElementById('vbsearchmainsbmt').style.display = 'none';
618 jQuery('.vbo-room-result-body-bookmsg, .vbo-room-result-body-bookbtn').hide();
619 var missingrooms = vboNeededBooked - totbooked;
620 var missmsg = missingrooms === 1 ? vboCompactMsg.missingRoomsSi : vboCompactMsg.missingRoomsPl;
621 missmsg = missmsg.replace('%d', missingrooms);
622 // display the message only if more rooms can be selected
623 jQuery('.vbo-selroom-ddown').each(function(k, v) {
624 var elem = jQuery(v);
625 if (elem.val() != elem.find('option').last().attr('value') && elem.prop('disabled') === false) {
626 // more units can be selected and drop down not disabled
627 elem.closest('.vbo-room-result-body-bookingsolution').find('.vbo-room-result-body-bookmsg').text(missmsg).show();
628 } else if (totbooked == 0 && elem.val() > 0 && elem.prop('disabled') === false) {
629 // reset units
630 elem.val('0');
631 // display message for this room as well
632 elem.closest('.vbo-room-result-body-bookingsolution').find('.vbo-room-result-body-bookmsg').text(missmsg).show();
633 }
634 });
635 }
636 }
637
638 function vboCompactProceed() {
639 document.getElementById('vbselectroomform').submit();
640 }
641
642 jQuery(function() {
643 <?php
644 foreach ($gallery_data as $idr => $gallery) {
645 ?>
646 window["vikfxgallery<?php echo $idr; ?>"] = jQuery("#vikfx-gallery<?php echo $idr; ?> a").vikFxGallery();
647 jQuery("#vikfx-gallery-previous-image<?php echo $idr; ?>, #vikfx-gallery-next-image<?php echo $idr; ?>, #vbroomimg<?php echo $idr; ?>").click(function() {
648 if (typeof window["vikfxgallery<?php echo $idr; ?>"] !== "undefined") {
649 window["vikfxgallery<?php echo $idr; ?>"].open();
650 }
651 });
652 <?php
653 }
654 ?>
655 });
656 </script>
657