PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.6
VikBooking Hotel Booking Engine & PMS v1.8.6
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 / helpers / vikbooking.php

vikbooking.php in VikBooking Hotel Booking Engine & PMS 1.8.6, at admin/helpers/vikbooking.php

1,284 lines 47.9 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 // No direct access to this file
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 class VikBookingHelper
15 {
16 public static function printHeader($highlight = "")
17 {
18 $app = JFactory::getApplication();
19 $cookie = $app->input->cookie;
20 $tmpl = VikRequest::getVar('tmpl');
21 $view = VikRequest::getVar('view');
22
23 if ($tmpl == 'component') {
24 return;
25 }
26
27 if (VBOPlatformDetection::isWordPress()) {
28 /**
29 * @wponly Hide menu for Pro-update views
30 */
31 if (in_array($view, ['getpro'])) {
32 return;
33 }
34 }
35
36 // JS lang def
37 JText::script('VBOGUESTREVSVCMREQ');
38 JText::script('VBO_QUICK_ACTIONS');
39
40 $session = JFactory::getSession();
41 $admin_user = JFactory::getUser();
42
43 $has_vcm = is_file(VCM_SITE_PATH.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'lib.vikchannelmanager.php');
44 $backlogo = VikBooking::getBackendLogo();
45 $vbo_auth_admin = $admin_user->authorise('core.admin', 'com_vikbooking');
46 $vbo_auth_global = $admin_user->authorise('core.vbo.global', 'com_vikbooking');
47 $vbo_auth_rateplans = $admin_user->authorise('core.vbo.rateplans', 'com_vikbooking');
48 $vbo_auth_rooms = $admin_user->authorise('core.vbo.rooms', 'com_vikbooking');
49 $vbo_auth_pricing = $admin_user->authorise('core.vbo.pricing', 'com_vikbooking');
50 $vbo_auth_bookings = $admin_user->authorise('core.vbo.bookings', 'com_vikbooking');
51 $vbo_auth_availability = $admin_user->authorise('core.vbo.availability', 'com_vikbooking');
52 $vbo_auth_management = $admin_user->authorise('core.vbo.management', 'com_vikbooking');
53 $vbo_auth_pms = $admin_user->authorise('core.vbo.pms', 'com_vikbooking');
54 $vbo_auth_reports = $admin_user->authorise('core.vbo.pmsreports', 'com_vikbooking');
55 $vbo_auth_tm = $admin_user->authorise('core.vbo.tm', 'com_vikbooking');
56 $reviews_dld = 0;
57
58 // check for stored quick actions only once
59 $admin_menu_actions_checked = $session->get('admin_menu.actions.check', null, 'vikbooking');
60 if (!$admin_menu_actions_checked) {
61 $session->set('admin_menu.actions.check', 1, 'vikbooking');
62 }
63
64 /**
65 * Check VCM subscription status.
66 *
67 * @since 1.15.0 (J) - 1.5.0 (WP)
68 */
69 $vcm_expiration_reminder = VikBooking::getVCMSubscriptionStatus();
70
71 /**
72 * New back-end menu structure would support sub-titles for menu entries.
73 *
74 * <span class="vbo-submenu-item">
75 * <span class="vbo-submenu-item-txt vbo-submenu-item-title">Entry Title</span>
76 * <span class="vbo-submenu-item-help">I am the entry sub-text.</span>
77 * </span>
78 *
79 * @since 1.16.0 (J) - 1.6.0 (WP)
80 */
81 ?>
82 <div class="vbo-menu-container<?php echo $view == 'dashboard' ? ' vbo-menu-container-closer' : ''; ?>">
83 <div class="vbo-menu-left">
84 <a href="index.php?option=com_vikbooking"><img src="<?php echo VBO_ADMIN_URI.(!empty($backlogo) ? 'resources/'.$backlogo : 'vikbooking.png'); ?>" alt="VikBooking Logo" /></a>
85 </div>
86 <div class="vbo-menu-right">
87 <ul class="vbo-menu-ul">
88 <?php
89 if ($vbo_auth_global || $vbo_auth_management) {
90 ?><li class="vbo-menu-parent-li">
91 <span><?php VikBookingIcons::e('cogs'); ?><a><?php echo JText::translate('VBMENUFOUR'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
92 <div class="vbo-submenu-wrap">
93 <ul class="vbo-submenu-ul" data-menu-scope="global">
94 <?php if ($vbo_auth_global) : ?>
95 <li>
96 <div class="<?php echo ($highlight == "14" ? "vmenulinkactive" : "vmenulink"); ?>">
97 <a href="index.php?option=com_vikbooking&amp;task=payments">
98 <?php VikBookingIcons::e('credit-card'); ?>
99 <span class="vbo-submenu-item">
100 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTENEIGHT'); ?></span>
101 </span>
102 </a>
103 </div>
104 </li>
105 <?php endif; ?>
106 <?php if ($vbo_auth_global) : ?>
107 <li>
108 <div class="<?php echo ($highlight == "16" || $highlight == 'states' || $highlight == 'managestate' ? "vmenulinkactive" : "vmenulink"); ?>">
109 <a href="index.php?option=com_vikbooking&amp;task=customf">
110 <?php VikBookingIcons::e('address-card'); ?>
111 <span class="vbo-submenu-item">
112 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTENTEN'); ?></span>
113 </span>
114 </a>
115 </div>
116 </li>
117 <?php endif; ?>
118 <?php if ($vbo_auth_management) : ?>
119 <li>
120 <div class="<?php echo ($highlight == "21" ? "vmenulinkactive" : "vmenulink"); ?>">
121 <a href="index.php?option=com_vikbooking&amp;task=translations">
122 <?php VikBookingIcons::e('language'); ?>
123 <span class="vbo-submenu-item">
124 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTRANSLATIONS'); ?></span>
125 </span>
126 </a>
127 </div>
128 </li>
129 <?php endif; ?>
130 <?php if ($vbo_auth_global) : ?>
131 <li>
132 <div class="<?php echo ($highlight == "11" || $highlight == 'backups' || $highlight == 'overrides' ? "vmenulinkactive" : "vmenulink"); ?>">
133 <a href="index.php?option=com_vikbooking&amp;task=config">
134 <?php VikBookingIcons::e('cogs'); ?>
135 <span class="vbo-submenu-item">
136 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTWELVE'); ?></span>
137 </span>
138 </a>
139 </div>
140 </li>
141 <?php endif; ?>
142 </ul>
143 </div>
144 </li><?php
145 }
146 if ($vbo_auth_rateplans) {
147 ?><li class="vbo-menu-parent-li">
148 <span><?php VikBookingIcons::e('briefcase'); ?><a><?php echo JText::translate('VBMENURATEPLANS'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
149 <div class="vbo-submenu-wrap">
150 <ul class="vbo-submenu-ul" data-menu-scope="rateplans">
151 <li>
152 <div class="<?php echo ($highlight == "2" ? "vmenulinkactive" : "vmenulink"); ?>">
153 <a href="index.php?option=com_vikbooking&amp;task=iva">
154 <?php VikBookingIcons::e('percent'); ?>
155 <span class="vbo-submenu-item">
156 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUNINE'); ?></span>
157 </span>
158 </a>
159 </div>
160 </li>
161 <li>
162 <div class="<?php echo ($highlight == "1" ? "vmenulinkactive" : "vmenulink"); ?>">
163 <a href="index.php?option=com_vikbooking&amp;task=prices">
164 <?php VikBookingIcons::e('tags'); ?>
165 <span class="vbo-submenu-item">
166 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUFIVE'); ?></span>
167 </span>
168 </a>
169 </div>
170 </li>
171 <li>
172 <div class="<?php echo ($highlight == "17" ? "vmenulinkactive" : "vmenulink"); ?>">
173 <a href="index.php?option=com_vikbooking&amp;task=coupons">
174 <?php VikBookingIcons::e('user-tag'); ?>
175 <span class="vbo-submenu-item">
176 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUCOUPONS'); ?></span>
177 </span>
178 </a>
179 </div>
180 </li>
181 <li>
182 <div class="<?php echo ($highlight == "packages" ? "vmenulinkactive" : "vmenulink"); ?>">
183 <a href="index.php?option=com_vikbooking&amp;task=packages">
184 <?php VikBookingIcons::e('box'); ?>
185 <span class="vbo-submenu-item">
186 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUPACKAGES'); ?></span>
187 </span>
188 </a>
189 </div>
190 </li>
191 </ul>
192 </div>
193 </li><?php
194 }
195 if ($vbo_auth_rooms || $vbo_auth_pricing) {
196 ?><li class="vbo-menu-parent-li">
197 <span><?php VikBookingIcons::e('bed'); ?><a><?php echo JText::translate('VBMENUTWO'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
198 <div class="vbo-submenu-wrap">
199 <ul class="vbo-submenu-ul" data-menu-scope="rooms">
200 <?php if ($vbo_auth_rooms) : ?>
201 <li>
202 <div class="<?php echo ($highlight == "4" ? "vmenulinkactive" : "vmenulink"); ?>">
203 <a href="index.php?option=com_vikbooking&amp;task=categories">
204 <?php VikBookingIcons::e('filter'); ?>
205 <span class="vbo-submenu-item">
206 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUSIX'); ?></span>
207 </span>
208 </a>
209 </div>
210 </li>
211 <?php endif; ?>
212 <?php if ($vbo_auth_rooms) : ?>
213 <li>
214 <div class="<?php echo ($highlight == "5" ? "vmenulinkactive" : "vmenulink"); ?>">
215 <a href="index.php?option=com_vikbooking&amp;task=carat">
216 <?php VikBookingIcons::e('icons'); ?>
217 <span class="vbo-submenu-item">
218 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTENFOUR'); ?></span>
219 </span>
220 </a>
221 </div>
222 </li>
223 <?php endif; ?>
224 <?php if ($vbo_auth_pricing) : ?>
225 <li>
226 <div class="<?php echo ($highlight == "6" ? "vmenulinkactive" : "vmenulink"); ?>">
227 <a href="index.php?option=com_vikbooking&amp;task=optionals">
228 <?php VikBookingIcons::e('couch'); ?>
229 <span class="vbo-submenu-item">
230 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTENFIVE'); ?></span>
231 </span>
232 </a>
233 </div>
234 </li>
235 <?php endif; ?>
236 <?php if ($vbo_auth_rooms) : ?>
237 <li>
238 <div class="<?php echo ($highlight == "7" ? "vmenulinkactive" : "vmenulink"); ?>">
239 <a href="index.php?option=com_vikbooking&amp;task=rooms">
240 <?php VikBookingIcons::e('bed'); ?>
241 <span class="vbo-submenu-item">
242 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTEN'); ?></span>
243 </span>
244 </a>
245 </div>
246 </li>
247 <?php endif; ?>
248 </ul>
249 </div>
250 </li><?php
251 }
252 if ($vbo_auth_pricing) {
253 ?><li class="vbo-menu-parent-li">
254 <span><i class="vboicn-calculator"></i><a><?php echo JText::translate('VBMENUFARES'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
255 <div class="vbo-submenu-wrap">
256 <ul class="vbo-submenu-ul" data-menu-scope="pricing">
257 <li>
258 <div class="<?php echo ($highlight == "fares" ? "vmenulinkactive" : "vmenulink"); ?>">
259 <a href="index.php?option=com_vikbooking&amp;task=tariffs">
260 <?php VikBookingIcons::e('toolbox'); ?>
261 <span class="vbo-submenu-item">
262 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUPRICESTABLE'); ?></span>
263 </span>
264 </a>
265 </div>
266 </li>
267 <li>
268 <div class="<?php echo ($highlight == "13" ? "vmenulinkactive" : "vmenulink"); ?>">
269 <a href="index.php?option=com_vikbooking&amp;task=seasons">
270 <?php VikBookingIcons::e('seedling'); ?>
271 <span class="vbo-submenu-item">
272 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTENSEVEN'); ?></span>
273 </span>
274 </a>
275 </div>
276 </li>
277 <li>
278 <div class="<?php echo ($highlight == "restrictions" ? "vmenulinkactive" : "vmenulink"); ?>">
279 <a href="index.php?option=com_vikbooking&amp;task=restrictions">
280 <?php VikBookingIcons::e('hand-paper'); ?>
281 <span class="vbo-submenu-item">
282 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENURESTRICTIONS'); ?></span>
283 </span>
284 </a>
285 </div>
286 </li>
287 <li>
288 <div class="<?php echo ($highlight == "20" ? "vmenulinkactive" : "vmenulink"); ?>">
289 <a href="index.php?option=com_vikbooking&amp;task=ratesoverv">
290 <?php VikBookingIcons::e('calculator'); ?>
291 <span class="vbo-submenu-item">
292 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENURATESOVERVIEW'); ?></span>
293 </span>
294 </a>
295 </div>
296 </li>
297 </ul>
298 </div>
299 </li><?php
300 }
301 ?><li class="vbo-menu-parent-li">
302 <span><?php VikBookingIcons::e('calendar-check'); ?><a><?php echo JText::translate('VBMENUTHREE'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
303 <div class="vbo-submenu-wrap">
304 <ul class="vbo-submenu-ul" data-menu-scope="bookings">
305 <li>
306 <div class="<?php echo (in_array($highlight, ['18', 'shortcodes', 'acl', 'gotopro']) ? "vmenulinkactive" : "vmenulink"); ?>">
307 <a href="index.php?option=com_vikbooking">
308 <?php VikBookingIcons::e('concierge-bell'); ?>
309 <span class="vbo-submenu-item">
310 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUDASHBOARD'); ?></span>
311 </span>
312 </a>
313 </div>
314 </li>
315 <?php if ($vbo_auth_availability || $vbo_auth_bookings) : ?>
316 <li>
317 <div class="<?php echo ($highlight == "19" ? "vmenulinkactive" : "vmenulink"); ?>">
318 <a href="index.php?option=com_vikbooking&amp;task=calendar">
319 <?php VikBookingIcons::e('calendar'); ?>
320 <span class="vbo-submenu-item">
321 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUQUICKRES'); ?></span>
322 </span>
323 </a>
324 </div>
325 </li>
326 <?php endif; ?>
327 <?php if ($vbo_auth_availability) : ?>
328 <li>
329 <div class="<?php echo ($highlight == "15" ? "vmenulinkactive" : "vmenulink"); ?>">
330 <a href="index.php?option=com_vikbooking&amp;task=overv">
331 <?php VikBookingIcons::e('calendar-check'); ?>
332 <span class="vbo-submenu-item">
333 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTENNINE'); ?></span>
334 </span>
335 </a>
336 </div>
337 </li>
338 <?php endif; ?>
339 <?php if ($vbo_auth_bookings) : ?>
340 <li>
341 <div class="<?php echo ($highlight == "8" ? "vmenulinkactive" : "vmenulink"); ?>">
342 <a href="index.php?option=com_vikbooking&amp;task=orders">
343 <?php VikBookingIcons::e('clipboard-list'); ?>
344 <span class="vbo-submenu-item">
345 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUSEVEN'); ?></span>
346 </span>
347 </a>
348 </div>
349 </li>
350 <?php endif; ?>
351 <?php if (($has_vcm || VBOPlatformDetection::isWordPress()) && ($vbo_auth_availability || $vbo_auth_bookings)) : ?>
352 <li class="vbo-menu-vcm-only">
353 <div class="<?php echo ($highlight == 'vikchannelmanager' ? 'vmenulinkactive' : 'vmenulink'); ?>">
354 <a href="index.php?option=com_vikchannelmanager" class="vbo-menu-vcmlink">
355 <?php VikBookingIcons::e('cloud'); ?>
356 <span class="vbo-submenu-item">
357 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUCHANNELMANAGER'); ?></span>
358 </span>
359 </a>
360 </div>
361 </li>
362 <?php endif; ?>
363 </ul>
364 </div>
365 </li><?php
366 if ($vbo_auth_management) {
367 ?><li class="vbo-menu-parent-li">
368 <span><?php VikBookingIcons::e('chart-pie'); ?><a><?php echo JText::translate('VBMENUMANAGEMENT'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
369 <div class="vbo-submenu-wrap">
370 <ul class="vbo-submenu-ul" data-menu-scope="management">
371 <li>
372 <div class="<?php echo ($highlight == "22" ? "vmenulinkactive" : "vmenulink"); ?>">
373 <a href="index.php?option=com_vikbooking&amp;task=customers">
374 <?php VikBookingIcons::e('users'); ?>
375 <span class="vbo-submenu-item">
376 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUCUSTOMERS'); ?></span>
377 </span>
378 </a>
379 </div>
380 </li>
381 <li>
382 <div class="<?php echo ($highlight == "invoices" ? "vmenulinkactive" : "vmenulink"); ?>">
383 <a href="index.php?option=com_vikbooking&amp;task=invoices">
384 <?php VikBookingIcons::e('file-invoice'); ?>
385 <span class="vbo-submenu-item">
386 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUINVOICES'); ?></span>
387 </span>
388 </a>
389 </div>
390 </li>
391 <li>
392 <div class="<?php echo ($highlight == "stats" ? "vmenulinkactive" : "vmenulink"); ?>">
393 <a href="index.php?option=com_vikbooking&amp;task=stats">
394 <?php VikBookingIcons::e('chart-line'); ?>
395 <span class="vbo-submenu-item">
396 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUSTATS'); ?></span>
397 </span>
398 </a>
399 </div>
400 </li>
401 <li>
402 <div class="<?php echo ($highlight == "trackings" ? "vmenulinkactive" : "vmenulink"); ?>">
403 <a href="index.php?option=com_vikbooking&amp;task=trackings">
404 <?php VikBookingIcons::e('compass'); ?>
405 <span class="vbo-submenu-item">
406 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTRACKINGS'); ?></span>
407 </span>
408 </a>
409 </div>
410 </li>
411 <li>
412 <div class="<?php echo (in_array($highlight, ["crons", "managecron"]) ? "vmenulinkactive" : "vmenulink"); ?>">
413 <a href="index.php?option=com_vikbooking&amp;view=crons">
414 <?php VikBookingIcons::e('stopwatch'); ?>
415 <span class="vbo-submenu-item">
416 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUCRONS'); ?></span>
417 </span>
418 </a>
419 </div>
420 </li>
421 </ul>
422 </div>
423 </li><?php
424 }
425 if ($vbo_auth_pms || $vbo_auth_reports || $vbo_auth_tm) {
426 ?><li class="vbo-menu-parent-li">
427 <span><?php VikBookingIcons::e('tasks'); ?><a><?php echo JText::translate('VBMENUPMS'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
428 <div class="vbo-submenu-wrap">
429 <ul class="vbo-submenu-ul" data-menu-scope="pms"><?php
430 if ($vbo_auth_pms) {
431 ?><li>
432 <div class="<?php echo ($highlight == "operators" ? "vmenulinkactive" : "vmenulink"); ?>">
433 <a href="index.php?option=com_vikbooking&amp;task=operators">
434 <?php VikBookingIcons::e('user-tie'); ?>
435 <span class="vbo-submenu-item">
436 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUOPERATORS'); ?></span>
437 </span>
438 </a>
439 </div>
440 </li>
441 <li>
442 <div class="<?php echo ($highlight == "tableaux" ? "vmenulinkactive" : "vmenulink"); ?>">
443 <a href="index.php?option=com_vikbooking&amp;task=tableaux">
444 <?php VikBookingIcons::e('stream'); ?>
445 <span class="vbo-submenu-item">
446 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTABLEAUX'); ?></span>
447 </span>
448 </a>
449 </div>
450 </li><?php
451 }
452 if ($vbo_auth_admin || $vbo_auth_reports) {
453 ?><li>
454 <div class="<?php echo ($highlight == "pmsreports" ? "vmenulinkactive" : "vmenulink"); ?>">
455 <a href="index.php?option=com_vikbooking&amp;task=pmsreports">
456 <?php VikBookingIcons::e('cash-register'); ?>
457 <span class="vbo-submenu-item">
458 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUPMSREPORTS'); ?></span>
459 </span>
460 </a>
461 </div>
462 </li><?php
463 }
464 if ($vbo_auth_pms) {
465 ?><li>
466 <div class="<?php echo ($highlight == "einvoicing" ? "vmenulinkactive" : "vmenulink"); ?>">
467 <a href="index.php?option=com_vikbooking&amp;task=einvoicing">
468 <?php VikBookingIcons::e('laptop-code'); ?>
469 <span class="vbo-submenu-item">
470 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUEINVOICING'); ?></span>
471 </span>
472 </a>
473 </div>
474 </li><?php
475 }
476 if ($vbo_auth_admin || $vbo_auth_tm) {
477 ?><li class="vbo-menu-vcm-only">
478 <div class="<?php echo ($highlight == "taskmanager" ? "vmenulinkactive" : "vmenulink"); ?>">
479 <a href="index.php?option=com_vikbooking&amp;view=taskmanager">
480 <?php VikBookingIcons::e('tasks'); ?>
481 <span class="vbo-submenu-item">
482 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBO_TASK_MANAGER'); ?></span>
483 </span>
484 </a>
485 </div>
486 </li><?php
487 }
488 ?></ul>
489 </div>
490 </li><?php
491 }
492 ?>
493 </ul>
494 <div class="vbo-menu-updates">
495 <?php
496 if (VBOPlatformDetection::isWordPress()) {
497 /**
498 * @wponly PRO Version
499 */
500 VikBookingLoader::import('update.license');
501 if (!VikBookingLicense::isPro()) {
502 ?>
503 <button type="button" class="vbo-gotopro" title="<?php echo addslashes(JText::translate('VBOGOTOPROBTN')); ?>" onclick="document.location.href='admin.php?option=com_vikbooking&view=gotopro';">
504 <?php VikBookingIcons::e('rocket'); ?>
505 <span><?php echo JText::translate('VBOGOTOPROBTN'); ?></span>
506 </button>
507 <?php
508 } else {
509 ?>
510 <button type="button" class="vbo-alreadypro" title="<?php echo addslashes(JText::translate('VBOISPROBTN')); ?>" onclick="document.location.href='admin.php?option=com_vikbooking&view=gotopro';">
511 <?php VikBookingIcons::e('trophy'); ?>
512 <span><?php echo JText::translate('VBOISPROBTN'); ?></span>
513 </button>
514 <?php
515 }
516 } else {
517 /**
518 * @joomlaonly
519 */
520 if (($highlight == '18' || $highlight == '11') && method_exists($app, 'triggerEvent')) {
521 // VikUpdater
522 JPluginHelper::importPlugin('e4j');
523 $callable = $app->triggerEvent('onUpdaterSupported');
524 if (count($callable) && $callable[0]) {
525 //Plugin enabled
526 $params = new stdClass;
527 $params->version = E4J_SOFTWARE_VERSION;
528 $params->alias = 'com_vikbooking';
529
530 $upd_btn_text = strrev('setadpU kcehC');
531 $ready_jsfun = '';
532 $result = $app->triggerEvent('onGetVersionContents', array(&$params));
533 if (count($result) && $result[0]) {
534 $upd_btn_text = $result[0]->response->shortTitle;
535 } else {
536 $ready_jsfun = 'jQuery("#vik-update-btn").trigger("click");';
537 }
538 ?>
539 <button type="button" id="vik-update-btn" onclick="<?php echo count($result) && $result[0] && $result[0]->response->compare == 1 ? 'document.location.href=\'index.php?option=com_vikbooking&task=updateprogram\'' : 'checkVersion(this);'; ?>">
540 <i class="vboicn-cloud"></i>
541 <span><?php echo $upd_btn_text; ?></span>
542 </button>
543 <script type="text/javascript">
544 function checkVersion(button) {
545 jQuery(button).find('span').text('Checking...');
546 jQuery.ajax({
547 type: 'POST',
548 url: 'index.php?option=com_vikbooking&task=checkversion&tmpl=component',
549 data: {}
550 }).done(function(resp) {
551 var obj = typeof resp === 'string' ? JSON.parse(resp) : resp;
552 console.log(obj);
553 if (obj.status == 1 && obj.response.status == 1) {
554 jQuery(button).find('span').text(obj.response.shortTitle);
555 if (obj.response.compare == 1) {
556 jQuery(button).attr('onclick', 'document.location.href="index.php?option=com_vikbooking&task=updateprogram"');
557 }
558 }
559 }).fail(function(resp) {
560 console.log(resp);
561 });
562 }
563 jQuery(function() {
564 <?php echo $ready_jsfun; ?>
565 });
566 </script>
567 <?php
568 } else {
569 /**
570 * When Vik Updater is not available or disabled, we now
571 * render a modal for the automated installation of the plugin.
572 *
573 * @since 1.15.1
574 */
575
576 $data = [
577 'hn' => getenv('HTTP_HOST'),
578 'sn' => getenv('SERVER_NAME'),
579 'app' => CREATIVIKAPP,
580 'ver' => VIKBOOKING_SOFTWARE_VERSION,
581 ];
582
583 $vikupdater_url = 'https://extensionsforjoomla.com/vikcheck/vikupdater.php?' . http_build_query($data);
584
585 echo JHtml::fetch(
586 'bootstrap.renderModal',
587 'jmodal-version-check',
588 array(
589 'title' => 'Install VikUpdater',
590 'closeButton' => true,
591 'keyboard' => true,
592 'bodyHeight' => 80,
593 'url' => $vikupdater_url,
594 'footer' => '<button type="button" class="btn btn-success" id="version-check-install">' . JText::translate('JTOOLBAR_INSTALL') . '</button>',
595 )
596 );
597 ?>
598 <button type="button" id="vik-update-btn">
599 <i class="vboicn-cloud"></i>
600 <span></span>
601 </button>
602
603 <?php echo VikBooking::getVboApplication()->getJmodalScript(); ?>
604
605 <script>
606 (function($) {
607 'use strict';
608
609 $(function() {
610 $('#vik-update-btn').on('click', () => {
611 vboOpenJModal('version-check');
612 });
613
614 $('#version-check-install').on('click', () => {
615 const form = $('<form action="index.php?option=com_installer&task=install.install" method="post"></form>');
616
617 form.append('<input type="hidden" name="installtype" value="url" />');
618 form.append('<input type="hidden" name="install_url" value="https://extensionsforjoomla.com/vikapi/?task=products.freedownload&sku=vup" />');
619 form.append('<input type="hidden" name="return" value="<?php echo base64_encode(JUri::getInstance()); ?>" />');
620 form.append('<?php echo JHtml::fetch('form.token'); ?>');
621
622 $('body').append(form);
623
624 form.submit();
625 });
626 });
627 })(jQuery);
628 </script>
629 <?php
630 }
631 }
632 }
633
634 if ($vbo_auth_management && in_array($highlight, array('18', '11'))) {
635 // VCM Opportunities
636 $opp = VikBooking::getVcmOpportunityInstance();
637 if (!is_null($opp)) {
638 // download opportunities if it's time to do it
639 if ($opp->shouldRequestOpportunities()) {
640 $opp->downloadOpportunities();
641 }
642 // count opportunities
643 $opp_filters = array(
644 'status' => 0,
645 'action' => 0,
646 );
647 $new_opp_count = count($opp->loadOpportunities($opp_filters, null, null));
648 if ($new_opp_count > 0) {
649 ?>
650 <!-- <button type="button" class="vbo-opportunities-btnbadge" data-opportunity-count="<?php echo $new_opp_count; ?>" title="<?php echo htmlspecialchars(JText::translate('VBOGOTOOPPORTUNITIES')); ?>" onclick="document.location.href='<?php echo VBOFactory::getPlatform()->getUri()->admin('index.php?option=com_vikchannelmanager&task=opportunities', false); ?>';">
651 <?php VikBookingIcons::e('crown'); ?>
652 <span><?php echo JText::translate('VBOGOTOOPPORTUNITIES'); ?></span>
653 </button> -->
654 <?php
655 }
656 }
657
658 // Guest Reviews
659 $reviews_dld = VikBooking::shouldDownloadReviews();
660 $base_lnk = VBOFactory::getPlatform()->getUri()->admin('index.php?option=com_vikchannelmanager&task=reviews', false);
661 if ($highlight == '18') {
662 ?>
663 <button type="button" class="vbo-reviews-btnbadge" data-reviews-count="" title="<?php echo htmlspecialchars(JText::translate('VBOPANELREVIEWS')); ?>" onclick="<?php echo $reviews_dld >= 0 ? "window.open('{$base_lnk}', '_blank'); jQuery(this).removeClass('vbo-reviews-btnbadge-alert').attr('data-reviews-count', '');" : "alert(Joomla.JText._('VBOGUESTREVSVCMREQ'));"; ?>">
664 <?php VikBookingIcons::e('star'); ?>
665 <span><?php echo JText::translate('VBOPANELREVIEWS'); ?></span>
666 </button>
667 <?php
668 }
669 }
670
671 /**
672 * Admin widgets multitasking side panel.
673 *
674 * @since 1.15.0 (J) - 1.5.0 (WP)
675 */
676 if ($view != 'dashboard') {
677 ?>
678 <button type="button" class="vbo-multitasking-apps" title="<?php echo htmlspecialchars(JText::translate('VBO_MULTITASK_PANEL'), ENT_QUOTES, 'UTF-8'); ?>">
679 <?php VikBookingIcons::e('th'); ?>
680 </button>
681
682 <?php
683 // prepare the layout data array
684 $layout_data = [
685 'vbo_page' => (empty($view) ? VikRequest::getString('task', '') : $view),
686 'btn_trigger' => '.vbo-multitasking-apps',
687 ];
688 // render the multitasking layout
689 echo JLayoutHelper::render('sidepanel.multitasking', $layout_data);
690 ?>
691 <?php
692 }
693
694 /**
695 * Notifications Center.
696 *
697 * @since 1.16.8 (J) - 1.6.8 (WP)
698 */
699 $ncInstance = VBOFactory::getNotificationCenter();
700
701 // read "old" notifications
702 $ncInstance->readOldNotifications();
703
704 // check if notifications should be downloaded
705 $ncInstance->downloadNotifications();
706
707 // count unread notifications
708 $unreadNotifs = $ncInstance->countUnread();
709 $unreadNotifsRead = $unreadNotifs > 99 ? '99+' : $unreadNotifs;
710 $unreadNotifsRead = !$unreadNotifsRead ? '' : $unreadNotifsRead;
711 ?>
712 <div class="vbo-notifications-center-container">
713 <button type="button" class="vbo-notifications-center-handler" data-badge-count="<?php echo $unreadNotifs; ?>" data-badge-read="<?php echo $unreadNotifsRead; ?>" title="<?php echo htmlspecialchars(JText::translate('VBO_W_NOTIFSCENTER_TITLE'), ENT_QUOTES, 'UTF-8'); ?>">
714 <?php VikBookingIcons::e('bell', 'can-shake'); ?>
715 </button>
716 <?php
717 // prepare the layout data array
718 $layout_data = [
719 'vbo_page' => (empty($view) ? VikRequest::getString('task', '') : $view),
720 'btn_trigger' => '.vbo-notifications-center-handler',
721 'badge_c_attr' => 'data-badge-count',
722 'badge_r_attr' => 'data-badge-read',
723 'badge_count' => $unreadNotifs,
724 ];
725 // render the notificationscenter layout
726 echo JLayoutHelper::render('sidepanel.notificationscenter', $layout_data);
727 ?>
728 </div>
729
730 </div>
731 </div>
732 </div>
733
734 <script type="text/javascript">
735 jQuery(function() {
736 jQuery('.vbo-menu-parent-li').hover(
737 function() {
738 jQuery(this).addClass('vbo-menu-parent-li-opened');
739 jQuery(this).find('.vbo-submenu-wrap').addClass('vbo-submenu-wrap-active');
740 },function() {
741 jQuery(this).removeClass('vbo-menu-parent-li-opened');
742 jQuery(this).find('.vbo-submenu-wrap').removeClass('vbo-submenu-wrap-active');
743 }
744 );
745
746 if (jQuery('.vmenulinkactive').length) {
747 // set active class to current menu block
748 jQuery('.vmenulinkactive').closest('.vbo-submenu-wrap').parent('li').addClass('vbo-menu-parent-li-active');
749 }
750
751 if (<?php echo $reviews_dld; ?> > 0) {
752 // download new reviews
753 VBOCore.doAjax(
754 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=reviews_download'); ?>",
755 {
756 return: 1,
757 everywhere: 1,
758 tmpl: 'component'
759 },
760 (resp) => {
761 try {
762 if (resp.indexOf('e4j.ok') >= 0) {
763 var tot_reviews = resp.replace('e4j.ok.', '');
764 tot_reviews = parseInt(tot_reviews);
765 if (!isNaN(tot_reviews) && tot_reviews > 0) {
766 // update button badge
767 jQuery('.vbo-reviews-btnbadge').attr('data-reviews-count', tot_reviews).addClass('vbo-reviews-btnbadge-alert');
768 }
769 }
770 } catch(err) {
771 console.error('Error in decoding response', err, resp);
772 }
773 },
774 (err) => {
775 console.error('Could not download new reviews from Channel Manager', err);
776 }
777 );
778 }
779
780 // handle quick actions storage
781 jQuery('.vbo-menu-right').find('.vbo-submenu-ul').find('a').on('click', function(e) {
782 if (!jQuery(this).find('.vbo-submenu-item-txt').length) {
783 // nothing to do
784 return true;
785 }
786
787 // handle the clicked menu entry
788 e.preventDefault();
789
790 try {
791 // register clicked page
792 VBOCore.registerAdminMenuAction({
793 name: jQuery(this).find('.vbo-submenu-item-txt').text(),
794 href: jQuery(this).attr('href'),
795 });
796 } catch(e) {
797 console.error(e);
798 }
799
800 if (e.metaKey) {
801 // open link on new window
802 window.open(jQuery(this).attr('href'), '_blank').focus();
803 } else {
804 // proceed with the navigation
805 window.location.href = jQuery(this).attr('href');
806 }
807
808 return true;
809 });
810
811 // register event to populate quick actions sub-menu helpers
812 document.addEventListener('vbo-adminmenu-quickactions-create', () => {
813 // load the action from the "widgets" scope to be used as fallback
814 let menu_widgets_actions = VBOCore.getAdminMenuActions('widgets');
815
816 // scan all menu scopes
817 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
818 let menu_ul = jQuery(this);
819 let scope = menu_ul.attr('data-menu-scope');
820 if (!scope) {
821 return;
822 }
823
824 let orig_scope = scope;
825 let wrapper = menu_ul.closest('.vbo-submenu-wrap');
826 if (!wrapper || !wrapper.length || wrapper.hasClass('vbo-submenu-wrap-multi') || wrapper.find('.vbo-submenu-helper-ul').length) {
827 return;
828 }
829
830 let menu_scope_actions = VBOCore.getAdminMenuActions(scope);
831 if (!Array.isArray(menu_scope_actions) || !menu_scope_actions.length) {
832 // check if we can fallback on the "widgets" scope
833 if (Array.isArray(menu_widgets_actions) && menu_widgets_actions.length) {
834 // overwrite scope values
835 scope = 'widgets';
836 menu_scope_actions = menu_widgets_actions;
837 } else {
838 // do not proceed with this scope
839 return;
840 }
841 }
842
843 // check if menu actions should be merged with the fallback scope
844 if (scope != 'widgets' && menu_scope_actions[0].hasOwnProperty('fallback')) {
845 let before_fill_length = menu_scope_actions.length;
846 menu_scope_actions = VBOCore.fillAdminMenuActions(menu_scope_actions, menu_widgets_actions, scope);
847 let after_fill_length = menu_scope_actions.length;
848 if (before_fill_length && after_fill_length > before_fill_length) {
849 // update scope for the filled entries
850 VBOCore.storageSetItem(VBOCore.getStorageScopeName(scope), menu_scope_actions);
851 }
852 }
853
854 wrapper.addClass('vbo-submenu-wrap-multi');
855 let quick_actions = jQuery('<ul></ul>').addClass('vbo-submenu-helper-ul');
856 quick_actions.append('<li class="vbo-submenu-helper-lbl-li"><span class="vbo-submenu-helper-lbl-txt">' + Joomla.JText._('VBO_QUICK_ACTIONS') + '</span></li>');
857
858 // scan all menu actions
859 menu_scope_actions.forEach((action, index) => {
860 let is_pinned = action.hasOwnProperty('pinned') && action['pinned'];
861 let quick_actions_entry = jQuery('<li></li>').addClass((is_pinned ? 'vbo-submenu-item-helper-pinned' : 'vbo-submenu-item-helper-unpinned'));
862 let quick_actions_div = jQuery('<div></div>').addClass('vmenulink');
863 let quick_action_link = jQuery('<a></a>').attr('href', action['href']).addClass('vbo-submenu-item-helper-link');
864
865 if (action.hasOwnProperty('target') && action['target']) {
866 quick_action_link.attr('target', action['target']);
867 }
868
869 if (action.hasOwnProperty('widget') && action['widget']) {
870 quick_action_link.on('click', () => {
871 VBOCore.handleDisplayWidgetNotification({widget_id: action['widget']});
872 });
873 }
874
875 if (action.hasOwnProperty('img') && action['img']) {
876 let quick_action_img = jQuery('<span></span>').addClass('vbo-submenu-item-helper-avatar');
877 quick_action_img.append('<img src="' + action['img'] + '" />');
878 quick_action_link.append(quick_action_img);
879 } else if (action.hasOwnProperty('icon') && action['icon']) {
880 let quick_action_icon = jQuery('<span></span>').addClass('vbo-submenu-item-helper-avatar');
881 quick_action_icon.append(action['icon']);
882 quick_action_link.append(quick_action_icon);
883 }
884
885 let quick_action_name = jQuery('<span></span>').addClass('vbo-submenu-item-helper-txt').text(action['name']);
886 quick_action_link.append(quick_action_name);
887 quick_actions_div.append(quick_action_link);
888
889 let quick_action_pin = jQuery('<span></span>').addClass('vbo-submenu-item-helper-setpin').on('click', function() {
890 // toggle pinned status and update admin menu action
891 if (!action.hasOwnProperty('pinned')) {
892 action['pinned'] = !is_pinned;
893 } else {
894 action['pinned'] = !action['pinned'];
895 }
896 try {
897 // register/unregister pin
898 if (orig_scope != scope && !VBOCore.getAdminMenuActions(orig_scope).length) {
899 // set fallbacked scope
900 action['fallback'] = scope;
901
902 // register scope on local storage with the fallbacked scope
903 VBOCore.registerAdminMenuAction(action, orig_scope);
904 } else {
905 // update local storage regularly on this scope
906 VBOCore.updateAdminMenuAction(action, scope);
907 }
908
909 // trigger event
910 VBOCore.emitEvent('vbo-adminmenu-quickactions-update');
911 } catch(e) {
912 console.error(e);
913 }
914 // update action status
915 if (action['pinned']) {
916 jQuery(this).closest('li').removeClass('vbo-submenu-item-helper-unpinned').addClass('vbo-submenu-item-helper-pinned');
917 } else {
918 jQuery(this).closest('li').removeClass('vbo-submenu-item-helper-pinned').addClass('vbo-submenu-item-helper-unpinned');
919 }
920 });
921
922 quick_action_pin.html('<?php VikBookingIcons::e('thumbtack'); ?>');
923 quick_actions_div.append(quick_action_pin);
924 quick_actions_entry.append(quick_actions_div);
925 quick_actions.append(quick_actions_entry);
926 });
927
928 // append to DOM element
929 wrapper.append(quick_actions);
930 });
931 });
932
933 // register event to update the pinned quick actions
934 document.addEventListener('vbo-adminmenu-quickactions-update', VBOCore.debounceEvent(() => {
935 let menu_scopes = [];
936 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
937 let menu_ul = jQuery(this);
938 let scope = menu_ul.attr('data-menu-scope');
939 if (!scope) {
940 scope = '';
941 }
942 if (menu_scopes.indexOf(scope) < 0) {
943 menu_scopes.push(scope);
944 }
945 });
946 let admin_menu_actions = [];
947 menu_scopes.forEach((scope) => {
948 let menu_actions = VBOCore.getAdminMenuActions(scope);
949 admin_menu_actions.push({
950 scope: scope,
951 actions: menu_actions,
952 });
953 });
954 VBOCore.doAjax(
955 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=menuactions.update'); ?>",
956 {
957 actions: admin_menu_actions,
958 },
959 (resp) => {
960 // do nothing
961 },
962 (err) => {
963 // log the error
964 console.error(err.responseText);
965 }
966 );
967 }, 300));
968
969 // append shortcut to title
970 jQuery('.vbo-multitasking-apps').attr('title',
971 jQuery('.vbo-multitasking-apps').attr('title') + ' '
972 + (navigator.platform.toUpperCase().indexOf('MAC') === 0 ? '' : '') + ''
973 );
974
975 // register shortcuts
976 var vbo_menu_last_keydown = null;
977 window.addEventListener('keydown', (e) => {
978 e = e || window.event;
979 if (!e.key) {
980 return;
981 }
982
983 let modifier = 'ctrl';
984
985 // change the modifier depending on the platform
986 if (navigator.platform.toUpperCase().indexOf('MAC') === 0) {
987 modifier = 'meta';
988 }
989
990 if (e.shortcut([modifier, 13])) {
991 // toggle multitask panel
992 VBOCore.emitEvent(VBOCore.multitask_shortcut_event);
993 return;
994 }
995
996 if (VBOCore.side_panel_on && e.shortcut([modifier, 'F'])) {
997 // focus search admin widget in multitask panel
998 VBOCore.emitEvent(VBOCore.multitask_searchfs_event);
999 e.preventDefault();
1000
1001 return;
1002 }
1003
1004 if (e.shortcut([modifier, 'K'])) {
1005 // set special key listener for sequences of combos
1006 e.preventDefault();
1007 vbo_menu_last_keydown = 'k';
1008 return;
1009 }
1010
1011 if (vbo_menu_last_keydown === 'k' && (e.shortcut([modifier, 'A']) || e.shortcut([modifier, 'D']) || e.shortcut([modifier, 'L']))) {
1012 // trigger event to change color scheme preferences
1013 e.preventDefault();
1014 // unset special key
1015 vbo_menu_last_keydown = '';
1016 // activate requested color scheme preference
1017 let color_schemes = {
1018 a: 'auto',
1019 d: 'dark',
1020 l: 'light',
1021 };
1022 jQuery('.vbo-sidepanel-colorscheme-option[data-scheme="' + color_schemes[e.key] + '"]').trigger('click');
1023 return;
1024 }
1025
1026 // always unset last key if this point gets reached
1027 vbo_menu_last_keydown = '';
1028 }, true);
1029
1030 // populate quick actions sub-menu helpers on page load
1031 VBOCore.emitEvent('vbo-adminmenu-quickactions-create');
1032
1033 // check (only once) if the quick actions should be imported from the db
1034 if (<?php echo !$admin_menu_actions_checked ? 'true' : 'false'; ?>) {
1035 setTimeout(() => {
1036 // count admin menu actions populated from local storage
1037 let tot_admin_menu_actions = 0;
1038 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
1039 let menu_ul = jQuery(this);
1040 let scope = menu_ul.attr('data-menu-scope');
1041 if (!scope) {
1042 return;
1043 }
1044 let menu_scope_actions = VBOCore.getAdminMenuActions(scope);
1045 if (!Array.isArray(menu_scope_actions) || !menu_scope_actions.length) {
1046 return;
1047 }
1048 tot_admin_menu_actions++;
1049 return false;
1050 });
1051
1052 if (tot_admin_menu_actions) {
1053 return;
1054 }
1055
1056 // request for any previously stored quick actions for this admin
1057 VBOCore.doAjax(
1058 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=menuactions.retrieve'); ?>",
1059 {},
1060 (resp) => {
1061 // store to local storage the quick actions just retrieved
1062 let obj_res = typeof resp === 'string' ? JSON.parse(resp) : resp;
1063 if (Array.isArray(obj_res) && obj_res.length) {
1064 obj_res.forEach((menu_actions) => {
1065 let storage_scope_name = VBOCore.options.admin_menu_actions_nm;
1066 if (menu_actions['scope']) {
1067 storage_scope_name += '.' + menu_actions['scope'];
1068 }
1069 VBOCore.storageSetItem(storage_scope_name, menu_actions['actions']);
1070 });
1071 }
1072 // trigger the event to populate the quick actions
1073 VBOCore.emitEvent('vbo-adminmenu-quickactions-create');
1074 },
1075 (err) => {
1076 // log the error
1077 console.error(err.responseText);
1078 }
1079 );
1080 }, 300);
1081 }
1082
1083 // declare window resize handler for setting the position of sub-menus
1084 const subMenuStylesPositioning = () => {
1085 // get window width
1086 let windowWidth = window.innerWidth;
1087
1088 // scan all sub-menu entries
1089 document.querySelectorAll('.vbo-submenu-wrap').forEach((submenu) => {
1090 // remove the class to style the sub-menu "to left"
1091 submenu.classList.remove('vbo-submenu-wrap-toleft');
1092
1093 // get sub-menu width and offset left position values
1094 let elemWidth = submenu.offsetWidth;
1095 let elemOffLeft = submenu.getBoundingClientRect().left;
1096
1097 if (elemWidth) {
1098 // sub-menu visibility is hidden, but width has been computed
1099 if ((elemWidth + elemOffLeft) > windowWidth) {
1100 // add "to left" positioning class or the sub-menu would exceed the window
1101 submenu.classList.add('vbo-submenu-wrap-toleft');
1102 }
1103 } else {
1104 // on small screens, the sub-menu may be hidden, hence with no width
1105 let parentmenu = submenu.closest('.vbo-menu-parent-li');
1106
1107 // register listener for mouseover event
1108 parentmenu.addEventListener('mouseover', (e) => {
1109 setTimeout(() => {
1110 let now_submenu = e.target.querySelector('.vbo-submenu-wrap');
1111 if (!now_submenu) {
1112 return;
1113 }
1114 if ((now_submenu.offsetWidth + now_submenu.getBoundingClientRect().left) > window.innerWidth) {
1115 // add "to left" positioning class or the sub-menu would exceed the window
1116 now_submenu.classList.add('vbo-submenu-wrap-toleft');
1117 }
1118 }, 0);
1119 });
1120
1121 // register listener for touchstart event
1122 parentmenu.addEventListener('touchstart', (e) => {
1123 let limenu = e.target;
1124 if (!limenu.matches('.vbo-menu-parent-li')) {
1125 limenu = limenu.closest('.vbo-menu-parent-li');
1126 }
1127 // propagate the mouseover event
1128 limenu.dispatchEvent(new Event('mouseover'));
1129 });
1130 }
1131 });
1132 };
1133
1134 // register listener for window resize event
1135 window.addEventListener('resize', subMenuStylesPositioning);
1136
1137 // trigger sub-menus styles positioning function on page load
1138 setTimeout(() => {
1139 subMenuStylesPositioning();
1140 }, 0);
1141
1142 // populate admin-dock
1143 VBOAdminDock.getInstance();
1144 });
1145 </script>
1146 <?php
1147
1148 // handle subscription expiration reminder modal
1149 if (is_array($vcm_expiration_reminder) && $vcm_expiration_reminder['days_to_exp'] >= 0) {
1150 // subscription is expiring, but it's not expired yet, display a modal-reminder
1151 ?>
1152 <div class="vbo-info-overlay-block vbo-info-overlay-expiration-reminder">
1153 <div class="vbo-info-overlay-content">
1154 <h3 style="color: var(--vbo-red-color);"><i class="vboicn-warning"></i> <?php echo JText::translate('VCM_EXPIRATION_REMINDERS'); ?></h3>
1155 <div>
1156 <h4><?php echo JText::sprintf('VCM_EXPIRATION_REMINDER_DAYS', $vcm_expiration_reminder['days_to_exp'], $vcm_expiration_reminder['expiration_ymd']); ?></h4>
1157 </div>
1158 <div class="vbo-info-overlay-footer">
1159 <div class="vbo-info-overlay-footer-right">
1160 <button type="button" class="btn btn-danger" onclick="jQuery('.vbo-info-overlay-expiration-reminder').fadeOut();"><?php echo JText::translate('VBOBTNKEEPREMIND'); ?></button>
1161 </div>
1162 </div>
1163 </div>
1164 </div>
1165
1166 <script type="text/javascript">
1167 jQuery(function() {
1168 jQuery('.vbo-info-overlay-expiration-reminder').fadeIn();
1169 });
1170 </script>
1171 <?php
1172 }
1173
1174 $helpWizardAjaxUrl = VBOFactory::getPlatform()->getUri()->ajax('index.php?option=com_vikbooking');
1175 JHtml::fetch('script', VBO_ADMIN_URI . 'resources/helpwizard.js', ['version' => VIKBOOKING_SOFTWARE_VERSION]);
1176 JText::script('VBSAVE');
1177 JText::script('VBDISMISS');
1178 JFactory::getDocument()->addScriptDeclaration(
1179 <<<JAVASCRIPT
1180 (function(w) {
1181 window.VBO_HELP_WIZARD_AJAX_URL = '{$helpWizardAjaxUrl}';
1182 })(window);
1183 JAVASCRIPT
1184 );
1185 }
1186
1187 public static function printFooter()
1188 {
1189 $tmpl = VikRequest::getVar('tmpl');
1190 if ($tmpl == 'component') return;
1191 /**
1192 * @wponly "Powered by" is VikWP.com
1193 */
1194 echo '<br clear="all" />' . '<div id="hmfooter">' . JText::sprintf('VBFOOTER', VIKBOOKING_SOFTWARE_VERSION) . ' <a href="https://vikwp.com/" target="_blank">VikWP - vikwp.com</a></div>';
1195 }
1196
1197 public static function pUpdateProgram($version)
1198 {
1199 /**
1200 * @wponly do nothing
1201 */
1202 }
1203
1204 /**
1205 * Method to add parameters to the update extra query.
1206 *
1207 * @joomlaonly this class is automatically loaded by Joomla
1208 * to invoke this method when updating the component.
1209 *
1210 * @param Update &$update An update definition
1211 * @param JTable &$table The update instance from the database
1212 *
1213 * @return void
1214 *
1215 * @since 1.16.0 (J) - 1.6.0 (WP)
1216 */
1217 public static function prepareUpdate(&$update, &$table)
1218 {
1219 // get current domain
1220 $server = JFactory::getApplication()->input->server;
1221
1222 // build query array
1223 $query = [
1224 'domain' => base64_encode($server->getString('HTTP_HOST')),
1225 'ip' => $server->getString('REMOTE_ADDR'),
1226 ];
1227
1228 // get license key
1229 $license_key = VBOFactory::getConfig()->get('licensekey');
1230 if ($license_key)
1231 {
1232 $query['key'] = $license_key;
1233 }
1234
1235 // always refresh the extra query before an update
1236 $update->set('extra_query', http_build_query($query, '', '&amp;'));
1237 }
1238
1239 /**
1240 * Returns the information about the first setup metrics and minimum requirements.
1241 *
1242 * @return array associative list of metrics.
1243 *
1244 * @since 1.16.4 (J) - 1.6.4 (WP)
1245 */
1246 public static function getFirstSetupMetrics()
1247 {
1248 $dbo = JFactory::getDbo();
1249
1250 $q = "SELECT COUNT(*) FROM `#__vikbooking_prices`;";
1251 $dbo->setQuery($q);
1252 $totprices = $dbo->loadResult();
1253
1254 $q = "SELECT COUNT(*) FROM `#__vikbooking_rooms`;";
1255 $dbo->setQuery($q);
1256 $totrooms = $dbo->loadResult();
1257
1258 $q = "SELECT COUNT(*) FROM `#__vikbooking_dispcost`;";
1259 $dbo->setQuery($q);
1260 $totdailyfares = $dbo->loadResult();
1261
1262 $metrics = [
1263 'totprices' => $totprices,
1264 'totrooms' => $totrooms,
1265 'totdailyfares' => $totdailyfares,
1266 'completed' => ($totprices && $totrooms && $totdailyfares),
1267 ];
1268
1269 // shortcodes (if platform-supported)
1270 if (VBOPlatformDetection::isWordPress()) {
1271 /**
1272 * @wponly - check if some shortcodes have been defined before showing the Dashboard
1273 */
1274 $model = JModel::getInstance('vikbooking', 'shortcodes');
1275 $metrics['shortcodes'] = $model->all('post_id');
1276
1277 // calculate again the completed status
1278 $metrics['completed'] = ($metrics['completed'] && $metrics['shortcodes']);
1279 }
1280
1281 return $metrics;
1282 }
1283 }
1284