PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.8
VikBooking Hotel Booking Engine & PMS v1.6.8
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 / orders / tmpl / default.php

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

1,314 lines 54.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage com_vikbooking
5 * @author Alessio Gaggii - e4j - Extensionsforjoomla.com
6 * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 * @link https://vikwp.com
9 */
10
11 defined('ABSPATH') or die('No script kiddies please!');
12
13 $rows = $this->rows;
14 $allrooms = $this->allrooms;
15 $lim0 = $this->lim0;
16 $navbut = $this->navbut;
17 $orderby = $this->orderby;
18 $ordersort = $this->ordersort;
19
20 // list of IDs for which VCM should monitor the guest messages in the chat
21 $vcm_bids = array();
22
23 $dbo = JFactory::getDbo();
24 $app = JFactory::getApplication();
25
26 $vbo_app = VikBooking::getVboApplication();
27 $vbo_app->loadDatePicker();
28 $vbo_app->loadContextMenuAssets();
29
30 // JS lang def
31 JText::script('VBOGENINVOICES');
32 JText::script('VBCONFIRMGENINV');
33 JText::script('VBADMINNOTESTOGGLE');
34 JText::script('VBDASHUPRESONE');
35 JText::script('VBOCHANNEL');
36 JText::script('VBCOUPON');
37 JText::script('VBCUSTOMERNOMINATIVE');
38
39 $nowdf = VikBooking::getDateFormat(true);
40 if ($nowdf == "%d/%m/%Y") {
41 $df = 'd/m/Y';
42 } elseif ($nowdf == "%m/%d/%Y") {
43 $df = 'm/d/Y';
44 } else {
45 $df = 'Y/m/d';
46 }
47 $datesep = VikBooking::getDateSeparator(true);
48 $juidf = $nowdf == "%d/%m/%Y" ? 'dd/mm/yy' : ($nowdf == "%m/%d/%Y" ? 'mm/dd/yy' : 'yy/mm/dd');
49
50 $cid = VikRequest::getVar('cid', array());
51 $pcust_id = $app->getUserStateFromRequest("vbo.orders.cust_id", 'cust_id', 0, 'int');
52 $pconfirmnumber = VikRequest::getString('confirmnumber', '', 'request');
53 //Color tags
54 $colortags = VikBooking::loadBookingsColorTags();
55 $bctags_tip = '';
56 if (count($colortags) > 0) {
57 $bctags_tip = '<div class=\"vbo-blist-tip-bctag-subtip-inner\">';
58 foreach ($colortags as $ctagk => $ctagv) {
59 $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 $bctags_tip .= '</div>';
62 }
63 //
64
65 if (empty($rows)) {
66 $rows = array();
67 ?>
68 <p class="warn"><?php echo JText::translate('VBNOORDERSFOUND'); ?></p>
69 <?php
70 if (VBOPlatformDetection::isWordPress()) {
71 /**
72 * In case of no bookings found, we check whether bookings can be imported from third party plugins.
73 *
74 * @wponly we do this only on WP.
75 *
76 * @since 1.3.5
77 */
78 $supported_plugins = VikBooking::canImportBookingsFromThirdPartyPlugins();
79 if ($supported_plugins !== false) {
80 $tpp_key = '';
81 foreach ($supported_plugins as $spkey => $spn) {
82 $tpp_key = $spkey;
83 break;
84 }
85 ?>
86 <div class="notice is-dismissible notice-info">
87 <div class="vbo-import-wrap">
88 <p>
89 <span><?php echo JText::sprintf('VBO_IMPBFROM_INTO_VBO', (isset($supported_plugins[$tpp_key]) ? $supported_plugins[$tpp_key] : '')); ?></span>
90 <a class="btn btn-success" href="admin.php?option=com_vikbooking&view=importbftpp"><?php echo JText::translate('VBO_IMPBFTPP_DOIMPORT_SHORT'); ?></a>
91 </p>
92 </div>
93 </div>
94 <?php
95 }
96 }
97 }
98
99 // filter by channel
100 $all_channels = array();
101 $q = "SELECT `channel` FROM `#__vikbooking_orders` WHERE `channel` IS NOT NULL GROUP BY `channel`;";
102 $dbo->setQuery($q);
103 $ord_channels = $dbo->loadAssocList();
104 if ($ord_channels) {
105 foreach ($ord_channels as $o_channel) {
106 $channel_parts = explode('_', $o_channel['channel']);
107 $channel_name = count($channel_parts) > 1 ? trim($channel_parts[1]) : trim($channel_parts[0]);
108 if (in_array($channel_name, $all_channels)) {
109 continue;
110 }
111 $all_channels[] = $channel_name;
112 }
113 }
114
115 // prepare modal
116 echo $vbo_app->getJmodalScript();
117 echo $vbo_app->getJmodalHtml('vbo-export-csv', JText::translate('VBCSVEXPORT'), '', 'width: 80%; height: 60%; margin-left: -40%; top: 20% !important;');
118 echo $vbo_app->getJmodalHtml('vbo-export-ics', JText::translate('VBICSEXPORT'), '', 'width: 80%; height: 60%; margin-left: -40%; top: 20% !important;');
119
120 $filters_set = false;
121
122 ?>
123
124 <script type="text/javascript">
125 function vboClearFilters() {
126 jQuery('#filter-bar, #vbo-search-tools-cont').find('input, select').val('');
127 jQuery('#adminForm').append('<input type=\'hidden\' name=\'limitstart\' value=\'0\' />');
128 document.getElementById('cust_id').value = '';
129 document.adminForm.submit();
130 }
131
132 function vboKeyupSearch(event) {
133 if (event && event.key && event.key == 'Enter') {
134 event.preventDefault();
135 document.adminForm.submit();
136 return;
137 }
138 }
139
140 function vboHandleSearchType(search_hint) {
141 if (!search_hint) {
142 search_hint = '';
143 } else {
144 search_hint += ': ';
145 }
146 jQuery('#confirmnumber').val(search_hint).focus();
147 }
148
149 jQuery(function() {
150
151 // register context menu
152 jQuery('.vbo-context-menu-searchtype').vboContextMenu({
153 placement: 'bottom-left',
154 buttons: [
155 {
156 icon: '<?php echo VikBookingIcons::i('search'); ?>',
157 text: Joomla.JText._('VBDASHUPRESONE'),
158 separator: false,
159 action: (root, config) => {
160 vboHandleSearchType('id');
161 },
162 },
163 {
164 icon: '<?php echo VikBookingIcons::i('search'); ?>',
165 text: Joomla.JText._('VBDASHUPRESONE') + ' (' + Joomla.JText._('VBOCHANNEL') + ')',
166 separator: false,
167 action: (root, config) => {
168 vboHandleSearchType('otaid');
169 },
170 },
171 {
172 icon: '<?php echo VikBookingIcons::i('user-tag'); ?>',
173 text: Joomla.JText._('VBCOUPON'),
174 separator: false,
175 action: (root, config) => {
176 vboHandleSearchType('coupon');
177 },
178 },
179 {
180 icon: '<?php echo VikBookingIcons::i('user'); ?>',
181 text: Joomla.JText._('VBCUSTOMERNOMINATIVE'),
182 separator: false,
183 action: (root, config) => {
184 vboHandleSearchType('name');
185 },
186 },
187 ],
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
200 });
201 </script>
202
203 <form action="index.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm" class="vbo-allbookings-fm">
204
205 <div id="filter-bar" class="btn-toolbar vbo-btn-toolbar" style="width: 100%; display: inline-block;">
206 <div class="btn-group pull-right">
207 <a href="javascript: void(0);" onclick="vboOpenJModal('vbo-export-csv', 'index.php?option=com_vikbooking&task=csvexportprepare&tmpl=component');" class="vbcsvexport"><?php VikBookingIcons::e('table'); ?> <span><?php echo JText::translate('VBCSVEXPORT'); ?></span></a>
208 <a href="javascript: void(0);" onclick="vboOpenJModal('vbo-export-ics', 'index.php?option=com_vikbooking&task=icsexportprepare&tmpl=component');" class="vbicsexport"><?php VikBookingIcons::e('calendar'); ?> <span><?php echo JText::translate('VBICSEXPORT'); ?></span></a>
209 </div>
210 <div class="btn-group pull-left input-append">
211 <button type="button" class="btn btn-secondary vbo-context-menu-btn vbo-context-menu-searchtype">
212 <span class="vbo-context-menu-ico"><?php VikBookingIcons::e('sort-down'); ?></span>
213 </button>
214 <input type="text" name="confirmnumber" id="confirmnumber" autocomplete="off" placeholder="<?php echo JHtml::fetch('esc_attr', JText::translate('VBOFILTCONFNUMCUST')); ?>" value="<?php echo strlen($pconfirmnumber) ? JHtml::fetch('esc_attr', $pconfirmnumber) : ''; ?>" onkeyup="vboKeyupSearch(event);" size="30" />
215 <button type="submit" class="btn"><i class="icon-search"></i></button>
216 </div>
217 <?php
218 $cust_id_filter = false;
219 if (is_array($rows) && isset($rows[0]) && array_key_exists('customer_fullname', $rows[0])) {
220 //customer ID filter
221 $cust_id_filter = true;
222 }
223 ?>
224 <div class="btn-group pull-left input-append">
225 <a style="display: none;" id="vbo-unset-cust-filter" href="index.php?option=com_vikbooking&task=orders&cust_id=0"></a>
226 <div id="vbo-allbsearchcust-res" class="vbo-allbsearchcust-res" style="display: none;"></div>
227 <input type="text" id="customernominative" autocomplete="off" placeholder="<?php echo JText::translate('VBCUSTOMERNOMINATIVE'); ?>" value="<?php echo $cust_id_filter ? htmlspecialchars($rows[0]['customer_fullname']) : ''; ?>" size="30" />
228 <button type="button" class="btn" onclick="<?php echo $cust_id_filter ? 'document.location.href=jQuery(\'#vbo-unset-cust-filter\').attr(\'href\');' : 'document.getElementById(\'customernominative\').focus();'; ?>"><i class="<?php echo $cust_id_filter ? 'icon-remove' : 'icon-user'; ?>"></i></button>
229 </div>
230 <div class="btn-group pull-left">
231 <button type="button" class="btn" id="vbo-search-tools-btn" onclick="if(jQuery(this).hasClass('btn-primary')){jQuery('#vbo-search-tools-cont').hide();jQuery(this).removeClass('btn-primary');}else{jQuery('#vbo-search-tools-cont').show();jQuery(this).addClass('btn-primary');}"><?php echo JText::translate('JSEARCH_TOOLS'); ?> <span class="caret"></span></button>
232 </div>
233 <div class="btn-group pull-left">
234 <button type="button" class="btn" onclick="vboClearFilters();"><?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?></button>
235 </div>
236
237 <div id="vbo-search-tools-cont" class="js-stools-container-filters clearfix" style="display: none;">
238 <div class="btn-group pull-left">
239 <select name="channel">
240 <option value=""><?php echo JText::translate('VBCHANNELFILTER'); ?></option>
241 <?php
242 $pchannel = $app->getUserStateFromRequest("vbo.orders.channel", 'channel', '', 'string');
243 if (count($all_channels) > 0) {
244 $filters_set = !empty($pchannel) || $filters_set;
245 ?>
246 <option value="-1"<?php echo $pchannel == '-1' ? ' selected="selected"' : ''; ?>>- <?php echo JText::translate('VBORDFROMSITE'); ?></option>
247 <?php
248 foreach ($all_channels as $o_channel) {
249 ?>
250 <option value="<?php echo $o_channel; ?>"<?php echo $pchannel == $o_channel ? ' selected="selected"' : ''; ?>>- <?php echo ucwords($o_channel); ?></option>
251 <?php
252 }
253 }
254 ?>
255 </select>
256 </div>
257 <div class="btn-group pull-left">
258 <?php
259 $pidroom = $app->getUserStateFromRequest("vbo.orders.idroom", 'idroom', 0, 'int');
260 if (count($allrooms) > 0) {
261 $filters_set = !empty($pidroom) || $filters_set;
262 $rsel = '<select name="idroom"><option value="">'.JText::translate('VBROOMFILTER').'</option>';
263 foreach ($allrooms as $room) {
264 $rsel .= '<option value="'.$room['id'].'"'.(!empty($pidroom) && $pidroom == $room['id'] ? ' selected="selected"' : '').'>'.$room['name'].'</option>';
265 }
266 $rsel .= '</select>';
267 }
268 echo $rsel;
269 ?>
270 </div>
271 <?php
272 $pcategory_id = $app->getUserStateFromRequest("vbo.orders.category_id", 'category_id', 0, 'int');
273 if (count($this->categories)) {
274 $filters_set = !empty($pcategory_id) || $filters_set;
275 ?>
276 <div class="btn-group pull-left">
277 <select name="category_id">
278 <option value=""><?php echo JText::translate('VBOCATEGORYFILTER'); ?></option>
279 <?php
280 foreach ($this->categories as $catid => $catname) {
281 ?>
282 <option value="<?php echo $catid; ?>"<?php echo $catid == $pcategory_id ? ' selected="selected"' : ''; ?>><?php echo $catname; ?></option>
283 <?php
284 }
285 ?>
286 </select>
287 </div>
288 <?php
289 }
290 ?>
291 <div class="btn-group pull-left">
292 <select name="idpayment">
293 <option value=""><?php echo JText::translate('VBOFILTERBYPAYMENT'); ?></option>
294 <?php
295 $pidpayment = $app->getUserStateFromRequest("vbo.orders.idpayment", 'idpayment', 0, 'int');
296 $payment_filter = '';
297 if (!empty($pidpayment)) {
298 $filters_set = !empty($pidpayment) || $filters_set;
299 $payment_filter = '&amp;idpayment='.$pidpayment;
300 }
301 $q = "SELECT `id`,`name` FROM `#__vikbooking_gpayments` ORDER BY `name` ASC;";
302 $dbo->setQuery($q);
303 $allpayments = $dbo->loadAssocList();
304 foreach ($allpayments as $paym) {
305 ?>
306 <option value="<?php echo $paym['id']; ?>"<?php echo $paym['id'] == $pidpayment ? ' selected="selected"' : ''; ?>><?php echo $paym['name']; ?></option>
307 <?php
308 }
309 ?>
310 </select>
311 </div>
312 <div class="btn-group pull-left">
313 <select name="status">
314 <option value=""><?php echo JText::translate('VBOFILTERBYSTATUS'); ?></option>
315 <?php
316 $pstatus = $app->getUserStateFromRequest("vbo.orders.status", 'status', '', 'string');
317 $filters_set = !empty($pstatus) || $filters_set;
318 $status_filter = !empty($pstatus) ? '&amp;status='.$pstatus : '';
319 ?>
320 <optgroup label="<?php echo JText::translate('VBSTATUS'); ?>">
321 <option value="confirmed"<?php echo $pstatus == 'confirmed' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBCONFIRMED'); ?></option>
322 <option value="standby"<?php echo $pstatus == 'standby' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBSTANDBY'); ?></option>
323 <option value="cancelled"<?php echo $pstatus == 'cancelled' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBCANCELLED'); ?></option>
324 <option value="closure"<?php echo $pstatus == 'closure' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBDBTEXTROOMCLOSED'); ?></option>
325 <option value="inquiry"<?php echo $pstatus == 'inquiry' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_BTYPE_INQUIRY'); ?></option>
326 <option value="request"<?php echo $pstatus == 'request' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_BTYPE_REQUEST'); ?></option>
327 <option value="split_stay"<?php echo $pstatus == 'split_stay' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_SPLIT_STAY'); ?></option>
328 <option value="overbooking"<?php echo $pstatus == 'overbooking' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_BTYPE_OVERBOOKING'); ?></option>
329 </optgroup>
330 <optgroup label="<?php echo JText::translate('VBOCHECKEDSTATUS'); ?>">
331 <option value="checkedin"<?php echo $pstatus == 'checkedin' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSIN'); ?></option>
332 <option value="checkedout"<?php echo $pstatus == 'checkedout' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSOUT'); ?></option>
333 <option value="noshow"<?php echo $pstatus == 'noshow' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSNOS'); ?></option>
334 <option value="none"<?php echo $pstatus == 'none' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSZERO'); ?></option>
335 </optgroup>
336 </select>
337 </div>
338 <div class="btn-group pull-left">
339 <?php
340 $dates_filter = '';
341 $pdatefilt = $app->getUserStateFromRequest("vbo.orders.datefilt", 'datefilt', 0, 'int');
342 $pdatefiltfrom = $app->getUserStateFromRequest("vbo.orders.datefiltfrom", 'datefiltfrom', '', 'string');
343 $pdatefiltto = $app->getUserStateFromRequest("vbo.orders.datefiltto", 'datefiltto', '', 'string');
344 if (!empty($pdatefilt) && (!empty($pdatefiltfrom) || !empty($pdatefiltto))) {
345 $filters_set = true;
346 $dates_filter = '&amp;datefilt='.$pdatefilt.(!empty($pdatefiltfrom) ? '&amp;datefiltfrom='.$pdatefiltfrom : '').(!empty($pdatefiltto) ? '&amp;datefiltto='.$pdatefiltto : '');
347 }
348 $datesel = '<select name="datefilt" onchange="vboToggleDateFilt(this.value);"><option value="">'.JText::translate('VBOFILTERBYDATES').'</option>';
349 $datesel .= '<option value="1"'.(!empty($pdatefilt) && $pdatefilt == 1 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEBOOK').'</option>';
350 $datesel .= '<option value="2"'.(!empty($pdatefilt) && $pdatefilt == 2 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEIN').'</option>';
351 $datesel .= '<option value="3"'.(!empty($pdatefilt) && $pdatefilt == 3 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEOUT').'</option>';
352 $datesel .= '</select>';
353 echo $datesel;
354 ?>
355 </div>
356 <div class="btn-group pull-left" id="vbo-dates-cont" style="display: <?php echo (!empty($pdatefilt) && (!empty($pdatefiltfrom) || !empty($pdatefiltto)) ? 'inline-block' : 'none'); ?>;">
357 <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" />
358 </div>
359 <div class="btn-group pull-left">
360 <button type="submit" class="btn btn-primary"><i class="icon-search"></i> <?php echo JText::translate('VBPVIEWORDERSSEARCHSUBM'); ?></button>
361 </div>
362 </div>
363 </div>
364
365 <div class="table-responsive">
366 <table cellpadding="4" cellspacing="0" border="0" width="100%" class="table table-striped vbo-bookingslist-table">
367 <thead>
368 <tr>
369 <th width="20">
370 <input type="checkbox" onclick="Joomla.checkAll(this)" value="" name="checkall-toggle">
371 </th>
372 <th class="title center" width="20" align="center">
373 <a href="index.php?option=com_vikbooking&amp;task=orders<?php echo ($cust_id_filter ? '&amp;cust_id='.$pcust_id : '').$dates_filter.$status_filter.$payment_filter; ?>&amp;vborderby=id&amp;vbordersort=<?php echo ($orderby == "id" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "id" && $ordersort == "ASC" ? "vbo-bookingslist-activesort" : ($orderby == "id" ? "vbo-bookingslist-activesort" : "")); ?>">
374 <?php echo 'ID'.($orderby == "id" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "id" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?>
375 </a>
376 </th>
377 <th class="title left" width="110">
378 <a href="index.php?option=com_vikbooking&amp;task=orders<?php echo ($cust_id_filter ? '&amp;cust_id='.$pcust_id : '').$dates_filter.$status_filter.$payment_filter; ?>&amp;vborderby=ts&amp;vbordersort=<?php echo ($orderby == "ts" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "ts" && $ordersort == "ASC" ? "vbo-bookingslist-activesort" : ($orderby == "ts" ? "vbo-bookingslist-activesort" : "")); ?>">
379 <?php echo JText::translate('VBPVIEWORDERSONE').($orderby == "ts" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "ts" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?>
380 </a>
381 </th>
382 <th class="title left" width="200"><span><?php echo JText::translate('VBPVIEWORDERSTWO'); ?></span></th>
383 <th class="title center" width="100" align="center"><span><?php echo JText::translate('VBPVIEWORDERSTHREE'); ?></span></th>
384 <th class="title left" width="120"><span><?php echo JText::translate('VBPVIEWORDERSPEOPLE'); ?></span></th>
385 <th class="title left" width="110">
386 <a href="index.php?option=com_vikbooking&amp;task=orders<?php echo ($cust_id_filter ? '&amp;cust_id='.$pcust_id : '').$dates_filter.$status_filter.$payment_filter; ?>&amp;vborderby=checkin&amp;vbordersort=<?php echo ($orderby == "checkin" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "checkin" && $ordersort == "ASC" ? "vbo-bookingslist-activesort" : ($orderby == "checkin" ? "vbo-bookingslist-activesort" : "")); ?>">
387 <?php echo JText::translate('VBPVIEWORDERSFOUR').($orderby == "checkin" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "checkin" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?>
388 </a>
389 </th>
390 <th class="title left" width="110">
391 <a href="index.php?option=com_vikbooking&amp;task=orders<?php echo ($cust_id_filter ? '&amp;cust_id='.$pcust_id : '').$dates_filter.$status_filter.$payment_filter; ?>&amp;vborderby=checkout&amp;vbordersort=<?php echo ($orderby == "checkout" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "checkout" && $ordersort == "ASC" ? "vbo-bookingslist-activesort" : ($orderby == "checkout" ? "vbo-bookingslist-activesort" : "")); ?>">
392 <?php echo JText::translate('VBPVIEWORDERSFIVE').($orderby == "checkout" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "checkout" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?>
393 </a>
394 </th>
395 <th class="title center" width="60" align="center">
396 <a href="index.php?option=com_vikbooking&amp;task=orders<?php echo ($cust_id_filter ? '&amp;cust_id='.$pcust_id : '').$dates_filter.$status_filter.$payment_filter; ?>&amp;vborderby=days&amp;vbordersort=<?php echo ($orderby == "days" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "days" && $ordersort == "ASC" ? "vbo-bookingslist-activesort" : ($orderby == "days" ? "vbo-bookingslist-activesort" : "")); ?>">
397 <?php echo JText::translate('VBPVIEWORDERSSIX').($orderby == "days" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "days" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?>
398 </a>
399 </th>
400 <th class="title center" width="110" align="center">
401 <a href="index.php?option=com_vikbooking&amp;task=orders<?php echo ($cust_id_filter ? '&amp;cust_id='.$pcust_id : '').$dates_filter.$status_filter.$payment_filter; ?>&amp;vborderby=total&amp;vbordersort=<?php echo ($orderby == "total" && $ordersort == "ASC" ? "DESC" : "ASC"); ?>" class="<?php echo ($orderby == "total" && $ordersort == "ASC" ? "vbo-bookingslist-activesort" : ($orderby == "total" ? "vbo-bookingslist-activesort" : "")); ?>">
402 <?php echo JText::translate('VBPVIEWORDERSSEVEN').($orderby == "total" && $ordersort == "ASC" ? '<i class="'.VikBookingIcons::i('sort-asc').'"></i>' : ($orderby == "total" ? '<i class="'.VikBookingIcons::i('sort-desc').'"></i>' : '<i class="'.VikBookingIcons::i('sort').'"></i>')); ?>
403 </a>
404 </th>
405 <th class="title center" width="30" align="center"><span>&nbsp;</span></th>
406 <th class="title center" width="50" align="center"><span>&nbsp;</span></th>
407 <th class="title center" width="100" align="center"><span><?php echo JText::translate('VBPVIEWORDERSEIGHT'); ?></span></th>
408 <th class="title center" width="100" align="center"><span><?php echo JText::translate('VBPVIEWORDERCHANNEL'); ?></span></th>
409 </tr>
410 </thead>
411 <?php
412 $currencysymb = VikBooking::getCurrencySymb(true);
413 $monsmap = array(
414 JText::translate('VBSHORTMONTHONE'),
415 JText::translate('VBSHORTMONTHTWO'),
416 JText::translate('VBSHORTMONTHTHREE'),
417 JText::translate('VBSHORTMONTHFOUR'),
418 JText::translate('VBSHORTMONTHFIVE'),
419 JText::translate('VBSHORTMONTHSIX'),
420 JText::translate('VBSHORTMONTHSEVEN'),
421 JText::translate('VBSHORTMONTHEIGHT'),
422 JText::translate('VBSHORTMONTHNINE'),
423 JText::translate('VBSHORTMONTHTEN'),
424 JText::translate('VBSHORTMONTHELEVEN'),
425 JText::translate('VBSHORTMONTHTWELVE')
426 );
427 $vcm_logos = VikBooking::getVcmChannelsLogo('', true);
428 $kk = 0;
429 $i = 0;
430 for ($i = 0, $n = count($rows); $i < $n; $i++) {
431 $row = $rows[$i];
432 if (!$row['closure']) {
433 array_push($vcm_bids, $row['id']);
434 }
435 $rooms = VikBooking::loadOrdersRoomsData($row['id']);
436 $peoplestr = '';
437 $guest_nums = [];
438 $room_names = array();
439 if (is_array($rooms)) {
440 $totadults = 0;
441 $totchildren = 0;
442 $totpets = 0;
443 foreach ($rooms as $rr) {
444 $totadults += $rr['adults'];
445 $totchildren += $rr['children'];
446 $totpets += $rr['pets'];
447 $room_names[] = $rr['room_name'];
448 if ($row['split_stay']) {
449 // do not sum the guests in case of split stay rooms
450 $totadults = $rr['adults'];
451 $totchildren = $rr['children'];
452 }
453 }
454 $guest_nums[] = $totadults . " " . ($totadults > 1 ? JText::translate('VBMAILADULTS') : JText::translate('VBMAILADULT'));
455 if ($totchildren > 0) {
456 $guest_nums[] = $totchildren . " " . ($totchildren > 1 ? JText::translate('VBMAILCHILDREN') : JText::translate('VBMAILCHILD'));
457 }
458 if ($totpets > 0) {
459 $guest_nums[] = $totpets . " " . ($totpets > 1 ? JText::translate('VBO_PETS') : JText::translate('VBO_PET'));
460 }
461 $peoplestr = implode(', ', $guest_nums);
462 }
463 $isdue = $row['total'];
464 $otachannel = '';
465 $otacurrency = '';
466 if (!empty($row['channel'])) {
467 $channelparts = explode('_', $row['channel']);
468 $otachannel = array_key_exists(1, $channelparts) && strlen($channelparts[1]) > 0 ? $channelparts[1] : ucwords($channelparts[0]);
469 $otachannelclass = $otachannel;
470 if (strstr($otachannelclass, '.') !== false) {
471 $otaccparts = explode('.', $otachannelclass);
472 $otachannelclass = $otaccparts[0];
473 }
474 $otacurrency = strlen((string)$row['chcurrency']) ? $row['chcurrency'] : '';
475 }
476 //Customer Details
477 $custdata = $row['custdata'];
478 $custdata_parts = explode("\n", $row['custdata']);
479 if (count($custdata_parts) > 2 && strpos($custdata_parts[0], ':') !== false && strpos($custdata_parts[1], ':') !== false) {
480 //get the first two fields
481 $custvalues = array();
482 foreach ($custdata_parts as $custdet) {
483 if (strlen($custdet) < 1) {
484 continue;
485 }
486 $custdet_parts = explode(':', $custdet);
487 if (count($custdet_parts) >= 2) {
488 unset($custdet_parts[0]);
489 array_push($custvalues, trim(implode(':', $custdet_parts)));
490 }
491 if (count($custvalues) > 1) {
492 break;
493 }
494 }
495 if (count($custvalues) > 1) {
496 $custdata = implode(' ', $custvalues);
497 }
498 }
499 if (strlen($custdata) > 45) {
500 if (function_exists('mb_substr')) {
501 $custdata = mb_substr($custdata, 0, 45, 'UTF-8') . " ...";
502 } else {
503 $custdata = substr($custdata, 0, 45) . " ...";
504 }
505 }
506
507 // customer profile picture
508 $customer_avatar = null;
509
510 $q = "SELECT `c`.*,`co`.`idorder` FROM `#__vikbooking_customers` AS `c` LEFT JOIN `#__vikbooking_customers_orders` `co` ON `c`.`id`=`co`.`idcustomer` WHERE `co`.`idorder`=".$row['id'];
511 $dbo->setQuery($q, 0, 1);
512 $cust_country = $dbo->loadAssoc();
513 if ($cust_country) {
514 if (!empty($cust_country['first_name'])) {
515 $custdata = $cust_country['first_name'].' '.$cust_country['last_name'];
516 if (!empty($cust_country['country'])) {
517 if (file_exists(VBO_ADMIN_PATH.DS.'resources'.DS.'countries'.DS.$cust_country['country'].'.png')) {
518 $custdata .= '<img src="'.VBO_ADMIN_URI.'resources/countries/'.$cust_country['country'].'.png'.'" title="'.$cust_country['country'].'" class="vbo-country-flag vbo-country-flag-left"/>';
519 }
520 }
521 }
522 if (!empty($cust_country['pic'])) {
523 $customer_avatar = $cust_country['pic'];
524 }
525 }
526 $custdata = $row['closure'] > 0 || JText::translate('VBDBTEXTROOMCLOSED') == $row['custdata'] ? '<span class="vbordersroomclosed"><i class="'.VikBookingIcons::i('ban').'"></i> '.JText::translate('VBDBTEXTROOMCLOSED').'</span>' : $custdata;
527
528 if ($row['status'] == "confirmed") {
529 $saystaus = '<span class="label label-success vbo-status-label">' . JText::translate('VBCONFIRMED') . '</span>';
530 if (!empty($row['type']) && !strcasecmp($row['type'], 'overbooking')) {
531 $saystaus .= '<div class="vbo-orders-substatus"><span class="label label-error">' . JText::translate('VBO_BTYPE_' . strtoupper($row['type'])) . '</span></div>';
532 }
533 } elseif ($row['status'] == "standby") {
534 $status_type = !empty($row['type']) ? JText::translate('VBO_BTYPE_' . strtoupper($row['type'])) : JText::translate('VBSTANDBY');
535 $saystaus = '<span class="label label-warning vbo-status-label">' . $status_type . '</span>';
536 } else {
537 $saystaus = '<span class="label label-error vbo-status-label">' . JText::translate('VBCANCELLED') . '</span>';
538 }
539 $ts_info = getdate($row['ts']);
540 $ts_wday = JText::translate('VB'.strtoupper(substr($ts_info['weekday'], 0, 3)));
541 $checkin_info = getdate($row['checkin']);
542 $checkin_wday = JText::translate('VB'.strtoupper(substr($checkin_info['weekday'], 0, 3)));
543 $checkout_info = getdate($row['checkout']);
544 $checkout_wday = JText::translate('VB'.strtoupper(substr($checkout_info['weekday'], 0, 3)));
545 ?>
546
547 <tr class="row<?php echo $kk; ?>">
548 <td class="skip">
549 <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onclick="Joomla.isChecked(this.checked);">
550 </td>
551 <td class="center">
552 <a class="vbo-bookingid" href="index.php?option=com_vikbooking&amp;task=editorder&amp;cid[]=<?php echo $row['id']; ?>"><?php echo $row['id']; ?></a>
553 </td>
554 <td>
555 <a class="vbo-bookingslist-viewdet-link" href="index.php?option=com_vikbooking&amp;task=editorder&amp;cid[]=<?php echo $row['id']; ?>">
556 <div class="vbo-bookingslist-viewdet">
557 <div class="vbo-bookingslist-viewdet-open">
558 <?php VikBookingIcons::e('external-link'); ?>
559 </div>
560 <div class="vbo-bookingslist-viewdet-fulldate">
561 <div class="vbo-bookingslist-viewdet-date">
562 <?php
563 if (strpos($df, 'd') < strpos($df, 'm')) {
564 //assuming d/m/Y or similar
565 ?>
566 <span><?php echo $ts_info['mday']; ?></span>
567 <span><?php echo $monsmap[($ts_info['mon'] - 1)]; ?></span>
568 <?php
569 } else {
570 //assuming m/d/Y or similar
571 ?>
572 <span><?php echo $monsmap[($ts_info['mon'] - 1)]; ?></span>
573 <span><?php echo $ts_info['mday']; ?></span>
574 <?php
575 }
576 ?>
577 <span><?php echo $ts_info['year']; ?></span>
578 </div>
579 <div class="vbo-bookingslist-viewdet-time">
580 <span class="vbo-bookingslist-viewdet-wday"><?php echo $ts_wday; ?></span>
581 <span class="vbo-bookingslist-viewdet-hour"><?php echo date('H:i', $row['ts']); ?></span>
582 </div>
583 </div>
584 </div>
585 </a>
586 </td>
587 <td>
588 <?php
589 if (!empty($customer_avatar)) {
590 // build caption name
591 $avatar_caption = '';
592 if (isset($cust_country) && !empty($cust_country) && !empty($cust_country['first_name'])) {
593 $avatar_caption = $cust_country['first_name'] . ' ' . $cust_country['last_name'];
594 }
595 ?>
596 <div class="vbo-customer-info-box">
597 <div class="vbo-customer-info-box-name">
598 <?php echo $custdata; ?>
599 </div>
600 <div class="vbo-customer-info-box-avatar vbo-customer-avatar-small">
601 <span>
602 <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); ?>" />
603 </span>
604 </div>
605 </div>
606 <?php
607 } else {
608 echo $custdata;
609 }
610 ?>
611 <span class="vbo-orders-review-link" style="display: none;" title="<?php echo addslashes(JText::translate('VBOSEEGUESTREVIEW')); ?>" data-bid="<?php echo $row['id']; ?>"></span>
612 </td>
613 <td class="center">
614 <?php
615 if (count($room_names) > 1) {
616 if ($row['split_stay']) {
617 ?>
618 <div class="vbo-booking-with-splitstay">
619 <span class="hasTooltip vbo-tip-small vbo-room-sharedcalendar vbo-booking-has-splitstay" title="<?php echo JHtml::fetch('esc_attr', JText::translate('VBO_SPLIT_STAY')); ?>"><?php VikBookingIcons::e('random'); ?></span>
620 <span class="hasTooltip vbo-tip-small vbo-bookingslist-numrooms" title="<?php echo implode(', ', $room_names); ?>"><?php echo $row['roomsnum']; ?></span>
621 </div>
622 <?php
623 } else {
624 ?>
625 <span class="hasTooltip vbo-tip-small vbo-bookingslist-numrooms" title="<?php echo implode(', ', $room_names); ?>"><?php echo $row['roomsnum']; ?></span>
626 <?php
627 }
628 } else {
629 ?>
630 <span class="vbo-bookingslist-roomname"><?php echo $row['roomsnum'] == 1 && count($room_names) > 0 ? $room_names[0] : $row['roomsnum']; ?></span>
631 <?php
632 $room_number = '';
633 if ($rooms && !empty($rooms[0]) && !empty($rooms[0]['roomindex']) && !empty($rooms[0]['params'])) {
634 // print the room number when it's just one room booked
635 $room_params = json_decode($rooms[0]['params'], true);
636 if (is_array($room_params) && !empty($room_params['features']) && is_array($room_params['features'])) {
637 // parse distinctive features
638 foreach ($room_params['features'] as $rind => $rfeatures) {
639 if ($rind != $rooms[0]['roomindex']) {
640 continue;
641 }
642 foreach ($rfeatures as $fname => $fval) {
643 if (strlen($fval)) {
644 $room_number = '#' . $fval;
645 break 2;
646 }
647 }
648 }
649 }
650 }
651 if ($room_number) {
652 ?>
653 <span class="vbo-bookingslist-roomunit"><?php echo $room_number; ?></span>
654 <?php
655 }
656 }
657 ?>
658 </td>
659 <td>
660 <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>
661 <span><?php echo $peoplestr; ?></span>
662 </td>
663 <td>
664 <div class="vbo-bookingslist-booktime vbo-bookingslist-booktime-checkin">
665 <div class="vbo-bookingslist-booktime-fulldate">
666 <div class="vbo-bookingslist-booktime-date">
667 <span><?php echo date(str_replace("/", $datesep, $df), $row['checkin']); ?></span>
668 </div>
669 <div class="vbo-bookingslist-booktime-time">
670 <span class="vbo-bookingslist-booktime-twrap">
671 <span class="vbo-bookingslist-booktime-wday"><?php echo $checkin_wday; ?></span>
672 <span class="vbo-bookingslist-booktime-hour"><?php echo date('H:i', $row['checkin']); ?></span>
673 </span>
674 <?php
675 if ($row['checked'] == 1) {
676 //checked in
677 ?>
678 <span class="vbo-bookingslist-booktime-checkedin"><i class="<?php echo VikBookingIcons::i('circle', 'hasTooltip'); ?>" title="<?php echo JText::translate('VBOCHECKEDSTATUSIN'); ?>"></i></span>
679 <?php
680 } elseif ($row['checked'] < 0) {
681 //no show
682 ?>
683 <span class="vbo-bookingslist-booktime-noshow"><i class="<?php echo VikBookingIcons::i('circle', 'hasTooltip'); ?>" title="<?php echo JText::translate('VBOCHECKEDSTATUSNOS'); ?>"></i></span>
684 <?php
685 }
686 ?>
687 </div>
688 </div>
689 </div>
690 </td>
691 <td>
692 <div class="vbo-bookingslist-booktime vbo-bookingslist-booktime-checkin">
693 <div class="vbo-bookingslist-booktime-fulldate">
694 <div class="vbo-bookingslist-booktime-date">
695 <span><?php echo date(str_replace("/", $datesep, $df), $row['checkout']); ?></span>
696 </div>
697 <div class="vbo-bookingslist-booktime-time">
698 <span class="vbo-bookingslist-booktime-twrap">
699 <span class="vbo-bookingslist-booktime-wday"><?php echo $checkout_wday; ?></span>
700 <span class="vbo-bookingslist-booktime-hour"><?php echo date('H:i', $row['checkout']); ?></span>
701 </span>
702 <?php
703 if ($row['checked'] == 2) {
704 //checked out
705 ?>
706 <span class="vbo-bookingslist-booktime-checkedout"><i class="<?php echo VikBookingIcons::i('circle', 'hasTooltip'); ?>" title="<?php echo JText::translate('VBOCHECKEDSTATUSOUT'); ?>"></i></span>
707 <?php
708 }
709 ?>
710 </div>
711 </div>
712 </div>
713 </td>
714 <td class="center">
715 <span class="vbo-bookingslist-numnights"><?php echo $row['days']; ?></span>
716 </td>
717 <td class="center">
718 <div class="vbo-bookingslist-total-wrap">
719 <div class="vbo-bookingslist-total-amount">
720 <span><?php echo strlen($otacurrency) > 0 ? $otacurrency : $currencysymb; ?></span>
721 <span><?php echo VikBooking::numberFormat($isdue); ?></span>
722 </div>
723 <?php
724 if (!is_null($row['totpaid'])) {
725 ?>
726 <div class="vbo-bookingslist-total-totpaid">
727 <span><?php echo $currencysymb; ?></span>
728 <span><?php echo VikBooking::numberFormat($row['totpaid']); ?></span>
729 <?php
730 if ($row['refund'] > 0) {
731 ?>
732 <span class="vbo-bookingslist-total-refunded">
733 <span><?php echo $currencysymb; ?></span>
734 <span><?php echo VikBooking::numberFormat($row['refund']); ?></span>
735 </span>
736 <?php
737 }
738 ?>
739 </div>
740 <?php
741 } elseif ($row['refund'] > 0) {
742 ?>
743 <div class="vbo-bookingslist-total-totpaid">
744 <span class="vbo-bookingslist-total-refunded">
745 <span><?php echo $currencysymb; ?></span>
746 <span><?php echo VikBooking::numberFormat($row['refund']); ?></span>
747 </span>
748 </div>
749 <?php
750 }
751 ?>
752 </div>
753 </td>
754 <td class="center">
755 <?php
756 $bcolortag = VikBooking::applyBookingColorTag($row, $colortags);
757 if (count($bcolortag) > 0) {
758 $bcolortag['name'] = JText::translate($bcolortag['name']);
759 ?>
760 <div class="vbo-colortag-circle hasTooltip" style="background-color: <?php echo $bcolortag['color']; ?>;" title="<?php echo $bcolortag['name']; ?>" data-ctagcolor="<?php echo $bcolortag['color']; ?>" data-bid="<?php echo $row['id']; ?>"></div>
761 <?php
762 }
763 ?>
764 </td>
765 <td class="center">
766 <?php
767 if (!empty($row['adminnotes'])) {
768 ?>
769 <span class="vbo-admin-tipsicon vbo-admin-notes-icn" data-bid="<?php echo $row['id']; ?>"><?php VikBookingIcons::e('sticky-note'); ?></span>&nbsp;
770 <div class="vbo-order-admin-notes-cnt" data-bid="<?php echo $row['id']; ?>" style="display: none;"><?php echo nl2br($row['adminnotes']); ?></div>
771 <?php
772 }
773 $invoice_path = implode(DIRECTORY_SEPARATOR, [VBO_SITE_PATH, 'helpers', 'invoices', 'generated', "{$row['id']}_{$row['sid']}.pdf"]);
774 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>' : '');
775 ?>
776 <span class="vbo-bookings-guestmessages-bubble-cont vbo-admin-tipsicon" style="display: none;" data-bid="<?php echo $row['id']; ?>">
777 <a href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $row['id']; ?>#messaging">
778 <i class="<?php echo VikBookingIcons::i('commenting'); ?>" data-message-count="0"></i>
779 </a>
780 </span>
781 </td>
782 <td class="center">
783 <?php echo $saystaus; ?>
784 </td>
785 <td class="center">
786 <?php
787 if (!empty($row['channel'])) {
788 //VBO 1.10: use of strtolower($otachannelclass) next to the class 'vbotasp' is deprecated. Fetch the OTA logo from VCM
789 $ota_logo_img = is_object($vcm_logos) ? $vcm_logos->setProvenience($otachannel, $row['channel'])->getLogoURL() : false;
790 if ($ota_logo_img !== false) {
791 ?>
792 <img src="<?php echo $ota_logo_img; ?>" class="vbo-channelimg-medium"/>
793 <?php
794 } else {
795 ?>
796 <span class="vbo-provenience"><?php echo $otachannel; ?></span>
797 <?php
798 }
799 } else {
800 ?>
801 <span class="vbo-provenience"><?php echo JText::translate('VBORDFROMSITE'); ?></span>
802 <?php
803 }
804 ?>
805 </td>
806 </tr>
807 <?php
808 $kk = 1 - $kk;
809
810 }
811 ?>
812
813 </table>
814 </div>
815 <input type="hidden" name="option" value="com_vikbooking" />
816 <input type="hidden" name="cust_id" id="cust_id" value="<?php echo !empty($pcust_id) ? $pcust_id : ''; ?>" />
817 <input type="hidden" name="task" value="orders" />
818 <input type="hidden" name="boxchecked" value="0" />
819 <?php echo JHtml::fetch('form.token'); ?>
820 <?php echo $navbut; ?>
821 </form>
822
823 <a style="display: none;" id="vcm-review-details-base" href="index.php?option=com_vikchannelmanager&task=reviews&revid="></a>
824
825 <script type="text/javascript">
826 if (jQuery.isFunction(jQuery.fn.tooltip)) {
827 jQuery(".hasTooltip").tooltip();
828 } else {
829 jQuery.fn.tooltip = function(){};
830 }
831 function vboToggleDateFilt(dtype) {
832 if (!(dtype.length > 0)) {
833 document.getElementById('vbo-dates-cont').style.display = 'none';
834 document.getElementById('vbo-date-from').value = '';
835 document.getElementById('vbo-date-to').value = '';
836 return true;
837 }
838 document.getElementById('vbo-dates-cont').style.display = 'inline-block';
839 return true;
840 }
841 var bctags_tip = "<?php echo $bctags_tip; ?>";
842 var applying_tag = false;
843 var bctags_tip_on = false;
844
845 jQuery(function() {
846
847 jQuery(document.body).on('click', '.vbo-colortag-circle', function() {
848 if (!jQuery(this).parent().find(".vbo-blist-tip-bctag-subtip").length) {
849 jQuery(".vbo-blist-tip-bctag-subtip").remove();
850 var cur_color = jQuery(this).attr("data-ctagcolor");
851 var cur_bid = jQuery(this).attr("data-bid");
852 jQuery(this).after("<div class=\"vbo-blist-tip-bctag-subtip\">"+bctags_tip+"</div>");
853 jQuery(this).parent().find(".vbo-blist-tip-bctag-subtip").find(".vbo-blist-tip-bctag-subtip-circle[data-ctagcolor='"+cur_color+"']").addClass("vbo-blist-tip-bctag-activecircle").css('border-color', cur_color);
854 jQuery(this).parent().find(".vbo-blist-tip-bctag-subtip").find(".vbo-blist-tip-bctag-subtip-circle").attr('data-bid', cur_bid);
855 jQuery(".vbo-blist-tip-bctag-subtip .hasTooltip").tooltip();
856 bctags_tip_on = true;
857 } else {
858 jQuery(".vbo-blist-tip-bctag-subtip").remove();
859 bctags_tip_on = false;
860 }
861 });
862
863 jQuery(document.body).on('click', '.vbo-blist-tip-bctag-subtip-circle', function() {
864 if (applying_tag === true) {
865 return false;
866 }
867 applying_tag = true;
868 var clickelem = jQuery(this);
869 var ctagkey = clickelem.attr('data-ctagkey');
870 var bid = clickelem.attr('data-bid');
871 // set opacity to circles as loading
872 jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '0.6');
873
874 VBOCore.doAjax(
875 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=setbookingtag'); ?>",
876 {
877 tmpl: "component",
878 idorder: bid,
879 tagkey: ctagkey
880 },
881 (res) => {
882 applying_tag = false;
883 if (res.indexOf('e4j.error') >= 0) {
884 console.log(res);
885 alert(res.replace("e4j.error.", ""));
886 //restore loading opacity in circles
887 jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '1');
888 } else {
889 var obj_res = JSON.parse(res);
890 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);
891 jQuery(".vbo-blist-tip-bctag-subtip").remove();
892 bctags_tip_on = false;
893 }
894 },
895 (err) => {
896 applying_tag = false;
897 alert("Request Failed");
898 //restore loading opacity in circles
899 jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '1');
900 }
901 );
902 });
903
904 jQuery('.vbo-bookingslist-viewdet-link').click(function(e) {
905 if (e && e.target.tagName.toUpperCase() == 'I') {
906 //open the link in a new window
907 e.preventDefault();
908 window.open(jQuery(this).attr('href'), '_blank');
909 }
910 });
911
912 jQuery('#vbo-date-from').datepicker({
913 showOn: 'focus',
914 dateFormat: '<?php echo $juidf; ?>',
915 onSelect: function( selectedDate ) {
916 jQuery('#vbo-date-to').datepicker('option', 'minDate', selectedDate);
917 }
918 });
919
920 jQuery('#vbo-date-to').datepicker({
921 showOn: 'focus',
922 dateFormat: '<?php echo $juidf; ?>',
923 onSelect: function( selectedDate ) {
924 jQuery('#vbo-date-from').datepicker('option', 'maxDate', selectedDate);
925 }
926 });
927
928 //Search customer - Start
929 var vbocustsdelay = (function() {
930 var timer = 0;
931 return function(callback, ms) {
932 clearTimeout (timer);
933 timer = setTimeout(callback, ms);
934 };
935 })();
936
937 function vboCustomerSearch(words) {
938 jQuery("#vbo-allbsearchcust-res").hide().html("");
939 jQuery("#customernominative").addClass('vbo-allbsearchcust-loading-inp');
940
941 VBOCore.doAjax(
942 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=searchcustomer'); ?>",
943 {
944 kw: words,
945 nopin: 1,
946 tmpl: "component"
947 },
948 (cont) => {
949 if (cont) {
950 var obj_res = typeof cont === 'string' ? JSON.parse(cont) : cont;
951 jQuery("#vbo-allbsearchcust-res").html(obj_res[1]);
952 } else {
953 jQuery("#vbo-allbsearchcust-res").html("");
954 }
955 jQuery("#vbo-allbsearchcust-res").show();
956 jQuery("#customernominative").removeClass('vbo-allbsearchcust-loading-inp');
957 },
958 (err) => {
959 jQuery("#customernominative").removeClass('vbo-allbsearchcust-loading-inp');
960 alert("Error Searching.");
961 }
962 );
963 }
964
965 jQuery("#customernominative").keyup(function(event) {
966 vbocustsdelay(function() {
967 var keywords = jQuery("#customernominative").val();
968 if (keywords.length > 1) {
969 if ((event.which > 96 && event.which < 123) || (event.which > 64 && event.which < 91) || event.which == 13) {
970 vboCustomerSearch(keywords);
971 }
972 } else {
973 if (jQuery("#vbo-allbsearchcust-res").is(":visible")) {
974 jQuery("#vbo-allbsearchcust-res").hide();
975 }
976 }
977 }, 600);
978 });
979
980 jQuery(document).on('click', '.vbo-custsearchres-entry', function() {
981 var customer_id = jQuery(this).attr('data-custid');
982 if (customer_id.length) {
983 document.location.href = 'index.php?option=com_vikbooking&task=orders&cust_id='+customer_id;
984 }
985 });
986 //Search customer - End
987
988 jQuery(document).keydown(function(e) {
989 if ( e.keyCode == 27 && bctags_tip_on === true ) {
990 jQuery(".vbo-blist-tip-bctag-subtip").remove();
991 bctags_tip_on = false;
992 }
993 if (e.keyCode == 13) {
994 //prevent form-submit by hitting enter
995 e.preventDefault();
996 return false;
997 }
998 });
999
1000 jQuery(document).mouseup(function(e) {
1001 if (!bctags_tip_on) {
1002 return false;
1003 }
1004 if (jQuery(".vbo-blist-tip-bctag-subtip").length) {
1005 var vbo_overlay_subtip_cont = jQuery(".vbo-blist-tip-bctag-subtip-inner");
1006 if (!vbo_overlay_subtip_cont.is(e.target) && vbo_overlay_subtip_cont.has(e.target).length === 0) {
1007 jQuery(".vbo-blist-tip-bctag-subtip").remove();
1008 bctags_tip_on = false;
1009 return true;
1010 }
1011 }
1012 });
1013
1014 jQuery(".vbo-bookingslist-table tr td").not(".skip").click(function() {
1015 //the checkbox for the booking is on the first TD of the row
1016 var trcbox = jQuery(this).parent("tr").find("td").first().find("input[type='checkbox']");
1017 if (!trcbox || !trcbox.length) {
1018 return;
1019 }
1020 trcbox.prop('checked', !(trcbox.prop('checked')));
1021 if (typeof Joomla !== 'undefined' && Joomla != null) {
1022 Joomla.isChecked(trcbox.prop('checked'));
1023 }
1024 });
1025
1026 jQuery(".vbo-bookingslist-table tr").dblclick(function() {
1027 if (document.selection && document.selection.empty) {
1028 document.selection.empty();
1029 } else if (window.getSelection) {
1030 var sel = window.getSelection();
1031 sel.removeAllRanges();
1032 }
1033 //the link to the booking details page is on the third TD of the row
1034 var olink = jQuery(this).find("td").first().next().next().find("a");
1035 if (!olink || !olink.length) {
1036 return;
1037 }
1038 document.location.href = olink.attr("href");
1039 });
1040
1041 <?php
1042 if ($filters_set) {
1043 ?>
1044 jQuery("#vbo-search-tools-btn").trigger("click");
1045 <?php
1046 }
1047 ?>
1048
1049 // count unread guest messages
1050 vcmCountGuestMessages();
1051
1052 // load guest reviews
1053 VBOCore.doAjax(
1054 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=bookings_have_reviews'); ?>",
1055 {
1056 tmpl: "component",
1057 bids: <?php echo json_encode($vcm_bids); ?>
1058 },
1059 (res) => {
1060 try {
1061 var obj = JSON.parse(res);
1062 var base_link = jQuery('#vcm-review-details-base').attr('href');
1063 for (var bid in obj) {
1064 if (!obj.hasOwnProperty(bid)) {
1065 continue;
1066 }
1067 jQuery('.vbo-orders-review-link[data-bid="' + bid + '"]').html('<a href="' + base_link + obj[bid] + '" target="_blank"><?php VikBookingIcons::e('star'); ?></a>').fadeIn();
1068 }
1069 } catch(err) {
1070 console.error(err);
1071 }
1072 },
1073 (err) => {
1074 console.log('request failed for loading booking reviews');
1075 }
1076 );
1077
1078 // zoom-able avatars
1079 jQuery('.vbo-customer-info-box-avatar').each(function() {
1080 var img = jQuery(this).find('img');
1081 if (!img.length) {
1082 return;
1083 }
1084 // register click listener
1085 img.on('click', function(e) {
1086 // stop events propagation
1087 e.preventDefault();
1088 e.stopPropagation();
1089
1090 // check for caption
1091 var caption = jQuery(this).attr('data-caption');
1092
1093 // build modal content
1094 var zoom_modal = jQuery('<div></div>').addClass('vbo-modal-overlay-block vbo-modal-overlay-zoom-image').css('display', 'block');
1095 var zoom_dismiss = jQuery('<a></a>').addClass('vbo-modal-overlay-close');
1096 zoom_dismiss.on('click', function() {
1097 jQuery('.vbo-modal-overlay-zoom-image').fadeOut();
1098 });
1099 zoom_modal.append(zoom_dismiss);
1100 var zoom_content = jQuery('<div></div>').addClass('vbo-modal-overlay-content vbo-modal-overlay-content-zoom-image');
1101 var zoom_head = jQuery('<div></div>').addClass('vbo-modal-overlay-content-head');
1102 var zoom_head_title = jQuery('<span></span>');
1103 if (caption) {
1104 zoom_head_title.text(caption);
1105 }
1106 var zoom_head_close = jQuery('<span></span>').addClass('vbo-modal-overlay-close-times').html('&times;');
1107 zoom_head_close.on('click', function() {
1108 jQuery('.vbo-modal-overlay-zoom-image').fadeOut();
1109 });
1110 zoom_head.append(zoom_head_title).append(zoom_head_close);
1111 var zoom_body = jQuery('<div></div>').addClass('vbo-modal-overlay-content-body vbo-modal-overlay-content-body-scroll');
1112 var zoom_image = jQuery('<div></div>').addClass('vbo-modal-zoom-image-wrap');
1113 zoom_image.append(jQuery(this).clone());
1114 zoom_body.append(zoom_image);
1115 zoom_content.append(zoom_head).append(zoom_body);
1116 zoom_modal.append(zoom_content);
1117 // append modal to body
1118 if (jQuery('.vbo-modal-overlay-zoom-image').length) {
1119 jQuery('.vbo-modal-overlay-zoom-image').remove();
1120 }
1121 jQuery('body').append(zoom_modal);
1122 });
1123 });
1124
1125 // open admin notes for a booking
1126 jQuery('.vbo-admin-notes-icn').click(function(e) {
1127 e.stopPropagation();
1128 var now_bid = jQuery(this).attr('data-bid');
1129 var hid_elm = jQuery('.vbo-order-admin-notes-cnt[data-bid="' + now_bid + '"]');
1130 if (!hid_elm || !hid_elm.length) {
1131 return;
1132 }
1133 VBOCore.displayModal({
1134 extra_class: 'vbo-modal-rounded',
1135 title: '<span class="label label-info">' + now_bid + '</span> ' + Joomla.JText._('VBADMINNOTESTOGGLE'),
1136 body: hid_elm.html(),
1137 });
1138 });
1139
1140 // view booking snapshot
1141 jQuery('.vbo-bookslist-snapshot').on('click', function(e) {
1142 e.stopPropagation();
1143 VBOCore.handleDisplayWidgetNotification({widget_id: 'booking_details'}, {booking_id: jQuery(this).attr('data-bid')});
1144 });
1145
1146 });
1147
1148 function vcmCountGuestMessages() {
1149 <?php
1150 // VCM Chat Guest Messages (if VCM is installed)
1151 if (count($vcm_bids) && is_file(VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php')) {
1152 ?>
1153 var all_bids = <?php echo json_encode($vcm_bids); ?>;
1154 VBOCore.doAjax(
1155 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=chat.count_unread_messages'); ?>",
1156 {
1157 tmpl: "component",
1158 id_order: all_bids
1159 },
1160 (res) => {
1161 var counters = JSON.parse(res);
1162 for (var bid in all_bids) {
1163 if (!all_bids.hasOwnProperty(bid)) {
1164 continue;
1165 }
1166 var booking_bubble = jQuery('.vbo-bookings-guestmessages-bubble-cont[data-bid="'+all_bids[bid]+'"]');
1167 if (!booking_bubble || !booking_bubble.length) {
1168 continue;
1169 }
1170 if (!counters.hasOwnProperty(all_bids[bid])) {
1171 // 0 messages to be read
1172 booking_bubble.find('i').attr('data-message-count', '0');
1173 booking_bubble.hide();
1174 continue;
1175 }
1176 booking_bubble.find('i').attr('data-message-count', counters[all_bids[bid]]);
1177 if (parseInt(counters[all_bids[bid]]) > 0) {
1178 booking_bubble.fadeIn();
1179 } else {
1180 booking_bubble.hide();
1181 }
1182 }
1183 },
1184 (err) => {
1185 console.error('AJAX request failed for counting guest messages from VCM');
1186 }
1187 );
1188 <?php
1189 }
1190 ?>
1191 }
1192 </script>
1193 <?php
1194
1195 //Invoices
1196 $pconfirmgen = VikRequest::getInt('confirmgen', '', 'request');
1197 if (count($cid) > 0 && !empty($cid[0])) {
1198 $oldinvdate = '';
1199 $nextinvnum = VikBooking::getNextInvoiceNumber();
1200 $invsuff = VikBooking::getInvoiceNumberSuffix();
1201 $companyinfo = VikBooking::getInvoiceCompanyInfo();
1202 //if editing an invoice (re-creating an existing invoice for a booking), do not increment the invoice number
1203 if (count($cid) == 1) {
1204 //the generate invoice btn of the booking details page can pass the invoice notes field via hidden field. If not empty, update invoice notes for this id
1205 $pinvnotes = VikRequest::getString('invnotes', '', 'request', VIKREQUEST_ALLOWHTML);
1206 if (!empty($pinvnotes)) {
1207 $pinvnotes = strpos($pinvnotes, '<br') !== false ? $pinvnotes : nl2br($pinvnotes);
1208 $q = "UPDATE `#__vikbooking_orders` SET `inv_notes`=".$dbo->quote($pinvnotes)." WHERE `id`=".(int)$cid[0].";";
1209 $dbo->setQuery($q);
1210 $dbo->execute();
1211 }
1212 //
1213 $q = "SELECT `number`,`for_date` FROM `#__vikbooking_invoices` WHERE `idorder`=" . (int)$cid[0];
1214 $dbo->setQuery($q, 0, 1);
1215 $prev_data = $dbo->loadAssoc();
1216 if ($prev_data) {
1217 $oldinvdate = $prev_data['for_date'];
1218 $prev_inv_number = intval(str_replace($invsuff, '', $prev_data['number']));
1219 if ($prev_inv_number > 0) {
1220 $nextinvnum = $prev_inv_number;
1221 }
1222 }
1223 }
1224 //
1225 ?>
1226 <div class="vbo-gen-invoices-helper" style="display: none;">
1227 <form action="index.php?option=com_vikbooking" method="post" id="vbo-geninv-form">
1228 <div class="vbo-calendar-cfield-entry">
1229 <label for="invoice_num"><?php echo JText::translate('VBINVSTARTNUM'); ?></label>
1230 <span><input type="number" min="1" size="4" value="<?php echo $nextinvnum; ?>" id="invoice_num" name="invoice_num" /></span>
1231 </div>
1232 <div class="vbo-calendar-cfield-entry">
1233 <label for="invoice_suff"><?php echo JText::translate('VBINVNUMSUFFIX'); ?></label>
1234 <span><input type="text" size="7" value="<?php echo $invsuff; ?>" id="invoice_suff" name="invoice_suff" /></span>
1235 </div>
1236 <div class="vbo-calendar-cfield-entry">
1237 <label for="invoice_date"><?php echo JText::translate('VBINVUSEDATE'); ?></label>
1238 <span>
1239 <select id="invoice_date" name="invoice_date">
1240 <?php
1241 if (!empty($oldinvdate)) {
1242 ?>
1243 <option value="<?php echo date($df, $oldinvdate); ?>"><?php echo date($df, $oldinvdate); ?></option>
1244 <?php
1245 }
1246 ?>
1247 <option value="<?php echo date($df, time()); ?>"><?php echo date($df, time()); ?></option>
1248 <option value="0"><?php echo JText::translate('VBINVUSEDATEBOOKING'); ?></option>
1249 </select>
1250 </span>
1251 </div>
1252 <div class="vbo-calendar-cfield-entry">
1253 <label for="company_info"><?php echo JText::translate('VBINVCOMPANYINFO'); ?></label>
1254 <span><textarea name="company_info" id="company_info" style="width: 98%; min-width: 98%; max-width: 98%; height: 70px;"><?php echo $companyinfo; ?></textarea></span>
1255 </div>
1256 <div class="vbo-calendar-cfield-entry">
1257 <label for="invoice_send"><i class="vboicn-envelop"></i><?php echo JText::translate('VBINVSENDVIAMAIL'); ?></label>
1258 <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>
1259 </div>
1260 <div class="vbo-calendar-cfields-bottom">
1261
1262 </div>
1263 <?php
1264 foreach ($cid as $invid) {
1265 echo '<input type="hidden" name="cid[]" value="'.$invid.'" />';
1266 }
1267 if ($pconfirmgen > 0) {
1268 echo '<input type="hidden" name="confirmgen" value="'.$cid[0].'" />';
1269 }
1270 ?>
1271 <input type="hidden" name="option" value="com_vikbooking" />
1272 <input type="hidden" name="task" value="geninvoices" />
1273 </form>
1274 </div>
1275
1276 <script type="text/javascript">
1277 jQuery(function() {
1278
1279 // render modal to generate the invoice(s)
1280 var gen_invoices_modal_body = VBOCore.displayModal({
1281 suffix: 'invoices',
1282 extra_class: 'vbo-modal-rounded vbo-modal-tall',
1283 title: Joomla.JText._('VBOGENINVOICES') + ' (<?php echo count($cid); ?>)',
1284 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>',
1285 <?php
1286 if (count($cid) === 1) {
1287 ?>
1288 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 addslashes(JText::translate('VBINVEDITBINFO')); ?></a>',
1289 <?php
1290 }
1291 ?>
1292 onDismiss: () => {
1293 jQuery('#vbo-geninv-form').appendTo('.vbo-gen-invoices-helper');
1294 },
1295 });
1296
1297 // set modal content
1298 jQuery('#vbo-geninv-form').appendTo(gen_invoices_modal_body);
1299
1300 <?php
1301 if ($pconfirmgen > 0) {
1302 ?>
1303 // prompt for immediate generation
1304 if (confirm(Joomla.JText._('VBCONFIRMGENINV'))) {
1305 document.getElementById('vbo-geninv-form').submit();
1306 }
1307 <?php
1308 }
1309 ?>
1310 });
1311 </script>
1312 <?php
1313 }
1314