PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
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 1.7.3 All 36 releases
vikbooking / admin / views / orders / tmpl / default.php

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

1,333 lines 56.2 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
54 // color tags
55 $colortags = VikBooking::loadBookingsColorTags();
56 $bctags_tip = '';
57 if (count($colortags) > 0) {
58 $bctags_tip = '<div class=\"vbo-blist-tip-bctag-subtip-inner\">';
59 foreach ($colortags as $ctagk => $ctagv) {
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>';
61 }
62 $bctags_tip .= '</div>';
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 JHtml::fetch('esc_attr', $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 echo $rsel;
268 }
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 JHtml::fetch('esc_attr', $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 (int) $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 JHtml::fetch('esc_attr', 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 </optgroup>
325 <optgroup label="<?php echo JHtml::fetch('esc_attr', JText::translate('VBPSHOWSEASONSTHREE')); ?>">
326 <option value="inquiry"<?php echo $pstatus == 'inquiry' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBO_BTYPE_INQUIRY'); ?></option>
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>
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>
332 </optgroup>
333 <optgroup label="<?php echo JHtml::fetch('esc_attr', JText::translate('VBOCHECKEDSTATUS')); ?>">
334 <option value="checkedin"<?php echo $pstatus == 'checkedin' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSIN'); ?></option>
335 <option value="checkedout"<?php echo $pstatus == 'checkedout' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSOUT'); ?></option>
336 <option value="noshow"<?php echo $pstatus == 'noshow' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSNOS'); ?></option>
337 <option value="none"<?php echo $pstatus == 'none' ? ' selected="selected"' : ''; ?>><?php echo JText::translate('VBOCHECKEDSTATUSZERO'); ?></option>
338 </optgroup>
339 </select>
340 </div>
341 <div class="btn-group pull-left">
342 <?php
343 $dates_filter = '';
344 $pdatefilt = $app->getUserStateFromRequest("vbo.orders.datefilt", 'datefilt', 0, 'int');
345 $pdatefiltfrom = $app->getUserStateFromRequest("vbo.orders.datefiltfrom", 'datefiltfrom', '', 'string');
346 $pdatefiltto = $app->getUserStateFromRequest("vbo.orders.datefiltto", 'datefiltto', '', 'string');
347 if (!empty($pdatefilt) && (!empty($pdatefiltfrom) || !empty($pdatefiltto))) {
348 $filters_set = true;
349 $dates_filter = JHtml::fetch('esc_attr', '&amp;datefilt='.$pdatefilt.(!empty($pdatefiltfrom) ? '&amp;datefiltfrom='.$pdatefiltfrom : '').(!empty($pdatefiltto) ? '&amp;datefiltto='.$pdatefiltto : ''));
350 }
351 $datesel = '<select name="datefilt" onchange="vboToggleDateFilt(this.value);"><option value="">'.JText::translate('VBOFILTERBYDATES').'</option>';
352 $datesel .= '<option value="1"'.(!empty($pdatefilt) && $pdatefilt == 1 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEBOOK').'</option>';
353 $datesel .= '<option value="2"'.(!empty($pdatefilt) && $pdatefilt == 2 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEIN').'</option>';
354 $datesel .= '<option value="3"'.(!empty($pdatefilt) && $pdatefilt == 3 ? ' selected="selected"' : '').'>'.JText::translate('VBOFILTERDATEOUT').'</option>';
355 $datesel .= '</select>';
356 echo $datesel;
357 ?>
358 </div>
359 <div class="btn-group pull-left" id="vbo-dates-cont" style="display: <?php echo (!empty($pdatefilt) && (!empty($pdatefiltfrom) || !empty($pdatefiltto)) ? 'inline-block' : 'none'); ?>;">
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" />
361 </div>
362 <div class="btn-group pull-left">
363 <button type="submit" class="btn btn-primary"><i class="icon-search"></i> <?php echo JText::translate('VBPVIEWORDERSSEARCHSUBM'); ?></button>
364 </div>
365 </div>
366 </div>
367
368 <div class="table-responsive">
369 <table cellpadding="4" cellspacing="0" border="0" width="100%" class="table table-striped vbo-bookingslist-table">
370 <thead>
371 <tr>
372 <th width="20">
373 <input type="checkbox" onclick="Joomla.checkAll(this)" value="" name="checkall-toggle">
374 </th>
375 <th class="title center" width="20" align="center">
376 <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" : "")); ?>">
377 <?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>')); ?>
378 </a>
379 </th>
380 <th class="title left" width="110">
381 <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" : "")); ?>">
382 <?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>')); ?>
383 </a>
384 </th>
385 <th class="title left" width="200"><span><?php echo JText::translate('VBPVIEWORDERSTWO'); ?></span></th>
386 <th class="title center" width="100" align="center"><span><?php echo JText::translate('VBPVIEWORDERSTHREE'); ?></span></th>
387 <th class="title left" width="120"><span><?php echo JText::translate('VBPVIEWORDERSPEOPLE'); ?></span></th>
388 <th class="title left" width="110">
389 <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" : "")); ?>">
390 <?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>')); ?>
391 </a>
392 </th>
393 <th class="title left" width="110">
394 <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" : "")); ?>">
395 <?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>')); ?>
396 </a>
397 </th>
398 <th class="title center" width="60" align="center">
399 <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" : "")); ?>">
400 <?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>')); ?>
401 </a>
402 </th>
403 <th class="title center" width="110" align="center">
404 <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" : "")); ?>">
405 <?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>')); ?>
406 </a>
407 </th>
408 <th class="title center" width="30" align="center"><span>&nbsp;</span></th>
409 <th class="title center" width="50" align="center"><span>&nbsp;</span></th>
410 <th class="title center" width="100" align="center"><span><?php echo JText::translate('VBPVIEWORDERSEIGHT'); ?></span></th>
411 <th class="title center" width="100" align="center"><span><?php echo JText::translate('VBPVIEWORDERCHANNEL'); ?></span></th>
412 </tr>
413 </thead>
414 <?php
415 $currencysymb = VikBooking::getCurrencySymb();
416 $monsmap = array(
417 JText::translate('VBSHORTMONTHONE'),
418 JText::translate('VBSHORTMONTHTWO'),
419 JText::translate('VBSHORTMONTHTHREE'),
420 JText::translate('VBSHORTMONTHFOUR'),
421 JText::translate('VBSHORTMONTHFIVE'),
422 JText::translate('VBSHORTMONTHSIX'),
423 JText::translate('VBSHORTMONTHSEVEN'),
424 JText::translate('VBSHORTMONTHEIGHT'),
425 JText::translate('VBSHORTMONTHNINE'),
426 JText::translate('VBSHORTMONTHTEN'),
427 JText::translate('VBSHORTMONTHELEVEN'),
428 JText::translate('VBSHORTMONTHTWELVE')
429 );
430 $vcm_logos = VikBooking::getVcmChannelsLogo('', true);
431 $kk = 0;
432 $i = 0;
433 for ($i = 0, $n = count($rows); $i < $n; $i++) {
434 $row = $rows[$i];
435 if (!$row['closure']) {
436 array_push($vcm_bids, $row['id']);
437 }
438 $rooms = VikBooking::loadOrdersRoomsData($row['id']);
439 $peoplestr = '';
440 $guest_nums = [];
441 $room_names = array();
442 if (is_array($rooms)) {
443 $totadults = 0;
444 $totchildren = 0;
445 $totpets = 0;
446 foreach ($rooms as $rr) {
447 $totadults += $rr['adults'];
448 $totchildren += $rr['children'];
449 $totpets += $rr['pets'];
450 $room_names[] = $rr['room_name'];
451 if ($row['split_stay']) {
452 // do not sum the guests in case of split stay rooms
453 $totadults = $rr['adults'];
454 $totchildren = $rr['children'];
455 }
456 }
457 $guest_nums[] = $totadults . " " . ($totadults > 1 ? JText::translate('VBMAILADULTS') : JText::translate('VBMAILADULT'));
458 if ($totchildren > 0) {
459 $guest_nums[] = $totchildren . " " . ($totchildren > 1 ? JText::translate('VBMAILCHILDREN') : JText::translate('VBMAILCHILD'));
460 }
461 if ($totpets > 0) {
462 $guest_nums[] = $totpets . " " . ($totpets > 1 ? JText::translate('VBO_PETS') : JText::translate('VBO_PET'));
463 }
464 $peoplestr = implode(', ', $guest_nums);
465 }
466 $isdue = $row['total'];
467 $otachannel = '';
468 $otacurrency = '';
469 if (!empty($row['channel'])) {
470 $channelparts = explode('_', $row['channel']);
471 $otachannel = array_key_exists(1, $channelparts) && strlen($channelparts[1]) > 0 ? $channelparts[1] : ucwords($channelparts[0]);
472 $otachannelclass = $otachannel;
473 if (strstr($otachannelclass, '.') !== false) {
474 $otaccparts = explode('.', $otachannelclass);
475 $otachannelclass = $otaccparts[0];
476 }
477 $otacurrency = strlen((string)$row['chcurrency']) ? $row['chcurrency'] : '';
478 }
479 //Customer Details
480 $custdata = $row['custdata'];
481 $custdata_parts = explode("\n", $row['custdata']);
482 if (count($custdata_parts) > 2 && strpos($custdata_parts[0], ':') !== false && strpos($custdata_parts[1], ':') !== false) {
483 //get the first two fields
484 $custvalues = array();
485 foreach ($custdata_parts as $custdet) {
486 if (strlen($custdet) < 1) {
487 continue;
488 }
489 $custdet_parts = explode(':', $custdet);
490 if (count($custdet_parts) >= 2) {
491 unset($custdet_parts[0]);
492 array_push($custvalues, trim(implode(':', $custdet_parts)));
493 }
494 if (count($custvalues) > 1) {
495 break;
496 }
497 }
498 if (count($custvalues) > 1) {
499 $custdata = implode(' ', $custvalues);
500 }
501 }
502 if (strlen($custdata) > 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 }
508 }
509
510 // customer profile picture
511 $customer_avatar = null;
512
513 $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'];
514 $dbo->setQuery($q, 0, 1);
515 $cust_country = $dbo->loadAssoc();
516 if ($cust_country) {
517 if (!empty($cust_country['first_name'])) {
518 $custdata = $cust_country['first_name'].' '.$cust_country['last_name'];
519 if (!empty($cust_country['country'])) {
520 if (file_exists(VBO_ADMIN_PATH.DS.'resources'.DS.'countries'.DS.$cust_country['country'].'.png')) {
521 $custdata .= '<img src="'.VBO_ADMIN_URI.'resources/countries/'.$cust_country['country'].'.png'.'" title="'.$cust_country['country'].'" class="vbo-country-flag vbo-country-flag-left"/>';
522 }
523 }
524 }
525 if (!empty($cust_country['pic'])) {
526 $customer_avatar = $cust_country['pic'];
527 }
528 }
529 $custdata = $row['closure'] > 0 || JText::translate('VBDBTEXTROOMCLOSED') == $row['custdata'] ? '<span class="vbordersroomclosed"><i class="'.VikBookingIcons::i('ban').'"></i> '.JText::translate('VBDBTEXTROOMCLOSED').'</span>' : $custdata;
530
531 if ($row['status'] == "confirmed") {
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 }
536 } elseif ($row['status'] == "standby") {
537 $status_type = !empty($row['type']) ? JText::translate('VBO_BTYPE_' . strtoupper($row['type'])) : JText::translate('VBSTANDBY');
538 $saystaus = '<span class="label label-warning vbo-status-label">' . $status_type . '</span>';
539 } else {
540 $saystaus = '<span class="label label-error vbo-status-label">' . JText::translate('VBCANCELLED') . '</span>';
541 }
542 $ts_info = getdate($row['ts']);
543 $ts_wday = JText::translate('VB'.strtoupper(substr($ts_info['weekday'], 0, 3)));
544 $checkin_info = getdate($row['checkin']);
545 $checkin_wday = JText::translate('VB'.strtoupper(substr($checkin_info['weekday'], 0, 3)));
546 $checkout_info = getdate($row['checkout']);
547 $checkout_wday = JText::translate('VB'.strtoupper(substr($checkout_info['weekday'], 0, 3)));
548 ?>
549
550 <tr class="row<?php echo $kk; ?>">
551 <td class="skip">
552 <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row['id']; ?>" onclick="Joomla.isChecked(this.checked);">
553 </td>
554 <td class="center">
555 <a class="vbo-bookingid" href="index.php?option=com_vikbooking&amp;task=editorder&amp;cid[]=<?php echo $row['id']; ?>"><?php echo $row['id']; ?></a>
556 </td>
557 <td>
558 <a class="vbo-bookingslist-viewdet-link" href="index.php?option=com_vikbooking&amp;task=editorder&amp;cid[]=<?php echo $row['id']; ?>">
559 <div class="vbo-bookingslist-viewdet">
560 <div class="vbo-bookingslist-viewdet-open">
561 <?php VikBookingIcons::e('external-link'); ?>
562 </div>
563 <div class="vbo-bookingslist-viewdet-fulldate">
564 <div class="vbo-bookingslist-viewdet-date">
565 <?php
566 if (strpos($df, 'd') < strpos($df, 'm')) {
567 //assuming d/m/Y or similar
568 ?>
569 <span><?php echo $ts_info['mday']; ?></span>
570 <span><?php echo $monsmap[($ts_info['mon'] - 1)]; ?></span>
571 <?php
572 } else {
573 //assuming m/d/Y or similar
574 ?>
575 <span><?php echo $monsmap[($ts_info['mon'] - 1)]; ?></span>
576 <span><?php echo $ts_info['mday']; ?></span>
577 <?php
578 }
579 ?>
580 <span><?php echo $ts_info['year']; ?></span>
581 </div>
582 <div class="vbo-bookingslist-viewdet-time">
583 <span class="vbo-bookingslist-viewdet-wday"><?php echo $ts_wday; ?></span>
584 <span class="vbo-bookingslist-viewdet-hour"><?php echo date('H:i', $row['ts']); ?></span>
585 </div>
586 </div>
587 </div>
588 </a>
589 </td>
590 <td>
591 <?php
592 if (!empty($customer_avatar)) {
593 // build caption name
594 $avatar_caption = '';
595 if (isset($cust_country) && !empty($cust_country) && !empty($cust_country['first_name'])) {
596 $avatar_caption = $cust_country['first_name'] . ' ' . $cust_country['last_name'];
597 }
598 ?>
599 <div class="vbo-customer-info-box">
600 <div class="vbo-customer-info-box-name">
601 <?php echo $custdata; ?>
602 </div>
603 <div class="vbo-customer-info-box-avatar vbo-customer-avatar-small">
604 <span>
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" />
606 </span>
607 </div>
608 </div>
609 <?php
610 } else {
611 echo $custdata;
612 }
613 ?>
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>
615 </td>
616 <td class="center">
617 <?php
618 if (count($room_names) > 1) {
619 if ($row['split_stay']) {
620 ?>
621 <div class="vbo-booking-with-splitstay">
622 <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>
623 <span class="hasTooltip vbo-tip-small vbo-bookingslist-numrooms" title="<?php echo implode(', ', $room_names); ?>"><?php echo $row['roomsnum']; ?></span>
624 </div>
625 <?php
626 } else {
627 ?>
628 <span class="hasTooltip vbo-tip-small vbo-bookingslist-numrooms" title="<?php echo implode(', ', $room_names); ?>"><?php echo $row['roomsnum']; ?></span>
629 <?php
630 }
631 } else {
632 ?>
633 <span class="vbo-bookingslist-roomname"><?php echo $row['roomsnum'] == 1 && count($room_names) > 0 ? $room_names[0] : $row['roomsnum']; ?></span>
634 <?php
635 $room_number = '';
636 if ($rooms && !empty($rooms[0]) && !empty($rooms[0]['roomindex']) && !empty($rooms[0]['params'])) {
637 // print the room number when it's just one room booked
638 $room_params = json_decode($rooms[0]['params'], true);
639 if (is_array($room_params) && !empty($room_params['features']) && is_array($room_params['features'])) {
640 // parse distinctive features
641 foreach ($room_params['features'] as $rind => $rfeatures) {
642 if ($rind != $rooms[0]['roomindex']) {
643 continue;
644 }
645 foreach ($rfeatures as $fname => $fval) {
646 if (strlen($fval)) {
647 $room_number = '#' . $fval;
648 break 2;
649 }
650 }
651 }
652 }
653 }
654 if ($room_number) {
655 ?>
656 <span class="vbo-bookingslist-roomunit"><?php echo $room_number; ?></span>
657 <?php
658 }
659 }
660 ?>
661 </td>
662 <td>
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>
665 </td>
666 <td>
667 <div class="vbo-bookingslist-booktime vbo-bookingslist-booktime-checkin">
668 <div class="vbo-bookingslist-booktime-fulldate">
669 <div class="vbo-bookingslist-booktime-date">
670 <span><?php echo date(str_replace("/", $datesep, $df), $row['checkin']); ?></span>
671 </div>
672 <div class="vbo-bookingslist-booktime-time">
673 <span class="vbo-bookingslist-booktime-twrap">
674 <span class="vbo-bookingslist-booktime-wday"><?php echo $checkin_wday; ?></span>
675 <span class="vbo-bookingslist-booktime-hour"><?php echo date('H:i', $row['checkin']); ?></span>
676 </span>
677 <?php
678 if ($row['checked'] == 1) {
679 //checked in
680 ?>
681 <span class="vbo-bookingslist-booktime-checkedin"><i class="<?php echo VikBookingIcons::i('circle', 'hasTooltip'); ?>" title="<?php echo JText::translate('VBOCHECKEDSTATUSIN'); ?>"></i></span>
682 <?php
683 } elseif ($row['checked'] < 0) {
684 //no show
685 ?>
686 <span class="vbo-bookingslist-booktime-noshow"><i class="<?php echo VikBookingIcons::i('circle', 'hasTooltip'); ?>" title="<?php echo JText::translate('VBOCHECKEDSTATUSNOS'); ?>"></i></span>
687 <?php
688 }
689 ?>
690 </div>
691 </div>
692 </div>
693 </td>
694 <td>
695 <div class="vbo-bookingslist-booktime vbo-bookingslist-booktime-checkin">
696 <div class="vbo-bookingslist-booktime-fulldate">
697 <div class="vbo-bookingslist-booktime-date">
698 <span><?php echo date(str_replace("/", $datesep, $df), $row['checkout']); ?></span>
699 </div>
700 <div class="vbo-bookingslist-booktime-time">
701 <span class="vbo-bookingslist-booktime-twrap">
702 <span class="vbo-bookingslist-booktime-wday"><?php echo $checkout_wday; ?></span>
703 <span class="vbo-bookingslist-booktime-hour"><?php echo date('H:i', $row['checkout']); ?></span>
704 </span>
705 <?php
706 if ($row['checked'] == 2) {
707 //checked out
708 ?>
709 <span class="vbo-bookingslist-booktime-checkedout"><i class="<?php echo VikBookingIcons::i('circle', 'hasTooltip'); ?>" title="<?php echo JText::translate('VBOCHECKEDSTATUSOUT'); ?>"></i></span>
710 <?php
711 }
712 ?>
713 </div>
714 </div>
715 </div>
716 </td>
717 <td class="center">
718 <span class="vbo-bookingslist-numnights"><?php echo $row['days']; ?></span>
719 </td>
720 <td class="center">
721 <div class="vbo-bookingslist-total-wrap">
722 <div class="vbo-bookingslist-total-amount">
723 <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($isdue), ($otacurrency ?: $currencysymb), ['<span>%s</span>', '<span>%s</span>']); ?>
724 </div>
725 <?php
726 if (!is_null($row['totpaid'])) {
727 ?>
728 <div class="vbo-bookingslist-total-totpaid">
729 <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($row['totpaid']), $currencysymb, ['<span>%s</span>', '<span>%s</span>']); ?>
730 <?php
731 if ($row['refund'] > 0) {
732 ?>
733 <span class="vbo-bookingslist-total-refunded">
734 <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($row['refund']), $currencysymb, ['<span>%s</span>', '<span>%s</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 <?php echo VikBooking::formatCurrencyNumber(VikBooking::numberFormat($row['refund']), $currencysymb, ['<span>%s</span>', '<span>%s</span>']); ?>
746 </span>
747 </div>
748 <?php
749 }
750 ?>
751 </div>
752 </td>
753 <td class="center">
754 <?php
755 $bcolortag = VikBooking::applyBookingColorTag($row, $colortags);
756 if (count($bcolortag) > 0) {
757 $bcolortag['name'] = JText::translate($bcolortag['name']);
758 ?>
759 <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>
760 <?php
761 }
762 ?>
763 </td>
764 <td class="center">
765 <?php
766 if (!empty($row['adminnotes'])) {
767 ?>
768 <span class="vbo-admin-tipsicon vbo-admin-notes-icn" data-bid="<?php echo $row['id']; ?>"><?php VikBookingIcons::e('sticky-note'); ?></span>&nbsp;
769 <div class="vbo-order-admin-notes-cnt" data-bid="<?php echo $row['id']; ?>" style="display: none;"><?php echo nl2br(htmlspecialchars($row['adminnotes'])); ?></div>
770 <?php
771 }
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
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>' : '');
782 ?>
783 <span class="vbo-bookings-guestmessages-bubble-cont vbo-admin-tipsicon" style="display: none;" data-bid="<?php echo $row['id']; ?>">
784 <a href="index.php?option=com_vikbooking&task=editorder&cid[]=<?php echo $row['id']; ?>#messaging">
785 <i class="<?php echo VikBookingIcons::i('commenting'); ?>" data-message-count="0"></i>
786 </a>
787 </span>
788 </td>
789 <td class="center">
790 <?php echo $saystaus; ?>
791 </td>
792 <td class="center">
793 <?php
794 if (!empty($row['channel'])) {
795 //VBO 1.10: use of strtolower($otachannelclass) next to the class 'vbotasp' is deprecated. Fetch the OTA logo from VCM
796 $ota_logo_img = is_object($vcm_logos) ? $vcm_logos->setProvenience($otachannel, $row['channel'])->getLogoURL() : false;
797 if ($ota_logo_img !== false) {
798 ?>
799 <img src="<?php echo $ota_logo_img; ?>" class="vbo-channelimg-medium"/>
800 <?php
801 } else {
802 ?>
803 <span class="vbo-provenience"><?php echo $otachannel; ?></span>
804 <?php
805 }
806 } else {
807 ?>
808 <span class="vbo-provenience"><?php echo JText::translate('VBORDFROMSITE'); ?></span>
809 <?php
810 }
811 ?>
812 </td>
813 </tr>
814 <?php
815 $kk = 1 - $kk;
816
817 }
818 ?>
819
820 </table>
821 </div>
822 <input type="hidden" name="option" value="com_vikbooking" />
823 <input type="hidden" name="cust_id" id="cust_id" value="<?php echo !empty($pcust_id) ? JHtml::fetch('esc_attr', $pcust_id) : ''; ?>" />
824 <input type="hidden" name="task" value="orders" />
825 <input type="hidden" name="boxchecked" value="0" />
826 <?php echo JHtml::fetch('form.token'); ?>
827 <?php echo $navbut; ?>
828 </form>
829
830 <script type="text/javascript">
831 if (typeof jQuery.fn.tooltip === 'function') {
832 jQuery(".hasTooltip").tooltip();
833 } else {
834 jQuery.fn.tooltip = function(){};
835 }
836 function vboToggleDateFilt(dtype) {
837 if (!(dtype.length > 0)) {
838 document.getElementById('vbo-dates-cont').style.display = 'none';
839 document.getElementById('vbo-date-from').value = '';
840 document.getElementById('vbo-date-to').value = '';
841 return true;
842 }
843 document.getElementById('vbo-dates-cont').style.display = 'inline-block';
844 return true;
845 }
846 var bctags_tip = "<?php echo $bctags_tip; ?>";
847 var applying_tag = false;
848 var bctags_tip_on = false;
849
850 jQuery(function() {
851
852 jQuery(document.body).on('click', '.vbo-colortag-circle', function() {
853 if (!jQuery(this).parent().find(".vbo-blist-tip-bctag-subtip").length) {
854 jQuery(".vbo-blist-tip-bctag-subtip").remove();
855 var cur_color = jQuery(this).attr("data-ctagcolor");
856 var cur_bid = jQuery(this).attr("data-bid");
857 jQuery(this).after("<div class=\"vbo-blist-tip-bctag-subtip\">"+bctags_tip+"</div>");
858 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);
859 jQuery(this).parent().find(".vbo-blist-tip-bctag-subtip").find(".vbo-blist-tip-bctag-subtip-circle").attr('data-bid', cur_bid);
860 jQuery(".vbo-blist-tip-bctag-subtip .hasTooltip").tooltip();
861 bctags_tip_on = true;
862 } else {
863 jQuery(".vbo-blist-tip-bctag-subtip").remove();
864 bctags_tip_on = false;
865 }
866 });
867
868 jQuery(document.body).on('click', '.vbo-blist-tip-bctag-subtip-circle', function() {
869 if (applying_tag === true) {
870 return false;
871 }
872 applying_tag = true;
873 var clickelem = jQuery(this);
874 var ctagkey = clickelem.attr('data-ctagkey');
875 var bid = clickelem.attr('data-bid');
876 // set opacity to circles as loading
877 jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '0.6');
878
879 VBOCore.doAjax(
880 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=setbookingtag'); ?>",
881 {
882 tmpl: "component",
883 idorder: bid,
884 tagkey: ctagkey
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");
903 //restore loading opacity in circles
904 jQuery('.vbo-blist-tip-bctag-subtip-circle').css('opacity', '1');
905 }
906 );
907 });
908
909 jQuery('.vbo-bookingslist-viewdet-link').click(function(e) {
910 if (e && e.target.tagName.toUpperCase() == 'I') {
911 //open the link in a new window
912 e.preventDefault();
913 window.open(jQuery(this).attr('href'), '_blank');
914 }
915 });
916
917 jQuery('#vbo-date-from').datepicker({
918 showOn: 'focus',
919 dateFormat: '<?php echo $juidf; ?>',
920 onSelect: function( selectedDate ) {
921 jQuery('#vbo-date-to').datepicker('option', 'minDate', selectedDate);
922 }
923 });
924
925 jQuery('#vbo-date-to').datepicker({
926 showOn: 'focus',
927 dateFormat: '<?php echo $juidf; ?>',
928 onSelect: function( selectedDate ) {
929 jQuery('#vbo-date-from').datepicker('option', 'maxDate', selectedDate);
930 }
931 });
932
933 //Search customer - Start
934 var vbocustsdelay = (function() {
935 var timer = 0;
936 return function(callback, ms) {
937 clearTimeout (timer);
938 timer = setTimeout(callback, ms);
939 };
940 })();
941
942 function vboCustomerSearch(words) {
943 jQuery("#vbo-allbsearchcust-res").hide().html("");
944 jQuery("#customernominative").addClass('vbo-allbsearchcust-loading-inp');
945
946 VBOCore.doAjax(
947 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=searchcustomer'); ?>",
948 {
949 kw: words,
950 nopin: 1,
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.");
966 }
967 );
968 }
969
970 jQuery("#customernominative").keyup(function(event) {
971 vbocustsdelay(function() {
972 var keywords = jQuery("#customernominative").val();
973 if (keywords.length > 1) {
974 if ((event.which > 96 && event.which < 123) || (event.which > 64 && event.which < 91) || event.which == 13) {
975 vboCustomerSearch(keywords);
976 }
977 } else {
978 if (jQuery("#vbo-allbsearchcust-res").is(":visible")) {
979 jQuery("#vbo-allbsearchcust-res").hide();
980 }
981 }
982 }, 600);
983 });
984
985 jQuery(document).on('click', '.vbo-custsearchres-entry', function() {
986 var customer_id = jQuery(this).attr('data-custid');
987 if (customer_id.length) {
988 document.location.href = 'index.php?option=com_vikbooking&task=orders&cust_id='+customer_id;
989 }
990 });
991 //Search customer - End
992
993 jQuery(document).keydown(function(e) {
994 if ( e.keyCode == 27 && bctags_tip_on === true ) {
995 jQuery(".vbo-blist-tip-bctag-subtip").remove();
996 bctags_tip_on = false;
997 }
998 if (e.keyCode == 13 && !e.altKey && !e.ctrlKey && !e.shiftKey) {
999 //prevent form-submit by hitting enter
1000 e.preventDefault();
1001 return false;
1002 }
1003 });
1004
1005 jQuery(document).mouseup(function(e) {
1006 if (!bctags_tip_on) {
1007 return;
1008 }
1009 if (jQuery(".vbo-blist-tip-bctag-subtip").length) {
1010 var vbo_overlay_subtip_cont = jQuery(".vbo-blist-tip-bctag-subtip-inner");
1011 if (!vbo_overlay_subtip_cont.is(e.target) && vbo_overlay_subtip_cont.has(e.target).length === 0) {
1012 jQuery(".vbo-blist-tip-bctag-subtip").remove();
1013 bctags_tip_on = false;
1014 return;
1015 }
1016 }
1017 });
1018
1019 jQuery(".vbo-bookingslist-table tr td").not(".skip").click(function() {
1020 //the checkbox for the booking is on the first TD of the row
1021 var trcbox = jQuery(this).parent("tr").find("td").first().find("input[type='checkbox']");
1022 if (!trcbox || !trcbox.length) {
1023 return;
1024 }
1025 trcbox.prop('checked', !(trcbox.prop('checked')));
1026 if (typeof Joomla !== 'undefined' && Joomla != null) {
1027 Joomla.isChecked(trcbox.prop('checked'));
1028 }
1029 });
1030
1031 jQuery(".vbo-bookingslist-table tr").dblclick(function() {
1032 if (document.selection && document.selection.empty) {
1033 document.selection.empty();
1034 } else if (window.getSelection) {
1035 var sel = window.getSelection();
1036 sel.removeAllRanges();
1037 }
1038 //the link to the booking details page is on the third TD of the row
1039 var olink = jQuery(this).find("td").first().next().next().find("a");
1040 if (!olink || !olink.length) {
1041 return;
1042 }
1043 document.location.href = olink.attr("href");
1044 });
1045
1046 <?php
1047 if ($filters_set) {
1048 ?>
1049 jQuery("#vbo-search-tools-btn").trigger("click");
1050 <?php
1051 }
1052 ?>
1053
1054 // count unread guest messages
1055 vcmCountGuestMessages();
1056
1057 // load guest reviews
1058 VBOCore.doAjax(
1059 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=bookings_have_reviews'); ?>",
1060 {
1061 tmpl: "component",
1062 bids: <?php echo json_encode($vcm_bids); ?>
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();
1087 }
1088 } catch(err) {
1089 console.error(err);
1090 }
1091 },
1092 (err) => {
1093 console.log('request failed for loading booking reviews');
1094 }
1095 );
1096
1097 // zoom-able avatars
1098 jQuery('.vbo-customer-info-box-avatar').each(function() {
1099 var img = jQuery(this).find('img');
1100 if (!img.length) {
1101 return;
1102 }
1103 // register click listener
1104 img.on('click', function(e) {
1105 // stop events propagation
1106 e.preventDefault();
1107 e.stopPropagation();
1108
1109 // check for caption
1110 var caption = jQuery(this).attr('data-caption');
1111
1112 // build modal content
1113 var zoom_modal = jQuery('<div></div>').addClass('vbo-modal-overlay-block vbo-modal-overlay-zoom-image').css('display', 'block');
1114 var zoom_dismiss = jQuery('<a></a>').addClass('vbo-modal-overlay-close');
1115 zoom_dismiss.on('click', function() {
1116 jQuery('.vbo-modal-overlay-zoom-image').fadeOut();
1117 });
1118 zoom_modal.append(zoom_dismiss);
1119 var zoom_content = jQuery('<div></div>').addClass('vbo-modal-overlay-content vbo-modal-overlay-content-zoom-image');
1120 var zoom_head = jQuery('<div></div>').addClass('vbo-modal-overlay-content-head');
1121 var zoom_head_title = jQuery('<span></span>');
1122 if (caption) {
1123 zoom_head_title.text(caption);
1124 }
1125 var zoom_head_close = jQuery('<span></span>').addClass('vbo-modal-overlay-close-times').html('&times;');
1126 zoom_head_close.on('click', function() {
1127 jQuery('.vbo-modal-overlay-zoom-image').fadeOut();
1128 });
1129 zoom_head.append(zoom_head_title).append(zoom_head_close);
1130 var zoom_body = jQuery('<div></div>').addClass('vbo-modal-overlay-content-body vbo-modal-overlay-content-body-scroll');
1131 var zoom_image = jQuery('<div></div>').addClass('vbo-modal-zoom-image-wrap');
1132 zoom_image.append(jQuery(this).clone());
1133 zoom_body.append(zoom_image);
1134 zoom_content.append(zoom_head).append(zoom_body);
1135 zoom_modal.append(zoom_content);
1136 // append modal to body
1137 if (jQuery('.vbo-modal-overlay-zoom-image').length) {
1138 jQuery('.vbo-modal-overlay-zoom-image').remove();
1139 }
1140 jQuery('body').append(zoom_modal);
1141 });
1142 });
1143
1144 // open admin notes for a booking
1145 jQuery('.vbo-admin-notes-icn').click(function(e) {
1146 e.stopPropagation();
1147 var now_bid = jQuery(this).attr('data-bid');
1148 var hid_elm = jQuery('.vbo-order-admin-notes-cnt[data-bid="' + now_bid + '"]');
1149 if (!hid_elm || !hid_elm.length) {
1150 return;
1151 }
1152 VBOCore.displayModal({
1153 extra_class: 'vbo-modal-rounded',
1154 title: '<span class="label label-info">' + now_bid + '</span> ' + Joomla.JText._('VBADMINNOTESTOGGLE'),
1155 body: hid_elm.html(),
1156 });
1157 });
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
1165 });
1166
1167 function vcmCountGuestMessages() {
1168 <?php
1169 // VCM Chat Guest Messages (if VCM is installed)
1170 if (count($vcm_bids) && is_file(VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php')) {
1171 ?>
1172 var all_bids = <?php echo json_encode($vcm_bids); ?>;
1173 VBOCore.doAjax(
1174 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=chat.count_unread_messages'); ?>",
1175 {
1176 tmpl: "component",
1177 id_order: all_bids
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 }
1201 }
1202 },
1203 (err) => {
1204 console.error('AJAX request failed for counting guest messages from VCM');
1205 }
1206 );
1207 <?php
1208 }
1209 ?>
1210 }
1211 </script>
1212 <?php
1213
1214 //Invoices
1215 $pconfirmgen = VikRequest::getInt('confirmgen', '', 'request');
1216 if (count($cid) > 0 && !empty($cid[0])) {
1217 $oldinvdate = '';
1218 $nextinvnum = VikBooking::getNextInvoiceNumber();
1219 $invsuff = VikBooking::getInvoiceNumberSuffix();
1220 $companyinfo = VikBooking::getInvoiceCompanyInfo();
1221 //if editing an invoice (re-creating an existing invoice for a booking), do not increment the invoice number
1222 if (count($cid) == 1) {
1223 //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
1224 $pinvnotes = VikRequest::getString('invnotes', '', 'request', VIKREQUEST_ALLOWHTML);
1225 if (!empty($pinvnotes)) {
1226 $pinvnotes = strpos($pinvnotes, '<br') !== false ? $pinvnotes : nl2br($pinvnotes);
1227 $q = "UPDATE `#__vikbooking_orders` SET `inv_notes`=".$dbo->quote($pinvnotes)." WHERE `id`=".(int)$cid[0].";";
1228 $dbo->setQuery($q);
1229 $dbo->execute();
1230 }
1231 //
1232 $q = "SELECT `number`,`for_date` FROM `#__vikbooking_invoices` WHERE `idorder`=" . (int)$cid[0];
1233 $dbo->setQuery($q, 0, 1);
1234 $prev_data = $dbo->loadAssoc();
1235 if ($prev_data) {
1236 $oldinvdate = $prev_data['for_date'];
1237 $prev_inv_number = intval(str_replace($invsuff, '', $prev_data['number']));
1238 if ($prev_inv_number > 0) {
1239 $nextinvnum = $prev_inv_number;
1240 }
1241 }
1242 }
1243 //
1244 ?>
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>',
1304 <?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
1309 }
1310 ?>
1311 onDismiss: () => {
1312 jQuery('#vbo-geninv-form').appendTo('.vbo-gen-invoices-helper');
1313 },
1314 });
1315
1316 // set modal content
1317 jQuery('#vbo-geninv-form').appendTo(gen_invoices_modal_body);
1318
1319 <?php
1320 if ($pconfirmgen > 0) {
1321 ?>
1322 // prompt for immediate generation
1323 if (confirm(Joomla.JText._('VBCONFIRMGENINV'))) {
1324 document.getElementById('vbo-geninv-form').submit();
1325 }
1326 <?php
1327 }
1328 ?>
1329 });
1330 </script>
1331 <?php
1332 }
1333