PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
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
← All changes | admin/views/orders/tmpl/default.php +257 -225 1.6.4 → 1.8.16 View file →
@@ -49,9 +49,10 @@
49 49
50 50 $cid = VikRequest::getVar('cid', array());
51 51 $pcust_id = $app->getUserStateFromRequest("vbo.orders.cust_id", 'cust_id', 0, 'int');
52 52 $pconfirmnumber = VikRequest::getString('confirmnumber', '', 'request');
53 -//Color tags
53 +
54 +// color tags
54 55 $colortags = VikBooking::loadBookingsColorTags();
55 56 $bctags_tip = '';
56 57 if (count($colortags) > 0) {
57 58 $bctags_tip = '<div class=\"vbo-blist-tip-bctag-subtip-inner\">';
@@ -59,9 +60,8 @@
59 60 $bctags_tip .= '<div class=\"vbo-blist-tip-bctag-subtip-circle hasTooltip\" data-ctagkey=\"'.$ctagk.'\" data-ctagcolor=\"'.$ctagv['color'].'\" title=\"'.addslashes(JText::translate($ctagv['name'])).'\"><div class=\"vbo-blist-tip-bctag-subtip-circlecont\" style=\"background-color: '.$ctagv['color'].';\"></div></div>';
60 61 }
61 62 $bctags_tip .= '</div>';
62 63 }
63 -//
64 64
65 65 if (empty($rows)) {
66 66 $rows = array();
67 67 ?>
@@ -66,9 +66,9 @@
66 66 $rows = array();
67 67 ?>
68 68 <p class="warn"><?php echo JText::translate('VBNOORDERSFOUND'); ?></p>
69 69 <?php
70 - if (defined('ABSPATH') && function_exists('wp_die')) {
70 + if (VBOPlatformDetection::isWordPress()) {
71 71 /**
72 72 * In case of no bookings found, we check whether bookings can be imported from third party plugins.
73 73 *
74 74 * @wponly we do this only on WP.
@@ -146,8 +146,10 @@
146 146 jQuery('#confirmnumber').val(search_hint).focus();
147 147 }
148 148
149 149 jQuery(function() {
150 +
151 + // register context menu
150 152 jQuery('.vbo-context-menu-searchtype').vboContextMenu({
151 153 placement: 'bottom-left',
152 154 buttons: [
153 155 {
@@ -183,8 +185,19 @@
183 185 },
184 186 },
185 187 ],
186 188 });
189 +
190 + // register to the event emitted when a booking is modified through an admin widget
191 + document.addEventListener('vbo_booking_modified', (e) => {
192 + if (!e || !e.detail || !e.detail.hasOwnProperty('bid') || !e.detail['bid']) {
193 + // do nothing
194 + return;
195 + }
196 + // reload the page to display the new information about the booking just modified
197 + location.reload();
198 + });
199 +
187 200 });
188 201 </script>
189 202
190 203 <form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm" class="vbo-allbookings-fm">
@@ -233,9 +246,9 @@
233 246 <option value="-1"<?php echo $pchannel == '-1' ? ' selected="selected"' : ''; ?>>- <?php echo JText::translate('VBORDFROMSITE'); ?></option>
234 247 <?php
235 248 foreach ($all_channels as $o_channel) {
236 249 ?>
237 - <option value="<?php echo $o_channel; ?>"<?php echo $pchannel == $o_channel ? ' selected="selected"' : ''; ?>>- <?php echo ucwords($o_channel); ?></option>
250 + <option value="<?php echo JHtml::fetch('esc_attr', $o_channel); ?>"<?php echo $pchannel == $o_channel ? ' selected="selected"' : ''; ?>>- <?php echo ucwords($o_channel); ?></option>
238 251 <?php
239 252 }
240 253 }
241 254 ?>
@@ -250,10 +263,10 @@
250 263 foreach ($allrooms as $room) {
251 264 $rsel .= '<option value="'.$room['id'].'"'.(!empty($pidroom) && $pidroom == $room['id'] ? ' selected="selected"' : '').'>'.$room['name'].'</option>';
252 265 }
253 266 $rsel .= '</select>';
267 + echo $rsel;
254 268 }
255 - echo $rsel;
256 269 ?>
257 270 </div>
258 271 <?php
259 272 $pcategory_id = $app->getUserStateFromRequest("vbo.orders.category_id", 'category_id', 0, 'int');
@@ -265,9 +278,9 @@
265 278 <option value=""><?php echo JText::translate('VBOCATEGORYFILTER'); ?></option>
266 279 <?php
267 280 foreach ($this->categories as $catid => $catname) {
268 281 ?>
269 - <option value="<?php echo $catid; ?>"<?php echo $catid == $pcategory_id ? ' selected="selected"' : ''; ?>><?php echo $catname; ?></option>
282 + <option value="<?php echo JHtml::fetch('esc_attr', $catid); ?>"<?php echo $catid == $pcategory_id ? ' selected="selected"' : ''; ?>><?php echo $catname; ?></option>
270 283 <?php
271 284 }
272 285 ?>
273 286 </select>
@@ -289,9 +302,9 @@
289 302 $dbo->setQuery($q);
290 303 $allpayments = $dbo->loadAssocList();
291 304 foreach ($allpayments as $paym) {
292 305 ?>
293 - <option value="<?php echo $paym['id']; ?>"<?php echo $paym['id'] == $pidpayment ? ' selected="selected"' : ''; ?>><?php echo $paym['name']; ?></option>
306 + <option value="<?php echo (int) $paym['id']; ?>"<?php echo $paym['id'] == $pidpayment ? ' selected="selected"' : ''; ?>><?php echo $paym['name']; ?></option>
294 307 <?php
295 308 }
296 309 ?>
297 310 </select>
@@ -303,18 +316,22 @@
303 316 $pstatus = $app->getUserStateFromRequest("vbo.orders.status", 'status', '', 'string');
304 317 $filters_set = !empty($pstatus) || $filters_set;
305 318 $status_filter = !empty($pstatus) ? '&amp;status='.$pstatus : '';
306 319 ?>
307 - <optgroup label="<?php echo JText::translate('VBSTATUS'); ?>">
320 + <optgroup label="<?php echo JHtml::fetch('esc_attr', JText::translate('VBSTATUS')); ?>">
308 321 <option value="confirmed"<?php echo $pstatus == 'confirmed' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBCONFIRMED'); ?></option>
309 322 <option value="standby"<?php echo $pstatus == 'standby' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBSTANDBY'); ?></option>
310 323 <option value="cancelled"<?php echo $pstatus == 'cancelled' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBCANCELLED'); ?></option>
311 - <option value="closure"<?php echo $pstatus == 'closure' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBDBTEXTROOMCLOSED'); ?></option>
324 + </optgroup>
325 + <optgroup label="<?php echo JHtml::fetch('esc_attr', JText::translate('VBPSHOWSEASONSTHREE')); ?>">
312 326 <option value="inquiry"<?php echo $pstatus == 'inquiry' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_BTYPE_INQUIRY'); ?></option>
313 327 <option value="request"<?php echo $pstatus == 'request' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_BTYPE_REQUEST'); ?></option>
328 + <option value="quote"<?php echo $pstatus == 'quote' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_BTYPE_QUOTE'); ?></option>
329 + <option value="overbooking"<?php echo $pstatus == 'overbooking' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_BTYPE_OVERBOOKING'); ?></option>
314 330 <option value="split_stay"<?php echo $pstatus == 'split_stay' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_SPLIT_STAY'); ?></option>
331 + <option value="closure"<?php echo $pstatus == 'closure' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBDBTEXTROOMCLOSED'); ?></option>
315 332 </optgroup>
316 - <optgroup label="<?php echo JText::translate('VBOCHECKEDSTATUS'); ?>">
333 + <optgroup label="<?php echo JHtml::fetch('esc_attr', JText::translate('VBOCHECKEDSTATUS')); ?>">
317 334 <option value="checkedin"<?php echo $pstatus == 'checkedin' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSIN'); ?></option>
318 335 <option value="checkedout"<?php echo $pstatus == 'checkedout' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSOUT'); ?></option>
319 336 <option value="noshow"<?php echo $pstatus == 'noshow' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSNOS'); ?></option>
320 337 <option value="none"<?php echo $pstatus == 'none' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSZERO'); ?></option>
@@ -328,9 +345,9 @@
328 345 $pdatefiltfrom = $app->getUserStateFromRequest("vbo.orders.datefiltfrom", 'datefiltfrom', '', 'string');
329 346 $pdatefiltto = $app->getUserStateFromRequest("vbo.orders.datefiltto", 'datefiltto', '', 'string');
330 347 if (!empty($pdatefilt) && (!empty($pdatefiltfrom) || !empty($pdatefiltto))) {
331 348 $filters_set = true;
332 - $dates_filter = '&amp;datefilt='.$pdatefilt.(!empty($pdatefiltfrom) ? '&amp;datefiltfrom='.$pdatefiltfrom : '').(!empty($pdatefiltto) ? '&amp;datefiltto='.$pdatefiltto : '');
349 + $dates_filter = JHtml::fetch('esc_attr', '&amp;datefilt='.$pdatefilt.(!empty($pdatefiltfrom) ? '&amp;datefiltfrom='.$pdatefiltfrom : '').(!empty($pdatefiltto) ? '&amp;datefiltto='.$pdatefiltto : ''));
333 350 }
334 351 $datesel = '<select name="datefilt" onchange="vboToggleDateFilt(this.value);"><option value="">'.JText::translate('VBOFILTERBYDATES').'</option>';
335 352 $datesel .= '<option value="1"'.(!empty($pdatefilt) && $pdatefilt == 1 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEBOOK').'</option>';
336 353 $datesel .= '<option value="2"'.(!empty($pdatefilt) && $pdatefilt == 2 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEIN').'</option>';
@@ -339,12 +356,12 @@
339 356 echo $datesel;
340 357 ?>
341 358 </div>
342 359 <div class="btn-group pull-left" id="vbo-dates-cont" style="display: <?php echo (!empty($pdatefilt) && (!empty($pdatefiltfrom) || !empty($pdatefiltto)) ? 'inline-block' : 'none'); ?>;">
343 - <input type="text" id="vbo-date-from" placeholder="<?php echo JText::translate('VBNEWSEASONONE'); ?>" value="<?php echo $pdatefiltfrom; ?>" size="10" name="datefiltfrom" autocomplete="off" />&nbsp;-&nbsp;<input type="text" id="vbo-date-to" placeholder="<?php echo JText::translate('VBNEWSEASONTWO'); ?>" value="<?php echo $pdatefiltto; ?>" size="10" name="datefiltto" autocomplete="off" />
360 + <input type="text" id="vbo-date-from" placeholder="<?php echo JText::translate('VBNEWSEASONONE'); ?>" value="<?php echo JHtml::fetch('esc_attr', $pdatefiltfrom); ?>" size="10" name="datefiltfrom" autocomplete="off" />&nbsp;-&nbsp;<input type="text" id="vbo-date-to" placeholder="<?php echo JText::translate('VBNEWSEASONTWO'); ?>" value="<?php echo JHtml::fetch('esc_attr', $pdatefiltto); ?>" size="10" name="datefiltto" autocomplete="off" />
344 361 </div>
345 362 <div class="btn-group pull-left">
346 - <button type="submit" class="btn"><i class="icon-search"></i> <?php echo JText::translate('VBPVIEWORDERSSEARCHSUBM'); ?></button>
363 + <button type="submit" class="btn btn-primary"><i class="icon-search"></i> <?php echo JText::translate('VBPVIEWORDERSSEARCHSUBM'); ?></button>
347 364 </div>
348 365 </div>
349 366 </div>
350 367
@@ -394,9 +411,9 @@
394 411 <th class="title center" width="100" align="center"><span><?php echo JText::translate('VBPVIEWORDERCHANNEL'); ?></span></th>
395 412 </tr>
396 413 </thead>
397 414 <?php
398 - $currencysymb = VikBooking::getCurrencySymb(true);
415 + $currencysymb = VikBooking::getCurrencySymb();
399 416 $monsmap = array(
400 417 JText::translate('VBSHORTMONTHONE'),
401 418 JText::translate('VBSHORTMONTHTWO'),
402 419 JText::translate('VBSHORTMONTHTHREE'),
@@ -456,9 +473,9 @@
456 473 if (strstr($otachannelclass, '.') !== false) {
457 474 $otaccparts = explode('.', $otachannelclass);
458 475 $otachannelclass = $otaccparts[0];
459 476 }
460 - $otacurrency = strlen($row['chcurrency']) > 0 ? $row['chcurrency'] : '';
477 + $otacurrency = strlen((string)$row['chcurrency']) ? $row['chcurrency'] : '';
461 478 }
462 479 //Customer Details
463 480 $custdata = $row['custdata'];
464 481 $custdata_parts = explode("\n", $row['custdata']);
@@ -482,9 +499,13 @@
482 499 $custdata = implode(' ', $custvalues);
483 500 }
484 501 }
485 502 if (strlen($custdata) > 45) {
486 - $custdata = substr($custdata, 0, 45)." ...";
503 + if (function_exists('mb_substr')) {
504 + $custdata = mb_substr($custdata, 0, 45, 'UTF-8') . " ...";
505 + } else {
506 + $custdata = substr($custdata, 0, 45) . " ...";
507 + }
487 508 }
488 509
489 510 // customer profile picture
490 511 $customer_avatar = null;
@@ -507,17 +528,17 @@
507 528 }
508 529 $custdata = $row['closure'] > 0 || JText::translate('VBDBTEXTROOMCLOSED') == $row['custdata'] ? '<span class="vbordersroomclosed"><i class="'.VikBookingIcons::i('ban').'"></i> '.JText::translate('VBDBTEXTROOMCLOSED').'</span>' : $custdata;
509 530
510 531 if ($row['status'] == "confirmed") {
511 - //$saystaus = "<span style=\"color: #4ca25a; font-weight: bold;\">".JText::translate('VBCONFIRMED')."</span>";
512 - $saystaus = '<span class="label label-success vbo-status-label">'.JText::translate('VBCONFIRMED').'</span>';
532 + $saystaus = '<span class="label label-success vbo-status-label">' . JText::translate('VBCONFIRMED') . '</span>';
533 + if (!empty($row['type']) && !strcasecmp($row['type'], 'overbooking')) {
534 + $saystaus .= '<div class="vbo-orders-substatus"><span class="label label-error">' . JText::translate('VBO_BTYPE_' . strtoupper($row['type'])) . '</span></div>';
535 + }
513 536 } elseif ($row['status'] == "standby") {
514 - //$saystaus = "<span style=\"color: #e0a504; font-weight: bold;\">".JText::translate('VBSTANDBY')."</span>";
515 537 $status_type = !empty($row['type']) ? JText::translate('VBO_BTYPE_' . strtoupper($row['type'])) : JText::translate('VBSTANDBY');
516 538 $saystaus = '<span class="label label-warning vbo-status-label">' . $status_type . '</span>';
517 539 } else {
518 - //$saystaus = "<span class=\"vbordcancelled\">".JText::translate('VBCANCELLED')."</span>";
519 - $saystaus = '<span class="label label-error vbo-status-label" style="background-color: #d9534f;">'.JText::translate('VBCANCELLED').'</span>';
540 + $saystaus = '<span class="label label-error vbo-status-label">' . JText::translate('VBCANCELLED') . '</span>';
520 541 }
521 542 $ts_info = getdate($row['ts']);
522 543 $ts_wday = JText::translate('VB'.strtoupper(substr($ts_info['weekday'], 0, 3)));
523 544 $checkin_info = getdate($row['checkin']);
@@ -580,9 +601,9 @@
580 601 <?php echo $custdata; ?>
581 602 </div>
582 603 <div class="vbo-customer-info-box-avatar vbo-customer-avatar-small">
583 604 <span>
584 - <img src="<?php echo strpos($customer_avatar, 'http') === 0 ? $customer_avatar : VBO_SITE_URI . 'resources/uploads/' . $customer_avatar; ?>" data-caption="<?php echo htmlspecialchars($avatar_caption); ?>" />
605 + <img src="<?php echo strpos($customer_avatar, 'http') === 0 ? $customer_avatar : VBO_SITE_URI . 'resources/uploads/' . $customer_avatar; ?>" data-caption="<?php echo htmlspecialchars($avatar_caption); ?>" decoding="async" loading="lazy" />
585 606 </span>
586 607 </div>
587 608 </div>
588 609 <?php
@@ -589,9 +610,9 @@
589 610 } else {
590 611 echo $custdata;
591 612 }
592 613 ?>
593 - <span class="vbo-orders-review-link" style="display: none;" title="<?php echo addslashes(JText::translate('VBOSEEGUESTREVIEW')); ?>" data-bid="<?php echo $row['id']; ?>"></span>
614 + <span class="vbo-orders-review-link" title="<?php echo $this->escape(JText::translate('VBOSEEGUESTREVIEW')); ?>" data-bid="<?php echo $row['id']; ?>" style="display: none;"></span>
594 615 </td>
595 616 <td class="center">
596 617 <?php
597 618 if (count($room_names) > 1) {
@@ -638,9 +659,10 @@
638 659 }
639 660 ?>
640 661 </td>
641 662 <td>
642 - <?php echo $peoplestr; ?>
663 + <span class="vbo-tooltip vbo-tooltip-top badge badge-info vbo-bookslist-snapshot" data-tooltiptext="<?php echo JHtml::fetch('esc_attr', JText::translate('VBOPREVIEW')); ?>" data-bid="<?php echo $row['id']; ?>"><?php VikBookingIcons::e('eye'); ?></span>
664 + <span><?php echo $peoplestr; ?></span>
643 665 </td>
644 666 <td>
645 667 <div class="vbo-bookingslist-booktime vbo-bookingslist-booktime-checkin">
646 668 <div class="vbo-bookingslist-booktime-fulldate">
@@ -697,23 +719,20 @@
697 719 </td>
698 720 <td class="center">
699 721 <div class="vbo-bookingslist-total-wrap">
700 722 <div class="vbo-bookingslist-total-amount">
701 - <span><?php echo strlen($otacurrency) > 0 ? $otacurrency : $currencysymb; ?></span>
702 - <span><?php echo VikBooking::numberFormat($isdue); ?></span>
723 + <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($isdue), ($otacurrency ?: $currencysymb), ['<span>%s</span>', '<span>%s</span>']); ?>
703 724 </div>
704 725 <?php
705 726 if (!is_null($row['totpaid'])) {
706 727 ?>
707 728 <div class="vbo-bookingslist-total-totpaid">
708 - <span><?php echo $currencysymb; ?></span>
709 - <span><?php echo VikBooking::numberFormat($row['totpaid']); ?></span>
729 + <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($row['totpaid']), $currencysymb, ['<span>%s</span>', '<span>%s</span>']); ?>
710 730 <?php
711 731 if ($row['refund'] > 0) {
712 732 ?>
713 733 <span class="vbo-bookingslist-total-refunded">
714 - <span><?php echo $currencysymb; ?></span>
715 - <span><?php echo VikBooking::numberFormat($row['refund']); ?></span>
734 + <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($row['refund']), $currencysymb, ['<span>%s</span>', '<span>%s</span>']); ?>
716 735 </span>
717 736 <?php
718 737 }
719 738 ?>
@@ -722,10 +741,9 @@
722 741 } elseif ($row['refund'] > 0) {
723 742 ?>
724 743 <div class="vbo-bookingslist-total-totpaid">
725 744 <span class="vbo-bookingslist-total-refunded">
726 - <span><?php echo $currencysymb; ?></span>
727 - <span><?php echo VikBooking::numberFormat($row['refund']); ?></span>
745 + <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($row['refund']), $currencysymb, ['<span>%s</span>', '<span>%s</span>']); ?>
728 746 </span>
729 747 </div>
730 748 <?php
731 749 }
@@ -747,12 +765,20 @@
747 765 <?php
748 766 if (!empty($row['adminnotes'])) {
749 767 ?>
750 768 <span class="vbo-admin-tipsicon vbo-admin-notes-icn" data-bid="<?php echo $row['id']; ?>"><?php VikBookingIcons::e('sticky-note'); ?></span>&nbsp;
751 - <div class="vbo-order-admin-notes-cnt" data-bid="<?php echo $row['id']; ?>" style="display: none;"><?php echo nl2br($row['adminnotes']); ?></div>
769 + <div class="vbo-order-admin-notes-cnt" data-bid="<?php echo $row['id']; ?>" style="display: none;"><?php echo nl2br(htmlspecialchars($row['adminnotes'])); ?></div>
752 770 <?php
753 771 }
754 - $invoice_path = implode(DIRECTORY_SEPARATOR, [VBO_SITE_PATH, 'helpers', 'invoices', 'generated', "{$row['id']}_{$row['sid']}.pdf"]);
772 +
773 + // build the proper invoice SID for bc
774 + $inv_sid = $row['sid'] ?: $row['idorderota'] ?: '';
775 + if (empty($row['sid']) && is_file(implode(DIRECTORY_SEPARATOR, [VBO_SITE_PATH, 'helpers', 'invoices', 'generated', "{$row['id']}_{$row['sid']}.pdf"]))) {
776 + // use the old file name signature for OTA bookings
777 + $inv_sid = $row['sid'];
778 + }
779 + $invoice_path = implode(DIRECTORY_SEPARATOR, [VBO_SITE_PATH, 'helpers', 'invoices', 'generated', "{$row['id']}_{$inv_sid}.pdf"]);
780 +
755 781 echo (is_file($invoice_path) ? '<a class="hasTooltip vbo-admin-invoiceicon" href="'.VBO_SITE_URI.'helpers/invoices/generated/'.$row['id'].'_'.$row['sid'].'.pdf" target="_blank" title="' . htmlspecialchars(JText::translate('VBOINVDOWNLOAD')) . '"><i class="' . VikBookingIcons::i('invoice') . '"></i></a>' : '');
756 782 ?>
757 783 <span class="vbo-bookings-guestmessages-bubble-cont vbo-admin-tipsicon" style="display: none;" data-bid="<?php echo $row['id']; ?>">
758 784 <a href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $row['id']; ?>#messaging">
@@ -793,9 +819,9 @@
793 819
794 820 </table>
795 821 </div>
796 822 <input type="hidden" name="option" value="com_vikbooking" />
797 -<input type="hidden" name="cust_id" id="cust_id" value="<?php echo !empty($pcust_id) ? $pcust_id : ''; ?>" />
823 +<input type="hidden" name="cust_id" id="cust_id" value="<?php echo !empty($pcust_id) ? JHtml::fetch('esc_attr', $pcust_id) : ''; ?>" />
798 824 <input type="hidden" name="task" value="orders" />
799 825 <input type="hidden" name="boxchecked" value="0" />
800 826 <?php echo JHtml::fetch('form.token'); ?>
801 827 <?php echo $navbut; ?>
@@ -800,12 +826,10 @@
800 826 <?php echo JHtml::fetch('form.token'); ?>
801 827 <?php echo $navbut; ?>
802 828 </form>
803 829
804 -<a style="display: none;" id="vcm-review-details-base" href="index.php?option=com_vikchannelmanager&task=reviews&revid="></a>
805 -
806 830 <script type="text/javascript">
807 -if (jQuery.isFunction(jQuery.fn.tooltip)) {
831 +if (typeof jQuery.fn.tooltip === 'function') {
808 832 jQuery(".hasTooltip").tooltip();
809 833 } else {
810 834 jQuery.fn.tooltip = function(){};
811 835 }
@@ -848,38 +872,39 @@
848 872 applying_tag = true;
849 873 var clickelem = jQuery(this);
850 874 var ctagkey = clickelem.attr('data-ctagkey');
851 875 var bid = clickelem.attr('data-bid');
852 - //set opacity to circles as loading
876 + // set opacity to circles as loading
853 877 jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '0.6');
854 - //
855 - var jqxhr = jQuery.ajax({
856 - type: "POST",
857 - url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=setbookingtag'); ?>",
858 - data: {
878 +
879 + VBOCore.doAjax(
880 + "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=setbookingtag'); ?>",
881 + {
859 882 tmpl: "component",
860 883 idorder: bid,
861 884 tagkey: ctagkey
862 - }
863 - }).done(function(res) {
864 - applying_tag = false;
865 - if (res.indexOf('e4j.error') >= 0 ) {
866 - console.log(res);
867 - alert(res.replace("e4j.error.", ""));
885 + },
886 + (res) => {
887 + applying_tag = false;
888 + if (res.indexOf('e4j.error') >= 0) {
889 + console.log(res);
890 + alert(res.replace("e4j.error.", ""));
891 + //restore loading opacity in circles
892 + jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '1');
893 + } else {
894 + var obj_res = JSON.parse(res);
895 + jQuery(clickelem).closest(".vbo-blist-tip-bctag-subtip").parent().find(".vbo-colortag-circle").css("background-color", obj_res.color).attr('data-ctagcolor', obj_res.color).attr('data-original-title', obj_res.name);
896 + jQuery(".vbo-blist-tip-bctag-subtip").remove();
897 + bctags_tip_on = false;
898 + }
899 + },
900 + (err) => {
901 + applying_tag = false;
902 + alert("Request Failed");
868 903 //restore loading opacity in circles
869 904 jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '1');
870 - } else {
871 - var obj_res = JSON.parse(res);
872 - jQuery(clickelem).closest(".vbo-blist-tip-bctag-subtip").parent().find(".vbo-colortag-circle").css("background-color", obj_res.color).attr('data-ctagcolor', obj_res.color).attr('data-original-title', obj_res.name);
873 - jQuery(".vbo-blist-tip-bctag-subtip").remove();
874 - bctags_tip_on = false;
875 905 }
876 - }).fail(function() {
877 - applying_tag = false;
878 - alert("Request Failed");
879 - //restore loading opacity in circles
880 - jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '1');
881 - });
906 + );
882 907 });
883 908
884 909 jQuery('.vbo-bookingslist-viewdet-link').click(function(e) {
885 910 if (e && e.target.tagName.toUpperCase() == 'I') {
@@ -916,29 +941,31 @@
916 941
917 942 function vboCustomerSearch(words) {
918 943 jQuery("#vbo-allbsearchcust-res").hide().html("");
919 944 jQuery("#customernominative").addClass('vbo-allbsearchcust-loading-inp');
920 - var jqxhr = jQuery.ajax({
921 - type: "POST",
922 - url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=searchcustomer'); ?>",
923 - data: {
945 +
946 + VBOCore.doAjax(
947 + "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=searchcustomer'); ?>",
948 + {
924 949 kw: words,
925 950 nopin: 1,
926 951 tmpl: "component"
952 + },
953 + (cont) => {
954 + if (cont) {
955 + var obj_res = typeof cont === 'string' ? JSON.parse(cont) : cont;
956 + jQuery("#vbo-allbsearchcust-res").html(obj_res[1]);
957 + } else {
958 + jQuery("#vbo-allbsearchcust-res").html("");
959 + }
960 + jQuery("#vbo-allbsearchcust-res").show();
961 + jQuery("#customernominative").removeClass('vbo-allbsearchcust-loading-inp');
962 + },
963 + (err) => {
964 + jQuery("#customernominative").removeClass('vbo-allbsearchcust-loading-inp');
965 + alert("Error Searching.");
927 966 }
928 - }).done(function(cont) {
929 - if (cont) {
930 - var obj_res = typeof cont === 'string' ? JSON.parse(cont) : cont;
931 - jQuery("#vbo-allbsearchcust-res").html(obj_res[1]);
932 - } else {
933 - jQuery("#vbo-allbsearchcust-res").html("");
934 - }
935 - jQuery("#vbo-allbsearchcust-res").show();
936 - jQuery("#customernominative").removeClass('vbo-allbsearchcust-loading-inp');
937 - }).fail(function() {
938 - jQuery("#customernominative").removeClass('vbo-allbsearchcust-loading-inp');
939 - alert("Error Searching.");
940 - });
967 + );
941 968 }
942 969
943 970 jQuery("#customernominative").keyup(function(event) {
944 971 vbocustsdelay(function() {
@@ -967,9 +994,9 @@
967 994 if ( e.keyCode == 27 && bctags_tip_on === true ) {
968 995 jQuery(".vbo-blist-tip-bctag-subtip").remove();
969 996 bctags_tip_on = false;
970 997 }
971 - if (e.keyCode == 13) {
998 + if (e.keyCode == 13 && !e.altKey && !e.ctrlKey && !e.shiftKey) {
972 999 //prevent form-submit by hitting enter
973 1000 e.preventDefault();
974 1001 return false;
975 1002 }
@@ -976,9 +1003,9 @@
976 1003 });
977 1004
978 1005 jQuery(document).mouseup(function(e) {
979 1006 if (!bctags_tip_on) {
980 - return false;
1007 + return;
981 1008 }
982 1009 if (jQuery(".vbo-blist-tip-bctag-subtip").length) {
983 1010 var vbo_overlay_subtip_cont = jQuery(".vbo-blist-tip-bctag-subtip-inner");
984 1011 if (!vbo_overlay_subtip_cont.is(e.target) && vbo_overlay_subtip_cont.has(e.target).length === 0) {
@@ -983,9 +1010,9 @@
983 1010 var vbo_overlay_subtip_cont = jQuery(".vbo-blist-tip-bctag-subtip-inner");
984 1011 if (!vbo_overlay_subtip_cont.is(e.target) && vbo_overlay_subtip_cont.has(e.target).length === 0) {
985 1012 jQuery(".vbo-blist-tip-bctag-subtip").remove();
986 1013 bctags_tip_on = false;
987 - return true;
1014 + return;
988 1015 }
989 1016 }
990 1017 });
991 1018
@@ -1023,39 +1050,50 @@
1023 1050 <?php
1024 1051 }
1025 1052 ?>
1026 1053
1054 + // count unread guest messages
1027 1055 vcmCountGuestMessages();
1028 1056
1029 - setInterval(function() {
1030 - vcmCountGuestMessages();
1031 - }, 15000);
1032 -
1033 1057 // load guest reviews
1034 - jQuery.ajax({
1035 - type: "POST",
1036 - url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=bookings_have_reviews'); ?>",
1037 - data: {
1058 + VBOCore.doAjax(
1059 + "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=bookings_have_reviews'); ?>",
1060 + {
1038 1061 tmpl: "component",
1039 1062 bids: <?php echo json_encode($vcm_bids); ?>
1040 - }
1041 - }).done(function(res) {
1042 - try {
1043 - var obj = JSON.parse(res);
1044 - var base_link = jQuery('#vcm-review-details-base').attr('href');
1045 - for (var bid in obj) {
1046 - if (!obj.hasOwnProperty(bid)) {
1047 - continue;
1063 + },
1064 + (res) => {
1065 + try {
1066 + // loop through all bookings with a review
1067 + var obj = typeof res === 'object' ? res : JSON.parse(res);
1068 + for (let bid in obj) {
1069 + if (!obj.hasOwnProperty(bid)) {
1070 + continue;
1071 + }
1072 +
1073 + // the review ID
1074 + let review_id = obj[bid];
1075 +
1076 + // click-able element
1077 + var rev_elem = jQuery('<a></a>').addClass('vbo-staropen-greview').html('<?php VikBookingIcons::e('star'); ?>');
1078 + rev_elem.on('click', (e) => {
1079 + e.stopPropagation();
1080 + VBOCore.handleDisplayWidgetNotification({widget_id: 'guest_reviews'}, {review_id: review_id});
1081 + });
1082 +
1083 + // review trigger element
1084 + var trigger = jQuery('.vbo-orders-review-link[data-bid="' + bid + '"]');
1085 + trigger.append(rev_elem);
1086 + trigger.fadeIn();
1048 1087 }
1049 - jQuery('.vbo-orders-review-link[data-bid="' + bid + '"]').html('<a href="' + base_link + obj[bid] + '" target="_blank"><?php VikBookingIcons::e('star'); ?></a>').fadeIn();
1088 + } catch(err) {
1089 + console.error(err);
1050 1090 }
1091 + },
1092 + (err) => {
1093 + console.log('request failed for loading booking reviews');
1051 1094 }
1052 - catch(err) {
1053 - console.error(err);
1054 - }
1055 - }).fail(function() {
1056 - console.log('request failed for loading booking reviews');
1057 - });
1095 + );
1058 1096
1059 1097 // zoom-able avatars
1060 1098 jQuery('.vbo-customer-info-box-avatar').each(function() {
1061 1099 var img = jQuery(this).find('img');
@@ -1117,8 +1155,14 @@
1117 1155 body: hid_elm.html(),
1118 1156 });
1119 1157 });
1120 1158
1159 + // view booking snapshot
1160 + jQuery('.vbo-bookslist-snapshot').on('click', function(e) {
1161 + e.stopPropagation();
1162 + VBOCore.handleDisplayWidgetNotification({widget_id: 'booking_details'}, {booking_id: jQuery(this).attr('data-bid')});
1163 + });
1164 +
1121 1165 });
1122 1166
1123 1167 function vcmCountGuestMessages() {
1124 1168 <?php
@@ -1125,41 +1169,42 @@
1125 1169 // VCM Chat Guest Messages (if VCM is installed)
1126 1170 if (count($vcm_bids) && is_file(VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php')) {
1127 1171 ?>
1128 1172 var all_bids = <?php echo json_encode($vcm_bids); ?>;
1129 - jQuery.ajax({
1130 - type: "POST",
1131 - url: "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=chat.count_unread_messages'); ?>",
1132 - data: {
1173 + VBOCore.doAjax(
1174 + "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=chat.count_unread_messages'); ?>",
1175 + {
1133 1176 tmpl: "component",
1134 1177 id_order: all_bids
1135 - }
1136 - }).done(function(res) {
1137 - var counters = JSON.parse(res);
1138 - for (var bid in all_bids) {
1139 - if (!all_bids.hasOwnProperty(bid)) {
1140 - continue;
1178 + },
1179 + (res) => {
1180 + var counters = typeof res === 'object' ? res : JSON.parse(res);
1181 + for (var bid in all_bids) {
1182 + if (!all_bids.hasOwnProperty(bid)) {
1183 + continue;
1184 + }
1185 + var booking_bubble = jQuery('.vbo-bookings-guestmessages-bubble-cont[data-bid="'+all_bids[bid]+'"]');
1186 + if (!booking_bubble || !booking_bubble.length) {
1187 + continue;
1188 + }
1189 + if (!counters.hasOwnProperty(all_bids[bid])) {
1190 + // 0 messages to be read
1191 + booking_bubble.find('i').attr('data-message-count', '0');
1192 + booking_bubble.hide();
1193 + continue;
1194 + }
1195 + booking_bubble.find('i').attr('data-message-count', counters[all_bids[bid]]);
1196 + if (parseInt(counters[all_bids[bid]]) > 0) {
1197 + booking_bubble.fadeIn();
1198 + } else {
1199 + booking_bubble.hide();
1200 + }
1141 1201 }
1142 - var booking_bubble = jQuery('.vbo-bookings-guestmessages-bubble-cont[data-bid="'+all_bids[bid]+'"]');
1143 - if (!booking_bubble || !booking_bubble.length) {
1144 - continue;
1145 - }
1146 - if (!counters.hasOwnProperty(all_bids[bid])) {
1147 - // 0 messages to be read
1148 - booking_bubble.find('i').attr('data-message-count', '0');
1149 - booking_bubble.hide();
1150 - continue;
1151 - }
1152 - booking_bubble.find('i').attr('data-message-count', counters[all_bids[bid]]);
1153 - if (parseInt(counters[all_bids[bid]]) > 0) {
1154 - booking_bubble.fadeIn();
1155 - } else {
1156 - booking_bubble.hide();
1157 - }
1202 + },
1203 + (err) => {
1204 + console.error('AJAX request failed for counting guest messages from VCM');
1158 1205 }
1159 - }).fail(function() {
1160 - console.error('AJAX request failed for counting guest messages from VCM');
1161 - });
1206 + );
1162 1207 <?php
1163 1208 }
1164 1209 ?>
1165 1210 }
@@ -1196,105 +1241,92 @@
1196 1241 }
1197 1242 }
1198 1243 //
1199 1244 ?>
1200 - <div class="vbo-info-overlay-block">
1201 - <a class="vbo-info-overlay-close" href="javascript: void(0);"></a>
1202 - <div class="vbo-info-overlay-content vbo-info-overlay-content-invoices">
1245 +<div class="vbo-gen-invoices-helper" style="display: none;">
1246 + <form action="index.php?option=com_vikbooking" method="post" id="vbo-geninv-form">
1247 + <div class="vbo-calendar-cfield-entry">
1248 + <label for="invoice_num"><?php echo JText::translate('VBINVSTARTNUM'); ?></label>
1249 + <span><input type="number" min="1" size="4" value="<?php echo JHtml::fetch('esc_attr', $nextinvnum); ?>" id="invoice_num" name="invoice_num" /></span>
1250 + </div>
1251 + <div class="vbo-calendar-cfield-entry">
1252 + <label for="invoice_suff"><?php echo JText::translate('VBINVNUMSUFFIX'); ?></label>
1253 + <span><input type="text" size="7" value="<?php echo JHtml::fetch('esc_attr', $invsuff); ?>" id="invoice_suff" name="invoice_suff" /></span>
1254 + </div>
1255 + <div class="vbo-calendar-cfield-entry">
1256 + <label for="invoice_date"><?php echo JText::translate('VBINVUSEDATE'); ?></label>
1257 + <span>
1258 + <select id="invoice_date" name="invoice_date">
1259 + <?php
1260 + if (!empty($oldinvdate)) {
1261 + ?>
1262 + <option value="<?php echo JHtml::fetch('esc_attr', date($df, $oldinvdate)); ?>"><?php echo date($df, $oldinvdate); ?></option>
1263 + <?php
1264 + }
1265 + ?>
1266 + <option value="<?php echo date($df, time()); ?>"><?php echo date($df, time()); ?></option>
1267 + <option value="0"><?php echo JText::translate('VBINVUSEDATEBOOKING'); ?></option>
1268 + </select>
1269 + </span>
1270 + </div>
1271 + <div class="vbo-calendar-cfield-entry">
1272 + <label for="company_info"><?php echo JText::translate('VBINVCOMPANYINFO'); ?></label>
1273 + <span><textarea name="company_info" id="company_info" style="width: 98%; min-width: 98%; max-width: 98%; height: 70px;"><?php echo $companyinfo; ?></textarea></span>
1274 + </div>
1275 + <div class="vbo-calendar-cfield-entry">
1276 + <label for="invoice_send"><i class="vboicn-envelop"></i><?php echo JText::translate('VBINVSENDVIAMAIL'); ?></label>
1277 + <span><select id="invoice_send" name="invoice_send"><option value=""><?php echo JText::translate('VBNO'); ?></option><option value="1"><?php echo JText::translate('VBYES'); ?></option></select></span>
1278 + </div>
1279 + <div class="vbo-calendar-cfields-bottom">
1280 +
1281 + </div>
1282 + <?php
1283 + foreach ($cid as $invid) {
1284 + echo '<input type="hidden" name="cid[]" value="'. (int) $invid . '" />';
1285 + }
1286 + if ($pconfirmgen > 0) {
1287 + echo '<input type="hidden" name="confirmgen" value="' . (int) $cid[0] . '" />';
1288 + }
1289 + ?>
1290 + <input type="hidden" name="option" value="com_vikbooking" />
1291 + <input type="hidden" name="task" value="geninvoices" />
1292 + </form>
1293 +</div>
1294 +
1295 +<script type="text/javascript">
1296 + jQuery(function() {
1297 +
1298 + // render modal to generate the invoice(s)
1299 + var gen_invoices_modal_body = VBOCore.displayModal({
1300 + suffix: 'invoices',
1301 + extra_class: 'vbo-modal-rounded vbo-modal-tall',
1302 + title: Joomla.JText._('VBOGENINVOICES') + ' (<?php echo count($cid); ?>)',
1303 + footer_right: '<button type="button" class="btn btn-success" onclick="document.getElementById(\'vbo-geninv-form\').submit();"><i class="vboicn-file-text2"></i><?php echo addslashes(JText::translate('VBOGENINVOICES')); ?></button>',
1203 1304 <?php
1204 - if (count($cid) == 1) {
1205 - ?>
1206 - <div style="float: right;"></div>
1207 - <?php
1305 + if (count($cid) === 1) {
1306 + ?>
1307 + footer_left: '<a href="index.php?option=com_vikbooking&task=editbusy&cid[]=<?php echo (int) $cid[0]; ?>&frominv=1" class="btn vbo-config-btn"><?php echo addslashes(JText::translate('VBINVEDITBINFO')); ?></a>',
1308 + <?php
1208 1309 }
1209 1310 ?>
1210 - <h4><?php echo JText::translate('VBOGENINVOICES') ?> (<?php echo count($cid); ?>)</h4>
1211 -
1311 + onDismiss: () => {
1312 + jQuery('#vbo-geninv-form').appendTo('.vbo-gen-invoices-helper');
1313 + },
1314 + });
1212 1315
1213 - <div class="vbo-gen-invoices-helper" style="display: none;">
1214 - <form action="index.php?option=com_vikbooking" method="post" id="vbo-geninv-form">
1215 - <div class="vbo-calendar-cfield-entry">
1216 - <label for="invoice_num"><?php echo JText::translate('VBINVSTARTNUM'); ?></label>
1217 - <span><input type="number" min="1" size="4" value="<?php echo $nextinvnum; ?>" id="invoice_num" name="invoice_num" /></span>
1218 - </div>
1219 - <div class="vbo-calendar-cfield-entry">
1220 - <label for="invoice_suff"><?php echo JText::translate('VBINVNUMSUFFIX'); ?></label>
1221 - <span><input type="text" size="7" value="<?php echo $invsuff; ?>" id="invoice_suff" name="invoice_suff" /></span>
1222 - </div>
1223 - <div class="vbo-calendar-cfield-entry">
1224 - <label for="invoice_date"><?php echo JText::translate('VBINVUSEDATE'); ?></label>
1225 - <span>
1226 - <select id="invoice_date" name="invoice_date">
1227 - <?php
1228 - if (!empty($oldinvdate)) {
1229 - ?>
1230 - <option value="<?php echo date($df, $oldinvdate); ?>"><?php echo date($df, $oldinvdate); ?></option>
1231 - <?php
1232 - }
1233 - ?>
1234 - <option value="<?php echo date($df, time()); ?>"><?php echo date($df, time()); ?></option>
1235 - <option value="0"><?php echo JText::translate('VBINVUSEDATEBOOKING'); ?></option>
1236 - </select>
1237 - </span>
1238 - </div>
1239 - <div class="vbo-calendar-cfield-entry">
1240 - <label for="company_info"><?php echo JText::translate('VBINVCOMPANYINFO'); ?></label>
1241 - <span><textarea name="company_info" id="company_info" style="width: 98%; min-width: 98%; max-width: 98%; height: 70px;"><?php echo $companyinfo; ?></textarea></span>
1242 - </div>
1243 - <div class="vbo-calendar-cfield-entry">
1244 - <label for="invoice_send"><i class="vboicn-envelop"></i><?php echo JText::translate('VBINVSENDVIAMAIL'); ?></label>
1245 - <span><select id="invoice_send" name="invoice_send"><option value=""><?php echo JText::translate('VBNO'); ?></option><option value="1"><?php echo JText::translate('VBYES'); ?></option></select></span>
1246 - </div>
1247 - <div class="vbo-calendar-cfields-bottom">
1248 -
1249 - </div>
1316 + // set modal content
1317 + jQuery('#vbo-geninv-form').appendTo(gen_invoices_modal_body);
1318 +
1250 1319 <?php
1251 - foreach ($cid as $invid) {
1252 - echo '<input type="hidden" name="cid[]" value="'.$invid.'" />';
1320 + if ($pconfirmgen > 0) {
1321 + ?>
1322 + // prompt for immediate generation
1323 + if (confirm(Joomla.JText._('VBCONFIRMGENINV'))) {
1324 + document.getElementById('vbo-geninv-form').submit();
1253 1325 }
1254 - if ($pconfirmgen > 0) {
1255 - echo '<input type="hidden" name="confirmgen" value="'.$cid[0].'" />';
1326 + <?php
1256 1327 }
1257 1328 ?>
1258 - <input type="hidden" name="option" value="com_vikbooking" />
1259 - <input type="hidden" name="task" value="geninvoices" />
1260 - </form>
1261 - </div>
1262 -
1263 - <script type="text/javascript">
1264 - jQuery(function() {
1265 -
1266 - // render modal to generate the invoice(s)
1267 - var gen_invoices_modal_body = VBOCore.displayModal({
1268 - suffix: 'invoices',
1269 - extra_class: 'vbo-modal-rounded vbo-modal-tall',
1270 - title: Joomla.JText._('VBOGENINVOICES') + ' (<?php echo count($cid); ?>)',
1271 - footer_right: '<button type="button" class="btn btn-success" onclick="document.getElementById(\'vbo-geninv-form\').submit();"><i class="vboicn-file-text2"></i><?php echo JText::translate('VBOGENINVOICES'); ?></button>',
1272 - <?php
1273 - if (count($cid) === 1) {
1274 - ?>
1275 - footer_left: '<a href="index.php?option=com_vikbooking&task=editbusy&cid[]=<?php echo $cid[0]; ?>&frominv=1" class="btn vbo-config-btn"><?php echo JText::translate('VBINVEDITBINFO'); ?></a>',
1276 - <?php
1277 - }
1278 - ?>
1279 - onDismiss: () => {
1280 - jQuery('#vbo-geninv-form').appendTo('.vbo-gen-invoices-helper');
1281 - },
1282 - });
1283 -
1284 - // set modal content
1285 - jQuery('#vbo-geninv-form').appendTo(gen_invoices_modal_body);
1286 -
1287 - <?php
1288 - if ($pconfirmgen > 0) {
1289 - ?>
1290 - // prompt for immediate generation
1291 - if (confirm(Joomla.JText._('VBCONFIRMGENINV'))) {
1292 - document.getElementById('vbo-geninv-form').submit();
1293 - }
1294 - <?php
1295 - }
1296 - ?>
1297 - });
1298 - </script>
1299 - <?php
1329 + });
1330 +</script>
1331 +<?php
1300 1332 }