PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.9
VikBooking Hotel Booking Engine & PMS v1.8.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 / admin / views / bookingcheckin / tmpl / default.php

default.php in VikBooking Hotel Booking Engine & PMS 1.8.9, at admin/views/bookingcheckin/tmpl/default.php

1,366 lines 52.8 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 $order = $this->row;
14 $rooms = $this->rooms;
15 $customer = $this->customer;
16
17 $dbo = JFactory::getDbo();
18
19 $vbo_app = VikBooking::getVboApplication();
20
21 /**
22 * This view is usually rendered within a modal window, and with WordPress
23 * the modal window is loaded through AJAX by the "editorder" View. For this
24 * reason, with WP we should not load the JS assets for the contextual menu,
25 * or we would reset the default setup of the library. We load the assets in
26 * the parent View "editorder" to avoid issues of any kind.
27 *
28 * @since 1.16.0 (J) - 1.6.0 (WP)
29 */
30 if ((VBOPlatformDetection::isJoomla()) || (VBOPlatformDetection::isWordPress() && !wp_doing_ajax())) {
31 $vbo_app->loadContextMenuAssets();
32 JText::script('VBRENTALORD');
33 JText::script('VBPVIEWORDERSPEOPLE');
34 }
35
36 $currencysymb = VikBooking::getCurrencySymb();
37 $nowdf = VikBooking::getDateFormat(true);
38 if ($nowdf == "%d/%m/%Y") {
39 $df = 'd/m/Y';
40 } elseif ($nowdf == "%m/%d/%Y") {
41 $df = 'm/d/Y';
42 } else {
43 $df = 'Y/m/d';
44 }
45 $datesep = VikBooking::getDateSeparator(true);
46 $pchanged = VikRequest::getInt('changed', '', 'request');
47 $tmpl = VikRequest::getVar('tmpl');
48 $set_parent_status = '';
49 $now_info = getdate();
50 $today_midnight = mktime(0, 0, 0, $now_info['mon'], $now_info['mday'], $now_info['year']);
51 $grace_ts = mktime(0, 0, 0, $now_info['mon'], $now_info['mday'] - 2, $now_info['year']);
52 $colortags = VikBooking::loadBookingsColorTags();
53 $otachannel = '';
54 $otachannel_name = '';
55 $otachannel_bid = '';
56 $otacurrency = '';
57 if (!empty($order['channel'])) {
58 $channelparts = explode('_', $order['channel']);
59 $otachannel = array_key_exists(1, $channelparts) && strlen($channelparts[1]) > 0 ? $channelparts[1] : ucwords($channelparts[0]);
60 $otachannel_name = $otachannel;
61 $otachannel_bid = $order['idorderota'];
62 if (strstr($otachannel, '.') !== false) {
63 $otaccparts = explode('.', $otachannel);
64 $otachannel = $otaccparts[0];
65 }
66 $otacurrency = strlen($order['chcurrency']) > 0 ? $order['chcurrency'] : '';
67 }
68 $sensible_k = array('first_name', 'last_name', 'country', 'gender', 'bdate', 'pbirth');
69 $missing_customer_det = false;
70 foreach ($customer as $ck => $cv) {
71 if ((!isset($customer[$ck]) || empty($customer[$ck])) && in_array($ck, $sensible_k)) {
72 $missing_customer_det = true;
73 }
74 }
75
76 /**
77 * Back-end guests registration now relies on dynamic drivers within Vik Booking.
78 *
79 * @since 1.15.0 (J) - 1.5.0 (WP)
80 */
81
82 // get the list of back-end pax fields according to settings
83 list($pax_fields, $pax_fields_attributes) = VikBooking::getPaxFields();
84
85 // grab also the fields for front-end pre check-in
86 list($pre_pax_fields, $pre_pax_fields_attributes) = VikBooking::getPaxFields(true);
87
88 // once the pax fields have been prepared, get the active driver instance
89 $pax_fields_obj = VBOCheckinPax::getInstance();
90
91 // load any previous checkin information from this customer
92 $previous_checkins = VBOCheckinPax::getCustomerAllPaxData($order['id']);
93
94 ?>
95 <div class="vbo-info-overlay-block">
96 <a class="vbo-info-overlay-close" href="javascript: void(0);"></a>
97 <div class="vbo-info-overlay-content">
98 <h3 id="vbo-overlay-title">
99 <span class="vbo-info-overlay-title-close">
100 <span onclick="vboOpenModal();"><?php VikBookingIcons::e('times-circle'); ?></span>
101 </span>
102 </h3>
103 <div class="vbo-overlay-checkin-body"></div>
104 </div>
105 </div>
106
107 <form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm">
108 <div class="vbo-bookdet-container">
109 <div class="vbo-bookdet-wrap">
110 <div class="vbo-bookdet-head">
111 <span>ID</span>
112 <?php
113 if (!empty($order['adminnotes'])) {
114 ?>
115 <i class="vboicn-info icn-bigger icn-nomargin icn-float-left icn-clickable" onclick="vboUpdateModal('<?php echo addslashes(JText::translate('VBADMINNOTESTOGGLE')); ?>', '.adminnotes', true);"></i>
116 <?php
117 }
118 ?>
119 </div>
120 <div class="vbo-bookdet-foot">
121 <span><a href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $order['id']; ?>" target="_blank"><?php echo $order['id']; ?></a></span>
122 </div>
123 </div>
124 <?php
125 if (!empty($order['channel'])) {
126 ?>
127 <div class="vbo-bookdet-wrap">
128 <div class="vbo-bookdet-head">
129 <?php echo $otachannel; ?>
130 </div>
131 <div class="vbo-bookdet-foot">
132 <span>ID <?php echo $otachannel_bid; ?></span>
133 </div>
134 </div>
135 <?php
136 }
137 ?>
138 <div class="vbo-bookdet-wrap">
139 <div class="vbo-bookdet-head">
140 <span><?php echo JText::translate('VBEDITORDERONE'); ?></span>
141 </div>
142 <div class="vbo-bookdet-foot">
143 <?php echo date(str_replace("/", $datesep, $df).' H:i', $order['ts']); ?>
144 </div>
145 </div>
146 <?php
147 if (count($customer)) {
148 ?>
149 <div class="vbo-bookdet-wrap">
150 <div class="vbo-bookdet-head">
151 <span><?php echo JText::translate('VBCUSTOMERNOMINATIVE'); ?></span>
152 <?php
153 if ($missing_customer_det) {
154 echo $vbo_app->createPopover(array('title' => JText::translate('VBCUSTOMERMISSIMPDET'), 'content' => JText::translate('VBCUSTOMERMISSIMPDETHELP'), 'icon_class' => VikBookingIcons::i('exclamation-triangle'), 'placement' => 'bottom'));
155 } elseif (!empty($customer['notes'])) {
156 ?>
157 <i class="vboicn-info icn-bigger icn-nomargin icn-float-left icn-clickable" onclick="vboUpdateModal('<?php echo addslashes(JText::translate('VBCUSTOMERNOTES')); ?>', '.customer_notes', true);"></i>
158 <?php
159 }
160 ?>
161 </div>
162 <div class="vbo-bookdet-foot">
163 <?php echo (isset($customer['country_img']) ? $customer['country_img'].' ' : '').'<a href="javascript: void(0);" onclick="vboUpdateModal(\''.addslashes(JText::translate('VBCUSTINFO')).'\', \'.customer_info\', true);">'.ltrim($customer['first_name'].' '.$customer['last_name']).'</a>'; ?>
164 </div>
165 </div>
166 <?php
167 }
168 ?>
169 <div class="vbo-bookdet-wrap">
170 <div class="vbo-bookdet-head">
171 <span><?php echo JText::translate('VBEDITORDERROOMSNUM'); ?></span>
172 </div>
173 <div class="vbo-bookdet-foot">
174 <?php echo $order['roomsnum']; ?>
175 </div>
176 </div>
177 <div class="vbo-bookdet-wrap">
178 <div class="vbo-bookdet-head">
179 <span><?php echo JText::translate('VBEDITORDERFOUR'); ?></span>
180 </div>
181 <div class="vbo-bookdet-foot">
182 <?php echo $order['days']; ?>
183 </div>
184 </div>
185 <div class="vbo-bookdet-wrap">
186 <div class="vbo-bookdet-head">
187 <span><?php echo JText::translate('VBEDITORDERFIVE'); ?></span>
188 </div>
189 <div class="vbo-bookdet-foot">
190 <?php
191 $checkin_info = getdate($order['checkin']);
192 $short_wday = JText::translate('VB'.strtoupper(substr($checkin_info['weekday'], 0, 3)));
193 ?>
194 <?php echo $short_wday.', '.date(str_replace("/", $datesep, $df).' H:i', $order['checkin']); ?>
195 </div>
196 </div>
197 <div class="vbo-bookdet-wrap">
198 <div class="vbo-bookdet-head">
199 <span><?php echo JText::translate('VBEDITORDERSIX'); ?></span>
200 </div>
201 <div class="vbo-bookdet-foot">
202 <?php
203 $checkout_info = getdate($order['checkout']);
204 $short_wday = JText::translate('VB'.strtoupper(substr($checkout_info['weekday'], 0, 3)));
205 ?>
206 <?php echo $short_wday.', '.date(str_replace("/", $datesep, $df).' H:i', $order['checkout']); ?>
207 </div>
208 </div>
209 <div class="vbo-bookdet-wrap vbo-bookdet-wrap-special">
210 <div class="vbo-bookdet-head">
211 <span><?php echo JText::translate('VBOCHECKEDSTATUS'); ?></span>
212 </div>
213 <div class="vbo-bookdet-foot">
214 <?php
215 if ($order['checked'] < 0) {
216 //no show
217 $checked_status = '<span class="label label-error">'.JText::translate('VBOCHECKEDSTATUSNOS').'</span>';
218 $set_parent_status = $pchanged > 0 ? '<span style="font-weight: bold; color: red;">'.strtoupper(JText::translate('VBOCHECKEDSTATUSNOS')).'</span>' : $set_parent_status;
219 } elseif ($order['checked'] == 1) {
220 //checked in
221 $checked_status = '<span class="label label-success">'.JText::translate('VBOCHECKEDSTATUSIN').'</span>';
222 $set_parent_status = $pchanged > 0 ? '<span style="font-weight: bold; color: green;">'.strtoupper(JText::translate('VBOCHECKEDSTATUSIN')).'</span>' : $set_parent_status;
223 } elseif ($order['checked'] == 2) {
224 //checked out
225 $checked_status = '<span class="label label-info">'.JText::translate('VBOCHECKEDSTATUSOUT').'</span>';
226 $set_parent_status = $pchanged > 0 ? '<span style="font-weight: bold; color: green;">'.strtoupper(JText::translate('VBOCHECKEDSTATUSOUT')).'</span>' : $set_parent_status;
227 } else {
228 //none (0)
229 $checked_status = '<span class="label">'.JText::translate('VBOCHECKEDSTATUSZERO').'</span>';
230 $set_parent_status = $pchanged > 0 ? '<span style="font-weight: bold; color: green;">'.strtoupper(JText::translate('VBCONFIRMED')).'</span>' : $set_parent_status;
231 }
232 ?>
233 <?php echo $checked_status; ?>
234 </div>
235 </div>
236 <?php
237 if (is_array($previous_checkins) && count($previous_checkins) && $order['checked'] < 1) {
238 foreach ($previous_checkins as $k => $prev_checkin) {
239 $previous_checkins[$k]['checkin_dt'] = date(str_replace("/", $datesep, $df), $prev_checkin['checkin']);
240 $previous_checkins[$k]['checkout_dt'] = date(str_replace("/", $datesep, $df), $prev_checkin['checkout']);
241 $previous_checkins[$k]['ts_dt'] = date(str_replace("/", $datesep, $df), $prev_checkin['ts']);
242 $book_tot_guests = 0;
243 $prev_checkin['pax_data'] = empty($prev_checkin['pax_data']) || !is_array($prev_checkin['pax_data']) ? [] : $prev_checkin['pax_data'];
244 foreach ($prev_checkin['pax_data'] as $rnum => $room_pax) {
245 foreach ($room_pax as $guest_num => $guest_data) {
246 $book_tot_guests++;
247 }
248 }
249 $previous_checkins[$k]['tot_guests'] = $book_tot_guests;
250 }
251 ?>
252 <div class="vbo-bookdet-wrap">
253 <div class="vbo-bookdet-head">
254 <span><?php echo JText::translate('VBO_PREVIOUS_CHECKINS'); ?></span>
255 </div>
256 <div class="vbo-bookdet-foot">
257 <button type="button" class="btn btn-small btn-primary vbo-context-menu-btn vbo-context-menu-prevchkins">
258 <span class="vbo-context-menu-lbl"><?php echo JText::translate('VBO_SELECT'); ?></span>
259 <span class="vbo-context-menu-ico"><?php VikBookingIcons::e('sort-down'); ?></span>
260 </button>
261 </div>
262 </div>
263
264 <script type="text/javascript">
265 var prev_checkins = <?php echo json_encode($previous_checkins); ?>;
266 var prev_checkins_btns = [];
267
268 function populatePreviousCheckin(pax_data) {
269 if (!pax_data || !pax_data.length) {
270 alert('Invalid previous check-in information');
271 return false;
272 }
273
274 var room_num = 0,
275 guest_num = 1,
276 guests_found = 0;
277
278 pax_data.forEach((room_pax, room_index) => {
279 for (let guest_num in room_pax) {
280 if (!room_pax.hasOwnProperty(guest_num)) {
281 continue;
282 }
283 if (jQuery('.vbo-roomdet-wrapper[data-roomnum="' + room_num + '"]').length && !jQuery('.vbo-roomdet-guest-details[data-guestnum="' + guest_num + '"]').length) {
284 // try to go to the first guest of the next room
285 room_num++;
286 guest_num = 1;
287 }
288 let guest_found = false;
289 for (let prop_name in room_pax[guest_num]) {
290 if (!room_pax[guest_num].hasOwnProperty(prop_name)) {
291 continue;
292 }
293 let field_name = 'guests[' + room_num + '][' + guest_num + '][' + prop_name + ']';
294 if (jQuery('[name="' + field_name + '"]').length) {
295 jQuery('[name="' + field_name + '"]').val(room_pax[guest_num][prop_name]).trigger('change');
296 if (!guest_found) {
297 guests_found++;
298 guest_found = true;
299 }
300 }
301 }
302 guest_num++;
303 if (jQuery('#vbo-roomdet-guests-details-' + room_num).length && !jQuery('#vbo-roomdet-guests-details-' + room_num).is(':visible')) {
304 jQuery('#vbo-roomdet-guests-details-' + room_num).slideDown();
305 }
306 }
307 });
308
309 return guests_found;
310 }
311
312 prev_checkins.forEach((prev_checkin, index) => {
313 prev_checkins_btns.push({
314 icon: '<?php echo VikBookingIcons::i('calendar-check'); ?>',
315 text: Joomla.JText._('VBRENTALORD') + ' #' + prev_checkin['idorder'] + ' - ' + Joomla.JText._('VBPVIEWORDERSPEOPLE') + ': ' + prev_checkin['tot_guests'],
316 separator: (index === prev_checkins.length - 1),
317 action: (root, config) => {
318 var guests_populated = populatePreviousCheckin(prev_checkins[index]['pax_data']);
319 console.log('guests_populated: ' + guests_populated);
320 },
321 });
322 });
323
324 jQuery(function() {
325 jQuery('.vbo-context-menu-prevchkins').vboContextMenu({
326 placement: 'bottom-left',
327 buttons: prev_checkins_btns,
328 });
329 });
330 </script>
331 <?php
332 }
333 ?>
334 </div>
335 <?php
336 //rooms details and total information
337 ?>
338 <div class="vbo-checkin-main-block">
339 <div class="vbo-roomsdet-container">
340 <?php
341 $tars = array();
342 $arrpeople = array();
343 $is_package = (!empty($order['pkg']));
344 $is_cust_cost = false;
345 foreach ($rooms as $ind => $or) {
346 $num = $ind + 1;
347 $arrpeople[$num]['adults'] = $or['adults'];
348 $arrpeople[$num]['children'] = $or['children'];
349 $arrpeople[$num]['children_age'] = $or['childrenage'];
350 $arrpeople[$num]['t_first_name'] = $or['t_first_name'];
351 $arrpeople[$num]['t_last_name'] = $or['t_last_name'];
352 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
353 //package or custom cost set from the back-end
354 $is_cust_cost = true;
355 continue;
356 }
357 $q = "SELECT * FROM `#__vikbooking_dispcost` WHERE `id`=".(int)$or['idtar'].";";
358 $dbo->setQuery($q);
359 $dbo->execute();
360 $tar = $dbo->loadAssocList();
361 $tars[$num] = $tar;
362 }
363 //compose the calculation for pax_data
364 $pax_data = array();
365 $count_pax_data = 0;
366 if (count($customer) > 0) {
367 $count_pax_data = 1;
368 if (!empty($customer['pax_data'])) {
369 $pax_data = json_decode($customer['pax_data'], true);
370 $pax_data = !is_array($pax_data) ? array() : $pax_data;
371 }
372 }
373 $all_countries = VikBooking::getCountriesArray();
374 //
375 foreach ($rooms as $ind => $or) {
376 $num = $ind + 1;
377 //total guests details available
378 $count_pax_data = $num < 2 ? $count_pax_data : 0;
379 if (isset($pax_data[$ind])) {
380 $count_pax_data = count($pax_data[$ind]);
381 }
382
383 //Room Specific Unit
384 $spec_unit = '';
385 if (!empty($or['params'])) {
386 $room_params = json_decode($or['params'], true);
387 $arr_features = array();
388 if (is_array($room_params) && array_key_exists('features', $room_params) && @count($room_params['features']) > 0) {
389 foreach ($room_params['features'] as $rind => $rfeatures) {
390 foreach ($rfeatures as $fname => $fval) {
391 if (strlen($fval)) {
392 $arr_features[$rind] = '#'.$rind.' - '.JText::translate($fname).': '.$fval;
393 break;
394 }
395 }
396 }
397 }
398 if (isset($arr_features[$or['roomindex']])) {
399 $spec_unit = $arr_features[$or['roomindex']];
400 }
401 }
402
403 // calculate the number of guests to register depending on settings
404 $guests_to_register = $pax_fields_obj->registerChildren() ? ($arrpeople[$num]['adults'] + $arrpeople[$num]['children']) : $arrpeople[$num]['adults'];
405 ?>
406 <div class="vbo-roomdet-wrapper" data-roomnum="<?php echo $ind; ?>">
407 <div class="vbo-roomdet-wrap">
408 <div class="vbo-roomdet-entry">
409 <div class="vbo-roomdet-head">
410 <span><?php echo $or['room_name']; ?></span>
411 </div>
412 <div class="vbo-roomdet-foot">
413 <?php
414 if (!empty($spec_unit)) {
415 ?>
416 <span><?php echo $spec_unit; ?></span>
417 <?php
418 }
419 ?>
420 <div class="vbo-roomdet-guests-toggle-cont">
421 <span tabindex="0" class="vbo-roomdet-guests-toggle <?php echo $count_pax_data >= $guests_to_register ? 'vbo-guestscount-complete' : 'vbo-guestscount-incomplete'; ?>" data-roomind="<?php echo $ind; ?>">
422 <i class="vboicn-user-plus"></i>
423 <span class="vbo-roomdet-guests-toggleword"><?php echo JText::translate('VBOGUESTSDETAILS'); ?> (<span id="vbo-guestscount-<?php echo $ind; ?>"><?php echo $count_pax_data; ?></span>/<?php echo $guests_to_register; ?>)</span>
424 </span>
425 </div>
426 </div>
427 </div>
428 <div class="vbo-roomdet-entry">
429 <div class="vbo-roomdet-head">
430 <span><?php echo JText::translate('VBEDITORDERADULTS'); ?></span>
431 </div>
432 <div class="vbo-roomdet-foot">
433 <span><?php echo $arrpeople[$num]['adults']; ?></span>
434 </div>
435 </div>
436 <?php
437 $age_str = '';
438 if ($arrpeople[$num]['children'] > 0) {
439 if (!empty($arrpeople[$num]['children_age'])) {
440 $json_child = json_decode($arrpeople[$num]['children_age'], true);
441 if (is_array($json_child['age']) && count($json_child['age']) > 0) {
442 $age_str = ' '.JText::sprintf('VBORDERCHILDAGES', implode(', ', $json_child['age']));
443 }
444 }
445 }
446 ?>
447 <div class="vbo-roomdet-entry">
448 <div class="vbo-roomdet-head">
449 <span><?php echo JText::translate('VBEDITORDERCHILDREN'); ?></span>
450 </div>
451 <div class="vbo-roomdet-foot">
452 <span><?php echo $arrpeople[$num]['children'].$age_str; ?></span>
453 </div>
454 </div>
455 <div class="vbo-roomdet-entry">
456 <div class="vbo-roomdet-head">
457 <span><?php echo JText::translate('VBEDITORDERSEVEN'); ?></span>
458 </div>
459 <div class="vbo-roomdet-foot">
460 <?php
461 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
462 ?>
463 <span>
464 <?php
465 if (!empty($or['pkg_name'])) {
466 //package
467 echo $or['pkg_name'];
468 } else {
469 //custom cost can have an OTA Rate Plan name
470 if (!empty($or['otarplan'])) {
471 echo ucwords($or['otarplan']);
472 } else {
473 echo JText::translate('VBOROOMCUSTRATEPLAN');
474 }
475 }
476 ?>
477 <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($or['cust_cost']), $currencysymb); ?>
478 </span>
479 <?php
480 } elseif (array_key_exists($num, $tars) && !empty($tars[$num][0]['idprice'])) {
481 $display_rate = !empty($or['room_cost']) ? $or['room_cost'] : $tars[$num][0]['cost'];
482 ?>
483 <span>
484 <?php echo VikBooking::getPriceName($tars[$num][0]['idprice']); ?>
485 <?php
486 if (!empty($or['room_cost'])) {
487 echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat(VikBooking::sayCostPlusIva($display_rate, $tars[$num][0]['idprice'])), $currencysymb);
488 }
489 ?>
490 </span>
491 <?php
492 } elseif (!empty($or['otarplan'])) {
493 ?>
494 <span><?php echo ucwords($or['otarplan']); ?></span>
495 <?php
496 } elseif ($this->row['closure'] < 1) {
497 ?>
498 <span><?php echo JText::translate('VBOROOMNORATE'); ?></span>
499 <?php
500 } else {
501 ?>
502 <span>-----</span>
503 <?php
504 }
505 ?>
506 </div>
507 </div>
508 <div class="vbo-roomdet-entry">
509 <div class="vbo-roomdet-head">
510 <span><?php echo JText::translate('VBEDITORDEREIGHT'); ?></span>
511 </div>
512 <div class="vbo-roomdet-foot">
513 <?php
514 if (!empty($or['optionals'])) {
515 $stepo = explode(";", $or['optionals']);
516 foreach ($stepo as $roptkey => $oo) {
517 if (empty($oo)) {
518 continue;
519 }
520 $hide_price = false;
521 $stept = explode(":", $oo);
522 $actopt = VikBooking::getSingleOption($stept[0]);
523 if (!$actopt) {
524 continue;
525 }
526 $chvar = '';
527 if (!empty($actopt['ageintervals']) && $or['children'] > 0 && strstr($stept[1], '-') != false) {
528 $optagenames = VikBooking::getOptionIntervalsAges($actopt['ageintervals']);
529 $optagepcent = VikBooking::getOptionIntervalsPercentage($actopt['ageintervals']);
530 $optageovrct = VikBooking::getOptionIntervalChildOverrides($actopt, $or['adults'], $or['children']);
531 $child_num = VikBooking::getRoomOptionChildNumber($or['optionals'], $actopt['id'], $roptkey, $or['children']);
532 $optagecosts = VikBooking::getOptionIntervalsCosts(isset($optageovrct['ageintervals_child' . ($child_num + 1)]) ? $optageovrct['ageintervals_child' . ($child_num + 1)] : $actopt['ageintervals']);
533 $agestept = explode('-', $stept[1]);
534 $stept[1] = $agestept[0];
535 $chvar = $agestept[1];
536 if (array_key_exists(($chvar - 1), $optagepcent) && $optagepcent[($chvar - 1)] == 1) {
537 //percentage value of the adults tariff
538 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
539 $optagecosts[($chvar - 1)] = $or['cust_cost'] * $optagecosts[($chvar - 1)] / 100;
540 } else {
541 $display_rate = !empty($or['room_cost']) ? $or['room_cost'] : $tars[$num][0]['cost'];
542 $hide_price = empty($or['room_cost']) ? true : $hide_price;
543 $optagecosts[($chvar - 1)] = $display_rate * $optagecosts[($chvar - 1)] / 100;
544 }
545 } elseif (array_key_exists(($chvar - 1), $optagepcent) && $optagepcent[($chvar - 1)] == 2) {
546 //VBO 1.10 - percentage value of room base cost
547 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
548 $optagecosts[($chvar - 1)] = $or['cust_cost'] * $optagecosts[($chvar - 1)] / 100;
549 } else {
550 $display_rate = isset($tars[$num][0]['room_base_cost']) ? $tars[$num][0]['room_base_cost'] : (!empty($or['room_cost']) ? $or['room_cost'] : $tars[$num][0]['cost']);
551 $hide_price = empty($or['room_cost']) ? true : $hide_price;
552 $optagecosts[($chvar - 1)] = $display_rate * $optagecosts[($chvar - 1)] / 100;
553 }
554 }
555 $actopt['chageintv'] = $chvar;
556 $actopt['name'] .= ' ('.$optagenames[($chvar - 1)].')';
557 $realcost = (intval($actopt['perday']) == 1 ? (floatval($optagecosts[($chvar - 1)]) * $order['days'] * $stept[1]) : (floatval($optagecosts[($chvar - 1)]) * $stept[1]));
558 } else {
559 // VBO 1.11 - options percentage cost of the room total fee
560 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
561 $deftar_basecosts = $or['cust_cost'];
562 } else {
563 $deftar_basecosts = !empty($or['room_cost']) ? $or['room_cost'] : $tars[$num][0]['cost'];
564 }
565 $actopt['cost'] = (int)$actopt['pcentroom'] ? ($deftar_basecosts * $actopt['cost'] / 100) : $actopt['cost'];
566 //
567 $realcost = (intval($actopt['perday']) == 1 ? ($actopt['cost'] * $order['days'] * $stept[1]) : ($actopt['cost'] * $stept[1]));
568 }
569 if ($actopt['maxprice'] > 0 && $realcost > $actopt['maxprice']) {
570 $realcost = $actopt['maxprice'];
571 if (intval($actopt['hmany']) == 1 && intval($stept[1]) > 1) {
572 $realcost = $actopt['maxprice'] * $stept[1];
573 }
574 }
575 $realcost = $actopt['perperson'] == 1 ? ($realcost * $arrpeople[$num]['adults']) : $realcost;
576
577 /**
578 * Trigger event to allow third party plugins to apply a custom calculation for the option/extra fee or tax.
579 *
580 * @since 1.17.7 (J) - 1.7.7 (WP)
581 */
582 $custom_calculation = VBOFactory::getPlatform()->getDispatcher()->filter('onCalculateBookingOptionFeeCost', [$realcost, &$actopt, $order, $or]);
583 if ($custom_calculation) {
584 $realcost = (float) $custom_calculation[0];
585 }
586
587 $tmpopr = VikBooking::sayOptionalsPlusIva($realcost, $actopt['idiva']);
588 ?>
589 <div class="vbo-roomdet-foot-options">
590 <?php echo ($stept[1] > 1 ? $stept[1]." " : "").$actopt['name'].(!$hide_price ? " " . VikBooking::formatCurrencyNumber(VikBooking::numberFormat($tmpopr), $currencysymb) : ''); ?>
591 </div>
592 <?php
593 }
594 }
595 ?>
596 </div>
597 </div>
598 <div class="vbo-roomdet-entry">
599 <div class="vbo-roomdet-head">
600 <span><?php echo JText::translate('VBPEDITBUSYEXTRACOSTS'); ?></span>
601 </div>
602 <div class="vbo-roomdet-foot">
603 <?php
604 if (!empty($or['extracosts'])) {
605 $cur_extra_costs = json_decode($or['extracosts'], true);
606 foreach ($cur_extra_costs as $eck => $ecv) {
607 ?>
608 <div class="vbo-roomdet-foot-extras">
609 <?php echo $ecv['name'] . " " . VikBooking::formatCurrencyNumber(VikBooking::numberFormat(VikBooking::sayOptionalsPlusIva($ecv['cost'], $ecv['idtax'])), $currencysymb); ?>
610 </div>
611 <?php
612 }
613 }
614 ?>
615 </div>
616 </div>
617 </div>
618 <?php
619 if ($arrpeople[$num]['adults'] > 0) {
620 ?>
621 <div class="vbo-roomdet-guests-details" id="vbo-roomdet-guests-details-<?php echo $ind; ?>">
622 <?php
623 /**
624 * Back-end guests registration now relies on dynamic drivers within Vik Booking.
625 *
626 * @since 1.15.0 (J) - 1.5.0 (WP)
627 */
628
629 // loop through all guests that should be registered within this room-party
630 for ($g = 1; $g <= $guests_to_register; $g++) {
631 $current_guest = array();
632 if (count($pax_data) && isset($pax_data[$ind]) && isset($pax_data[$ind][$g])) {
633 $current_guest = $pax_data[$ind][$g];
634 } elseif ($ind < 1 && $g == 1 && count($customer)) {
635 $current_guest = $customer;
636 }
637 ?>
638 <div class="vbo-roomdet-guest-details" data-roomind="<?php echo $ind; ?>" data-guestnum="<?php echo $g; ?>" data-totguests="<?php echo $guests_to_register; ?>">
639 <div class="vbo-roomdet-guest-detail vbo-roomdet-guest-detail-num">
640 <span><?php echo JText::sprintf('VBOGUESTNUM', $g); ?></span>
641 </div>
642 <?php
643 $pax_field_ind = 1;
644 foreach ($pax_fields as $paxk => $paxv) {
645 // get an instance of the VBOCheckinPaxfield object
646 $pax_field_obj = $pax_fields_obj->getField($paxk);
647
648 // detect the current type of guest
649 $guest_type = $g > $arrpeople[$num]['adults'] ? 'child' : 'adult';
650
651 // set object data
652 $pax_field_obj->setGuestType($guest_type)
653 ->setFieldNumber($pax_field_ind)
654 ->setGuestNumber($g)
655 ->setGuestData($current_guest)
656 ->setRoomIndex($ind)
657 ->setBooking($this->row)
658 ->setBookingRooms($this->rooms)
659 ->setRoomGuests($arrpeople[$num]['adults'], $arrpeople[$num]['children'])
660 ->setTotalRooms(count($arrpeople));
661
662 // render input field
663 $pax_field_html = $pax_fields_obj->render($pax_field_obj);
664 if (empty($pax_field_html)) {
665 // nothing to display, increase the counter and continue
666 $pax_field_ind++;
667 continue;
668 }
669
670 // access the implementor object
671 $implementor = $pax_fields_obj->getFieldTypeImplementor($pax_field_obj);
672
673 // check if a particular CSS class has been defined
674 $field_container_class = $implementor->getContainerClassAttr();
675 $field_container_class = !empty($field_container_class) ? " $field_container_class" : '';
676
677 ?>
678 <div class="vbo-roomdet-guest-detail<?php echo $field_container_class; ?>">
679 <div class="vbo-roomdet-guest-detail-lbl">
680 <label for="<?php echo $implementor->getFieldIdAttr(); ?>"><?php echo $paxv; ?></label>
681 </div>
682 <div class="vbo-roomdet-guest-detail-val">
683 <?php echo $pax_field_html; ?>
684 </div>
685 </div>
686 <?php
687 $pax_field_ind++;
688 }
689 // display any other information collected through the pre check-in
690 if (count($pax_data) && isset($pax_data[$ind]) && isset($pax_data[$ind][$g])) {
691 foreach ($pax_data[$ind][$g] as $extrak => $extrav) {
692 if (isset($pax_fields[$extrak]) || (is_scalar($extrav) && !strlen($extrav))) {
693 // this is a default pax field, we skip it
694 continue;
695 }
696 // obtain field label and field type
697 $precheckin_field_lbl = isset($pre_pax_fields[$extrak]) ? $pre_pax_fields[$extrak] : $extrak;
698 $precheckin_field_typ = isset($pre_pax_fields_attributes[$extrak]) && $pre_pax_fields_attributes[$extrak] == 'file' ? 'file' : 'text';
699 // ensure the field should be displayed
700 if (substr($extrak, 0, 1) === '_') {
701 // this is a "protected" pax field to be kept within a hidden input field and no labels
702 ?>
703 <input type="hidden" data-gind="<?php echo $g; ?>" class="vbo-paxfield" name="guests[<?php echo $ind; ?>][<?php echo $g; ?>][<?php echo $extrak; ?>]" value="<?php echo htmlspecialchars($extrav); ?>" />
704 <?php
705 // do not display anyting else
706 continue;
707 }
708 ?>
709 <div class="vbo-roomdet-guest-detail vbo-roomdet-guest-detail-precheckin">
710 <div class="vbo-roomdet-guest-detail-lbl">
711 <span><?php echo $precheckin_field_lbl; ?></span>
712 </div>
713 <div class="vbo-roomdet-guest-detail-val">
714 <?php
715 if ($precheckin_field_typ == 'file') {
716 // documents uploaded by the customer during pre-checkin
717 $guest_files = explode('|', $extrav);
718 foreach ($guest_files as $gfk => $guest_file) {
719 if (empty($guest_file) || strpos($guest_file, 'http') !== 0) {
720 continue;
721 }
722 $furl_segments = explode('/', $guest_file);
723 $guest_fname = $furl_segments[(count($furl_segments) - 1)];
724 $read_fname = substr($guest_fname, (strpos($guest_fname, '_') + 1));
725 ?>
726 <div class="vbo-paxfield-file-uploaded">
727 <a href="<?php echo $guest_file; ?>" target="_blank">
728 <?php VikBookingIcons::e('image'); ?>
729 <span><?php echo $read_fname; ?></span>
730 </a>
731 </div>
732 <?php
733 }
734 ?>
735 <input type="hidden" data-gind="<?php echo $g; ?>" name="guests[<?php echo $ind; ?>][<?php echo $g; ?>][<?php echo $extrak; ?>]" value="<?php echo $extrav; ?>" />
736 <?php
737 } else {
738 ?>
739 <input type="text" data-gind="<?php echo $g; ?>" class="vbo-paxfield" name="guests[<?php echo $ind; ?>][<?php echo $g; ?>][<?php echo $extrak; ?>]" value="<?php echo htmlspecialchars($extrav); ?>" />
740 <?php
741 }
742 ?>
743 </div>
744 </div>
745 <?php
746 }
747 }
748 ?>
749 </div>
750 <?php
751 }
752 ?>
753 </div>
754 </div>
755 <?php
756 }
757 }
758 ?>
759 </div>
760
761 <div class="vbo-checkin-payment-container">
762 <div class="vbo-checkin-payment-detail">
763 <?php
764 $bcolortag = VikBooking::applyBookingColorTag($order, $colortags);
765 $usectag = '';
766 if (count($bcolortag) > 0) {
767 $bcolortag['name'] = JText::translate($bcolortag['name']);
768 $usectag = '<span class="vbo-colortag-circle hasTooltip" style="background-color: '.$bcolortag['color'].';" title="'.htmlspecialchars($bcolortag['name']).'"></span> ';
769 }
770 ?>
771 <span class="vbo-checkin-payment-detail-lbl"><?php echo $usectag; ?><strong><?php echo JText::translate('VBEDITORDERNINE'); ?></strong></span>
772 <span class="vbo-checkin-payment-detail-v"><?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($order['total']), (strlen($otacurrency) > 0 ? '('.$otacurrency.') '.$currencysymb : $currencysymb)); ?></span>
773 </div>
774 <?php
775 if (!empty($order['totpaid']) && $order['totpaid'] > 0) {
776 $diff_to_pay = $order['total'] - $order['totpaid'];
777 ?>
778 <div class="vbo-checkin-payment-detail">
779 <span class="vbo-checkin-payment-detail-lbl"><?php echo JText::translate('VBAMOUNTPAID'); ?></span>
780 <span class="vbo-checkin-payment-detail-v"><?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($order['totpaid']), $currencysymb); ?></span>
781 </div>
782 <?php
783 if ($diff_to_pay > 0) {
784 ?>
785 <div class="vbo-checkin-payment-detail">
786 <span class="vbo-checkin-payment-detail-lbl"><?php echo JText::translate('VBTOTALREMAINING'); ?></span>
787 <span class="vbo-checkin-payment-detail-v"><?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($diff_to_pay), $currencysymb, ['%s', '<span id="vbo-checkin-remaining">%s</span>']); ?></span>
788 </div>
789 <div class="vbo-checkin-payment-detail">
790 <span class="vbo-checkin-payment-detail-lbl"><?php echo JText::translate('VBONEWAMOUNTPAID'); ?></span>
791 <span class="vbo-checkin-payment-detail-v"><?php echo $currencysymb; ?> <input name="newtotpaid" id="newtotpaid" value="" min="0" type="number" step="any" style="margin: 0;"></span>
792 </div>
793 <?php
794 }
795 } else {
796 // print the new amount paid anyway to let it update
797 ?>
798 <div class="vbo-checkin-payment-detail">
799 <span class="vbo-checkin-payment-detail-lbl"><?php echo JText::translate('VBONEWAMOUNTPAID'); ?></span>
800 <span class="vbo-checkin-payment-detail-v"><?php echo $currencysymb; ?> <input name="newtotpaid" id="newtotpaid" value="" min="0" type="number" step="any" style="margin: 0;"></span>
801 </div>
802 <?php
803 }
804 $payment = VikBooking::getPayment($order['idpayment']);
805 if (is_array($payment)) {
806 ?>
807 <div class="vbo-checkin-payment-detail">
808 <span class="vbo-checkin-payment-detail-lbl"><?php echo JText::translate('VBPAYMENTMETHOD'); ?></span>
809 <span class="vbo-checkin-payment-detail-v"><?php echo $payment['name']; ?></span>
810 </div>
811 <?php
812 }
813 if (!empty($order['paymentlog'])) {
814 ?>
815 <div class="vbo-checkin-payment-detail">
816 <span class="vbo-checkin-payment-detail-lbl vbo-checkin-payment-detail-click" onclick="vboUpdateModal('<?php echo addslashes(JText::translate('VBPAYMENTLOGTOGGLE')); ?>', '.paymentlog', true);">
817 <i class="vboicn-credit-card"></i> <?php echo JText::translate('VBPAYMENTLOGTOGGLE'); ?>
818 </span>
819 </div>
820 <?php
821 }
822 ?>
823 </div>
824 </div>
825
826 <div class="vbo-checkin-notes-wrap">
827 <div class="vbo-checkin-notes-inner">
828 <div class="vbo-checkin-notes-trig">
829 <span onclick="vboToggleCheckinNotes();"><i class="<?php echo count($customer) && !empty($customer['comments']) ? 'vboicn-bubbles2' : 'vboicn-bubble2'; ?>"></i> <?php echo JText::translate('VBOTOGGLECHECKINNOTES'); ?></span>
830 </div>
831 <div class="vbo-checkin-notes-cont">
832 <textarea name="comments"><?php echo count($customer) && isset($customer['comments']) ? htmlspecialchars($customer['comments']) : ''; ?></textarea>
833 </div>
834 </div>
835 </div>
836
837 <div class="vbo-checkin-update-wrap">
838 <div class="vbo-checkin-update-inner">
839 <div>
840 <button type="button" class="btn btn-primary" onclick="jQuery('#adminForm').submit();"><i class="vboicn-checkmark"></i> <?php echo JText::translate('VBOCHECKINUPDATEBTN'); ?></button>
841 </div>
842 </div>
843 </div>
844
845 <div class="vbo-checkin-commands-wrap">
846 <div class="vbo-checkin-commands-inner">
847 <?php
848 if ($today_midnight < $order['checkout'] || $grace_ts < $order['checkout']) {
849 $allowed_btns = array();
850 if ($order['checked'] <= 0) {
851 //check-in btn only for no-status or no-show
852 $allowed_btns[] = 1;
853 }
854 if ($order['checked'] < 0 && !empty($order['channel']) && strpos($order['channel'], 'booking.com') !== false && VikBooking::vcmBcomReportingSupported($order)) {
855 //report no show to Booking.com btn only for no-status
856 $allowed_btns[] = -11;
857 }
858 if ($order['checked'] == 0) {
859 //no-show button only if no-status
860 $allowed_btns[] = -1;
861 }
862 if ($order['checked'] == 1 && (count($customer) && empty($customer['checkindoc']))) {
863 //generate check-in doc button only for checked-in and no check-in doc
864 $allowed_btns[] = 11;
865 } elseif ($order['checked'] > 0 && (count($customer) && !empty($customer['checkindoc']))) {
866 //download check-in doc button only for checked-in||out and check-in doc
867 $allowed_btns[] = 12;
868 //add also the possibility of re-creating the document
869 $allowed_btns[] = 11;
870 }
871 if ($order['checked'] == 1 && $today_midnight > $order['checkin']) {
872 //check-out button only for checked-in and after the check-in day
873 $allowed_btns[] = 2;
874 }
875 if ($order['checked'] != 0) {
876 //cancel button only if not no-status
877 $allowed_btns[] = 0;
878 }
879 //print buttons
880 foreach ($allowed_btns as $chstatus) {
881 switch ($chstatus) {
882 case -1:
883 ?>
884 <div class="vbo-checkin-commands-btn">
885 <button type="button" onclick="vboSetCheckinAction(-1);" class="btn btn-large btn-danger"><i class="vboicn-blocked"></i> <?php echo JText::translate('VBOSETCHECKEDSTATUSNOS'); ?></button>
886 </div>
887 <?php
888 break;
889 case 0:
890 ?>
891 <div class="vbo-checkin-commands-btn">
892 <button type="button" onclick="vboSetCheckinAction(0);" class="btn btn-large btn-secondary"><i class="vboicn-cancel-circle"></i> <?php echo JText::translate('VBOSETCHECKEDSTATUSZERO'); ?></button>
893 </div>
894 <?php
895 break;
896 case 1:
897 ?>
898 <div class="vbo-checkin-commands-btn">
899 <button type="button" onclick="vboSetCheckinAction(1);" class="btn btn-large btn-success"><i class="vboicn-checkmark"></i> <?php echo JText::translate('VBOSETCHECKEDSTATUSIN'); ?></button>
900 </div>
901 <?php
902 break;
903 case 2:
904 ?>
905 <div class="vbo-checkin-commands-btn">
906 <button type="button" onclick="vboSetCheckinAction(2);" class="btn btn-large btn-success"><i class="vboicn-exit"></i> <?php echo JText::translate('VBOSETCHECKEDSTATUSOUT'); ?></button>
907 </div>
908 <?php
909 break;
910 case 11:
911 ?>
912 <div class="vbo-checkin-commands-btn">
913 <a href="index.php?option=com_vikbooking&task=gencheckindoc&cid[]=<?php echo $order['id'].($tmpl == 'component' ? '&tmpl=component' : ''); ?>" class="btn btn-large btn-success"><i class="vboicn-profile"></i> <?php echo JText::translate('VBOGENCHECKINDOC'); ?></a>
914 </div>
915 <?php
916 break;
917 case 12:
918 ?>
919 <div class="vbo-checkin-commands-btn">
920 <button type="button" onclick="window.open('<?php echo VBO_SITE_URI.'helpers/checkins/generated/'.$customer['checkindoc']; ?>', '_blank');" class="btn btn-large btn-success"><i class="vboicn-download"></i> <?php echo JText::translate('VBODWNLCHECKINDOC'); ?></button>
921 </div>
922 <?php
923 break;
924 case -11:
925 /**
926 * Build the contextual menu buttons to report the no-show to the OTA through AJAX requests.
927 *
928 * @since 1.16.8 (J) - 1.6.8 (WP)
929 *
930 * @requires VCM >= 1.8.24
931 */
932 ?>
933 <div class="vbo-checkin-commands-btn">
934 <button type="button" class="btn btn-large btn-danger vbo-context-menu-btn vbo-context-menu-otanoshow">
935 <span class="vbo-context-menu-lbl"><?php VikBookingIcons::e('ban'); ?> <?php echo JText::translate('VBOBCOMREPORTNOSHOW'); ?></span>
936 <span class="vbo-context-menu-ico"><?php VikBookingIcons::e('sort-down'); ?></span>
937 </button>
938 </div>
939
940 <script type="text/javascript">
941 jQuery(function() {
942
943 // callback constant will receive this.waived_fees (do not use an arrow function)
944 const notify_noshow = function() {
945 if (confirm('<?php echo addslashes(JText::translate('VBOBCOMREPORTNOSHOWCONF')); ?>')) {
946 // show inner modal
947 VBOCore.displayModal({
948 title: '.....',
949 dismiss_event: 'vbo-bookingcheckin-ajax-dismiss',
950 loading_event: 'vbo-bookingcheckin-ajax-loading',
951 loading_body: '<?php VikBookingIcons::e('circle-notch', 'fa-spin fa-fw'); ?>',
952 });
953
954 // start loading
955 VBOCore.emitEvent('vbo-bookingcheckin-ajax-loading');
956
957 // perform the request
958 VBOCore.doAjax(
959 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=breporting.no_show'); ?>",
960 {
961 otaid: '<?php echo $order['idorderota']; ?>',
962 waived_fees: this.waived_fees,
963 },
964 (success) => {
965 // remove inner modal
966 VBOCore.emitEvent('vbo-bookingcheckin-ajax-dismiss');
967
968 // hide main modal
969 try {
970 jQuery('#jmodal-vbo-checkin-booking').modal('hide');
971 } catch(e) {
972 // do nothing
973 }
974
975 // reload (parent/current) window
976 (window.parent || window).location.reload();
977 },
978 (error) => {
979 // remove inner modal
980 VBOCore.emitEvent('vbo-bookingcheckin-ajax-dismiss');
981
982 // log and display the error
983 console.error(error);
984 alert(error.responseText);
985 }
986 );
987 }
988 };
989
990 jQuery('.vbo-context-menu-otanoshow').vboContextMenu({
991 placement: 'bottom-right',
992 buttons: [
993 {
994 icon: '<?php echo VikBookingIcons::i('ban'); ?>',
995 text: '<?php echo addslashes(JText::translate('VBO_DONT_WAIVE_FEES')); ?>',
996 class: 'vbo-context-menu-entry-warning',
997 separator: true,
998 waived_fees: 0,
999 action: notify_noshow,
1000 },
1001 {
1002 icon: '<?php echo VikBookingIcons::i('ban'); ?>',
1003 text: '<?php echo addslashes(JText::translate('VBO_DO_WAIVE_FEES')); ?>',
1004 class: 'vbo-context-menu-entry-danger',
1005 separator: false,
1006 waived_fees: 1,
1007 action: notify_noshow,
1008 },
1009 ],
1010 });
1011 });
1012 </script>
1013 <?php
1014 break;
1015 default:
1016 break;
1017 }
1018 }
1019 } else {
1020 ?>
1021 <p class="warn"><?php echo JText::translate('VBOCHECKINTIMEOVER'); ?></p>
1022 <?php
1023 //if the document exists, print the download button even if the check-out date is in the past
1024 if ($order['checked'] != 0 && (count($customer) && !empty($customer['checkindoc']))) {
1025 //download check-in doc button only for checked-in||out and check-in doc
1026 ?>
1027 <div class="vbo-checkin-commands-btn">
1028 <button type="button" onclick="window.open('<?php echo VBO_SITE_URI.'helpers/checkins/generated/'.$customer['checkindoc']; ?>', '_blank');" class="btn btn-large btn-success"><i class="vboicn-download"></i> <?php echo JText::translate('VBODWNLCHECKINDOC'); ?></button>
1029 </div>
1030 <?php
1031 }
1032 }
1033 ?>
1034 </div>
1035 </div>
1036 <input type="hidden" name="cid[]" value="<?php echo $order['id']; ?>">
1037 <input type="hidden" name="checkin_action" id="vbo-checkin-action" value="<?php echo $order['checked']; ?>">
1038 <input type="hidden" name="task" value="updatebookingcheckin" />
1039 <input type="hidden" name="option" value="com_vikbooking" />
1040 <?php
1041 if ($tmpl == 'component') {
1042 ?>
1043 <input type="hidden" name="tmpl" value="component" />
1044 <?php
1045 }
1046 ?>
1047 </form>
1048 <?php
1049 //
1050 ?>
1051 <script type="text/javascript">
1052 var vbo_overlay_data = {};
1053 <?php
1054 if (!empty($order['adminnotes'])) {
1055 $order['adminnotes'] = VikBooking::strTrimLiteral(nl2br(htmlspecialchars($order['adminnotes'])));
1056 ?>
1057 vbo_overlay_data['adminnotes'] = '<pre><?php echo addslashes($order['adminnotes']); ?></pre>';
1058 <?php
1059 }
1060 if (!empty($order['paymentlog'])) {
1061 $plain_log = htmlspecialchars($order['paymentlog']);
1062 $order['paymentlog'] = VikBooking::strTrimLiteral(nl2br(htmlspecialchars($order['paymentlog'])));
1063 ?>
1064 vbo_overlay_data['paymentlog'] = '<pre><?php echo addslashes($order['paymentlog']); ?></pre>';
1065 <?php
1066 //PCI Data Retrieval
1067 if (!empty($order['idorderota']) && !empty($order['channel'])) {
1068 $channel_source = $order['channel'];
1069 if (strpos($order['channel'], '_') !== false) {
1070 $channelparts = explode('_', $order['channel']);
1071 $channel_source = $channelparts[0];
1072 }
1073 //Limit set to Check-out date at 29:59:59
1074 $checkout_info = getdate($order['checkout']);
1075 $checkout_midnight = mktime(23, 59, 59, $checkout_info['mon'], $checkout_info['mday'], $checkout_info['year']);
1076 if (time() < $checkout_midnight) {
1077 if ((stripos($plain_log, 'card number') !== false && strpos($plain_log, '****') !== false) || !strcasecmp($channel_source, 'Booking.com')) {
1078 /*
1079 * Log contains credit card details.
1080 * Build the URI for the administrator section of VCM according to the platform.
1081 */
1082 $exec_pcid_uri = VBOFactory::getPlatform()->getUri()->admin('index.php?option=com_vikchannelmanager&task=execpcid&channel_source=' . $channel_source . '&otaid=' . $order['idorderota'] . '&tmpl=component', false);
1083 ?>
1084 var pci_vcm_frame = '<iframe src="<?php echo $exec_pcid_uri; ?>"></iframe>';
1085 vbo_overlay_data['paymentlog'] = '<div class="vcm-notif-pcidrq-container">'+
1086 '<button type="button" class="btn vbo-config-btn vcm-pcid-launch" onclick="vboUpdateModal(\'<?php echo addslashes(JText::translate('VBPAYMENTLOGTOGGLE')); ?>\', pci_vcm_frame, false);">'+
1087 '<?php VikBookingIcons::e('credit-card'); ?>'+
1088 '<?php echo addslashes(JText::translate('GETFULLCARDDETAILS')); ?>'+
1089 '</button>'+
1090 '</div>'+
1091 vbo_overlay_data['paymentlog'];
1092 <?php
1093 }
1094 }
1095 }
1096 //
1097 }
1098 if (count($customer) && !empty($customer['notes'])) {
1099 $customer['notes'] = VikBooking::strTrimLiteral(nl2br(htmlspecialchars($customer['notes'])));
1100 ?>
1101 vbo_overlay_data['customer_notes'] = '<pre><?php echo addslashes($customer['notes']); ?></pre>';
1102 <?php
1103 }
1104 if (count($customer)) {
1105 $displayable_fields = array(
1106 'first_name' => JText::translate('VBCUSTOMERFIRSTNAME'),
1107 'last_name' => JText::translate('VBCUSTOMERLASTNAME'),
1108 'company' => JText::translate('VBCUSTOMERCOMPANY'),
1109 'vat' => JText::translate('VBCUSTOMERCOMPANYVAT'),
1110 'email' => JText::translate('VBCUSTOMEREMAIL'),
1111 'phone' => JText::translate('VBCUSTOMERPHONE'),
1112 'address' => JText::translate('VBCUSTOMERADDRESS'),
1113 'city' => JText::translate('VBCUSTOMERCITY'),
1114 'zip' => JText::translate('VBCUSTOMERZIP'),
1115 'country' => JText::translate('VBCUSTOMERCOUNTRY'),
1116 'gender' => JText::translate('VBCUSTOMERGENDER'),
1117 'bdate' => JText::translate('VBCUSTOMERBDATE'),
1118 'pbirth' => JText::translate('VBCUSTOMERPBIRTH'),
1119 'doctype' => JText::translate('VBCUSTOMERDOCTYPE'),
1120 'docnum' => JText::translate('VBCUSTOMERDOCNUM')
1121 );
1122 /**
1123 * We use a link rather than a button to support the
1124 * modal navigation through AJAX on both J and WP.
1125 */
1126 ?>
1127 vbo_overlay_data['customer_info'] = '<a class="btn btn-primary pull-right" href="index.php?option=com_vikbooking&task=editcustomer&cid[]=<?php echo $customer['id'].'&checkin=1&bid='.$order['id'].($tmpl == 'component' ? '&tmpl=component' : ''); ?>"><i class="vboicn-profile"></i> <?php echo addslashes(JText::translate('VBMAINCUSTOMEREDIT')); ?></a>'+
1128 '<div class="vbo-checkin-custdet-cont">'+
1129 <?php
1130 foreach ($displayable_fields as $k => $v) {
1131 $customer_val = isset($customer[$k]) && !empty($customer[$k]) ? addslashes(VikBooking::strTrimLiteral(nl2br(htmlspecialchars($customer[$k])))) : '---';
1132 ?>
1133 '<div class="vbo-checkin-custdet-entry">'+
1134 '<span class="vbo-checkin-custdet-key<?php echo (!isset($customer[$k]) || empty($customer[$k])) && in_array($k, $sensible_k) ? ' vbo-checkin-custdet-key-warn' : ''; ?>"><?php echo addslashes(JText::translate($v)); ?></span>'+
1135 '<span class="vbo-checkin-custdet-value"><?php echo $customer_val; ?></span>'+
1136 '</div>'+
1137 <?php
1138 }
1139 ?>
1140 '</div>';
1141 <?php
1142 }
1143 if (!empty($set_parent_status)) {
1144 /**
1145 * This function supports the admin widgets arriving today and departing today.
1146 */
1147 ?>
1148 if (jQuery('[data-status="<?php echo $order['id']; ?>"]', window.parent.document).length) {
1149 jQuery('[data-status="<?php echo $order['id']; ?>"]', window.parent.document).html('<?php echo str_replace("'", "", $set_parent_status); ?>');
1150 }
1151 <?php
1152 }
1153 ?>
1154 </script>
1155 <script type="text/javascript">
1156 /* Global Variables and Functions */
1157 var vbo_overlay_on = false;
1158 var booking_total = <?php echo (float)$order['total']; ?>;
1159 var tot_rooms = <?php echo (int)$order['roomsnum']; ?>;
1160 var current_checked = <?php echo (int)$order['checked']; ?>;
1161
1162 function vboOpenModal() {
1163 <?php
1164 if (VBOPlatformDetection::isWordPress()) {
1165 ?>
1166 /**
1167 * @wponly - we are inside the same parent page as the modal is loaded via Ajax.
1168 * We need to select the values from the modal container.
1169 */
1170 jQuery('.modal-body').find(".vbo-info-overlay-block").fadeToggle(400, function() {
1171 if (jQuery('.modal-body').find(".vbo-info-overlay-block").is(":visible")) {
1172 vbo_overlay_on = true;
1173 } else {
1174 vbo_overlay_on = false;
1175 jQuery('.modal-body').find('.vbo-overlay-checkin-body').html('');
1176 }
1177 });
1178 <?php
1179 } else {
1180 ?>
1181 jQuery(".vbo-info-overlay-block").fadeToggle(400, function() {
1182 if (jQuery(".vbo-info-overlay-block").is(":visible")) {
1183 vbo_overlay_on = true;
1184 } else {
1185 vbo_overlay_on = false;
1186 jQuery('.vbo-overlay-checkin-body').html('');
1187 }
1188 });
1189 <?php
1190 }
1191 ?>
1192 }
1193
1194 function vboUpdateModal(title, body, call_toggle) {
1195 <?php
1196 if (VBOPlatformDetection::isWordPress()) {
1197 ?>
1198 /**
1199 * @wponly - we are inside the same parent page as the modal is loaded via Ajax.
1200 * We need to select the values from the modal container.
1201 */
1202 var keep_closing_btn = jQuery('.modal-body').find('#vbo-overlay-title').find('.vbo-info-overlay-title-close').html();
1203 jQuery('.modal-body').find('#vbo-overlay-title').html(title + '<span class="vbo-info-overlay-title-close">' + keep_closing_btn + '</span>');
1204 if (body.substr(0, 1) == '.') {
1205 //look for this value inside the global array
1206 body = body.substr(1, (body.length - 1));
1207 if (vbo_overlay_data.hasOwnProperty(body)) {
1208 body = vbo_overlay_data[body];
1209 }
1210 }
1211 jQuery('.modal-body').find('.vbo-overlay-checkin-body').html(body);
1212 if (call_toggle) {
1213 vboOpenModal();
1214 }
1215 /**
1216 * @wponly - the customer_info 'body' has a link to another page, which must be manually
1217 * registered for preventing the browser to follow it and make the Ajax request instead.
1218 */
1219 var parent_modal_id = jQuery('.modal-body').find('.vbo-overlay-checkin-body').closest('.modal').attr('id');
1220 ajaxPreventFormSubmit(parent_modal_id);
1221 <?php
1222 } else {
1223 ?>
1224 var keep_closing_btn = jQuery('#vbo-overlay-title').find('.vbo-info-overlay-title-close').html();
1225 jQuery('#vbo-overlay-title').html(title + '<span class="vbo-info-overlay-title-close">' + keep_closing_btn + '</span>');
1226 if (body.substr(0, 1) == '.') {
1227 //look for this value inside the global array
1228 body = body.substr(1, (body.length - 1));
1229 if (vbo_overlay_data.hasOwnProperty(body)) {
1230 body = vbo_overlay_data[body];
1231 }
1232 }
1233 jQuery('.vbo-overlay-checkin-body').html(body);
1234 if (call_toggle) {
1235 vboOpenModal();
1236 }
1237 <?php
1238 }
1239 ?>
1240 }
1241
1242 function vboToggleCheckinNotes() {
1243 jQuery('.vbo-checkin-notes-cont').toggle();
1244 }
1245
1246 function vboSetCheckinAction(action) {
1247 jQuery('#vbo-checkin-action').val(action);
1248 if (action > 0) {
1249 //check if guests details were filled in for check-in/out actions
1250 var guests_filled = true;
1251 for (var i = 0; i < tot_rooms; i++) {
1252 var elem = jQuery(".vbo-roomdet-guests-toggle[data-roomind='"+i+"']");
1253 if (elem.length && elem.hasClass('vbo-guestscount-incomplete')) {
1254 guests_filled = false;
1255 break;
1256 }
1257 }
1258 if (!guests_filled) {
1259 if (confirm('<?php echo addslashes(JText::translate('VBOCHECKINACTCONFGUESTS')) ?>')) {
1260 jQuery('#adminForm').submit();
1261 }
1262 return true;
1263 }
1264 }
1265 jQuery('#adminForm').submit();
1266 }
1267
1268 if (typeof jQuery.fn.tooltip === 'function') {
1269 jQuery(".hasTooltip").tooltip();
1270 } else {
1271 jQuery.fn.tooltip = function(){};
1272 }
1273
1274 jQuery(function() {
1275 /* Guests Details events - Start */
1276 var focused = null;
1277 jQuery('.vbo-roomdet-guests-toggle').focus(function(e) {
1278 // focus event will be fired before the click event
1279 focused = null;
1280 e.stopPropagation();
1281 e.preventDefault();
1282 var roomind = jQuery(this).attr('data-roomind');
1283 var elem = jQuery('#vbo-roomdet-guests-details-'+roomind);
1284 if (elem.length && elem.is(':hidden')) {
1285 focused = '#vbo-roomdet-guests-details-'+roomind;
1286 elem.slideDown();
1287 }
1288 });
1289 jQuery('.vbo-roomdet-guests-toggle').click(function(e) {
1290 // click event will be fired after the focus event
1291 var roomind = jQuery(this).attr('data-roomind');
1292 var elem = jQuery('#vbo-roomdet-guests-details-'+roomind);
1293 if (!elem.length || focused == '#vbo-roomdet-guests-details-'+roomind) {
1294 // focus event has already displayed the content
1295 focused = null;
1296 return;
1297 }
1298 elem.slideToggle();
1299 });
1300 jQuery('.vbo-paxfield').keyup(function() {
1301 var cur_gind = jQuery(this).attr('data-gind');
1302 var roomind = jQuery(this).closest('.vbo-roomdet-guest-details').attr('data-roomind');
1303 var tot_room_guests = parseInt(jQuery(this).closest('.vbo-roomdet-guest-details').attr('data-totguests'));
1304 if (!cur_gind.length || isNaN(tot_room_guests) || !jQuery(this).hasClass('vbo-paxfield-'+roomind)) {
1305 return true;
1306 }
1307 var cur_val = jQuery(this).val();
1308 var tot_full_guests = 0;
1309 for (var i = 1; i <= tot_room_guests; i++) {
1310 var fullfilled = true;
1311 jQuery(".vbo-paxfield-"+roomind+"[data-gind='"+i+"']").each(function(k, v) {
1312 if (!jQuery(this).val().length) {
1313 fullfilled = false;
1314 }
1315 });
1316 if (fullfilled) {
1317 tot_full_guests++;
1318 }
1319 }
1320 if (tot_full_guests >= tot_room_guests) {
1321 var add_class = 'vbo-guestscount-complete';
1322 var rm_class = 'vbo-guestscount-incomplete';
1323 var ico_add_class = 'vboicn-user-check';
1324 var ico_rm_class = 'vboicn-user-plus';
1325 } else {
1326 var add_class = 'vbo-guestscount-incomplete';
1327 var rm_class = 'vbo-guestscount-complete';
1328 var ico_add_class = 'vboicn-user-plus';
1329 var ico_rm_class = 'vboicn-user-check';
1330 }
1331 jQuery('#vbo-guestscount-'+roomind).text(tot_full_guests).closest('.vbo-roomdet-guests-toggle').addClass(add_class).removeClass(rm_class).find('i').addClass(ico_add_class).removeClass(ico_rm_class);
1332 });
1333 /* Guests Details events - End */
1334 /* Overlay for Customer Notes, Booking Notes, Payment Logs - Start */
1335 jQuery(document).mouseup(function(e) {
1336 if (!vbo_overlay_on) {
1337 return;
1338 }
1339 var vbo_overlay_cont = jQuery(".vbo-info-overlay-content");
1340 if (!vbo_overlay_cont.is(e.target) && vbo_overlay_cont.has(e.target).length === 0) {
1341 jQuery(".vbo-info-overlay-block").fadeOut();
1342 vbo_overlay_on = false;
1343 }
1344 });
1345 jQuery(document).keyup(function(e) {
1346 if (e.keyCode == 27 && vbo_overlay_on) {
1347 jQuery(".vbo-info-overlay-block").fadeOut();
1348 vbo_overlay_on = false;
1349 }
1350 });
1351 /* Overlay for Customer Notes, Booking Notes, Payment Logs - End */
1352 /* Update amount paid and remaining balance */
1353 jQuery('#newtotpaid').change(function() {
1354 if (!jQuery('#vbo-checkin-remaining').length) {
1355 return true;
1356 }
1357 var cur_val = parseFloat(jQuery(this).val());
1358 if (!(cur_val > 0)) {
1359 return true;
1360 }
1361 var new_val = booking_total - cur_val;
1362 jQuery('#vbo-checkin-remaining').text(new_val.toFixed(2));
1363 });
1364 });
1365 </script>
1366