PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.7
VikBooking Hotel Booking Engine & PMS v1.6.7
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 / editorder / tmpl / default.php

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

3,060 lines 131.4 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 $row = $this->row;
14 $rooms = $this->rooms;
15 $busy = $this->busy;
16 $customer = $this->customer;
17 $payments = $this->payments;
18
19 $history_obj = VikBooking::getBookingHistoryInstance();
20 $history_obj->setBid($row['id']);
21
22 // availability helper
23 $av_helper = VikBooking::getAvailabilityInstance();
24
25 // load datepicker for all CMS compatibility
26 JHtml::fetch('stylesheet', VBO_SITE_URI.'resources/jquery-ui.min.css');
27 JHtml::fetch('jquery.framework', true, true);
28 JHtml::fetch('script', VBO_SITE_URI.'resources/jquery-ui.min.js');
29
30 // js lang def
31 JText::script('VBO_CONV_RES_OTA_CURRENCY_APPLY');
32 JText::script('VBDELCONFIRM');
33 JText::script('VBSENDCANCORDEMAIL');
34 JText::script('VBO_SET_STANDBY');
35 JText::script('VBO_CONF_RM_OVERBOOKING_FLAG');
36
37 $dbo = JFactory::getDbo();
38
39 $vbo_app = VikBooking::getVboApplication();
40 $vbo_app->loadVisualEditorAssets();
41
42 /**
43 * This View can render within a modal the "bookingcheckin" View, and with WP
44 * this is loaded via AJAX. In order to not interfere or reset the contextual menu,
45 * we load the assets from the parent View. Context menu may also be used in this View.
46 *
47 * @since 1.16.0 (J) - 1.6.0 (WP)
48 */
49 $vbo_app->loadContextMenuAssets();
50 if (VBOPlatformDetection::isWordPress()) {
51 JText::script('VBRENTALORD');
52 JText::script('VBPVIEWORDERSPEOPLE');
53 }
54
55 $canDo = JFactory::getUser();
56 $vbo_auth_bookings = $canDo->authorise('core.vbo.bookings', 'com_vikbooking');
57
58 $currencyname = VikBooking::getCurrencyName();
59 $after_tax = VikBooking::ivaInclusa();
60 $nowdf = VikBooking::getDateFormat(true);
61 if ($nowdf == "%d/%m/%Y") {
62 $df = 'd/m/Y';
63 } elseif ($nowdf == "%m/%d/%Y") {
64 $df = 'm/d/Y';
65 } else {
66 $df = 'Y/m/d';
67 }
68 $datesep = VikBooking::getDateSeparator(true);
69 $vbo_modals_html = array();
70 $payment = VikBooking::getPayment($row['idpayment']);
71 $pactive_tab = VikRequest::getString('vbo_active_tab', 'vbo-tab-details', 'request');
72 $printreceipt = VikRequest::getInt('print', 0, 'request');
73 $printreceipt = ($printreceipt > 0);
74 if ($printreceipt) {
75 //we set a different page title when printing the receipt for the "PDF Printer" to give the file a good name.
76 JFactory::getDocument()->setTitle(VikBooking::getFrontTitle()." - ".JText::translate('VBOFISCRECEIPT')." #".$row['id']);
77 }
78 $gotouri = 'index.php?option=com_vikbooking&task=editorder&cid[]='.$row['id'];
79
80 if ($row['status'] == "confirmed") {
81 $use_js_bid = $row['id'];
82 JFactory::getDocument()->addScriptDeclaration(
83 <<<JS
84 window["vbo_current_bid"] = $use_js_bid;
85 JS
86 );
87 }
88
89 $tars = array();
90 $arrpeople = array();
91 $is_package = !empty($row['pkg']) ? true : false;
92 $is_cust_cost = false;
93 foreach ($rooms as $ind => $or) {
94 $num = $ind + 1;
95 $arrpeople[$num]['adults'] = $or['adults'];
96 $arrpeople[$num]['children'] = $or['children'];
97 $arrpeople[$num]['children_age'] = $or['childrenage'];
98 $arrpeople[$num]['t_first_name'] = $or['t_first_name'];
99 $arrpeople[$num]['t_last_name'] = $or['t_last_name'];
100 $arrpeople[$num]['pets'] = $or['pets'];
101 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
102 //package or custom cost set from the back-end
103 $is_cust_cost = true;
104 continue;
105 }
106 $q = "SELECT * FROM `#__vikbooking_dispcost` WHERE `id`=".(int)$or['idtar'].";";
107 $dbo->setQuery($q);
108 $tar = $dbo->loadAssocList();
109 $tar = VikBooking::applySeasonsRoom($tar, $row['checkin'], $row['checkout']);
110
111 // apply OBP rules
112 $tar = VBORoomHelper::getInstance()->applyOBPRules($tar, $or, $or['adults']);
113
114 $tars[$num] = $tar;
115 }
116 $pcheckin = $row['checkin'];
117 $pcheckout = $row['checkout'];
118 $secdiff = $pcheckout - $pcheckin;
119 $daysdiff = $secdiff / 86400;
120 if (is_int($daysdiff)) {
121 if ($daysdiff < 1) {
122 $daysdiff = 1;
123 }
124 } else {
125 if ($daysdiff < 1) {
126 $daysdiff = 1;
127 } else {
128 $sum = floor($daysdiff) * 86400;
129 $newdiff = $secdiff - $sum;
130 $maxhmore = VikBooking::getHoursMoreRb() * 3600;
131 if ($maxhmore >= $newdiff) {
132 $daysdiff = floor($daysdiff);
133 } else {
134 $daysdiff = ceil($daysdiff);
135 }
136 }
137 }
138 $otachannel = '';
139 $otachannel_name = '';
140 $otachannel_bid = '';
141 $otacurrency = '';
142 if (!empty($row['channel'])) {
143 $channelparts = explode('_', $row['channel']);
144 $otachannel = array_key_exists(1, $channelparts) && strlen($channelparts[1]) > 0 ? $channelparts[1] : ucwords($channelparts[0]);
145 $otachannel_name = $otachannel;
146 $otachannel_bid = $otachannel.(!empty($row['idorderota']) ? ' - Booking ID: '.$row['idorderota'] : '');
147 if (strstr($otachannel, '.') !== false) {
148 $otaccparts = explode('.', $otachannel);
149 $otachannel = $otaccparts[0];
150 }
151 $otacurrency = strlen($row['chcurrency']) > 0 ? $row['chcurrency'] : '';
152 }
153
154 $status_type = '';
155 if (!empty($row['type'])) {
156 $status_type = JText::translate('VBO_BTYPE_' . strtoupper($row['type']));
157 if (!strcasecmp($row['type'], 'overbooking')) {
158 $status_type = '<span class="label label-error vbo-label-nested vbo-label-overbooking">' . $status_type . '</span>';
159 }
160 $status_type .= ' / ';
161 }
162 $extra_status = $row['refund'] > 0 ? ' / ' . JText::translate('VBO_STATUS_REFUNDED') : '';
163 if ($row['status'] == "confirmed") {
164 $saystaus = '<span class="label label-success">' . $status_type . JText::translate('VBCONFIRMED') . $extra_status . '</span>';
165 } elseif ($row['status'] == "standby") {
166 $saystaus = '<span class="label label-warning">' . $status_type . JText::translate('VBSTANDBY') . $extra_status . '</span>';
167 } else {
168 $saystaus = '<span class="label label-error">' . $status_type . JText::translate('VBCANCELLED') . $extra_status . '</span>';
169 }
170
171 // extend booking details main panel
172 $bookingPanelForms = $this->onDisplayView();
173
174 // extend booking details sidebar
175 $bookingSidebarForms = $this->onDisplayView('Sidebar');
176
177 // extend administration main panel
178 $adminFormsSetup = new stdClass;
179 $adminFormsSetup->icons = [];
180 $adminPanelForms = $this->onDisplayView('Administration', $adminFormsSetup);
181
182 // extend administration sidebar
183 $adminSidebarForms = $this->onDisplayView('AdministrationSidebar');
184
185 //Prepare modal (used for the Registration and for reconstructing the credit card details through the channel manager)
186 echo $vbo_app->getJmodalScript();
187 //end Prepare modal
188 ?>
189 <script type="text/javascript">
190 function changePayment() {
191 var newpayment = document.getElementById('newpayment').value;
192 if (newpayment != '') {
193 var paymentname = document.getElementById('newpayment').options[document.getElementById('newpayment').selectedIndex].text;
194 if (confirm('<?php echo addslashes(JText::translate('VBCHANGEPAYCONFIRM')); ?>' + paymentname + '?')) {
195 document.adminForm.submit();
196 } else {
197 document.getElementById('newpayment').selectedIndex = 0;
198 }
199 }
200 }
201 function vbToggleLog(elem) {
202 vbToggleDynamicPanel(elem, '#vbpaymentlogdiv');
203 }
204 function vbToggleNotes(elem) {
205 vbToggleDynamicPanel(elem, '#vbadminnotesdiv');
206 }
207 function vbToggleHistory(elem) {
208 vbToggleDynamicPanel(elem, '#vbhistorydiv');
209 }
210 function vbToggleInvNotes(elem) {
211 vbToggleDynamicPanel(elem, '#vbinvnotesdiv');
212 }
213 function vbToggleMessaging(elem) {
214 vbToggleDynamicPanel(elem, '#vbmessagingdiv');
215 if (typeof VCMChat !== 'undefined') {
216 VCMChat.getInstance().scrollToBottom();
217 }
218 }
219 function vbToggleDynamicPanel(elem, target) {
220 if (jQuery(target).is(':visible')) {
221 return;
222 }
223
224 jQuery(".vbo-bookingdet-noteslogs-btn-active").removeClass("vbo-bookingdet-noteslogs-btn-active");
225
226 jQuery('.vbo-extra-panel').hide();
227 jQuery(target).show();
228
229 jQuery(elem).parent(".vbo-bookingdet-noteslogs-btn").addClass("vbo-bookingdet-noteslogs-btn-active");
230
231 if (typeof sessionStorage !== 'undefined') {
232 sessionStorage.setItem('vboEditOrderTab<?php echo $row['id']; ?>', jQuery(elem).parent().data('id'));
233 }
234 }
235 function toggleDiscount(elem) {
236 var discsp = document.getElementById('vbdiscenter').style.display;
237 if (discsp == 'block') {
238 document.getElementById('vbdiscenter').style.display = 'none';
239 jQuery(elem).find('i').attr('class', '<?php echo VikBookingIcons::i('chevron-down'); ?>');
240 } else {
241 document.getElementById('vbdiscenter').style.display = 'block';
242 jQuery(elem).find('i').attr('class', '<?php echo VikBookingIcons::i('chevron-up'); ?>');
243 }
244 }
245 </script>
246
247 <div class="vbo-bookingdet-topcontainer">
248 <form name="adminForm" id="adminForm" action="<?php echo VBOPlatformDetection::isWordPress() ? 'admin.php' : 'index.php'; ?>?option=com_vikbooking&amp;task=editorder&amp;cid[]=<?php echo $row['id']; ?>" method="post">
249 <?php
250 if ($printreceipt) {
251 //print the company details
252 $companylogo = VikBooking::getSiteLogo();
253 $next_receipt = VikBooking::getNextReceiptNumber($row['id']);
254 ?>
255 <div class="vbo-receipt-company-block-outer">
256 <div class="vbo-receipt-company-block">
257 <?php
258 if (!empty($companylogo)) {
259 ?>
260 <div class="vbo-receipt-company-logo"><img src="<?php echo VBO_ADMIN_URI.'resources/'.$companylogo; ?>" /></div>
261 <?php
262 }
263 ?>
264 <div class="vbo-receipt-company-info"><?php echo VikBooking::getInvoiceCompanyInfo(); ?></div>
265 </div>
266 <div class="vbo-receipt-numdate-block">
267 <div class="vbo-receipt-numdate-inner">
268 <div class="vbo-receipt-numdate-title">
269 <span><?php echo JText::translate('VBOFISCRECEIPT'); ?></span>
270 <span style="float: right; cursor: pointer; color: #ff0000;" onclick="vboMakePrintOnly();"><?php VikBookingIcons::e('times-circle'); ?></span>
271 </div>
272 <div class="vbo-receipt-numdate-num">
273 <span class="vbo-receipt-numdate-num-lbl"><?php echo JText::translate('VBOFISCRECEIPTNUM'); ?></span>
274 <span class="vbo-receipt-numdate-num-val">
275 <span class="vbo-showin-print" id="vbo-receipt-num"><?php echo $next_receipt; ?></span>
276 <input class="vbo-hidein-print" id="vbo-receipt-num-inp" type="number" min="0" value="<?php echo $next_receipt; ?>" onchange="document.getElementById('vbo-receipt-num').innerText = this.value;" />
277 </span>
278 </div>
279 <div class="vbo-receipt-numdate-date">
280 <span class="vbo-receipt-numdate-date-lbl"><?php echo JText::translate('VBOFISCRECEIPTDATE'); ?></span>
281 <span class="vbo-receipt-numdate-date-val"><?php echo date(str_replace("/", $datesep, $df)); ?></span>
282 </div>
283 </div>
284 </div>
285 <div class="vbo-receipt-print-confirm vbo-hidein-print">
286 <div class="vbo-receipt-print-btn">
287 <span onclick="vboLaunchPrintReceipt();">
288 <?php VikBookingIcons::e('print'); ?>
289 <span id="vbo-receipt-print-btn-name"><?php echo JText::translate('VBOPRINTRECEIPT'); ?></span>
290 </span>
291 </div>
292 </div>
293 </div>
294 <?php
295 }
296 ?>
297
298 <div class="vbo-bookdet-container">
299 <div class="vbo-bookdet-wrap">
300 <div class="vbo-bookdet-head">
301 <span>ID</span>
302 </div>
303 <div class="vbo-bookdet-foot">
304 <span><?php echo $row['id']; ?></span>
305 </div>
306 </div>
307 <div class="vbo-bookdet-wrap">
308 <div class="vbo-bookdet-head">
309 <span><?php echo JText::translate('VBEDITORDERONE'); ?></span>
310 </div>
311 <div class="vbo-bookdet-foot">
312 <span><?php echo date(str_replace("/", $datesep, $df).' H:i', $row['ts']); ?></span>
313 </div>
314 </div>
315 <?php
316 if (!$printreceipt && count($customer)) {
317 ?>
318 <div class="vbo-bookdet-wrap">
319 <div class="vbo-bookdet-head">
320 <span><?php echo JText::translate('VBCUSTOMERNOMINATIVE'); ?></span>
321 </div>
322 <div class="vbo-bookdet-foot">
323 <div class="vbo-customer-info-box">
324 <div class="vbo-customer-info-box-name">
325 <?php echo (isset($customer['country_img']) ? $customer['country_img'] . ' ' : ''); ?>
326
327 <?php if ($canDo->authorise('core.edit', 'com_vikbooking') && $canDo->authorise('core.vbo.management', 'com_vikbooking')): ?>
328 <a href="index.php?option=com_vikbooking&task=editcustomer&cid[]=<?php echo $customer['id']; ?>&goto=<?php echo base64_encode($gotouri); ?>"><?php echo ltrim($customer['first_name'] . ' ' . $customer['last_name']); ?></a>
329 <?php else: ?>
330 <?php echo ltrim($customer['first_name'] . ' ' . $customer['last_name']); ?>
331 <?php endif; ?>
332 </div>
333 <?php
334 if (!empty($customer['pic'])) {
335 $avatar_caption = ltrim($customer['first_name'] . ' ' . $customer['last_name']);
336 ?>
337 <div class="vbo-customer-info-box-avatar vbo-customer-avatar-small">
338 <span>
339 <img src="<?php echo strpos($customer['pic'], 'http') === 0 ? $customer['pic'] : VBO_SITE_URI . 'resources/uploads/' . $customer['pic']; ?>" data-caption="<?php echo htmlspecialchars($avatar_caption); ?>" />
340 </span>
341 </div>
342 <?php
343 }
344 ?>
345 </div>
346 </div>
347 </div>
348 <?php
349 }
350 if (!$printreceipt) {
351 ?>
352 <div class="vbo-bookdet-wrap">
353 <div class="vbo-bookdet-head">
354 <span><?php echo JText::translate('VBEDITORDERROOMSNUM'); ?></span>
355 </div>
356 <div class="vbo-bookdet-foot">
357 <?php echo $row['roomsnum']; ?>
358 </div>
359 </div>
360 <?php
361 }
362 ?>
363 <div class="vbo-bookdet-wrap">
364 <div class="vbo-bookdet-head">
365 <span><?php echo JText::translate('VBEDITORDERFOUR'); ?></span>
366 </div>
367 <div class="vbo-bookdet-foot">
368 <span><?php echo $row['days']; ?></span>
369 <?php
370 if ($row['split_stay']) {
371 ?>
372 <span class="hasTooltip" title="<?php echo JHtml::fetch('esc_attr', JText::translate('VBO_SPLIT_STAY')); ?>"><?php VikBookingIcons::e('random'); ?></span>
373 <?php
374 }
375 ?>
376 </div>
377 </div>
378 <div class="vbo-bookdet-wrap">
379 <div class="vbo-bookdet-head">
380 <span><?php echo JText::translate('VBEDITORDERFIVE'); ?></span>
381 </div>
382 <div class="vbo-bookdet-foot">
383 <?php
384 $checkin_info = getdate($row['checkin']);
385 $short_wday = JText::translate('VB'.strtoupper(substr($checkin_info['weekday'], 0, 3)));
386 ?>
387 <?php echo $short_wday.', '.date(str_replace("/", $datesep, $df).' H:i', $row['checkin']); ?>
388 </div>
389 </div>
390 <div class="vbo-bookdet-wrap">
391 <div class="vbo-bookdet-head">
392 <span><?php echo JText::translate('VBEDITORDERSIX'); ?></span>
393 </div>
394 <div class="vbo-bookdet-foot">
395 <?php
396 $checkout_info = getdate($row['checkout']);
397 $short_wday = JText::translate('VB'.strtoupper(substr($checkout_info['weekday'], 0, 3)));
398 ?>
399 <?php echo $short_wday.', '.date(str_replace("/", $datesep, $df).' H:i', $row['checkout']); ?>
400 </div>
401 </div>
402 <?php
403 if (!$printreceipt && $vbo_auth_bookings && $row['closure'] != 1 && $row['status'] == 'confirmed') {
404 // we don't need to check in the IF above "&& $row['checked'] != 0" because the registration is useful for all bookings.
405 $checked_btn = 'btn-primary';
406 switch ($row['checked']) {
407 case -1:
408 $checked_status = JText::translate('VBOCHECKEDSTATUSNOS');
409 $checked_btn = 'btn-danger';
410 break;
411 case 1:
412 $checked_status = JText::translate('VBOCHECKEDSTATUSIN');
413 $checked_btn = 'btn-success';
414 break;
415 case 2:
416 $checked_status = JText::translate('VBOCHECKEDSTATUSOUT');
417 $checked_btn = 'btn-warning';
418 break;
419 default:
420 $checked_status = JText::translate('VBOCHECKEDSTATUSZERO');
421 if (count($customer) && isset($customer['pax_data']) && !empty($customer['pax_data'])) {
422 // pre check-in performed via front-end
423 $checked_status = JText::translate('VBOCHECKEDSTATUSPRECHECKIN');
424 }
425 break;
426 }
427 ?>
428 <div class="vbo-bookdet-wrap pro-feature">
429 <div class="vbo-bookdet-head">
430 <span><?php echo JText::translate('VBOCHECKEDSTATUS'); ?></span>
431 </div>
432 <div class="vbo-bookdet-foot">
433 <button type="button" class="btn btn-small <?php echo $checked_btn; ?>" onclick="vboOpenJModal('vbo-checkin-booking', 'index.php?option=com_vikbooking&task=bookingcheckin&cid[]=<?php echo $row['id']; ?>&tmpl=component');">
434 <?php echo $checked_status; ?>
435 </button>
436 </div>
437 </div>
438 <?php
439 //Prepare modal (Registration)
440 array_push($vbo_modals_html, $vbo_app->getJmodalHtml('vbo-checkin-booking', JText::translate('VBOMANAGECHECKSINOUT')));
441 //end Prepare modal
442 }
443
444 /**
445 * Check whether the booking can be refunded.
446 *
447 * @since 1.14 (J) - 1.4.0 (WP)
448 */
449
450 // refundable up to 3 days after check-out day
451 $max_refund_ts = mktime(23, 59, 59, $checkout_info['mon'], ($checkout_info['mday'] + 3), $checkout_info['year']);
452 // current payment driver must be set
453 $tn_driver = is_array($payment) ? $payment['file'] : null;
454 // transaction data validation callback
455 $tn_data_callback = function($data) use ($tn_driver) {
456 return (is_object($data) && isset($data->driver) && basename($data->driver, '.php') == basename($tn_driver, '.php'));
457 };
458 $prev_tn_data = $history_obj->getEventsWithData(array('P0', 'PN'), $tn_data_callback);
459 $refundable = ($row['status'] != 'standby' && $max_refund_ts >= time() && is_array($prev_tn_data) && count($prev_tn_data));
460 if ($refundable) {
461 // prepare modal (refundtn) with a custom function to trigger the opening
462 array_push($vbo_modals_html, $vbo_app->getJmodalHtml('vbo-refund-tn', JText::translate('VBO_ISSUE_REFUND')));
463 echo $vbo_app->getJmodalScript('Refund', 'vboDetectRefundChanges();');
464 // count the number of refunds made
465 $refunds = $history_obj->getEventsWithData('RF', null, false);
466 $refunds = !is_array($refunds) ? array() : $refunds;
467 ?>
468 <script type="text/javascript">
469 var vbo_refund_performed = false;
470 function vboDetectRefundChanges() {
471 if (vbo_refund_performed === true) {
472 location.reload();
473 }
474 }
475 </script>
476
477 <div class="vbo-bookdet-wrap">
478 <div class="vbo-bookdet-head">
479 <span><?php echo JText::translate('VBO_ISSUE_REFUND'); ?></span>
480 </div>
481 <div class="vbo-bookdet-foot">
482 <button type="button" class="btn btn-small btn-danger vbo-dorefund-btn"<?php echo count($refunds) ? ' data-totrefunds="' . count($refunds) . '"' : ''; ?> onclick="vboOpenJModalRefund('vbo-refund-tn', 'index.php?option=com_vikbooking&task=refundtn&cid[]=<?php echo $row['id']; ?>&tmpl=component');">
483 <?php echo JText::translate('VBO_REFUND'); ?>
484 </button>
485 </div>
486 </div>
487 <?php
488 }
489 //
490
491 if (!$printreceipt && !empty($row['channel'])) {
492 $ota_logo_img = VikBooking::getVcmChannelsLogo($row['channel']);
493 if ($ota_logo_img === false) {
494 $ota_logo_img = $otachannel_name;
495 } else {
496 $ota_logo_img = '<img src="'.$ota_logo_img.'" class="vbo-channelimg-medium"/>';
497 }
498 ?>
499 <div class="vbo-bookdet-wrap">
500 <div class="vbo-bookdet-head">
501 <span><?php echo JText::translate('VBPVIEWORDERCHANNEL'); ?></span>
502 </div>
503 <div class="vbo-bookdet-foot">
504 <span><?php echo $ota_logo_img; ?></span>
505 </div>
506 </div>
507 <?php
508 } elseif (!$printreceipt && class_exists('VCMOtaBooking')) {
509 /**
510 * Vik Channel Manager booking assignable channels.
511 *
512 * @since 1.16.3 (J) - 1.6.3 (WP)
513 */
514 $assignable_channels = VCMOtaBooking::getInstance($row, true)->getChannelsAssignable();
515 if ($assignable_channels) {
516 JText::script('VBO_ASSIGN_BOOKING_TO_OTA_CONFIRM');
517 JFactory::getDocument()->addScriptDeclaration(
518 <<<JS
519 function vboConfirmAssignChannel(ch_key, ch_name) {
520 if (!ch_key || !ch_name) {
521 return true;
522 }
523 if (confirm(Joomla.JText._('VBO_ASSIGN_BOOKING_TO_OTA_CONFIRM').replace('%s', ch_name))) {
524 document.adminForm.submit();
525 return true;
526 } else {
527 return false;
528 }
529 }
530 JS
531 );
532 ?>
533 <div class="vbo-bookdet-wrap">
534 <div class="vbo-bookdet-head">
535 <span><?php echo JText::translate('VBPVIEWORDERCHANNEL'); ?></span>
536 </div>
537 <div class="vbo-bookdet-foot">
538 <select name="vcm_assign_channel" class="vbo-select-small" onchange="return vboConfirmAssignChannel(this.value, this.options[this.selectedIndex].text);">
539 <option value=""><?php echo JText::translate('VBORDFROMSITE'); ?></option>
540 <?php
541 foreach ($assignable_channels as $assign_ch_key => $assign_ch_name) {
542 ?>
543 <option value="<?php echo JHtml::fetch('esc_attr', $assign_ch_key); ?>"><?php echo $assign_ch_name; ?></option>
544 <?php
545 }
546 ?>
547 </select>
548 </div>
549 </div>
550 <?php
551 }
552 }
553 if (!$printreceipt) {
554 ?>
555 <div class="vbo-bookdet-wrap">
556 <div class="vbo-bookdet-head">
557 <span><?php echo JText::translate('VBSTATUS'); ?></span>
558 </div>
559 <div class="vbo-bookdet-foot">
560 <span><?php echo $saystaus; ?></span>
561 </div>
562 </div>
563 <?php
564 if (is_array($this->vcm_pre_approval)) {
565 ?>
566 <div class="vbo-bookdet-wrap">
567 <div class="vbo-bookdet-head">
568 <span><?php echo $this->vcm_pre_approval[1]; ?></span>
569 </div>
570 <div class="vbo-bookdet-foot">
571 <span>
572 <?php
573 if (empty($this->vcm_pre_approval[2]) || !empty($this->vcm_pre_approval[3])) {
574 // no pre-approvals before, or withdrawn before
575 ?>
576 <a href="index.php?option=com_vikchannelmanager&task=sendSpecialOffer&vbo_oid=<?php echo $row['id']; ?>&spo_type=preapproval&spo_action=send&ota_thread_id=<?php echo $this->vcm_pre_approval[0]; ?>" class="btn btn-small btn-primary vcm-btn-channel-<?php echo strtolower($this->vcm_pre_approval[1]); ?>"><?php VikBookingIcons::e('thumbs-up'); ?> <?php echo JText::translate('VBO_PREAPPROVE_INQUIRY'); ?></a>
577 <?php
578 } else {
579 // pre-approved before, pass the ID
580 ?>
581 <a href="index.php?option=com_vikchannelmanager&task=sendSpecialOffer&vbo_oid=<?php echo $row['id']; ?>&spo_type=preapproval&spo_action=withdraw&ota_thread_id=<?php echo $this->vcm_pre_approval[0]; ?>&spo_id=<?php echo $this->vcm_pre_approval[2]; ?>" class="btn btn-small btn-danger"><?php VikBookingIcons::e('thumbs-down'); ?> <?php echo JText::translate('VBO_WITHDRAW_PREAPPROVAL'); ?></a>
582 <?php
583 }
584 ?>
585 </span>
586 </div>
587 </div>
588 <?php
589 }
590 if (!empty($row['channel']) && stripos($row['channel'], 'booking.com') !== false && $row['checkin'] <= time() && strtotime('+ 7 days', $row['checkout']) >= time()) {
591 /**
592 * Guest misconduct reporting API for Booking.com.
593 * Only after reservation check-in date and no later than 7 days after check-out date.
594 *
595 * @since 1.13.5 - VCM 1.7.2
596 */
597 $misconduct_reported = $history_obj->hasEvent('GM');
598 ?>
599 <div class="vbo-bookdet-wrap">
600 <div class="vbo-bookdet-head">
601 <span><?php echo JText::translate('VBOGUESTMISCONDUCT'); ?></span>
602 </div>
603 <div class="vbo-bookdet-foot">
604 <?php
605 if ($misconduct_reported === false) {
606 // allow to report the guest misconduct
607 ?>
608 <button type="button" class="btn btn-small btn-danger" onclick="vboRenderGuestMisconduct();"><?php VikBookingIcons::e('user-slash'); ?> <?php echo JText::translate('VBOREPORTMISCONDUCT'); ?></button>
609 <?php
610 } else {
611 // guest misconduct already reported
612 ?>
613 <button type="button" class="btn btn-small btn-warning" onclick="vboShowGuestMisconductReported();"><?php VikBookingIcons::e('user-slash'); ?> <?php echo $misconduct_reported; ?></button>
614 <?php
615 }
616 ?>
617 <a id="vbo-gm-reloadlink" style="display: none;" href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $row['id']; ?>"></a>
618 </div>
619 </div>
620
621 <div class="vbo-modal-overlay-block vbo-modal-overlay-block-guestmisconduct">
622 <a class="vbo-modal-overlay-close" href="javascript: void(0);"></a>
623 <div class="vbo-modal-overlay-content vbo-modal-overlay-content-guestmisconduct">
624 <div class="vbo-modal-overlay-content-head vbo-modal-overlay-content-head-guestmisconduct">
625 <h3><?php VikBookingIcons::e('exclamation-circle'); ?> <?php echo JText::sprintf('VBOREPGUESTMISCONDUCTTO', 'Booking.com'); ?> <span class="vbo-modal-overlay-close-times" onclick="hideVboDialogGuestMisconduct();">&times;</span></h3>
626 </div>
627 <div class="vbo-modal-overlay-content-body">
628 <div class="vbo-modal-guestmisconduct-addnew" data-bid="<?php echo $row['id']; ?>" data-otabid="<?php echo $row['idorderota']; ?>">
629 <div class="vbo-modal-guestmisconduct-report-elems"></div>
630 <div class="vbo-modal-guestmisconduct-addnew-save">
631 <button type="button" id="vbo-guest-misconduct-submit-btn" class="btn btn-success" onclick="vboSubmitGuestMisconduct();" style="display: none;"><?php echo JText::translate('VBCHANNELMANAGERSENDRQ'); ?></button>
632 <button type="button" class="btn btn-danger" onclick="hideVboDialogGuestMisconduct();"><?php echo JText::translate('VBOCLOSE'); ?></button>
633 </div>
634 </div>
635 </div>
636 </div>
637 </div>
638
639 <script type="text/javascript">
640 var vbodialogguestmisconduct_on = false;
641 var vbo_guest_misconduct_fields = new Array;
642
643 function vboShowGuestMisconductReported() {
644 // this is like simulating the navigation to the booking history tab
645 jQuery(".vbo-bookingdet-tab[data-vbotab='vbo-tab-admin']").trigger('click');
646 vbToggleHistory(document.getElementById('vbo-trig-bookhistory'));
647 }
648
649 function vboRenderGuestMisconduct() {
650 // empty content
651 jQuery('.vbo-modal-guestmisconduct-report-elems').html('<?php echo $this->escape(JText::translate('VIKLOADING') . '...'); ?>');
652 vbo_guest_misconduct_fields = new Array;
653 // display modal
654 jQuery('.vbo-modal-overlay-block-guestmisconduct').fadeIn();
655 vbodialogguestmisconduct_on = true;
656 // make AJAX request to VCM to always reload the form fields
657 var jqxhr = jQuery.ajax({
658 type: "POST",
659 url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=get_bcom_misconduct_categories'); ?>",
660 data: { tmpl: "component" }
661 }).done(function(res) {
662 // parse the JSON response that contains the categories object with all fields for the reporting
663 try {
664 var misconduct_fields_rs = JSON.parse(res);
665 console.log(misconduct_fields_rs);
666
667 // make sure the request was successful
668 if (!misconduct_fields_rs.status) {
669 alert(misconduct_fields_rs.error);
670 hideVboDialogGuestMisconduct();
671 return false;
672 }
673
674 // render form from response obtained
675 var misconduct_html = '';
676 var misconduct_fields = misconduct_fields_rs.data;
677 if (!misconduct_fields.hasOwnProperty('categories') || !misconduct_fields.hasOwnProperty('fields')) {
678 alert('Unexptected response. Vik Channel Manager needs to be installed, configured and updated to the latest version.');
679 hideVboDialogGuestMisconduct();
680 return false;
681 }
682
683 // main category of misconduct
684 misconduct_html += '<div class="vbo-modal-form-addnew-elem vbo-modal-guestmisconduct-addnew-elem">' + "\n";
685 misconduct_html += '<label for="vbo-gm-category">' + misconduct_fields['labels']['category'] + '</label>';
686 misconduct_html += '<select id="vbo-gm-category" data-gmname="category_id" onchange="vboGuestMisconductChangeCategory(this.value);">' + "\n";
687 for (var category in misconduct_fields['categories']) {
688 if (!misconduct_fields['categories'].hasOwnProperty(category)) {
689 continue;
690 }
691 misconduct_html += '<option value="' + misconduct_fields['categories'][category]['id'] + '">' + misconduct_fields['categories'][category]['title'] + '</option>' + "\n";
692 }
693 misconduct_html += '</select>' + "\n";
694 misconduct_html += '</div>' + "\n";
695 // push category field in fields list for later submit
696 vbo_guest_misconduct_fields.push('vbo-gm-category');
697
698 // sub-categories or additional fields of misconduct categories
699 for (var category in misconduct_fields['categories']) {
700 if (!misconduct_fields['categories'].hasOwnProperty(category)) {
701 continue;
702 }
703 if (!misconduct_fields['categories'][category].hasOwnProperty('subcategories') && !misconduct_fields['categories'][category].hasOwnProperty('additional_fields')) {
704 // at least one of these two properties must be set
705 continue;
706 }
707 if (misconduct_fields['categories'][category].hasOwnProperty('subcategories') && misconduct_fields['categories'][category]['subcategories'].length) {
708 // sub-categories in drop down
709 var subcat_field_id = 'vbo-gm-subcategory' + misconduct_fields['categories'][category]['id'];
710 misconduct_html += '<div class="vbo-modal-form-addnew-elem vbo-modal-guestmisconduct-addnew-elem vbo-modal-guestmisconduct-addnew-cond" data-gmcid="' + misconduct_fields['categories'][category]['id'] + '" style="display: none;">' + "\n";
711 misconduct_html += '<label for="' + subcat_field_id + '">' + misconduct_fields['labels']['subcategory'] + '</label>';
712 misconduct_html += '<select id="' + subcat_field_id + '" data-gmname="subcategory_id">' + "\n";
713 for (var subcategory in misconduct_fields['categories'][category]['subcategories']) {
714 if (!misconduct_fields['categories'][category]['subcategories'].hasOwnProperty(subcategory)) {
715 continue;
716 }
717 misconduct_html += '<option value="' + misconduct_fields['categories'][category]['subcategories'][subcategory]['id'] + '">' + misconduct_fields['categories'][category]['subcategories'][subcategory]['title'] + '</option>' + "\n";
718 }
719 misconduct_html += '</select>' + "\n";
720 misconduct_html += '</div>' + "\n";
721 // push sub-category field in fields list for later submit
722 if (vbo_guest_misconduct_fields.indexOf(subcat_field_id) < 0) {
723 vbo_guest_misconduct_fields.push(subcat_field_id);
724 }
725 } else if (misconduct_fields['categories'][category].hasOwnProperty('additional_fields') && misconduct_fields['categories'][category]['additional_fields'].length) {
726 // additional fields
727 for (var extra_field in misconduct_fields['categories'][category]['additional_fields']) {
728 if (!misconduct_fields['categories'][category]['additional_fields'].hasOwnProperty(extra_field)) {
729 continue;
730 }
731 var field_id = 'vbo-gm-extrafield-' + misconduct_fields['categories'][category]['additional_fields'][extra_field]['name'];
732 var field_name = misconduct_fields['categories'][category]['additional_fields'][extra_field]['name'];
733 misconduct_html += '<div class="vbo-modal-form-addnew-elem vbo-modal-guestmisconduct-addnew-elem vbo-modal-guestmisconduct-addnew-cond" data-gmcid="' + misconduct_fields['categories'][category]['id'] + '" style="display: none;">' + "\n";
734 misconduct_html += '<label for="' + field_id + '">' + misconduct_fields['categories'][category]['additional_fields'][extra_field]['label'] + '</label>';
735 if (misconduct_fields['categories'][category]['additional_fields'][extra_field]['type'] == 'number') {
736 misconduct_html += '<input data-gmname="' + field_name + '" type="number" id="' + field_id + '" value="" step="any" min="0" />';
737 } else if (misconduct_fields['categories'][category]['additional_fields'][extra_field]['type'] == 'text') {
738 misconduct_html += '<input data-gmname="' + field_name + '" type="text" id="' + field_id + '" value="" />';
739 } else if (misconduct_fields['categories'][category]['additional_fields'][extra_field]['type'] == 'text') {
740 misconduct_html += '<input data-gmname="' + field_name + '" type="text" id="' + field_id + '" value="" />';
741 } else if (misconduct_fields['categories'][category]['additional_fields'][extra_field]['type'] == 'textarea') {
742 misconduct_html += '<textarea data-gmname="' + field_name + '" id="' + field_id + '" rows="5" cols="50" maxlength="240"></textarea>';
743 } else if (misconduct_fields['categories'][category]['additional_fields'][extra_field]['type'] == 'select') {
744 misconduct_html += '<select data-gmname="' + field_name + '" id="' + field_id + '">';
745 for (var choicekey in misconduct_fields['categories'][category]['additional_fields'][extra_field]['choices']) {
746 // this is either an array when keys are numeric from 0, or an object when keys start from like 1, but with choicekey we take the proper key in the object
747 if (!misconduct_fields['categories'][category]['additional_fields'][extra_field]['choices'].hasOwnProperty(choicekey)) {
748 continue;
749 }
750 misconduct_html += '<option value="' + choicekey + '">' + misconduct_fields['categories'][category]['additional_fields'][extra_field]['choices'][choicekey] + '</option>';
751 }
752 misconduct_html += '</select>';
753 }
754 misconduct_html += '</div>' + "\n";
755 // push additional field in fields list for later submit
756 vbo_guest_misconduct_fields.push(field_id);
757 }
758 }
759 }
760
761 // mandatory fields for all categories of guest misconduct reporting
762 for (var mandfield in misconduct_fields['fields']) {
763 if (!misconduct_fields['fields'].hasOwnProperty(mandfield)) {
764 continue;
765 }
766 var field_id = 'vbo-gm-mandfield-' + misconduct_fields['fields'][mandfield]['name'];
767 var field_name = misconduct_fields['fields'][mandfield]['name'];
768 misconduct_html += '<div class="vbo-modal-form-addnew-elem vbo-modal-guestmisconduct-addnew-elem">' + "\n";
769 misconduct_html += '<label for="' + field_id + '">' + misconduct_fields['fields'][mandfield]['label'] + '</label>';
770 if (misconduct_fields['fields'][mandfield]['type'] == 'number') {
771 misconduct_html += '<input data-gmname="' + field_name + '" type="number" id="' + field_id + '" value="" step="any" min="0" />';
772 } else if (misconduct_fields['fields'][mandfield]['type'] == 'text') {
773 misconduct_html += '<input data-gmname="' + field_name + '" type="text" id="' + field_id + '" value="" />';
774 } else if (misconduct_fields['fields'][mandfield]['type'] == 'text') {
775 misconduct_html += '<input data-gmname="' + field_name + '" type="text" id="' + field_id + '" value="" />';
776 } else if (misconduct_fields['fields'][mandfield]['type'] == 'textarea') {
777 misconduct_html += '<textarea data-gmname="' + field_name + '" id="' + field_id + '" rows="5" cols="50" maxlength="240"></textarea>';
778 } else if (misconduct_fields['fields'][mandfield]['type'] == 'select') {
779 misconduct_html += '<select data-gmname="' + field_name + '" id="' + field_id + '">';
780 for (var choicekey in misconduct_fields['fields'][mandfield]['choices']) {
781 if (!misconduct_fields['fields'][mandfield]['choices'].hasOwnProperty(choicekey)) {
782 continue;
783 }
784 misconduct_html += '<option value="' + choicekey + '">' + misconduct_fields['fields'][mandfield]['choices'][choicekey] + '</option>';
785 }
786 misconduct_html += '</select>';
787 }
788 misconduct_html += '</div>' + "\n";
789 // push mandatory field in fields list for later submit
790 vbo_guest_misconduct_fields.push(field_id);
791 }
792
793 // display HTML content and submit button
794 jQuery('.vbo-modal-guestmisconduct-report-elems').html(misconduct_html);
795 jQuery('#vbo-guest-misconduct-submit-btn').show();
796 // trigger change of main category drop down
797 jQuery('#vbo-gm-category').trigger('change');
798 } catch (e) {
799 console.log(res);
800 alert('Invalid response. Vik Channel Manager needs to be installed, configured and updated to the latest version.');
801 hideVboDialogGuestMisconduct();
802 return false;
803 }
804 }).fail(function() {
805 alert('Request failed. Vik Channel Manager needs to be installed, configured and updated to the latest version.');
806 hideVboDialogGuestMisconduct();
807 });
808 }
809
810 function vboSubmitGuestMisconduct() {
811 if (!vbo_guest_misconduct_fields.length) {
812 alert('Empty data to submit. Vik Channel Manager needs to be installed, configured and updated to the latest version.');
813 return false;
814 }
815
816 // prevent double submissions
817 vboGuestMisconductDisableSubmit();
818 //
819
820 var submit_fields = {
821 tmpl: "component",
822 bid: jQuery('.vbo-modal-guestmisconduct-addnew').attr('data-bid'),
823 otabid: jQuery('.vbo-modal-guestmisconduct-addnew').attr('data-otabid'),
824 bcom_keys: new Array
825 };
826 for (var elemid in vbo_guest_misconduct_fields) {
827 if (!vbo_guest_misconduct_fields.hasOwnProperty(elemid)) {
828 continue;
829 }
830 if (!jQuery('#' + vbo_guest_misconduct_fields[elemid]).length || !jQuery('#' + vbo_guest_misconduct_fields[elemid]).closest('.vbo-modal-guestmisconduct-addnew-elem').length) {
831 // form element not found, or parent container not found
832 continue;
833 }
834 if (jQuery('#' + vbo_guest_misconduct_fields[elemid]).closest('.vbo-modal-guestmisconduct-addnew-elem').is(':visible')) {
835 // we include this value in the AJAX request
836 var field_name = jQuery('#' + vbo_guest_misconduct_fields[elemid]).attr('data-gmname');
837 var submit_key = 'bcom_' + field_name;
838 submit_fields[submit_key] = jQuery('#' + vbo_guest_misconduct_fields[elemid]).val();
839 submit_fields['bcom_keys'].push(submit_key);
840 }
841 }
842
843 // make the AJAX request to VCM
844 var jqxhr = jQuery.ajax({
845 type: "POST",
846 url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=submit_bcom_guestmisconduct'); ?>",
847 data: submit_fields
848 }).done(function(res) {
849 try {
850 var misconduct_rs = JSON.parse(res);
851 console.log(submit_fields, misconduct_rs);
852
853 // make sure the request was successful
854 if (!misconduct_rs.status) {
855 alert(misconduct_rs.error);
856 vboGuestMisconductEnableSubmit();
857 return false;
858 }
859
860 // make another AJAX request (now on VBO) to update the booking history
861 var event_descr = jQuery('#vbo-gm-mandfield-details_text').length ? jQuery('#vbo-gm-mandfield-details_text').val() : '';
862 jQuery.ajax({
863 type: "POST",
864 url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=store_booking_history_event'); ?>",
865 data: {
866 tmpl: "component",
867 bid: jQuery('.vbo-modal-guestmisconduct-addnew').attr('data-bid'),
868 event: 'GM',
869 descr: event_descr
870 }
871 }).done(function(res) {
872 // just reload the page in case of success
873 document.location.href = jQuery('#vbo-gm-reloadlink').attr('href');
874 }).fail(function() {
875 // we reload the page even in case of failure
876 document.location.href = jQuery('#vbo-gm-reloadlink').attr('href');
877 });
878 } catch (e) {
879 console.log(res);
880 alert('Invalid update response. Vik Channel Manager needs to be installed, configured and updated to the latest version.');
881 vboGuestMisconductEnableSubmit();
882 hideVboDialogGuestMisconduct();
883 return false;
884 }
885 }).fail(function() {
886 alert('Update Request failed. Vik Channel Manager needs to be installed, configured and updated to the latest version.');
887 vboGuestMisconductEnableSubmit();
888 return false;
889 });
890 }
891
892 function hideVboDialogGuestMisconduct() {
893 if (vbodialogguestmisconduct_on === true) {
894 jQuery(".vbo-modal-overlay-block-guestmisconduct").fadeOut(400, function () {
895 jQuery(".vbo-modal-overlay-content-guestmisconduct").show();
896 });
897 // turn flag off
898 vbodialogguestmisconduct_on = false;
899 }
900 }
901
902 function vboGuestMisconductChangeCategory(gmcid) {
903 jQuery('.vbo-modal-guestmisconduct-addnew-cond').each(function() {
904 if (jQuery(this).attr('data-gmcid') == gmcid) {
905 jQuery(this).show();
906 } else {
907 jQuery(this).hide();
908 }
909 });
910 }
911
912 function vboGuestMisconductDisableSubmit() {
913 jQuery('#vbo-guest-misconduct-submit-btn').prepend('<i class="<?php echo VikBookingIcons::i('refresh', 'fa-spin fa-fw'); ?>"></i> ').prop('disabled', true);
914 }
915
916 function vboGuestMisconductEnableSubmit() {
917 jQuery('#vbo-guest-misconduct-submit-btn').prop('disabled', false).find('i').remove();
918 }
919 </script>
920 <?php
921 }
922 if ($this->vcm_host_to_guest_review) {
923 ?>
924 <div class="vbo-bookdet-wrap">
925 <div class="vbo-bookdet-head">
926 <span><?php echo JText::translate('VBO_REVIEW_YOUR_GUEST'); ?></span>
927 </div>
928 <div class="vbo-bookdet-foot">
929 <button type="button" class="btn btn-small btn-primary vcm-btn-channel-airbnbapi" onclick="vboOpenJModal('vbo-vcm-host-to-guest-review', 'index.php?option=com_vikchannelmanager&task=hostguestreview&cid[]=<?php echo $row['id']; ?>&tmpl=component');">
930 <?php VikBookingIcons::e('smile'); ?>
931 <?php echo JText::translate('VBO_WRITE_REVIEW'); ?>
932 </button>
933 </div>
934 </div>
935 <?php
936 // prepare modal (host-to-guest review)
937 array_push($vbo_modals_html, $vbo_app->getJmodalHtml('vbo-vcm-host-to-guest-review', JText::translate('VBO_REVIEW_YOUR_GUEST')));
938
939 // check if a notification was clicked
940 if (VikRequest::getString('notif_action', '', 'request') == 'airbnb_host_guest_review') {
941 JFactory::getDocument()->addScriptDeclaration(
942 <<<JS
943 jQuery(function() {
944 setTimeout(() => {
945 jQuery('.vcm-btn-channel-airbnbapi').trigger('click');
946 }, 500);
947 });
948 JS
949 );
950 }
951 }
952 }
953 ?>
954 </div>
955
956 <?php
957 if (!$printreceipt && $this->allows_conversion !== false) {
958 ?>
959 <div class="vbo-bookdet-container vbo-bookdet-conv-currency">
960 <div class="vbo-bookdet-conv-currency-inner">
961 <div class="vbo-bookdet-conv-currency-info">
962 <span><?php echo JText::sprintf('VBO_CONV_RES_OTA_CURRENCY', $this->conv_from_currency, $this->conv_to_currency); ?></span>
963 <span><?php echo JText::sprintf('VBO_CONV_RES_OTA_CURRENCY_EXC', ($this->conv_from_currency . ' ' . VikBooking::numberFormat($row['total'])), ($this->conv_to_currency . ' ' . VikBooking::numberFormat($this->allows_conversion))); ?></span>
964 </div>
965 <div class="vbo-bookdet-conv-currency-apply">
966 <a class="btn vbo-config-btn" onclick="return confirm(Joomla.JText._('VBO_CONV_RES_OTA_CURRENCY_APPLY') + '?');" href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $row['id']; ?>&do_ota_curr_conv=1"><?php VikBookingIcons::e('exchange-alt'); ?> <?php echo JText::translate('VBO_CONV_RES_OTA_CURRENCY_APPLY'); ?></a>
967 </div>
968 </div>
969 </div>
970 <?php
971 }
972
973 if (!$printreceipt && $row['status'] == "standby" && empty($row['idorderota']) && !strcasecmp((string)$row['type'], 'Inquiry')) {
974 // website pending reservation inquiry
975 $ir_data_callback = function($data) {
976 return (is_object($data) && !empty($data->av_type));
977 };
978 $prev_ir_data = $history_obj->getEventsWithData('IR', $ir_data_callback, true);
979 if (is_array($prev_ir_data) && count($prev_ir_data)) {
980 // display a message about the availability type at the time of creation of the inquiry reservation
981
982 // parse original stay dates into DateTime objects
983 $orig_checkin_dt_obj = new JDate($prev_ir_data[0]->checkin_date);
984 $orig_checkout_dt_obj = new JDate($prev_ir_data[0]->checkout_date);
985 ?>
986 <div class="vbo-bookdet-container vbo-bookdet-inquiry-alert">
987 <div class="vbo-bookdet-inquiry-alert-dismiss">
988 <button type="button" class="btn btn-warning" onclick="jQuery('.vbo-bookdet-inquiry-alert').remove();"><?php VikBookingIcons::e('times-circle'); ?> <?php echo JText::translate('VBOBTNKEEPREMIND'); ?></button>
989 </div>
990 <div class="vbo-bookdet-inquiry-alert-message">
991 <div class="vbo-bookdet-inquiry-alert-top">
992 <span><?php echo JText::translate('VBO_WEB_INQUIRY_ALERT'); ?></span>
993 </div>
994 <div class="vbo-bookdet-inquiry-alert-avtype">
995 <span class="vbo-bookdet-inquiry-alert-mess-avtype"><?php
996 // explain what was the availability at the time of inquiry
997 if ($prev_ir_data[0]->av_type === 1) {
998 echo JText::translate('VBO_WEB_INQUIRY_AVTYPE_1');
999 } elseif ($prev_ir_data[0]->av_type === 2) {
1000 echo JText::translate('VBO_WEB_INQUIRY_AVTYPE_2');
1001 } elseif ($prev_ir_data[0]->av_type === 3) {
1002 echo JText::translate('VBO_WEB_INQUIRY_AVTYPE_3');
1003 } else {
1004 echo JText::translate('VBO_WEB_INQUIRY_AVTYPE_4');
1005 }
1006 ?></span>
1007 <span class="vbo-bookdet-inquiry-alert-mess-origrq">
1008 <strong><?php echo JText::translate('VBO_WEB_INQUIRY_ORIGRQ') . ':'; ?></strong>
1009 <span class="badge"><?php echo JText::translate('VBPICKUPAT') . ': ' . $orig_checkin_dt_obj->format('D, d M Y', true); ?></span>
1010 <span class="badge"><?php echo JText::translate('VBRELEASEAT') . ': ' . $orig_checkout_dt_obj->format('D, d M Y', true); ?></span>
1011 <span class="badge"><?php echo JText::translate('VBEDITORDERADULTS') . ': ' . $prev_ir_data[0]->adults; ?></span>
1012 <?php
1013 if (!empty($prev_ir_data[0]->children)) {
1014 ?>
1015 <span class="badge"><?php echo JText::translate('VBEDITORDERCHILDREN') . ': ' . $prev_ir_data[0]->children; ?></span>
1016 <?php
1017 }
1018 ?>
1019 </span>
1020 </div>
1021 <div class="vbo-bookdet-inquiry-alert-bottom">
1022 <span><?php echo JText::translate('VBO_WEB_INQUIRY_SUGG'); ?></span>
1023 </div>
1024 </div>
1025 </div>
1026 <?php
1027 }
1028 }
1029 ?>
1030
1031 <div class="vbo-bookingdet-innertop">
1032 <div class="vbo-bookingdet-commands">
1033 <?php
1034 if ($busy || $row['status'] == "standby") {
1035 ?>
1036 <div class="vbo-bookingdet-command">
1037 <button onclick="document.location.href='index.php?option=com_vikbooking&task=editbusy&cid[]=<?php echo $row['id']; ?>';" class="btn vbo-config-btn" type="button"><i class="icon-pencil"></i> <?php echo JText::translate('VBMODRES'); ?></button>
1038 </div>
1039 <?php
1040 }
1041 if ((array_key_exists(1, $tars) && count($tars[1]) > 0) || ($is_package || $is_cust_cost)) {
1042
1043 if (VBOPlatformDetection::isWordPress()) {
1044 /**
1045 * @wponly display warning message if no valid Shortcodes found
1046 */
1047 $model = JModel::getInstance('vikbooking', 'shortcodes');
1048 $itemid = $model->best('booking');
1049 if (!$itemid) {
1050 VikError::raiseWarning('', 'No Shortcodes found, or no Shortcodes being used in Pages/Posts.');
1051 }
1052 }
1053
1054 ?>
1055 <div class="vbo-bookingdet-command">
1056 <button onclick="window.open('<?php echo VikBooking::externalroute('index.php?option=com_vikbooking&view=booking&sid='.(!empty($row['sid']) ? $row['sid'] : $row['idorderota']).'&ts='.$row['ts'], false); ?>', '_blank');" type="button" class="btn vbo-config-btn"><?php VikBookingIcons::e('external-link'); ?> <?php echo JText::translate('VBVIEWORDFRONT'); ?></button>
1057 </div>
1058 <?php
1059 }
1060 if (($row['status'] == "confirmed" || ($row['status'] == "standby" && !empty($row['custmail']))) && ((array_key_exists(1, $tars) && count($tars[1]) > 0) || ($is_package || $is_cust_cost))) {
1061 ?>
1062 <div class="vbo-bookingdet-command">
1063 <button class="btn vbo-config-btn" type="button" onclick="document.location.href='index.php?option=com_vikbooking&task=resendordemail&cid[]=<?php echo $row['id']; ?>';"><?php VikBookingIcons::e('envelope'); ?> <?php echo JText::translate('VBRESENDORDEMAIL'); ?></button>
1064 </div>
1065 <?php
1066 }
1067 if (is_array($this->vcm_special_offer)) {
1068 if (empty($this->vcm_special_offer[3]) || !empty($this->vcm_special_offer[4])) {
1069 // no special offer sent before, or withdrawn
1070 ?>
1071 <div class="vbo-bookingdet-command">
1072 <button type="button" class="btn btn-primary vcm-btn-channel-<?php echo strtolower($this->vcm_special_offer[2]); ?>" onclick="vboOpenJModal('vbo-vcm-special-offer', 'index.php?option=com_vikchannelmanager&task=specialoffer&bid=<?php echo $row['id']; ?>&listing_id=<?php echo $this->vcm_special_offer[0]; ?>&ota_thread_id=<?php echo $this->vcm_special_offer[1]; ?>&tmpl=component');"><?php VikBookingIcons::e('certificate'); ?> <?php echo JText::sprintf('VBO_VCM_SPECIAL_OFFER', $this->vcm_special_offer[2]); ?></button>
1073 </div>
1074 <?php
1075 // prepare modal (VCM prepare special offer)
1076 array_push($vbo_modals_html, $vbo_app->getJmodalHtml('vbo-vcm-special-offer', JText::sprintf('VBO_VCM_SPECIAL_OFFER', $this->vcm_special_offer[2])));
1077 // end prepare modal
1078 } else {
1079 // special offer sent before, link to withdraw it
1080 ?>
1081 <div class="vbo-bookingdet-command">
1082 <a href="index.php?option=com_vikchannelmanager&task=sendSpecialOffer&vbo_oid=<?php echo $row['id']; ?>&spo_type=special_offer&spo_action=withdraw&ota_thread_id=<?php echo $this->vcm_special_offer[1]; ?>&spo_id=<?php echo $this->vcm_special_offer[3]; ?>" class="btn btn-danger"><?php VikBookingIcons::e('ban'); ?> <?php echo JText::translate('VBO_WITHDRAW_SPOFFER'); ?></a>
1083 </div>
1084 <?php
1085 }
1086 }
1087 if ($row['status'] == "standby" || ($row['status'] == "cancelled" && $row['checkout'] >= time())) {
1088 ?>
1089 <div class="vbo-bookingdet-command">
1090 <button class="btn btn-success" type="button" onclick="if (confirm('<?php echo htmlspecialchars(JText::translate('VBSETORDCONFIRMED')); ?> ?')) {document.location.href='index.php?option=com_vikbooking&task=setordconfirmed&cid[]=<?php echo $row['id'] . ($row['status'] == "cancelled" ? '&skip_notification=1' : ''); ?>';}"><?php VikBookingIcons::e('check'); ?> <?php echo JText::translate('VBSETORDCONFIRMED'); ?></button>
1091 </div>
1092 <?php
1093 }
1094 if ($row['status'] == "cancelled" && !$row['closure']) {
1095 ?>
1096 <div class="vbo-bookingdet-command">
1097 <button type="button" class="btn btn-warning vbo-context-menu-btn vbo-context-menu-actionscanc">
1098 <span class="vbo-context-menu-lbl"><?php echo JText::translate('VBCRONACTIONS'); ?> &#8230;</span>
1099 <span class="vbo-context-menu-ico"><?php VikBookingIcons::e('sort-down'); ?></span>
1100 </button>
1101 </div>
1102
1103 <script type="text/javascript">
1104 jQuery(function() {
1105 jQuery('.vbo-context-menu-actionscanc').vboContextMenu({
1106 placement: 'bottom-right',
1107 buttons: [
1108 <?php
1109 if (!empty($row['custmail'])) :
1110 ?>
1111 {
1112 icon: '<?php echo VikBookingIcons::i('envelope'); ?>',
1113 text: Joomla.JText._('VBSENDCANCORDEMAIL'),
1114 class: 'vbo-context-menu-entry-danger',
1115 separator: true,
1116 action: (root, config) => {
1117 document.location.href = 'index.php?option=com_vikbooking&task=sendcancordemail&cid[]=<?php echo $row['id']; ?>';
1118 },
1119 },
1120 <?php
1121 endif;
1122 ?>
1123 {
1124 icon: '<?php echo VikBookingIcons::i('hourglass-half'); ?>',
1125 text: Joomla.JText._('VBO_SET_STANDBY'),
1126 class: 'vbo-context-menu-entry-warning',
1127 separator: false,
1128 action: (root, config) => {
1129 document.location.href = '<?php echo VBOFactory::getPlatform()->getUri()->addCSRF('index.php?option=com_vikbooking&task=bookings.set_to_pending&bid=' . $row['id']); ?>';
1130 },
1131 },
1132 ],
1133 });
1134 });
1135 </script>
1136 <?php
1137 }
1138 if ($row['status'] == 'confirmed' && $row['closure'] < 1) {
1139 ?>
1140 <div class="vbo-bookingdet-command pro-feature">
1141 <button type="button" class="btn vbo-config-btn" onclick="document.getElementById('invnotes-hid').value=document.getElementById('invnotes').value;document.getElementById('vbo-gen-invoice').submit();"><?php VikBookingIcons::e('file-text-o'); ?> <?php echo JText::translate('VBOGENBOOKINGINVOICE'); ?></button>
1142 </div>
1143 <?php
1144 }
1145 if ($row['status'] == 'confirmed' && $row['closure'] < 1) {
1146 ?>
1147 <div class="vbo-bookingdet-command pro-feature">
1148 <button type="button" class="btn vbo-config-btn" onclick="window.open('index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $row['id']; ?>&print=1&tmpl=component', '_blank');"><?php VikBookingIcons::e('print'); ?> <?php echo JText::translate('VBOPRINTRECEIPT'); ?></button>
1149 </div>
1150 <?php
1151 }
1152 if ($row['status'] != 'confirmed' || $row['closure'] > 0 || $this->vcm_cancel_active_res) {
1153 if ($this->vcm_decline_actions) {
1154 // this booking requires some decline actions before being removed
1155 ?>
1156 <div class="vbo-bookingdet-command">
1157 <button type="button" class="btn btn-danger" onclick="vboOpenJModal('vbo-vcm-decline-booking', 'index.php?option=com_vikchannelmanager&task=declinebooking&cid[]=<?php echo $row['id']; ?>&tmpl=component');"><?php VikBookingIcons::e('trash'); ?> <?php echo JText::translate('VBMAINEBUSYDEL'); ?></button>
1158 </div>
1159 <?php
1160 // prepare modal (VCM decline booking)
1161 array_push($vbo_modals_html, $vbo_app->getJmodalHtml('vbo-vcm-decline-booking', JText::translate('VBMAINEBUSYDEL')));
1162 // end prepare modal
1163 } elseif ($this->vcm_cancel_active_res) {
1164 // the active OTA booking can be cancelled
1165 ?>
1166 <div class="vbo-bookingdet-command">
1167 <button type="button" class="btn btn-danger" onclick="vboOpenJModal('vbo-vcm-cancel-reservation', 'index.php?option=com_vikchannelmanager&task=cancelreservation&vbo_oid=<?php echo $row['id']; ?>&tmpl=component');"><?php VikBookingIcons::e('trash'); ?> <?php echo JText::translate('VBMAINEBUSYDEL'); ?></button>
1168 </div>
1169 <?php
1170 // prepare modal (VCM cancel reservation)
1171 array_push($vbo_modals_html, $vbo_app->getJmodalHtml('vbo-vcm-cancel-reservation', JText::translate('VBMAINEBUSYDEL')));
1172 // end prepare modal
1173 } else {
1174 // regular remove button with confirmation
1175 ?>
1176 <div class="vbo-bookingdet-command">
1177 <button type="button" class="btn btn-danger" onclick="if (confirm(Joomla.JText._('VBDELCONFIRM'))){document.location.href='index.php?option=com_vikbooking&task=removeorders&cid[]=<?php echo $row['id']; ?>&goto=<?php echo $row['id']; ?>';}"><?php VikBookingIcons::e('trash'); ?> <?php echo $row['status'] == 'cancelled' ? JText::translate('VBO_PURGERM_RESERVATION') : JText::translate('VBMAINEBUSYDEL'); ?></button>
1178 </div>
1179 <?php
1180 }
1181 }
1182 ?>
1183
1184 <!-- Define role to detect the supported hook -->
1185 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorder","key":"buttons","type":"field"} -->
1186
1187 <?php
1188 if (isset($bookingPanelForms['buttons']))
1189 {
1190 echo $bookingPanelForms['buttons'];
1191 }
1192 ?>
1193 </div>
1194
1195 <div class="vbo-bookingdet-tabs">
1196 <div class="vbo-bookingdet-tab vbo-bookingdet-tab-active" data-vbotab="vbo-tab-details"><?php echo JText::translate('VBOBOOKDETTABDETAILS'); ?></div>
1197 <div class="vbo-bookingdet-tab" data-vbotab="vbo-tab-admin"><?php echo JText::translate('VBOBOOKDETTABADMIN'); ?></div>
1198 </div>
1199 </div>
1200
1201 <div class="vbo-bookingdet-tab-cont" id="vbo-tab-details" style="display: block;">
1202 <div class="vbo-bookingdet-innercontainer">
1203 <div class="vbo-bookingdet-customer">
1204 <div class="vbo-bookingdet-detcont<?php echo $row['closure'] > 0 ? ' vbo-bookingdet-closure' : ''; ?>">
1205 <?php
1206 $custdata_parts = explode("\n", $row['custdata']);
1207 if (count($custdata_parts) > 2 && strpos($custdata_parts[0], ':') !== false && strpos($custdata_parts[1], ':') !== false) {
1208 //attempt to format labels and values
1209 foreach ($custdata_parts as $custdet) {
1210 if (strlen($custdet) < 1) {
1211 continue;
1212 }
1213 $custdet_parts = explode(':', $custdet);
1214 $custd_lbl = '';
1215 $custd_val = '';
1216 if (count($custdet_parts) < 2) {
1217 $custd_val = $custdet;
1218 } else {
1219 $custd_lbl = $custdet_parts[0];
1220 if ($custd_lbl == 'http' || $custd_lbl == 'https') {
1221 // shift values
1222 $custdet_parts[2] = $custdet_parts[1];
1223 $custdet_parts[1] = $custdet_parts[0];
1224 $custd_lbl = '';
1225 }
1226 unset($custdet_parts[0]);
1227 if ((!strcasecmp(trim($custdet_parts[1]), 'http') || !strcasecmp(trim($custdet_parts[1]), 'https')) && !empty($custdet_parts[2]) && strpos($custdet_parts[2], '//') !== false) {
1228 // this is a URI
1229 $custd_val = '<a href="' . trim(implode(':', $custdet_parts)) . '" target="_blank"><i class="' . VikBookingIcons::i('external-link') . '"></i></a>';
1230 } else {
1231 $custd_val = trim(implode(':', $custdet_parts));
1232 }
1233 }
1234 ?>
1235 <div class="vbo-bookingdet-userdetail">
1236 <?php
1237 if (strlen($custd_lbl)) {
1238 ?>
1239 <span class="vbo-bookingdet-userdetail-lbl"><?php echo VikBooking::tnCustomerRawDataLabel($custd_lbl); ?></span>
1240 <?php
1241 }
1242 if (strlen($custd_val)) {
1243 ?>
1244 <span class="vbo-bookingdet-userdetail-val"><?php echo $custd_val; ?></span>
1245 <?php
1246 }
1247 ?>
1248 </div>
1249 <?php
1250 }
1251 } else {
1252 if ($row['closure'] > 0) {
1253 ?>
1254 <div class="vbo-bookingdet-userdetail">
1255 <span class="vbo-bookingdet-userdetail-val"><?php echo nl2br($row['custdata']); ?></span>
1256 </div>
1257 <?php
1258 } else {
1259 echo nl2br($row['custdata']);
1260 ?>
1261 <div class="vbo-bookingdet-userdetail">
1262 <span class="vbo-bookingdet-userdetail-val">&nbsp;</span>
1263 </div>
1264 <?php
1265 }
1266 }
1267 if (!empty($row['ujid'])) {
1268 $orig_user = JFactory::getUser($row['ujid']);
1269 $author_name = is_object($orig_user) && property_exists($orig_user, 'name') && !empty($orig_user->name) ? $orig_user->name : '';
1270 ?>
1271 <div class="vbo-bookingdet-userdetail">
1272 <span class="vbo-bookingdet-userdetail-val"><?php echo JText::sprintf('VBOBOOKINGCREATEDBY', $row['ujid'].(!empty($author_name) ? ' ('.$author_name.')' : '')); ?></span>
1273 </div>
1274 <?php
1275 }
1276 ?>
1277
1278 <!-- Define role to detect the supported hook -->
1279 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderSidebar","key":"userdetails","type":"field"} -->
1280
1281 <?php
1282 if (isset($bookingSidebarForms['userdetails']))
1283 {
1284 echo $bookingSidebarForms['userdetails'];
1285 }
1286 ?>
1287
1288 </div>
1289
1290 <?php
1291 // build list of invoice details (path/uri & label/button), one by default
1292 $invoice_details = [
1293 [
1294 'path' => implode(DIRECTORY_SEPARATOR, [VBO_SITE_PATH, 'helpers', 'invoices', 'generated', "{$row['id']}_{$row['sid']}.pdf"]),
1295 'uri' => VBO_SITE_URI . 'helpers/invoices/generated/' . "{$row['id']}_{$row['sid']}.pdf",
1296 'label' => JText::translate('VBOCOLORTAGRULEINVONE'),
1297 'btn' => JText::translate('VBOINVDOWNLOAD'),
1298 ]
1299 ];
1300
1301 /**
1302 * Merge the additional invoices generated by the e-invoicing drivers for this booking.
1303 *
1304 * @since 1.16.7 (J) - 1.6.7 (WP)
1305 */
1306 $invoice_details = array_merge($invoice_details, VBOEinvoicingFactory::getInstance()->getBookingExtraInvoices($row['id']));
1307
1308 /**
1309 * Trigger event to allow third-party plugins to define additional invoices or paths/urls.
1310 *
1311 * @since 1.16.7 (J) - 1.6.7 (WP)
1312 */
1313 VBOFactory::getPlatform()->getDispatcher()->trigger('onBeforeListInvoices', [$row, &$invoice_details]);
1314
1315 // check if an invoice exists
1316 $invoiced = false;
1317 foreach ((array) $invoice_details as $invoice_detail) {
1318 $invoiced = $invoiced || is_file($invoice_detail['path']);
1319 }
1320
1321 // extra booking details
1322 if (!$printreceipt && ((!empty($row['channel']) && !empty($row['idorderota'])) || strlen((string)$row['confirmnumber']) || $invoiced)) {
1323 ?>
1324 <div class="vbo-bookingdet-detcont vbo-bookingdet-detcont-labels-wrap vbo-hidein-print">
1325 <?php
1326 if (!empty($row['channel']) && !empty($row['idorderota'])) {
1327 ?>
1328 <div class="vbo-bookingdet-detcont-label vbo-bookingdet-detcont-label-idorderota">
1329 <span class="label label-info">
1330 <span><?php echo $otachannel_name . ' ID'; ?></span>
1331 <span class="badge"><?php echo !strcasecmp((string)$row['type'], 'Inquiry') && $row['status'] == 'standby' ? '-----' : $row['idorderota']; ?></span>
1332 </span>
1333 </div>
1334 <?php
1335 }
1336 if (strlen((string)$row['confirmnumber'])) {
1337 ?>
1338 <div class="vbo-bookingdet-detcont-label vbo-bookingdet-detcont-label-confirmnumber">
1339 <span class="label label-success">
1340 <span><?php echo JText::translate('VBCONFIRMNUMB'); ?></span>
1341 <span class="badge"><?php echo $row['confirmnumber']; ?></span>
1342 </span>
1343 </div>
1344 <?php
1345 }
1346 if ($invoiced) {
1347 foreach ($invoice_details as $invoice_detail) {
1348 ?>
1349 <div class="vbo-bookingdet-detcont-label vbo-bookingdet-detcont-label-invoice">
1350 <span class="label label-success">
1351 <span><?php echo $invoice_detail['label'] ?? JText::translate('VBOCOLORTAGRULEINVONE'); ?></span>
1352 <span class="badge"><a href="<?php echo $invoice_detail['uri'] . (strpos($invoice_detail['uri'], '?') === false ? '?' . rand() . '=1' : ''); ?>" target="_blank"><?php VikBookingIcons::e('download'); ?> <?php echo $invoice_detail['btn'] ?? JText::translate('VBOINVDOWNLOAD'); ?></a></span>
1353 </span>
1354 </div>
1355 <?php
1356 }
1357 }
1358 if ($this->vcm_review) {
1359 ?>
1360 <div class="vbo-bookingdet-detcont-label vbo-bookingdet-detcont-label-review">
1361 <span class="label label-warning">
1362 <a href="index.php?option=com_vikchannelmanager&task=reviews&revid=<?php echo $this->vcm_review['id']; ?>" target="_blank" style="color: #fff;"><i class="vboicn-star-full"></i> <?php echo JText::translate('VBOSEEGUESTREVIEW'); ?></a>
1363 </span>
1364 </div>
1365 <?php
1366 // check if a notification was clicked
1367 if (VikRequest::getString('notif_action', '', 'request') == 'see_guest_review') {
1368 $vcm_review_link = VBOFactory::getPlatform()->getUri()->admin('index.php?option=com_vikchannelmanager&task=reviews&revid=' . $this->vcm_review['id'], false);
1369 JFactory::getDocument()->addScriptDeclaration(
1370 <<<JS
1371 jQuery(function() {
1372 setTimeout(() => {
1373 document.location.href = '$vcm_review_link';
1374 }, 200);
1375 });
1376 JS
1377 );
1378 }
1379 }
1380 ?>
1381
1382 <!-- Define role to detect the supported hook -->
1383 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderSidebar","key":"invoice","type":"field"} -->
1384
1385 <?php
1386 if (isset($bookingSidebarForms['invoice']))
1387 {
1388 echo $bookingSidebarForms['invoice'];
1389 }
1390 ?>
1391
1392 </div>
1393 <?php
1394 }
1395 if (!$printreceipt && $row['closure'] < 1) {
1396 ?>
1397 <div class="vbo-bookingdet-detcont vbo-hidein-print">
1398 <div class="vbo-bookingdet-lblcont">
1399 <label for="custmail"><?php echo JText::translate('VBCUSTEMAIL'); ?></label>
1400 </div>
1401 <div class="vbo-bookingdet-inpwrap">
1402 <div class="vbo-bookingdet-inpcont">
1403 <input type="text" name="custmail" id="custmail" value="<?php echo $this->escape($row['custmail']); ?>" size="25" onkeyup="vboKeyupEmail(event);"/>
1404 </div>
1405 <div class="vbo-bookingdet-btncont vbo-bookingdet-save-email" style="display: none;">
1406 <button type="button" class="btn btn-success" onclick="document.adminForm.submit();"><?php VikBookingIcons::e('save'); ?> <?php echo JText::translate('VBSAVE'); ?></button>
1407 </div>
1408 <?php if (!empty($row['custmail'])) : ?>
1409 <div class="vbo-bookingdet-btncont">
1410 <button type="button" class="btn vbo-config-btn" onclick="vboToggleSendEmail();" style="vertical-align: top;"><?php VikBookingIcons::e('envelope'); ?> <?php echo JText::translate('VBSENDEMAILACTION'); ?></button>
1411 </div>
1412 <?php endif; ?>
1413 </div>
1414
1415 <!-- Define role to detect the supported hook -->
1416 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderSidebar","key":"email","type":"field"} -->
1417
1418 <?php
1419 if (isset($bookingSidebarForms['email']))
1420 {
1421 echo $bookingSidebarForms['email'];
1422 }
1423 ?>
1424
1425 </div>
1426 <div class="vbo-bookingdet-detcont vbo-hidein-print">
1427 <div class="vbo-bookingdet-lblcont">
1428 <label for="custphone"><?php echo JText::translate('VBCUSTOMERPHONE'); ?></label>
1429 </div>
1430 <div class="vbo-bookingdet-inpwrap">
1431 <div class="vbo-bookingdet-inpcont">
1432 <?php echo $vbo_app->printPhoneInputField(array('name' => 'custphone', 'id' => 'custphone', 'value' => $this->escape($row['phone'])), array('nationalMode' => false, 'fullNumberOnBlur' => true)); ?>
1433 </div>
1434 <?php if (!empty($row['phone'])) : ?>
1435 <div class="vbo-bookingdet-btncont">
1436 <button type="button" class="btn vbo-config-btn" onclick="vboToggleSendSMS();" style="vertical-align: top;"><?php VikBookingIcons::e('comment-dots'); ?> <?php echo JText::translate('VBSENDSMSACTION'); ?></button>
1437 </div>
1438 <?php endif; ?>
1439 </div>
1440
1441 <!-- Define role to detect the supported hook -->
1442 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderSidebar","key":"phone","type":"field"} -->
1443
1444 <?php
1445 if (isset($bookingSidebarForms['phone']))
1446 {
1447 echo $bookingSidebarForms['phone'];
1448 }
1449 ?>
1450
1451 </div>
1452
1453 <!-- Define role to detect the supported hook -->
1454 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderSidebar","type":"fieldset"} -->
1455
1456 <?php
1457 foreach ($bookingSidebarForms as $legend => $form)
1458 {
1459 if (in_array($legend, ['userdetails', 'invoice', 'email', 'phone']))
1460 {
1461 // skip default forms
1462 continue;
1463 }
1464 ?>
1465 <div class="vbo-bookingdet-detcont vbo-hidein-print">
1466 <h3><?php echo JText::translate($legend); ?></h3>
1467
1468 <?php echo $form; ?>
1469 </div>
1470 <?php
1471 }
1472 ?>
1473
1474 <?php
1475 }
1476 ?>
1477 </div>
1478
1479 <?php
1480 $all_id_prices = array();
1481 $used_indexes_map = array();
1482 ?>
1483 <div class="vbo-bookingdet-summary">
1484 <div class="table-responsive">
1485 <table class="table">
1486 <?php
1487 // room stay dates in case of split stay (or modified room nights)
1488 $room_stay_dates = [];
1489 $room_stay_records = [];
1490 if ($row['split_stay']) {
1491 if ($row['status'] == 'confirmed') {
1492 $room_stay_dates = $av_helper->loadSplitStayBusyRecords($row['id']);
1493 } else {
1494 $room_stay_dates = VBOFactory::getConfig()->getArray('split_stay_' . $row['id'], []);
1495 }
1496 } elseif (!$row['split_stay'] && $row['roomsnum'] > 1 && $row['days'] > 1 && $row['status'] == 'confirmed') {
1497 // load the occupied stay dates for each room in case they were modified
1498 $room_stay_records = $av_helper->loadSplitStayBusyRecords($row['id']);
1499 }
1500
1501 // parse all rooms booked
1502 foreach ($rooms as $ind => $or) {
1503 $num = $ind + 1;
1504 $room_icon = $row['split_stay'] && $ind > 0 ? 'random' : 'bed';
1505 $room_stay_nights = $row['days'];
1506 ?>
1507 <tr class="vbo-bookingdet-summary-room">
1508 <td class="vbo-bookingdet-summary-room-firstcell">
1509 <div class="vbo-bookingdet-summary-room-wrap">
1510 <div class="vbo-bookingdet-summary-roomnum"><?php VikBookingIcons::e($room_icon); ?> <?php echo JText::translate('VBEDITORDERTHREE').' '.$num; ?></div>
1511 <?php
1512 //Room Specific Unit
1513 if (!$row['closure'] && $row['status'] == "confirmed" && !empty($or['params'])) {
1514 $room_params = json_decode($or['params'], true);
1515 $arr_features = array();
1516 $unavailable_indexes = VikBooking::getRoomUnitNumsUnavailable($row, $or['idroom']);
1517 if (is_array($room_params) && array_key_exists('features', $room_params) && !empty($room_params['features'])) {
1518 foreach ($room_params['features'] as $rind => $rfeatures) {
1519 if (in_array($rind, $unavailable_indexes) || (isset($used_indexes_map[$or['idroom']]) && in_array($rind, $used_indexes_map[$or['idroom']]))) {
1520 continue;
1521 }
1522 foreach ($rfeatures as $fname => $fval) {
1523 if (strlen($fval)) {
1524 $arr_features[$rind] = '#'.$rind.' - '.JText::translate($fname).': '.$fval;
1525 break;
1526 }
1527 }
1528 }
1529 }
1530 if (count($arr_features)) {
1531 // $or['id'] equals to the ID of each matching record in _ordersrooms
1532 ?>
1533 <div class="vbo-bookingdet-summary-roomnum-chunit">
1534 <?php echo !$printreceipt ? $vbo_app->getNiceSelect($arr_features, $or['roomindex'], 'roomindex['.$or['id'].']', JText::translate('VBOFEATASSIGNUNIT'), JText::translate('VBOFEATASSIGNUNITEMPTY'), '', 'document.adminForm.submit();', $or['id']) : (!empty($or['roomindex']) && isset($arr_features[$or['roomindex']]) ? $arr_features[$or['roomindex']] : ''); ?>
1535 </div>
1536 <?php
1537 if (!empty($or['idroom']) && !empty($or['roomindex'])) {
1538 if (!array_key_exists($or['idroom'], $used_indexes_map)) {
1539 $used_indexes_map[$or['idroom']] = array();
1540 }
1541 $used_indexes_map[$or['idroom']][] = $or['roomindex'];
1542 }
1543 }
1544 }
1545 //
1546 ?>
1547 </div>
1548 <div class="vbo-bookingdet-summary-roomguests">
1549 <?php VikBookingIcons::e('male'); ?>
1550 <div class="vbo-bookingdet-summary-roomadults">
1551 <span><?php echo JText::translate('VBEDITORDERADULTS'); ?>:</span> <?php echo $arrpeople[$num]['adults']; ?>
1552 </div>
1553 <?php
1554 if ($arrpeople[$num]['children'] > 0) {
1555 $age_str = '';
1556 if (!empty($arrpeople[$num]['children_age'])) {
1557 $json_child = json_decode($arrpeople[$num]['children_age'], true);
1558 if (is_array($json_child) && isset($json_child['age']) && is_array($json_child['age']) && count($json_child['age'])) {
1559 $age_str = ' '.JText::sprintf('VBORDERCHILDAGES', implode(', ', $json_child['age']));
1560 }
1561 }
1562 ?>
1563 <div class="vbo-bookingdet-summary-roomchildren">
1564 <span><?php echo JText::translate('VBEDITORDERCHILDREN'); ?>:</span> <?php echo $arrpeople[$num]['children'].$age_str; ?>
1565 </div>
1566 <?php
1567 }
1568 if ($arrpeople[$num]['pets'] > 0) {
1569 ?>
1570 <div class="vbo-bookingdet-summary-roompets">
1571 <span><?php VikBookingIcons::e('dog'); ?> <?php echo JText::translate('VBO_PETS'); ?>:</span> <?php echo $arrpeople[$num]['pets']; ?>
1572 </div>
1573 <?php
1574 }
1575 ?>
1576 </div>
1577 <?php
1578 if (!empty($arrpeople[$num]['t_first_name'])) {
1579 ?>
1580 <div class="vbo-bookingdet-summary-guestname">
1581 <span><?php echo $arrpeople[$num]['t_first_name'].' '.$arrpeople[$num]['t_last_name']; ?></span>
1582 </div>
1583 <?php
1584 }
1585 ?>
1586 </td>
1587 <td>
1588 <div class="vbo-bookingdet-summary-roomname"><?php echo $or['name']; ?></div>
1589 <div class="vbo-bookingdet-summary-roomrate">
1590 <?php
1591 $active_rplan_id = 0;
1592 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
1593 if (!empty($or['pkg_name'])) {
1594 //package
1595 echo $or['pkg_name'];
1596 } else {
1597 //custom cost can have an OTA Rate Plan name
1598 if (!empty($or['otarplan'])) {
1599 echo ucwords($or['otarplan']);
1600 } else {
1601 echo JText::translate('VBOROOMCUSTRATEPLAN');
1602 }
1603 }
1604 } elseif (!empty($tars[$num]) && !empty($tars[$num][0]['idprice'])) {
1605 $active_rplan_id = $tars[$num][0]['idprice'];
1606 $all_id_prices[] = $tars[$num][0]['idprice'];
1607 echo VikBooking::getPriceName($tars[$num][0]['idprice']);
1608 if (!empty($tars[$num][0]['attrdata'])) {
1609 ?>
1610 <div>
1611 <?php echo VikBooking::getPriceAttr($tars[$num][0]['idprice']).": ".$tars[$num][0]['attrdata']; ?>
1612 </div>
1613 <?php
1614 }
1615 } elseif (!empty($or['otarplan'])) {
1616 echo ucwords($or['otarplan']);
1617 } elseif ($row['closure'] < 1) {
1618 echo JText::translate('VBOROOMNORATE');
1619 }
1620 ?>
1621 </div>
1622 <?php
1623 // meals included in the room rate
1624 if (!empty($or['meals'])) {
1625 // display included meals defined at room-reservation record
1626 $included_meals = VBOMealplanManager::getInstance()->roomRateIncludedMeals($or);
1627 } else {
1628 // fetch default included meals in the selected rate plan
1629 $included_meals = $active_rplan_id ? VBOMealplanManager::getInstance()->ratePlanIncludedMeals($active_rplan_id) : [];
1630 }
1631 if (!$included_meals && empty($or['meals']) && !empty($row['idorderota']) && !empty($row['channel']) && !empty($row['custdata'])) {
1632 // attempt to fetch the included meal plans from the raw customer data or OTA reservation and room
1633 $included_meals = VBOMealplanManager::getInstance()->otaDataIncludedMeals($row, $or);
1634 }
1635 if ($included_meals) {
1636 ?>
1637 <div class="vbo-bookingdet-summary-roomrate vbo-bookingdet-summary-roommeals vbo-wider-badges-wrap">
1638 <?php
1639 foreach ($included_meals as $included_meal) {
1640 ?>
1641 <span class="badge badge-info"><?php echo $included_meal; ?></span>
1642 <?php
1643 }
1644 ?>
1645 </div>
1646 <?php
1647 }
1648
1649 if ($row['split_stay'] && count($room_stay_dates) && isset($room_stay_dates[$ind]) && $room_stay_dates[$ind]['idroom'] == $or['idroom']) {
1650 // print split stay information for this room
1651 $room_stay_checkin = !empty($room_stay_dates[$ind]['checkin_ts']) ? $room_stay_dates[$ind]['checkin_ts'] : $room_stay_dates[$ind]['checkin'];
1652 $room_stay_checkout = !empty($room_stay_dates[$ind]['checkout_ts']) ? $room_stay_dates[$ind]['checkout_ts'] : $room_stay_dates[$ind]['checkout'];
1653 $room_stay_nights = $av_helper->countNightsOfStay($room_stay_checkin, $room_stay_checkout);
1654 ?>
1655 <div class="vbo-cal-splitstay-details vbo-bookdet-splitstay-details">
1656 <div class="vbo-cal-splitstay-dates">
1657 <span class="vbo-cal-splitstay-room-nights"><?php VikBookingIcons::e('moon'); ?> <?php echo $room_stay_nights . ' ' . ($room_stay_nights > 1 ? JText::translate('VBDAYS') : JText::translate('VBDAY')); ?></span>
1658 <span class="vbo-cal-splitstay-dates-in" title="<?php echo date('H:i', $room_stay_checkin); ?>"><?php VikBookingIcons::e('plane-arrival'); ?> <?php echo date(str_replace("/", $datesep, $df), $room_stay_checkin); ?></span>
1659 <span class="vbo-cal-splitstay-dates-out" title="<?php echo date('H:i', $room_stay_checkout); ?>"><?php VikBookingIcons::e('plane-departure'); ?> <?php echo date(str_replace("/", $datesep, $df), $room_stay_checkout); ?></span>
1660 </div>
1661 </div>
1662 <?php
1663 } elseif (!$row['split_stay'] && count($room_stay_records) && isset($room_stay_records[$ind]) && $room_stay_records[$ind]['idroom'] == $or['idroom']) {
1664 // print modified stay dates information for this room
1665 $room_stay_checkin = $room_stay_records[$ind]['checkin'];
1666 $room_stay_checkout = $room_stay_records[$ind]['checkout'];
1667 $room_stay_nights = $av_helper->countNightsOfStay($room_stay_checkin, $room_stay_checkout);
1668 if ($room_stay_checkin != $row['checkin'] || $room_stay_checkout != $row['checkout']) {
1669 ?>
1670 <div class="vbo-cal-splitstay-details vbo-bookdet-splitstay-details vbo-bookdet-roomdatesmod-details">
1671 <div class="vbo-cal-splitstay-dates">
1672 <span class="vbo-cal-splitstay-room-nights"><?php VikBookingIcons::e('moon'); ?> <?php echo $room_stay_nights . ' ' . ($room_stay_nights > 1 ? JText::translate('VBDAYS') : JText::translate('VBDAY')); ?></span>
1673 <span class="vbo-cal-splitstay-dates-in" title="<?php echo date('H:i', $room_stay_checkin); ?>"><?php VikBookingIcons::e('plane-arrival'); ?> <?php echo date(str_replace("/", $datesep, $df), $room_stay_checkin); ?></span>
1674 <span class="vbo-cal-splitstay-dates-out" title="<?php echo date('H:i', $room_stay_checkout); ?>"><?php VikBookingIcons::e('plane-departure'); ?> <?php echo date(str_replace("/", $datesep, $df), $room_stay_checkout); ?></span>
1675 </div>
1676 </div>
1677 <?php
1678 }
1679 }
1680 ?>
1681 </td>
1682 <td>
1683 <div class="vbo-bookingdet-summary-price">
1684 <?php
1685 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
1686 echo $currencyname.' '.VikBooking::numberFormat($or['cust_cost']);
1687 } elseif (!empty($tars[$num]) && !empty($tars[$num][0]['idprice'])) {
1688 $display_rate = !empty($or['room_cost']) ? $or['room_cost'] : $tars[$num][0]['cost'];
1689 echo $currencyname.' '.VikBooking::numberFormat(($after_tax ? VikBooking::sayCostPlusIva($display_rate, $tars[$num][0]['idprice']) : $display_rate));
1690 }
1691 ?>
1692 </div>
1693 </td>
1694 </tr>
1695 <?php
1696 //Options
1697 if (!empty($or['optionals'])) {
1698 $stepo = explode(";", $or['optionals']);
1699 $counter = 0;
1700 foreach ($stepo as $roptkey => $oo) {
1701 if (empty($oo)) {
1702 continue;
1703 }
1704 $stept = explode(":", $oo);
1705 $q = "SELECT * FROM `#__vikbooking_optionals` WHERE `id`=".(int)$stept[0].";";
1706 $dbo->setQuery($q);
1707 $dbo->execute();
1708 if ($dbo->getNumRows() != 1) {
1709 continue;
1710 }
1711 $counter++;
1712 $actopt = $dbo->loadAssocList();
1713 $chvar = '';
1714 if (!empty($actopt[0]['ageintervals']) && $or['children'] > 0 && strstr($stept[1], '-') != false) {
1715 $optagenames = VikBooking::getOptionIntervalsAges($actopt[0]['ageintervals']);
1716 $optagepcent = VikBooking::getOptionIntervalsPercentage($actopt[0]['ageintervals']);
1717 $optageovrct = VikBooking::getOptionIntervalChildOverrides($actopt[0], $or['adults'], $or['children']);
1718 $child_num = VikBooking::getRoomOptionChildNumber($or['optionals'], $actopt[0]['id'], $roptkey, $or['children']);
1719 $optagecosts = VikBooking::getOptionIntervalsCosts(isset($optageovrct['ageintervals_child' . ($child_num + 1)]) ? $optageovrct['ageintervals_child' . ($child_num + 1)] : $actopt[0]['ageintervals']);
1720 $agestept = explode('-', $stept[1]);
1721 $stept[1] = $agestept[0];
1722 $chvar = $agestept[1];
1723 if (array_key_exists(($chvar - 1), $optagepcent) && $optagepcent[($chvar - 1)] == 1) {
1724 //percentage value of the adults tariff
1725 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
1726 $optagecosts[($chvar - 1)] = $or['cust_cost'] * $optagecosts[($chvar - 1)] / 100;
1727 } else {
1728 $display_rate = !empty($or['room_cost']) ? $or['room_cost'] : $tars[$num][0]['cost'];
1729 $optagecosts[($chvar - 1)] = $display_rate * $optagecosts[($chvar - 1)] / 100;
1730 }
1731 } elseif (array_key_exists(($chvar - 1), $optagepcent) && $optagepcent[($chvar - 1)] == 2) {
1732 //VBO 1.10 - percentage value of room base cost
1733 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
1734 $optagecosts[($chvar - 1)] = $or['cust_cost'] * $optagecosts[($chvar - 1)] / 100;
1735 } else {
1736 $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']);
1737 $optagecosts[($chvar - 1)] = $display_rate * $optagecosts[($chvar - 1)] / 100;
1738 }
1739 }
1740 if (!isset($optagenames[($chvar - 1)])) {
1741 $optagenames[($chvar - 1)] = '';
1742 }
1743 if (!isset($optagecosts[($chvar - 1)])) {
1744 $optagecosts[($chvar - 1)] = 0;
1745 }
1746 $actopt[0]['chageintv'] = $chvar;
1747 $actopt[0]['name'] .= ' ('.$optagenames[($chvar - 1)].')';
1748 $realcost = (intval($actopt[0]['perday']) == 1 ? (floatval($optagecosts[($chvar - 1)]) * $room_stay_nights * $stept[1]) : (floatval($optagecosts[($chvar - 1)]) * $stept[1]));
1749 } else {
1750 // VBO 1.11 - options percentage cost of the room total fee
1751 if ($is_package === true || (!empty($or['cust_cost']) && $or['cust_cost'] > 0.00)) {
1752 $deftar_basecosts = $or['cust_cost'];
1753 } else {
1754 $use_def_tar = isset($tars[$num]) && isset($tars[$num][0]) ? $tars[$num][0]['cost'] : 0;
1755 $deftar_basecosts = !empty($or['room_cost']) ? $or['room_cost'] : $use_def_tar;
1756 }
1757 $actopt[0]['cost'] = (int)$actopt[0]['pcentroom'] ? ($deftar_basecosts * $actopt[0]['cost'] / 100) : $actopt[0]['cost'];
1758 //
1759 $realcost = (intval($actopt[0]['perday']) == 1 ? ($actopt[0]['cost'] * $room_stay_nights * $stept[1]) : ($actopt[0]['cost'] * $stept[1]));
1760 }
1761 if ($actopt[0]['maxprice'] > 0 && $realcost > $actopt[0]['maxprice']) {
1762 $realcost = $actopt[0]['maxprice'];
1763 if (intval($actopt[0]['hmany']) == 1 && intval($stept[1]) > 1) {
1764 $realcost = $actopt[0]['maxprice'] * $stept[1];
1765 }
1766 }
1767 $realcost = $actopt[0]['perperson'] == 1 ? ($realcost * $arrpeople[$num]['adults']) : $realcost;
1768 $tmpopr = VikBooking::sayOptionalsPlusIva($realcost, $actopt[0]['idiva']);
1769 ?>
1770 <tr class="vbo-bookingdet-summary-options">
1771 <td class="vbo-bookingdet-summary-options-title"><?php echo $counter == 1 ? JText::translate('VBEDITORDEREIGHT') : '&nbsp;'; ?></td>
1772 <td>
1773 <span class="vbo-bookingdet-summary-lbl"><?php echo ($stept[1] > 1 ? $stept[1]." " : "").$actopt[0]['name']; ?></span>
1774 </td>
1775 <td>
1776 <span class="vbo-bookingdet-summary-cost"><?php echo $currencyname." ".VikBooking::numberFormat(($after_tax ? $tmpopr : $realcost)); ?></span>
1777 </td>
1778 </tr>
1779 <?php
1780 }
1781 }
1782 //Custom extra costs
1783 if (!empty($or['extracosts'])) {
1784 $counter = 0;
1785 $cur_extra_costs = json_decode($or['extracosts'], true);
1786 foreach ($cur_extra_costs as $eck => $ecv) {
1787 $counter++;
1788 $ecv['idtax'] = isset($ecv['idtax']) ? $ecv['idtax'] : 0;
1789 ?>
1790 <tr class="vbo-bookingdet-summary-custcosts">
1791 <td class="vbo-bookingdet-summary-custcosts-title"><?php echo $counter == 1 ? JText::translate('VBPEDITBUSYEXTRACOSTS') : '&nbsp;'; ?></td>
1792 <td>
1793 <?php
1794 if (!empty($ecv['type'])) {
1795 ?>
1796 <span class="vbo-tooltip vbo-tooltip-top" data-tooltiptext="<?php echo JHtml::fetch('esc_attr', JText::translate('VBPSHOWSEASONSTHREE') . ': ' . $ecv['type']); ?>">
1797 <span class="vbo-bookingdet-summary-lbl"><?php echo $ecv['name']; ?></span>
1798 </span>
1799 <?php
1800 } else {
1801 ?>
1802 <span class="vbo-bookingdet-summary-lbl"><?php echo $ecv['name']; ?></span>
1803 <?php
1804 }
1805 ?>
1806 </td>
1807 <td>
1808 <span class="vbo-bookingdet-summary-cost"><?php echo $currencyname." ".VikBooking::numberFormat(($after_tax ? VikBooking::sayOptionalsPlusIva($ecv['cost'], $ecv['idtax']) : $ecv['cost'])); ?></span>
1809 </td>
1810 </tr>
1811 <?php
1812 }
1813 }
1814 }
1815 //vikbooking 1.1 coupon
1816 if (strlen((string)$row['coupon']) > 0) {
1817 $expcoupon = explode(";", $row['coupon']);
1818 ?>
1819 <tr class="vbo-bookingdet-summary-coupon">
1820 <td><?php echo JText::translate('VBCOUPON'); ?></td>
1821 <td>
1822 <span class="vbo-bookingdet-summary-lbl"><?php echo $expcoupon[2]; ?></span>
1823 </td>
1824 <td>
1825 <span class="vbo-bookingdet-summary-cost">- <?php echo $currencyname; ?> <?php echo VikBooking::numberFormat($expcoupon[1]); ?></span>
1826 </td>
1827 </tr>
1828 <?php
1829 }
1830 if ($row['refund'] > 0) {
1831 ?>
1832 <tr class="vbo-bookingdet-summary-totpaid vbo-bookingdet-summary-totrefunded">
1833 <td>
1834 <strong><?php echo JText::translate('VBOBOOKHISTORYTRF'); ?></strong>
1835 </td>
1836 <td>
1837 <span class="vbo-amount-refunded-lbl"><?php echo JText::translate('VBO_AMOUNT_REFUNDED'); ?></span>
1838 </td>
1839 <td>
1840 <div id="vbo-amountrefunded-cont">
1841 <span id="vbo-amountrefunded-current"><?php echo $currencyname.' '.VikBooking::numberFormat($row['refund']); ?></span>
1842 <span id="vbo-amountrefunded-edit" style="margin-left: 5px; cursor: pointer;"><?php VikBookingIcons::e('edit'); ?></span>
1843 </div>
1844 <div id="vbo-amountrefunded-modcont" style="display: none;">
1845 <span id="vbo-amountrefunded-cancedit" style="margin-right: 5px; cursor: pointer;"><?php VikBookingIcons::e('times'); ?></span>
1846 <span id="vbo-amountrefunded-new"><input type="number" step="any" name="newamountrefunded" value="" min="0" style="margin: 0;" placeholder="<?php echo $row['refund']; ?>" disabled /></span>
1847 <span id="vbo-amountrefunded-save"><button type="submit" class="btn btn-success"><?php echo JText::translate('VBAPPLYDISCOUNTSAVE'); ?></button></span>
1848 </div>
1849 </td>
1850 </tr>
1851 <?php
1852 }
1853 //Reservation Total
1854 //Taxes Breakdown (only if tot_taxes is greater than 0)
1855 $tax_breakdown = array();
1856 $base_aliq = 0;
1857 if (count($all_id_prices) > 0 && $row['tot_taxes'] > 0) {
1858 //only last type of price assuming that the tax breakdown is equivalent in case of different rates
1859 $q = "SELECT `p`.`id`,`p`.`name`,`p`.`idiva`,`t`.`aliq`,`t`.`breakdown` FROM `#__vikbooking_prices` AS `p` LEFT JOIN `#__vikbooking_iva` `t` ON `p`.`idiva`=`t`.`id` WHERE `p`.`id`=".intval(array_pop($all_id_prices))." LIMIT 1;";
1860 $dbo->setQuery($q);
1861 $dbo->execute();
1862 if ($dbo->getNumRows() > 0) {
1863 $breakdown_info = $dbo->loadAssoc();
1864 if (!empty($breakdown_info['breakdown']) && !empty($breakdown_info['aliq'])) {
1865 $tax_breakdown = json_decode($breakdown_info['breakdown'], true);
1866 $tax_breakdown = is_array($tax_breakdown) && count($tax_breakdown) > 0 ? $tax_breakdown : array();
1867 $base_aliq = $breakdown_info['aliq'];
1868 }
1869 }
1870 }
1871 //
1872 if ($printreceipt && $row['tot_taxes'] > 0) {
1873 // only when printing the receipt we display an additional row for the total amount of tax
1874 ?>
1875 <tr class="vbo-bookingdet-summary-total vbo-bookingdet-summary-totaltax">
1876 <td>
1877
1878 </td>
1879 <td>
1880 <span class="vbo-bookingdet-summary-lbl"><?php echo JText::translate('VBTOTALVAT'); ?></span>
1881 </td>
1882 <td>
1883 <span class="vbo-bookingdet-summary-cost"><?php echo $currencyname; ?> <?php echo VikBooking::numberFormat($row['tot_taxes']); ?></span>
1884 </td>
1885 </tr>
1886 <?php
1887 }
1888 ?>
1889 <tr class="vbo-bookingdet-summary-total">
1890 <td>
1891 <?php
1892 if (!$printreceipt) {
1893 ?>
1894 <span class="vbapplydiscsp" onclick="toggleDiscount(this);">
1895 <i class="<?php echo VikBookingIcons::i('chevron-down'); ?>" title="<?php echo htmlspecialchars(JText::translate('VBAPPLYDISCOUNT')); ?>"></i>
1896 </span>
1897 <?php
1898 }
1899 ?>
1900 </td>
1901 <td>
1902 <span class="vbo-bookingdet-summary-lbl"><?php echo JText::translate('VBEDITORDERNINE'); ?></span>
1903
1904 <div class="vbdiscenter" id="vbdiscenter" style="display: none;">
1905 <div class="vbdiscenter-entry">
1906 <span class="vbdiscenter-label"><?php echo JText::translate('VBTOTALVAT'); ?>:</span><span class="vbdiscenter-value"><?php echo $currencyname; ?> <input type="number" step="any" name="tot_taxes" value="<?php echo $row['tot_taxes']; ?>" size="4"/></span>
1907 </div>
1908 <?php
1909 if (count($tax_breakdown)) {
1910 foreach ($tax_breakdown as $tbkk => $tbkv) {
1911 $tax_break_cost = $row['tot_taxes'] * floatval($tbkv['aliq']) / $base_aliq;
1912 ?>
1913 <div class="vbdiscenter-entry vbdiscenter-entry-breakdown">
1914 <span class="vbdiscenter-label"><?php echo $tbkv['name']; ?>:</span><span class="vbdiscenter-value"><?php echo $currencyname; ?> <?php echo VikBooking::numberFormat($tax_break_cost); ?></span>
1915 </div>
1916 <?php
1917 }
1918 }
1919 ?>
1920 <div class="vbdiscenter-entry">
1921 <span class="vbdiscenter-label"><?php echo JText::translate('VBTOTALCITYTAX'); ?>:</span><span class="vbdiscenter-value"><?php echo $currencyname; ?> <input type="number" step="any" name="tot_city_taxes" value="<?php echo $row['tot_city_taxes']; ?>" size="4"/></span>
1922 </div>
1923 <div class="vbdiscenter-entry">
1924 <span class="vbdiscenter-label"><?php echo JText::translate('VBTOTALFEES'); ?>:</span><span class="vbdiscenter-value"><?php echo $currencyname; ?> <input type="number" step="any" name="tot_fees" value="<?php echo $row['tot_fees']; ?>" size="4"/></span>
1925 </div>
1926 <div class="vbdiscenter-entry">
1927 <span class="vbdiscenter-label hasTooltip"<?php echo !empty($otachannel_name) ? ' title="'.$otachannel_name.'"' : ''; ?>><?php echo JText::translate('VBTOTALCOMMISSIONS'); ?>:</span><span class="vbdiscenter-value"><?php echo $currencyname; ?> <input type="number" step="any" name="cmms" value="<?php echo $row['cmms']; ?>" size="4"/></span>
1928 </div>
1929 <div class="vbdiscenter-entry">
1930 <span class="vbdiscenter-label"><?php echo JText::translate('VBAPPLYDISCOUNT'); ?>:</span><span class="vbdiscenter-value"><?php echo $currencyname; ?> <input type="number" step="any" name="admindisc" value="<?php echo isset($expcoupon) ? (float)$expcoupon[1] : ''; ?>" size="4"/></span>
1931 </div>
1932 <div class="vbdiscenter-entrycentered">
1933 <button type="submit" class="btn btn-success"><?php echo JText::translate('VBAPPLYDISCOUNTSAVE'); ?></button>
1934 </div>
1935 </div>
1936 </td>
1937 <td>
1938 <span class="vbo-bookingdet-summary-cost"><?php echo (strlen($otacurrency) > 0 ? '('.$otacurrency.') '.$currencyname : $currencyname); ?> <?php echo VikBooking::numberFormat($row['total']); ?></span>
1939 </td>
1940 </tr>
1941 <?php
1942 if ($row['total'] > 0 && !$row['closure']) {
1943 $has_paid = ($row['totpaid'] > 0);
1944 $diff_to_pay = $has_paid ? ($row['total'] - $row['totpaid']) : 0;
1945 if ($has_paid || $row['status'] != 'standby') {
1946 ?>
1947 <tr class="vbo-bookingdet-summary-totpaid">
1948 <td>&nbsp;</td>
1949 <td><?php echo JText::translate('VBAMOUNTPAID'); ?></td>
1950 <td>
1951 <div id="vbo-amountpaid-cont">
1952 <span id="vbo-amountpaid-current"><?php echo $has_paid ? ($currencyname . ' ' . VikBooking::numberFormat($row['totpaid'])) : ''; ?></span>
1953 <span id="vbo-amountpaid-edit" style="margin-left: 5px; cursor: pointer;"><?php VikBookingIcons::e('edit'); ?></span>
1954 </div>
1955 <div id="vbo-amountpaid-modcont" style="display: none;">
1956 <span id="vbo-amountpaid-cancedit" style="margin-right: 5px; cursor: pointer;"><?php VikBookingIcons::e('times'); ?></span>
1957 <span id="vbo-amountpaid-new"><input type="number" step="any" name="newamountpaid" value="" min="0" style="margin: 0;" placeholder="<?php echo $has_paid ? $row['totpaid'] : ''; ?>" disabled /></span>
1958 <?php
1959 if ($payments) {
1960 ?>
1961 <span id="vbo-amountpaid-paymeth" style="margin: 0 5px; max-width: 160px;">
1962 <select name="newamountpaymeth" style="margin: 0;">
1963 <option value=""><?php echo JText::translate('VBPAYMENTMETHOD'); ?></option>
1964 <?php
1965 foreach ($payments as $pay) {
1966 ?>
1967 <option value="<?php echo JHtml::fetch('esc_attr', $pay['id'] . '_' . $pay['name']); ?>"><?php echo $pay['name']; ?></option>
1968 <?php
1969 }
1970 ?>
1971 </select>
1972 </span>
1973 <?php
1974 }
1975 ?>
1976 <span id="vbo-amountpaid-save"><button type="submit" class="btn btn-success"><?php echo JText::translate('VBAPPLYDISCOUNTSAVE'); ?></button></span>
1977 </div>
1978 </td>
1979 </tr>
1980 <?php
1981 }
1982 if ($diff_to_pay > 1 && $row['status'] != 'cancelled') {
1983 ?>
1984 <tr class="vbo-bookingdet-summary-totpaid vbo-bookingdet-summary-totremaining">
1985 <td>&nbsp;</td>
1986 <td>
1987 <div><?php echo JText::translate('VBTOTALREMAINING'); ?></div>
1988 <?php
1989 // enable second payment
1990 if (!$printreceipt && $row['status'] == 'confirmed' && !($row['paymcount'] > 0) && VikBooking::multiplePayments() && is_array($payment) && !empty($payment['id'])) {
1991 ?>
1992 <div style="margin-top: 5px;">
1993 <a href="index.php?option=com_vikbooking&amp;task=editorder&amp;makepay=1&amp;cid[]=<?php echo $row['id']; ?>" class="vbo-makepayable-link"><?php VikBookingIcons::e('credit-card'); ?> <?php echo JText::translate('VBMAKEORDERPAYABLE'); ?></a>
1994 </div>
1995 <?php
1996 }
1997 ?>
1998 </td>
1999 <td><?php echo $currencyname . ' ' . VikBooking::numberFormat($diff_to_pay); ?></td>
2000 </tr>
2001 <?php
2002 }
2003 }
2004 if (!$printreceipt && $row['status'] == 'confirmed' && VikBooking::multiplePayments() && is_array($payment) && !empty($payment['id']) && $row['checkout'] > time()) {
2005 /**
2006 * The amount payable can be modified by the admin.
2007 *
2008 * @since 1.14 (J) - 1.4.0 (WP)
2009 */
2010 ?>
2011 <tr class="vbo-bookingdet-summary-totpaid vbo-bookingdet-summary-totpayable">
2012 <td>&nbsp;</td>
2013 <td>
2014 <span class="vbo-amount-payable-lbl<?php echo $row['payable'] > 0 ? ' vbo-amount-payable-lbl-requested' : ''; ?>"><?php echo $row['payable'] > 0 ? JText::translate('VBO_AMOUNT_PAYABLE') : JText::translate('VBO_AMOUNT_PAYABLE_RQ'); ?></span>
2015 </td>
2016 <td>
2017 <div id="vbo-amountpayable-cont">
2018 <?php
2019 if ($row['payable'] > 0) {
2020 ?>
2021 <span id="vbo-amountpayable-current"><?php echo $currencyname . ' ' . VikBooking::numberFormat($row['payable']); ?></span>
2022 <?php
2023 }
2024 ?>
2025 <span id="vbo-amountpayable-edit" style="margin-left: 5px; cursor: pointer;"><?php VikBookingIcons::e('edit'); ?></span>
2026 </div>
2027 <div id="vbo-amountpayable-modcont" style="display: none;">
2028 <span id="vbo-amountpayable-cancedit" style="margin-right: 5px; cursor: pointer;"><?php VikBookingIcons::e('times'); ?></span>
2029 <span id="vbo-amountpayable-new"><input type="number" step="any" name="newamountpayable" value="" min="0" style="margin: 0;" placeholder="<?php echo $row['payable']; ?>" disabled /></span>
2030 <span id="vbo-amountpayable-save"><button type="submit" class="btn btn-success"><?php echo JText::translate('VBAPPLYDISCOUNTSAVE'); ?></button></span>
2031 </div>
2032 </td>
2033 </tr>
2034 <?php
2035 }
2036
2037 /**
2038 * Cancellation fee for cancelled bookings after the deadline.
2039 *
2040 * @since 1.16.0 (J) - 1.6.0 (WP)
2041 */
2042 if ($row['status'] == 'cancelled' && !$row['closure'] && $row['total'] > 0) {
2043 ?>
2044 <tr class="vbo-bookingdet-summary-cancfee">
2045 <td>&nbsp;</td>
2046 <td><?php echo JText::translate('VBO_CANC_FEE'); ?></td>
2047 <td>
2048 <div id="vbo-cancfee-cont">
2049 <span id="vbo-cancfee-current"><?php echo $currencyname.' '.VikBooking::numberFormat($row['canc_fee']); ?></span>
2050 <span id="vbo-cancfee-edit" style="margin-left: 5px; cursor: pointer;"><?php VikBookingIcons::e('edit'); ?></span>
2051 </div>
2052 <div id="vbo-cancfee-modcont" style="display: none;">
2053 <span id="vbo-cancfee-cancedit" style="margin-right: 5px; cursor: pointer;"><?php VikBookingIcons::e('times'); ?></span>
2054 <span id="vbo-cancfee-new"><input type="number" step="any" name="newcancfee" value="" min="0" style="margin: 0;" placeholder="<?php echo $row['canc_fee']; ?>" disabled /></span>
2055 <span id="vbo-cancfee-save"><button type="submit" class="btn btn-success"><?php echo JText::translate('VBAPPLYDISCOUNTSAVE'); ?></button></span>
2056 </div>
2057 </td>
2058 </tr>
2059 <?php
2060 }
2061 ?>
2062 </table>
2063 </div>
2064
2065 <!-- Define role to detect the supported hook -->
2066 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorder","type":"fieldset"} -->
2067
2068 <?php
2069 foreach ($bookingPanelForms as $legend => $form)
2070 {
2071 if (in_array($legend, ['buttons']))
2072 {
2073 // skip default forms
2074 continue;
2075 }
2076 ?>
2077 <div class="table-responsive">
2078 <h3><?php echo JText::translate($legend); ?></h3>
2079
2080 <?php echo $form; ?>
2081 </div>
2082 <?php
2083 }
2084 ?>
2085
2086 </div>
2087 </div>
2088 <?php
2089 if ($printreceipt) {
2090 $receipt_notes = VikBooking::getReceiptNotes();
2091 ?>
2092 <div class="vbo-receipt-notes-container">
2093 <div class="vbo-receipt-notes-inner">
2094 <div class="vbo-receipt-notes-val vbo-showin-print" id="vbo-receipt-notes-val"><?php echo $receipt_notes; ?></div>
2095 <div class="vbo-receipt-notes-tarea vbo-hidein-print">
2096 <textarea id="vbo-receipt-notes" placeholder="<?php echo JText::translate('VBORECEIPTNOTESDEF'); ?>"><?php echo htmlspecialchars($receipt_notes); ?></textarea>
2097 </div>
2098 </div>
2099 </div>
2100 <?php
2101 }
2102 ?>
2103 </div>
2104
2105 <div class="vbo-bookingdet-tab-cont" id="vbo-tab-admin" style="display: none;">
2106 <div class="vbo-bookingdet-innercontainer">
2107 <div class="vbo-bookingdet-admindata">
2108 <?php
2109 if (!$row['closure']) {
2110 ?>
2111 <div class="vbo-bookingdet-admin-entry">
2112 <label for="vbo-searchcust"><?php echo JText::translate(count($customer) ? 'VBOASSIGNNEWCUST' : 'VBFILLCUSTFIELDS'); ?></label>
2113 <span style="display: block;"><?php echo JText::translate('VBOSEARCHEXISTCUST'); ?></span>
2114 <span class="vbo-eorder-assigncust" style="margin-bottom: 1px;">
2115 <input type="text" id="vbo-searchcust" autocomplete="off" value="" placeholder="<?php echo JText::translate('VBOSEARCHCUSTBY'); ?>" size="30" style="margin-bottom: 0;" />
2116 </span>
2117 <span id="vbo-searchcust-loading">
2118 <?php VikBookingIcons::e('hourglass-half'); ?>
2119 </span>
2120 <input type="hidden" name="newcustid" id="newcustid" value="" />
2121 <div id="vbo-searchcust-res" style="position: absolute; background-color: #fff;"></div>
2122 <span class="vbo-eorder-assignnewcust" style="display: block; margin-top: 10px;">
2123 <a class="vbo-assign-customer" href="index.php?option=com_vikbooking&task=newcustomer&bid=<?php echo $row['id']; ?>&goto=<?php echo base64_encode($gotouri.'#tab-admin'); ?>">
2124 <?php VikBookingIcons::e('user-circle'); ?>
2125 <span><?php echo JText::translate('VBOCREATENEWCUST'); ?></span>
2126 </a>
2127 </span>
2128
2129 <?php
2130 if (isset($adminSidebarForms['customer']))
2131 {
2132 echo $adminSidebarForms['customer'];
2133 }
2134 ?>
2135
2136 </div>
2137 <?php
2138 }
2139 ?>
2140 <div class="vbo-bookingdet-admin-entry">
2141 <label for="newpayment"><?php echo JText::translate('VBPAYMENTMETHOD'); ?></label>
2142 <?php
2143 if (is_array($payment)) {
2144 ?>
2145 <span><?php echo $payment['name']; ?></span>
2146 <?php
2147 }
2148 $chpayment = '';
2149 if ($payments) {
2150 $chpayment = '<div><select name="newpayment" id="newpayment" onchange="changePayment();"><option value="">'.JText::translate('VBCHANGEPAYLABEL').'</option>';
2151 foreach ($payments as $pay) {
2152 $chpayment .= '<option value="'.$pay['id'].'">'.(is_array($payment) && $payment['id'] == $pay['id'] ? ' ::' : '').$pay['name'].'</option>';
2153 }
2154 $chpayment .= '</select></div>';
2155 }
2156 echo $chpayment;
2157 ?>
2158
2159 <!-- Define role to detect the supported hook -->
2160 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderAdministrationSidebar","key":"payment","type":"field"} -->
2161
2162 <?php
2163 if (isset($adminSidebarForms['payment']))
2164 {
2165 echo $adminSidebarForms['payment'];
2166 }
2167 ?>
2168
2169 </div>
2170 <?php
2171 $tn = VikBooking::getTranslator();
2172 $all_langs = $tn->getLanguagesList();
2173 if (count($all_langs) > 1) {
2174 ?>
2175 <div class="vbo-bookingdet-admin-entry">
2176 <label for="newlang"><?php echo JText::translate('VBOBOOKINGLANG'); ?></label>
2177 <select name="newlang" id="newlang" onchange="document.adminForm.submit();">
2178 <?php
2179 foreach ($all_langs as $lk => $lv) {
2180 ?>
2181 <option value="<?php echo $lk; ?>"<?php echo $row['lang'] == $lk ? ' selected="selected"' : ''; ?>><?php echo isset($lv['nativeName']) ? $lv['nativeName'] : $lv['name']; ?></option>
2182 <?php
2183 }
2184 ?>
2185 </select>
2186
2187 <!-- Define role to detect the supported hook -->
2188 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderAdministrationSidebar","key":"language","type":"field"} -->
2189
2190 <?php
2191 if (isset($adminSidebarForms['language']))
2192 {
2193 echo $adminSidebarForms['language'];
2194 }
2195 ?>
2196 </div>
2197 <?php
2198 }
2199 ?>
2200
2201 <!-- Define role to detect the supported hook -->
2202 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderAdministrationSidebar","type":"fieldset"} -->
2203
2204 <?php
2205 foreach ($adminSidebarForms as $legend => $form)
2206 {
2207 if (in_array($legend, ['customer', 'payment', 'language']))
2208 {
2209 // skip default forms
2210 continue;
2211 }
2212 ?>
2213 <div class="vbo-bookingdet-admin-entry">
2214 <h3><?php echo JText::translate($legend); ?></h3>
2215
2216 <?php echo $form; ?>
2217 </div>
2218 <?php
2219 }
2220 ?>
2221
2222 </div>
2223 <div class="vbo-bookingdet-noteslogs">
2224 <?php
2225 $history = $history_obj->loadHistory();
2226 ?>
2227 <div class="vbo-bookingdet-noteslogs-btns">
2228 <div class="vbo-bookingdet-noteslogs-btn vbo-bookingdet-noteslogs-btn-active" data-id="notes">
2229 <a href="javascript: void(0);" id="vbo-trig-notes" onclick="javascript: vbToggleNotes(this);"><?php VikBookingIcons::e('user-lock'); ?> <?php echo JText::translate('VBADMINNOTESTOGGLE'); ?></a>
2230 </div>
2231 <?php
2232 /**
2233 * Initialize chat instance by getting the proper channel name
2234 *
2235 * @since 1.12
2236 */
2237 if (empty($row['channel'])) {
2238 // front-end reservation chat handler
2239 $chat_channel = 'vikbooking';
2240 } else {
2241 $channelparts = explode('_', $row['channel']);
2242 // check if this is a meta search channel
2243 $is_meta_search = false;
2244 if (preg_match("/(customer).*[0-9]$/", $channelparts[0]) || !strcasecmp($channelparts[0], 'googlehotel') || !strcasecmp($channelparts[0], 'trivago')) {
2245 $is_meta_search = empty($row['idorderota']);
2246 }
2247 if ($is_meta_search) {
2248 // customer of type sales channel should use front-end reservation chat handler
2249 $chat_channel = 'vikbooking';
2250 } else {
2251 // let the getInstance method validate the channel chat handler
2252 $chat_channel = $row['channel'];
2253 }
2254 }
2255 $messaging = VikBooking::getVcmChatInstance($row['id'], $chat_channel);
2256 //
2257 if (!$printreceipt && !is_null($messaging)) {
2258 ?>
2259 <div class="vbo-bookingdet-noteslogs-btn" data-id="messaging">
2260 <a name="messaging" href="javascript: void(0);" id="vbo-trig-messaging" onclick="javascript: vbToggleMessaging(this);"><?php VikBookingIcons::e('comment-dots'); ?> <?php echo JText::translate('VBO_GUEST_MESSAGING'); ?></a>
2261 </div>
2262 <?php
2263 }
2264 if (!empty($row['paymentlog'])) {
2265 ?>
2266 <div class="vbo-bookingdet-noteslogs-btn" data-id="paylogs">
2267 <a href="javascript: void(0);" id="vbo-trig-paylogs" onclick="javascript: vbToggleLog(this);"><?php VikBookingIcons::e('credit-card'); ?> <?php echo JText::translate('VBPAYMENTLOGTOGGLE'); ?></a>
2268 <a name="paymentlog" href="javascript: void(0);"></a>
2269 </div>
2270 <?php
2271 }
2272 if (count($history)) {
2273 ?>
2274 <div class="vbo-bookingdet-noteslogs-btn" data-id="history">
2275 <a href="javascript: void(0);" id="vbo-trig-bookhistory" onclick="javascript: vbToggleHistory(this);"><?php VikBookingIcons::e('history'); ?> <?php echo JText::translate('VBOBOOKHISTORYTAB'); ?></a>
2276 </div>
2277 <script type="text/javascript">
2278 if (window.location.hash == '#bookhistory') {
2279 setTimeout(function() {
2280 jQuery(".vbo-bookingdet-tab[data-vbotab='vbo-tab-admin']").trigger('click');
2281 vbToggleHistory(document.getElementById('vbo-trig-bookhistory'));
2282 }, 500);
2283 }
2284 </script>
2285 <?php
2286 }
2287 ?>
2288 <div class="vbo-bookingdet-noteslogs-btn pro-feature" data-id="invnotes">
2289 <a href="javascript: void(0);" class="hasTooltip" id="vbo-trig-invnotes" onclick="javascript: vbToggleInvNotes(this);" title="<?php echo addslashes(JText::translate('VBBOOKINGINVNOTESHELP')); ?>"><?php VikBookingIcons::e('file-invoice'); ?> <?php echo JText::translate('VBBOOKINGINVNOTES'); ?></a>
2290 </div>
2291
2292 <!-- Define role to detect the supported hook -->
2293 <!-- {"rule":"customizer","event":"onDisplayViewVikBookingEditorderAdministration","type":"fieldset"} -->
2294
2295 <?php
2296 foreach ($adminPanelForms as $legend => $form)
2297 {
2298 $legendId = preg_replace("/[^a-zA-Z0-9_\-]+/", '', $legend);
2299 ?>
2300 <div class="vbo-bookingdet-noteslogs-btn" data-id="<?php echo $legendId; ?>">
2301 <a href="javascript: void(0);" class="hasTooltip" id="vbo-trig-<?php echo $legendId; ?>" onclick="javascript: vbToggleDynamicPanel(this, '#vboextrapanel-<?php echo $legendId; ?>');">
2302 <?php
2303 VikBookingIcons::e(!empty($adminFormsSetup->icons[$legend]) ? $adminFormsSetup->icons[$legend] : 'plug');
2304 echo JText::translate($legend);
2305 ?>
2306 </a>
2307 </div>
2308 <?php
2309 }
2310 ?>
2311 </div>
2312 <div class="vbo-bookingdet-noteslogs-cont">
2313 <div id="vbadminnotesdiv" class="vbo-extra-panel" style="display: block;">
2314 <textarea name="adminnotes" class="vbadminnotestarea"><?php echo strip_tags((string)$row['adminnotes']); ?></textarea>
2315 <input type="submit" name="updadmnotes" value="<?php echo JText::translate('VBADMINNOTESUPD'); ?>" class="btn btn-success" />
2316 </div>
2317 <?php
2318 if (count($history)) {
2319 ?>
2320 <div id="vbhistorydiv" class="vbo-extra-panel" style="display: none;">
2321 <div class="vbo-booking-history-container table-responsive">
2322 <table class="table">
2323 <thead>
2324 <tr class="vbo-booking-history-firstrow">
2325 <td class="vbo-booking-history-td-type"><?php echo JText::translate('VBOBOOKHISTORYLBLTYPE'); ?></td>
2326 <td class="vbo-booking-history-td-date"><?php echo JText::translate('VBOBOOKHISTORYLBLDATE'); ?></td>
2327 <td class="vbo-booking-history-td-descr"><?php echo JText::translate('VBOBOOKHISTORYLBLDESC'); ?></td>
2328 <td class="vbo-booking-history-td-totpaid"><?php echo JText::translate('VBOBOOKHISTORYLBLTPAID'); ?></td>
2329 <td class="vbo-booking-history-td-tot"><?php echo JText::translate('VBOBOOKHISTORYLBLTOT'); ?></td>
2330 </tr>
2331 </thead>
2332 <tbody>
2333 <?php
2334 foreach ($history as $hist) {
2335 $hdescr = strpos($hist['descr'], '<') !== false ? $hist['descr'] : nl2br($hist['descr']);
2336 ?>
2337 <tr class="vbo-booking-history-row">
2338 <td><?php echo $history_obj->validType($hist['type'], true); ?></td>
2339 <td><?php echo JHtml::fetch('date', $hist['dt'], 'Y-m-d H:i:s'); ?></td>
2340 <td><?php echo $hdescr; ?></td>
2341 <td><?php echo $currencyname.' '.VikBooking::numberFormat($hist['totpaid']); ?></td>
2342 <td><?php echo $currencyname.' '.VikBooking::numberFormat($hist['total']); ?></td>
2343 </tr>
2344 <?php
2345 }
2346 ?>
2347 </tbody>
2348 </table>
2349 </div>
2350 </div>
2351 <?php
2352 }
2353 ?>
2354 <div id="vbinvnotesdiv" class="vbo-extra-panel" style="display: none;">
2355 <textarea name="invnotes" id="invnotes" class="vbadminnotestarea"><?php echo $row['inv_notes']; ?></textarea>
2356 <input type="submit" name="updinvnotes" value="<?php echo JText::translate('VBADMINNOTESUPD'); ?>" class="btn btn-success" />
2357 <button type="button" class="btn vbo-config-btn btn-secondary pull-right" onclick="document.getElementById('invnotes-hid').value=document.getElementById('invnotes').value;document.getElementById('vbo-gen-invoice').submit();"><?php VikBookingIcons::e('file-invoice'); ?> <?php echo JText::translate('VBOGENBOOKINGINVOICE'); ?></button>
2358 </div>
2359 <?php
2360 if (!empty($row['paymentlog'])) {
2361 ?>
2362 <div id="vbpaymentlogdiv" class="vbo-extra-panel" style="display: none;">
2363 <?php
2364 // PCI Data Retrieval
2365 $cc_acl_denied = false;
2366 if (!empty($row['idorderota']) && !empty($row['channel'])) {
2367 $channel_source = $row['channel'];
2368 if (strpos($row['channel'], '_') !== false) {
2369 $channelparts = explode('_', $row['channel']);
2370 $channel_source = $channelparts[0];
2371 }
2372 $checkout_info = getdate($row['checkout']);
2373
2374 // validate ACL for credit card details
2375 if (!$canDo->authorise('core.admin', 'com_vikchannelmanager')) {
2376 // permissions to access VCM are required
2377 $cc_acl_denied = true;
2378 ?>
2379 <p class="err"><?php echo JText::translate('JERROR_ALERTNOAUTHOR'); ?></p>
2380 <?php
2381 } else {
2382 /**
2383 * Limit for accessing the credit card details has been changed to check-out
2384 * day at 23:59:59 + 10 extra days. It used to be at 23:59:59 on check-out day.
2385 *
2386 * @since 1.13
2387 */
2388 $cardlimit = mktime(23, 59, 59, $checkout_info['mon'], ($checkout_info['mday'] + 10), $checkout_info['year']);
2389 if (time() < $cardlimit) {
2390 $plain_log = htmlspecialchars($row['paymentlog']);
2391 if (stripos($plain_log, 'card number') !== false && strpos($plain_log, '****') !== false) {
2392 // log contains credit card details
2393 // Prepare modal (Credit Card Details)
2394 array_push($vbo_modals_html, $vbo_app->getJmodalHtml('vbo-vcm-pcid', JText::translate('GETFULLCARDDETAILS'), '', 'width: 80%; height: 60%; margin-left: -40%; top: 20% !important;'));
2395 // end Prepare modal
2396 ?>
2397 <div class="vcm-notif-pcidrq-container">
2398 <button type="button" class="btn vbo-config-btn vcm-pcid-launch" onclick="vboOpenJModal('vbo-vcm-pcid', 'index.php?option=com_vikchannelmanager&task=execpcid&channel_source=<?php echo $channel_source; ?>&otaid=<?php echo $row['idorderota']; ?>&tmpl=component');"><?php VikBookingIcons::e('credit-card'); ?> <?php echo JText::translate('GETFULLCARDDETAILS'); ?></button>
2399 </div>
2400 <?php
2401 }
2402 }
2403 }
2404 } elseif (empty($row['idorderota']) && !empty($row['paymentlog']) && $row['status'] == 'standby') {
2405 ?>
2406 <div class="vbo-eorder-emptyccdata">
2407 <a class="btn btn-warning" href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $row['id']; ?>&unset_cc=1" onclick="return confirm(Joomla.JText._('VBDELCONFIRM'));"><?php VikBookingIcons::e('broom'); ?> <?php echo JText::translate('VBO_EMPTY_DATA'); ?></a>
2408 </div>
2409 <?php
2410 }
2411
2412 if (!$cc_acl_denied) {
2413 ?>
2414 <pre><?php echo htmlspecialchars($row['paymentlog']); ?></pre>
2415 <?php
2416 }
2417 ?>
2418 </div>
2419
2420 <script type="text/javascript">
2421 if (window.location.hash == '#paymentlog') {
2422 setTimeout(function() {
2423 jQuery(".vbo-bookingdet-tab[data-vbotab='vbo-tab-admin']").trigger('click');
2424 vbToggleLog(document.getElementById('vbo-trig-paylogs'));
2425 }, 500);
2426 }
2427 </script>
2428 <?php
2429 }
2430 if (!$printreceipt && !is_null($messaging)) {
2431 ?>
2432 <div id="vbmessagingdiv" class="vbo-extra-panel" style="display: none;">
2433 <?php echo $messaging->renderChat(); ?>
2434 </div>
2435 <script type="text/javascript">
2436 jQuery(function() {
2437 if (window.location.hash == '#messaging') {
2438 setTimeout(function() {
2439 jQuery(".vbo-bookingdet-tab[data-vbotab='vbo-tab-admin']").trigger('click');
2440 vbToggleMessaging(document.getElementById('vbo-trig-messaging'));
2441 }, 100);
2442 }
2443 });
2444 </script>
2445 <?php
2446 }
2447
2448 foreach ($adminPanelForms as $legend => $form)
2449 {
2450 $legendId = preg_replace("/[^a-zA-Z0-9_\-]+/", '', $legend);
2451 ?>
2452 <div class="vbo-extra-panel" id="vboextrapanel-<?php echo $legendId; ?>" style="display: none;">
2453 <?php echo $form; ?>
2454 </div>
2455 <?php
2456 }
2457 ?>
2458 </div>
2459 </div>
2460 </div>
2461 </div>
2462
2463 <input type="hidden" name="task" value="editorder">
2464 <input type="hidden" name="vbo_active_tab" id="vbo_active_tab" value="">
2465 <input type="hidden" name="whereup" value="<?php echo $row['id']; ?>">
2466 <input type="hidden" name="cid[]" value="<?php echo $row['id']; ?>">
2467 <input type="hidden" name="option" value="com_vikbooking">
2468 <?php
2469 $tmpl = VikRequest::getVar('tmpl');
2470 if ($tmpl == 'component') {
2471 echo '<input type="hidden" name="tmpl" value="component" />';
2472 }
2473 $pgoto = VikRequest::getString('goto', '', 'request');
2474 if (in_array($pgoto, ['overv', 'ratesoverv'])) {
2475 echo '<input type="hidden" name="goto" value="' . $pgoto . '" />';
2476 }
2477 ?>
2478 </form>
2479 </div>
2480 <?php
2481 foreach ($vbo_modals_html as $modalhtml) {
2482 echo $modalhtml;
2483 }
2484 ?>
2485 <form action="index.php?option=com_vikbooking&amp;task=orders" method="post" id="vbo-gen-invoice">
2486 <input type="hidden" name="option" value="com_vikbooking" />
2487 <input type="hidden" name="task" value="orders" />
2488 <input type="hidden" name="cid[]" value="<?php echo $row['id']; ?>" />
2489 <input type="hidden" name="invnotes" id="invnotes-hid" value="" />
2490 </form>
2491
2492 <div class="vbo-modal-overlay-block vbo-modal-overlay-block-sms-email">
2493 <a class="vbo-modal-overlay-close" href="javascript: void(0);"></a>
2494 <div class="vbo-modal-overlay-content vbo-modal-overlay-content-large vbo-modal-overlay-content-sms-email">
2495
2496 <div class="vbo-modal-overlay-content-head vbo-modal-overlay-content-sms-email-head">
2497 <h3>
2498 <span></span>
2499 <span class="vbo-modal-overlay-close-times" onclick="vboToggleSendEmail();">&times;</span>
2500 </h3>
2501 </div>
2502
2503 <div class="vbo-modal-overlay-content-body vbo-modal-overlay-content-body-scroll">
2504
2505 <div id="vbo-overlay-sms-cont" style="display: none;">
2506 <h4 style="display: none;"><?php echo JText::translate('VBSENDSMSACTION'); ?>: <span id="smstophone-lbl"><?php echo $row['phone']; ?></span></h4>
2507 <form action="index.php?option=com_vikbooking" method="post" id="vbo-modal-form-sms">
2508 <div class="vbo-calendar-cfield-entry">
2509 <label for="smscont"><?php echo JText::translate('VBSENDSMSCUSTCONT'); ?></label>
2510 <span><textarea name="smscont" id="smscont" style="width: 99%; min-width: 99%;max-width: 99%; height: 120px;"></textarea></span>
2511 </div>
2512 <input type="hidden" name="phone" id="smstophone" value="<?php echo $row['phone']; ?>" />
2513 <input type="hidden" name="goto" value="<?php echo urlencode('index.php?option=com_vikbooking&task=editorder&cid[]='.$row['id']); ?>" />
2514 <input type="hidden" name="task" value="sendcustomsms" />
2515 </form>
2516 </div>
2517
2518 <div id="vbo-overlay-email-cont" style="display: none;">
2519 <h4 style="display: none;"><?php echo JText::translate('VBSENDEMAILACTION'); ?>: <span id="emailto-lbl"><?php echo $row['custmail']; ?></span></h4>
2520 <form action="index.php?option=com_vikbooking" method="post" enctype="multipart/form-data" id="vbo-modal-form-email">
2521 <input type="hidden" name="bid" value="<?php echo $row['id']; ?>" />
2522 <?php
2523 $cur_emtpl = array();
2524 $q = "SELECT `setting` FROM `#__vikbooking_config` WHERE `param`='customemailtpls';";
2525 $dbo->setQuery($q);
2526 $dbo->execute();
2527 if ($dbo->getNumRows() > 0) {
2528 $cur_emtpl = $dbo->loadResult();
2529 $cur_emtpl = empty($cur_emtpl) ? array() : json_decode($cur_emtpl, true);
2530 $cur_emtpl = is_array($cur_emtpl) ? $cur_emtpl : array();
2531 }
2532 if (count($cur_emtpl) > 0) {
2533 ?>
2534 <div class="vbo-calendar-custmail-tpls-wrap">
2535 <select id="emtpl-customemail" onchange="vboLoadEmailTpl(this.value);">
2536 <option value=""><?php echo JText::translate('VBEMAILCUSTFROMTPL'); ?></option>
2537 <?php
2538 foreach ($cur_emtpl as $emk => $emv) {
2539 ?>
2540 <optgroup label="<?php echo $emv['emailsubj']; ?>">
2541 <option value="<?php echo $emk; ?>"><?php echo JText::translate('VBEMAILCUSTFROMTPLUSE'); ?></option>
2542 <option value="rm<?php echo $emk; ?>"><?php echo JText::translate('VBEMAILCUSTFROMTPLRM'); ?></option>
2543 </optgroup>
2544 <?php
2545 }
2546 ?>
2547 </select>
2548 </div>
2549 <?php
2550 }
2551
2552 /**
2553 * Load all conditional text special tags.
2554 *
2555 * @since 1.14 (J) - 1.4.0 (WP)
2556 */
2557 $extra_btns = array();
2558 $condtext_tags = VikBooking::getConditionalRulesInstance()->getSpecialTags();
2559 if (count($condtext_tags)) {
2560 $condtext_tags = array_keys($condtext_tags);
2561 foreach ($condtext_tags as $tag) {
2562 array_push($extra_btns, '<button type="button" class="btn btn-secondary btn-small vbo-condtext-specialtag-btn" onclick="setSpecialTplTag(\'emailcont\', \'' . $tag . '\');">' . $tag . '</button>');
2563 }
2564 }
2565 //
2566 ?>
2567 <div class="vbo-calendar-cfields-wrap">
2568 <div class="vbo-calendar-cfield-entry">
2569 <label for="emailsubj"><?php echo JText::translate('VBSENDEMAILCUSTSUBJ'); ?></label>
2570 <span><input type="text" name="emailsubj" id="emailsubj" value="" size="30" /></span>
2571 </div>
2572 <div class="vbo-calendar-cfield-entry">
2573 <label for="emailcont"><?php echo JText::translate('VBSENDEMAILCUSTCONT'); ?></label>
2574 <?php
2575 $special_tags_base = array(
2576 '{customer_name}',
2577 '{booking_id}',
2578 '{checkin_date}',
2579 '{checkout_date}',
2580 '{num_nights}',
2581 '{rooms_booked}',
2582 '{rooms_names}',
2583 '{tot_adults}',
2584 '{tot_children}',
2585 '{tot_guests}',
2586 '{total}',
2587 '{total_paid}',
2588 '{remaining_balance}',
2589 '{booking_link}',
2590 );
2591
2592 $special_tags_base_html = '';
2593 foreach ($special_tags_base as $sp_tag) {
2594 $special_tags_base_html .= '<button type="button" class="btn btn-secondary btn-small" onclick="setSpecialTplTag(\'emailcont\', \'' . $sp_tag . '\');">' . $sp_tag . '</button>' . "\n";
2595 }
2596
2597 /**
2598 * Use the rich text editor (visual editor) to build custom email messages.
2599 *
2600 * @since 1.15.0 (J) - 1.5.0 (WP)
2601 */
2602 $tarea_attr = array(
2603 'id' => 'emailcont',
2604 'rows' => '7',
2605 'cols' => '170',
2606 'style' => 'width: 99%; min-width: 99%; max-width: 99%; height: 120px; margin-bottom: 1px;',
2607 );
2608 $editor_opts = array(
2609 'modes' => array(
2610 'text',
2611 'visual',
2612 ),
2613 );
2614 $editor_btns = $special_tags_base;
2615 if (count($condtext_tags)) {
2616 $editor_btns = array_merge($editor_btns, $condtext_tags);
2617 }
2618 echo $vbo_app->renderVisualEditor('emailcont', '', $tarea_attr, $editor_opts, $editor_btns);
2619 ?>
2620 <div class="btn-group pull-left vbo-smstpl-bgroup vbo-custmail-bgroup vik-contentbuilder-textmode-sptags">
2621 <?php echo $special_tags_base_html . "\n" . implode("\n", $extra_btns); ?>
2622 </div>
2623 </div>
2624 <div class="vbo-calendar-cfield-entry">
2625 <label for="emailattch"><?php echo JText::translate('VBSENDEMAILCUSTATTCH'); ?></label>
2626 <span><input type="file" name="emailattch" id="emailattch" /></span>
2627 </div>
2628 <div class="vbo-calendar-cfield-entry">
2629 <label for="emailfrom"><?php echo JText::translate('VBSENDEMAILCUSTFROM'); ?></label>
2630 <span><input type="text" name="emailfrom" id="emailfrom" value="<?php echo VikBooking::getSenderMail(); ?>" size="30" /></span>
2631 </div>
2632 </div>
2633 <input type="hidden" name="email" id="emailto" value="<?php echo $row['custmail']; ?>" />
2634 <input type="hidden" name="goto" value="<?php echo urlencode('index.php?option=com_vikbooking&task=editorder&cid[]='.$row['id']); ?>" />
2635 <input type="hidden" name="task" value="sendcustomemail" />
2636 </form>
2637 </div>
2638
2639 </div>
2640
2641 <div class="vbo-modal-overlay-content-footer">
2642 <div class="vbo-modal-overlay-content-footer-right">
2643 <div id="vbo-modal-footer-sms" style="display: none;">
2644 <button type="submit" class="btn vbo-config-btn" onclick="document.getElementById('vbo-modal-form-sms').submit();"><?php VikBookingIcons::e('comment'); ?> <?php echo JText::translate('VBSENDSMSACTION'); ?></button>
2645 </div>
2646 <div id="vbo-modal-footer-email" style="display: none;">
2647 <button type="submit" class="btn vbo-config-btn" onclick="document.getElementById('vbo-modal-form-email').submit();"><?php VikBookingIcons::e('envelope'); ?> <?php echo JText::translate('VBSENDEMAILACTION'); ?></button>
2648 </div>
2649 </div>
2650 </div>
2651
2652 </div>
2653 </div>
2654
2655 <script type="text/javascript">
2656 var vbo_overlay_on = false;
2657 var vbo_print_only = false;
2658 if (jQuery.isFunction(jQuery.fn.tooltip)) {
2659 jQuery(".hasTooltip").tooltip();
2660 }
2661 function vboToggleSendSMS() {
2662 var cur_phone = jQuery("#smstophone").val();
2663 var phone_set = jQuery("#custphone").trigger('vboupdatephonenumber').val();
2664 if (phone_set.length && phone_set != cur_phone) {
2665 jQuery("#smstophone").val(phone_set);
2666 jQuery("#smstophone-lbl").text(phone_set);
2667 }
2668
2669 // toggle email/sms contents
2670 jQuery("#vbo-overlay-email-cont, #vbo-modal-footer-email").hide();
2671 jQuery("#vbo-overlay-sms-cont, #vbo-modal-footer-sms").show();
2672 var use_modal_title = jQuery("#vbo-overlay-sms-cont").find('h4').first().html();
2673 jQuery('.vbo-modal-overlay-content-sms-email-head').find('h3').find('span').first().html(use_modal_title);
2674
2675 jQuery(".vbo-modal-overlay-block-sms-email").fadeToggle(400, function() {
2676 if (jQuery(".vbo-modal-overlay-block-sms-email").is(":visible")) {
2677 vbo_overlay_on = true;
2678 } else {
2679 vbo_overlay_on = false;
2680 }
2681 });
2682 }
2683 function vboToggleSendEmail() {
2684 var cur_email = jQuery("#emailto").val();
2685 var email_set = jQuery("#custmail").val();
2686 if (email_set.length && email_set != cur_email) {
2687 jQuery("#emailto").val(email_set);
2688 jQuery("#emailto-lbl").text(email_set);
2689 }
2690
2691 // toggle email/sms contents
2692 jQuery("#vbo-overlay-sms-cont, #vbo-modal-footer-sms").hide();
2693 jQuery("#vbo-overlay-email-cont, #vbo-modal-footer-email").show();
2694 var use_modal_title = jQuery("#vbo-overlay-email-cont").find('h4').first().html();
2695 jQuery('.vbo-modal-overlay-content-sms-email-head').find('h3').find('span').first().html(use_modal_title);
2696
2697 jQuery(".vbo-modal-overlay-block-sms-email").fadeToggle(400, function() {
2698 if (jQuery(".vbo-modal-overlay-block-sms-email").is(":visible")) {
2699 vbo_overlay_on = true;
2700 } else {
2701 vbo_overlay_on = false;
2702 }
2703 });
2704 }
2705 function vboKeyupEmail(event) {
2706 if (event.key && event.key == 'Enter') {
2707 event.preventDefault();
2708 document.adminForm.submit();
2709 return;
2710 }
2711 jQuery('.vbo-bookingdet-save-email').show();
2712 }
2713 function setSpecialTplTag(taid, tpltag) {
2714 var tplobj = document.getElementById(taid);
2715 if (tplobj != null) {
2716 var start = tplobj.selectionStart;
2717 var end = tplobj.selectionEnd;
2718 tplobj.value = tplobj.value.substring(0, start) + tpltag + tplobj.value.substring(end);
2719 tplobj.selectionStart = tplobj.selectionEnd = start + tpltag.length;
2720 tplobj.focus();
2721 }
2722 }
2723 jQuery(function() {
2724 // register to the event emitted when a new payment is made through the virtual terminal widget
2725 document.addEventListener('vbo_new_payment_transaction', (e) => {
2726 if (!e || !e.detail || !e.detail.hasOwnProperty('tn') || !e.detail['tn']) {
2727 // do nothing
2728 return;
2729 }
2730 // reload the page to display the updated information
2731 location.reload();
2732 });
2733 // register to the event emitted when a booking is modified through an admin widget
2734 document.addEventListener('vbo_booking_modified', (e) => {
2735 if (!e || !e.detail || !e.detail.hasOwnProperty('bid') || !e.detail['bid']) {
2736 // do nothing
2737 return;
2738 }
2739 // reload the page to display the new information about the booking just modified
2740 location.reload();
2741 });
2742 // remove overbooking flag
2743 jQuery('.vbo-label-overbooking').on('click', function() {
2744 if (confirm(Joomla.JText._('VBO_CONF_RM_OVERBOOKING_FLAG'))) {
2745 VBOCore.doAjax(
2746 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=bookings.delete_type_flag'); ?>",
2747 {
2748 bid: '<?php echo $row['id']; ?>',
2749 flag: 'overbooking',
2750 },
2751 (success) => {
2752 // remove "overbooking" label
2753 let parent_label = jQuery('.vbo-bookdet-container').find('.vbo-label-overbooking').parent('.label');
2754 jQuery('.vbo-bookdet-container').find('.vbo-label-overbooking').remove();
2755 parent_label.text(parent_label.text().replace(' / ', ''));
2756 },
2757 (error) => {
2758 alert(error.responseText);
2759 }
2760 );
2761 }
2762 });
2763 // sessionStorage for current tab
2764 if (typeof sessionStorage !== 'undefined' && !window.location.hash && <?php echo $printreceipt ? 'false' : 'true'; ?>) {
2765 var curtab = sessionStorage.getItem('vboEditOrderTab<?php echo $row['id']; ?>');
2766
2767 setTimeout(() => {
2768 let link = jQuery('.vbo-bookingdet-noteslogs-btn[data-id="' + curtab + '"] a');
2769
2770 if (link.length) {
2771 jQuery(".vbo-bookingdet-tab[data-vbotab='vbo-tab-admin']").trigger('click');
2772 link.trigger('click');
2773 }
2774 }, 128);
2775 }
2776 if (window.location.hash == '#tab-admin') {
2777 setTimeout(function() {
2778 jQuery(".vbo-bookingdet-tab[data-vbotab='vbo-tab-admin']").trigger('click');
2779 }, 100);
2780 }
2781 // Search customer - Start
2782 var vbocustsdelay = (function() {
2783 var timer = 0;
2784 return function(callback, ms) {
2785 clearTimeout(timer);
2786 timer = setTimeout(callback, ms);
2787 };
2788 })();
2789 function vboCustomerSearch(words) {
2790 jQuery("#vbo-searchcust-res").hide().html("");
2791 jQuery("#vbo-searchcust-loading").show();
2792 var jqxhr = jQuery.ajax({
2793 type: "POST",
2794 url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=searchcustomer'); ?>",
2795 data: {
2796 kw: words,
2797 tmpl: "component"
2798 }
2799 }).done(function(cont) {
2800 if (cont) {
2801 var obj_res = typeof cont === 'string' ? JSON.parse(cont) : cont;
2802 customers_search_vals = obj_res[0];
2803 jQuery("#vbo-searchcust-res").html(obj_res[1]);
2804 } else {
2805 customers_search_vals = "";
2806 jQuery("#vbo-searchcust-res").html("----");
2807 }
2808 jQuery("#vbo-searchcust-res").show();
2809 jQuery("#vbo-searchcust-loading").hide();
2810 }).fail(function() {
2811 jQuery("#vbo-searchcust-loading").hide();
2812 alert("Error Searching.");
2813 });
2814 }
2815 jQuery("#vbo-searchcust").keyup(function(event) {
2816 vbocustsdelay(function() {
2817 var keywords = jQuery("#vbo-searchcust").val();
2818 var chars = keywords.length;
2819 if (chars > 1) {
2820 if ((event.which > 96 && event.which < 123) || (event.which > 64 && event.which < 91) || event.which == 13) {
2821 vboCustomerSearch(keywords);
2822 }
2823 } else {
2824 if (jQuery("#vbo-searchcust-res").is(":visible")) {
2825 jQuery("#vbo-searchcust-res").hide();
2826 }
2827 }
2828 }, 600);
2829 });
2830 jQuery("body").on("click", ".vbo-custsearchres-entry", function() {
2831 var custid = jQuery(this).attr("data-custid");
2832 if (confirm('<?php echo addslashes(JText::translate('VBOASSIGNNEWCUSTCONF')); ?>')) {
2833 jQuery('#newcustid').val(custid);
2834 document.adminForm.submit();
2835 return;
2836 }
2837 });
2838 // Search customer - End
2839 jQuery(document).mouseup(function(e) {
2840 if (!vbo_overlay_on) {
2841 return false;
2842 }
2843 var vbo_overlay_cont = jQuery(".vbo-modal-overlay-content-sms-email");
2844 if (!vbo_overlay_cont.is(e.target) && vbo_overlay_cont.has(e.target).length === 0 && !jQuery(e.target).is('svg')) {
2845 jQuery(".vbo-modal-overlay-block-sms-email").fadeOut();
2846 vbo_overlay_on = false;
2847 }
2848 });
2849 jQuery(document).keyup(function(e) {
2850 if (e.keyCode == 27 && vbo_overlay_on) {
2851 jQuery(".vbo-modal-overlay-block-sms-email").fadeOut();
2852 vbo_overlay_on = false;
2853 }
2854 });
2855 jQuery(".vbo-bookingdet-tab").click(function() {
2856 var newtabrel = jQuery(this).attr('data-vbotab');
2857 var oldtabrel = jQuery(".vbo-bookingdet-tab-active").attr('data-vbotab');
2858 if (newtabrel == oldtabrel) {
2859 return;
2860 }
2861 if (newtabrel == 'vbo-tab-details' && typeof sessionStorage !== 'undefined') {
2862 sessionStorage.setItem('vboEditOrderTab<?php echo $row['id']; ?>', 'details');
2863 }
2864 jQuery(".vbo-bookingdet-tab").removeClass("vbo-bookingdet-tab-active");
2865 jQuery(this).addClass("vbo-bookingdet-tab-active");
2866 jQuery("#"+oldtabrel).hide();
2867 jQuery("#"+newtabrel).fadeIn();
2868 jQuery("#vbo_active_tab").val(newtabrel);
2869 });
2870 jQuery(".vbo-bookingdet-tab[data-vbotab='<?php echo $pactive_tab; ?>']").trigger('click');
2871 // edit amount paid
2872 jQuery('#vbo-amountpaid-edit').click(function() {
2873 jQuery('#vbo-amountpaid-cont').hide();
2874 jQuery('#vbo-amountpaid-modcont').show();
2875 jQuery('input[name="newamountpaid"]').prop('disabled', false);
2876 if (jQuery('input[name="newamountrefunded"]').length) {
2877 jQuery('input[name="newamountrefunded"]').val('');
2878 }
2879 });
2880 jQuery('#vbo-amountpaid-cancedit').click(function() {
2881 jQuery('#vbo-amountpaid-modcont').hide();
2882 jQuery('#vbo-amountpaid-cont').show();
2883 });
2884 // edit amount refunded
2885 jQuery('#vbo-amountrefunded-edit').click(function() {
2886 jQuery('#vbo-amountrefunded-cont').hide();
2887 jQuery('#vbo-amountrefunded-modcont').show();
2888 jQuery('input[name="newamountrefunded"]').prop('disabled', false);
2889 if (jQuery('input[name="newamountpaid"]').length) {
2890 jQuery('input[name="newamountpaid"]').val('');
2891 }
2892 });
2893 jQuery('#vbo-amountrefunded-cancedit').click(function() {
2894 jQuery('#vbo-amountrefunded-modcont').hide();
2895 jQuery('#vbo-amountrefunded-cont').show();
2896 });
2897 // edit amount payable
2898 jQuery('#vbo-amountpayable-edit').click(function() {
2899 jQuery('#vbo-amountpayable-cont').hide();
2900 jQuery('#vbo-amountpayable-modcont').show();
2901 jQuery('input[name="newamountpayable"]').prop('disabled', false);
2902 });
2903 jQuery('#vbo-amountpayable-cancedit').click(function() {
2904 jQuery('#vbo-amountpayable-modcont').hide();
2905 jQuery('#vbo-amountpayable-cont').show();
2906 });
2907 // edit cancellation fee
2908 jQuery('#vbo-cancfee-edit').click(function() {
2909 jQuery('#vbo-cancfee-cont').hide();
2910 jQuery('#vbo-cancfee-modcont').show();
2911 jQuery('input[name="newcancfee"]').prop('disabled', false);
2912 });
2913 jQuery('#vbo-cancfee-cancedit').click(function() {
2914 jQuery('#vbo-cancfee-modcont').hide();
2915 jQuery('#vbo-cancfee-cont').show();
2916 });
2917 // chat listener
2918 if (typeof VCMChat !== 'undefined') {
2919 jQuery(window).on('chatsync', function(e) {
2920 if (!jQuery("#vcm-chat-audio-notification").length) {
2921 jQuery("body").append("<audio id=\"vcm-audio-notification\" preload=\"auto\"><source type=\"audio/mp3\" src=\"<?php echo VCM_ADMIN_URI; ?>assets/css/audio/new_chat_message.mp3\"></source></audio>");
2922 }
2923 try {
2924 var promise = document.getElementById('vcm-audio-notification').play();
2925 console.log(promise);
2926 } catch (err) {
2927 console.warn('Could not play sound', err);
2928 }
2929 });
2930 }
2931
2932 // zoom-able avatars
2933 jQuery('.vbo-customer-info-box-avatar').each(function() {
2934 var img = jQuery(this).find('img');
2935 if (!img.length) {
2936 return;
2937 }
2938 // register click listener
2939 img.on('click', function(e) {
2940 // stop events propagation
2941 e.preventDefault();
2942 e.stopPropagation();
2943
2944 // check for caption
2945 var caption = jQuery(this).attr('data-caption');
2946
2947 // build modal content
2948 var zoom_modal = jQuery('<div></div>').addClass('vbo-modal-overlay-block vbo-modal-overlay-zoom-image').css('display', 'block');
2949 var zoom_dismiss = jQuery('<a></a>').addClass('vbo-modal-overlay-close');
2950 zoom_dismiss.on('click', function() {
2951 jQuery('.vbo-modal-overlay-zoom-image').fadeOut();
2952 });
2953 zoom_modal.append(zoom_dismiss);
2954 var zoom_content = jQuery('<div></div>').addClass('vbo-modal-overlay-content vbo-modal-overlay-content-zoom-image');
2955 var zoom_head = jQuery('<div></div>').addClass('vbo-modal-overlay-content-head');
2956 var zoom_head_title = jQuery('<span></span>');
2957 if (caption) {
2958 zoom_head_title.text(caption);
2959 }
2960 var zoom_head_close = jQuery('<span></span>').addClass('vbo-modal-overlay-close-times').html('&times;');
2961 zoom_head_close.on('click', function() {
2962 jQuery('.vbo-modal-overlay-zoom-image').fadeOut();
2963 });
2964 zoom_head.append(zoom_head_title).append(zoom_head_close);
2965 var zoom_body = jQuery('<div></div>').addClass('vbo-modal-overlay-content-body vbo-modal-overlay-content-body-scroll');
2966 var zoom_image = jQuery('<div></div>').addClass('vbo-modal-zoom-image-wrap');
2967 zoom_image.append(jQuery(this).clone());
2968 zoom_body.append(zoom_image);
2969 zoom_content.append(zoom_head).append(zoom_body);
2970 zoom_modal.append(zoom_content);
2971 // append modal to body
2972 if (jQuery('.vbo-modal-overlay-zoom-image').length) {
2973 jQuery('.vbo-modal-overlay-zoom-image').remove();
2974 }
2975 jQuery('body').append(zoom_modal);
2976 });
2977 });
2978
2979 });
2980 var cur_emtpl = <?php echo json_encode($cur_emtpl); ?>;
2981 function vboLoadEmailTpl(tplind) {
2982 if (!(tplind.length > 0)) {
2983 jQuery('#emailsubj').val('');
2984 jQuery('#emailcont').val('').trigger('change');
2985 return true;
2986 }
2987 if (tplind.substr(0, 2) == 'rm') {
2988 if (confirm(Joomla.JText._('VBDELCONFIRM'))) {
2989 document.location.href = 'index.php?option=com_vikbooking&task=rmcustomemailtpl&cid[]=<?php echo $row['id']; ?>&tplind='+tplind.substr(2);
2990 }
2991 return false;
2992 }
2993 if (!cur_emtpl.hasOwnProperty(tplind)) {
2994 jQuery('#emailsubj').val('');
2995 jQuery('#emailcont').val('').trigger('change');
2996 return true;
2997 }
2998 jQuery('#emailsubj').val(cur_emtpl[tplind]['emailsubj']);
2999 jQuery('#emailcont').val(cur_emtpl[tplind]['emailcont']).trigger('change');
3000 jQuery('#emailfrom').val(cur_emtpl[tplind]['emailfrom']);
3001 return true;
3002 }
3003 <?php
3004 $pcustomemail = VikRequest::getInt('customemail', '', 'request');
3005 if ($pcustomemail > 0) {
3006 ?>
3007 vboToggleSendEmail();
3008 <?php
3009 }
3010 if ($printreceipt) {
3011 ?>
3012 jQuery(function() {
3013 jQuery('button, .vbo-bookingdet-innertop').hide();
3014 jQuery('body').find('a').each(function(k, v) {
3015 jQuery(this).replaceWith(jQuery(this).html());
3016 });
3017 jQuery('body').find("input[type='text']").each(function(k, v) {
3018 jQuery(this).replaceWith(jQuery(this).val());
3019 });
3020 });
3021 function vboMakePrintOnly() {
3022 vbo_print_only = true;
3023 jQuery(".vbo-receipt-numdate-block").remove();
3024 jQuery("#vbo-receipt-print-btn-name").text("<?php echo addslashes(JText::translate('VBOPRINT')); ?>");
3025 }
3026 function vboLaunchPrintReceipt() {
3027 var rcnotes = jQuery('#vbo-receipt-notes').val();
3028 var rnewnum = jQuery('#vbo-receipt-num-inp').val();
3029 if (rcnotes.length) {
3030 if (rcnotes.indexOf('<') < 0) {
3031 rcnotes = rcnotes.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br />$2');
3032 }
3033 jQuery('#vbo-receipt-notes-val').html(rcnotes);
3034 } else {
3035 jQuery('.vbo-receipt-notes-container').remove();
3036 }
3037 if (vbo_print_only === true) {
3038 window.print();
3039 return;
3040 }
3041 jQuery.ajax({
3042 type: "POST",
3043 url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=updatereceiptnum'); ?>",
3044 data: {
3045 newnum: rnewnum,
3046 newnotes: rcnotes,
3047 oid: "<?php echo $row['id']; ?>"
3048 }
3049 }).done(function(res) {
3050 window.print();
3051 }).fail(function() {
3052 alert('Could not update the next receipt number.')
3053 window.print();
3054 });
3055 }
3056 <?php
3057 }
3058 ?>
3059 </script>
3060