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

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