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 / helpers / vikbooking.php

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

1,294 lines 48.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage com_vikbooking
5 * @author Alessio Gaggii - e4j - Extensionsforjoomla.com
6 * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 * @link https://vikwp.com
9 */
10
11 // 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('filter-circle-dollar'); ?>
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 <li>
327 <div class="<?php echo ($highlight == "managequote" ? "vmenulinkactive" : "vmenulink"); ?>">
328 <a href="index.php?option=com_vikbooking&amp;view=managequote">
329 <?php VikBookingIcons::e('file-alt'); ?>
330 <span class="vbo-submenu-item">
331 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBO_CREATE_QUOTE'); ?></span>
332 </span>
333 </a>
334 </div>
335 </li>
336 <?php endif; ?>
337 <?php if ($vbo_auth_availability) : ?>
338 <li>
339 <div class="<?php echo ($highlight == "15" ? "vmenulinkactive" : "vmenulink"); ?>">
340 <a href="index.php?option=com_vikbooking&amp;task=overv">
341 <?php VikBookingIcons::e('calendar-check'); ?>
342 <span class="vbo-submenu-item">
343 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTENNINE'); ?></span>
344 </span>
345 </a>
346 </div>
347 </li>
348 <?php endif; ?>
349 <?php if ($vbo_auth_bookings) : ?>
350 <li>
351 <div class="<?php echo ($highlight == "8" ? "vmenulinkactive" : "vmenulink"); ?>">
352 <a href="index.php?option=com_vikbooking&amp;task=orders">
353 <?php VikBookingIcons::e('clipboard-list'); ?>
354 <span class="vbo-submenu-item">
355 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUSEVEN'); ?></span>
356 </span>
357 </a>
358 </div>
359 </li>
360 <?php endif; ?>
361 <?php if (($has_vcm || VBOPlatformDetection::isWordPress()) && ($vbo_auth_availability || $vbo_auth_bookings)) : ?>
362 <li class="vbo-menu-vcm-only">
363 <div class="<?php echo ($highlight == 'vikchannelmanager' ? 'vmenulinkactive' : 'vmenulink'); ?>">
364 <a href="index.php?option=com_vikchannelmanager" class="vbo-menu-vcmlink">
365 <?php VikBookingIcons::e('cloud'); ?>
366 <span class="vbo-submenu-item">
367 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUCHANNELMANAGER'); ?></span>
368 </span>
369 </a>
370 </div>
371 </li>
372 <?php endif; ?>
373 </ul>
374 </div>
375 </li><?php
376 if ($vbo_auth_management) {
377 ?><li class="vbo-menu-parent-li">
378 <span><?php VikBookingIcons::e('chart-pie'); ?><a><?php echo JText::translate('VBMENUMANAGEMENT'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
379 <div class="vbo-submenu-wrap">
380 <ul class="vbo-submenu-ul" data-menu-scope="management">
381 <li>
382 <div class="<?php echo ($highlight == "22" ? "vmenulinkactive" : "vmenulink"); ?>">
383 <a href="index.php?option=com_vikbooking&amp;task=customers">
384 <?php VikBookingIcons::e('users'); ?>
385 <span class="vbo-submenu-item">
386 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUCUSTOMERS'); ?></span>
387 </span>
388 </a>
389 </div>
390 </li>
391 <li>
392 <div class="<?php echo ($highlight == "invoices" ? "vmenulinkactive" : "vmenulink"); ?>">
393 <a href="index.php?option=com_vikbooking&amp;task=invoices">
394 <?php VikBookingIcons::e('file-invoice'); ?>
395 <span class="vbo-submenu-item">
396 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUINVOICES'); ?></span>
397 </span>
398 </a>
399 </div>
400 </li>
401 <li>
402 <div class="<?php echo ($highlight == "stats" ? "vmenulinkactive" : "vmenulink"); ?>">
403 <a href="index.php?option=com_vikbooking&amp;task=stats">
404 <?php VikBookingIcons::e('chart-line'); ?>
405 <span class="vbo-submenu-item">
406 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUSTATS'); ?></span>
407 </span>
408 </a>
409 </div>
410 </li>
411 <li>
412 <div class="<?php echo ($highlight == "trackings" ? "vmenulinkactive" : "vmenulink"); ?>">
413 <a href="index.php?option=com_vikbooking&amp;task=trackings">
414 <?php VikBookingIcons::e('compass'); ?>
415 <span class="vbo-submenu-item">
416 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTRACKINGS'); ?></span>
417 </span>
418 </a>
419 </div>
420 </li>
421 <li>
422 <div class="<?php echo (in_array($highlight, ["crons", "managecron"]) ? "vmenulinkactive" : "vmenulink"); ?>">
423 <a href="index.php?option=com_vikbooking&amp;view=crons">
424 <?php VikBookingIcons::e('stopwatch'); ?>
425 <span class="vbo-submenu-item">
426 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUCRONS'); ?></span>
427 </span>
428 </a>
429 </div>
430 </li>
431 </ul>
432 </div>
433 </li><?php
434 }
435 if ($vbo_auth_pms || $vbo_auth_reports || $vbo_auth_tm) {
436 ?><li class="vbo-menu-parent-li">
437 <span><?php VikBookingIcons::e('tasks'); ?><a><?php echo JText::translate('VBMENUPMS'); ?> <?php VikBookingIcons::e('chevron-down', 'vbo-submenu-chevron'); ?></a></span>
438 <div class="vbo-submenu-wrap">
439 <ul class="vbo-submenu-ul" data-menu-scope="pms"><?php
440 if ($vbo_auth_pms) {
441 ?><li>
442 <div class="<?php echo ($highlight == "operators" ? "vmenulinkactive" : "vmenulink"); ?>">
443 <a href="index.php?option=com_vikbooking&amp;task=operators">
444 <?php VikBookingIcons::e('user-tie'); ?>
445 <span class="vbo-submenu-item">
446 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUOPERATORS'); ?></span>
447 </span>
448 </a>
449 </div>
450 </li>
451 <li>
452 <div class="<?php echo ($highlight == "tableaux" ? "vmenulinkactive" : "vmenulink"); ?>">
453 <a href="index.php?option=com_vikbooking&amp;task=tableaux">
454 <?php VikBookingIcons::e('stream'); ?>
455 <span class="vbo-submenu-item">
456 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUTABLEAUX'); ?></span>
457 </span>
458 </a>
459 </div>
460 </li><?php
461 }
462 if ($vbo_auth_admin || $vbo_auth_reports) {
463 ?><li>
464 <div class="<?php echo ($highlight == "pmsreports" ? "vmenulinkactive" : "vmenulink"); ?>">
465 <a href="index.php?option=com_vikbooking&amp;task=pmsreports">
466 <?php VikBookingIcons::e('cash-register'); ?>
467 <span class="vbo-submenu-item">
468 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUPMSREPORTS'); ?></span>
469 </span>
470 </a>
471 </div>
472 </li><?php
473 }
474 if ($vbo_auth_pms) {
475 ?><li>
476 <div class="<?php echo ($highlight == "einvoicing" ? "vmenulinkactive" : "vmenulink"); ?>">
477 <a href="index.php?option=com_vikbooking&amp;task=einvoicing">
478 <?php VikBookingIcons::e('laptop-code'); ?>
479 <span class="vbo-submenu-item">
480 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBMENUEINVOICING'); ?></span>
481 </span>
482 </a>
483 </div>
484 </li><?php
485 }
486 if ($vbo_auth_admin || $vbo_auth_tm) {
487 ?><li class="vbo-menu-vcm-only">
488 <div class="<?php echo ($highlight == "taskmanager" ? "vmenulinkactive" : "vmenulink"); ?>">
489 <a href="index.php?option=com_vikbooking&amp;view=taskmanager">
490 <?php VikBookingIcons::e('tasks'); ?>
491 <span class="vbo-submenu-item">
492 <span class="vbo-submenu-item-txt"><?php echo JText::translate('VBO_TASK_MANAGER'); ?></span>
493 </span>
494 </a>
495 </div>
496 </li><?php
497 }
498 ?></ul>
499 </div>
500 </li><?php
501 }
502 ?>
503 </ul>
504 <div class="vbo-menu-updates">
505 <?php
506 if (VBOPlatformDetection::isWordPress()) {
507 /**
508 * @wponly PRO Version
509 */
510 VikBookingLoader::import('update.license');
511 if (!VikBookingLicense::isPro()) {
512 ?>
513 <button type="button" class="vbo-gotopro" title="<?php echo addslashes(JText::translate('VBOGOTOPROBTN')); ?>" onclick="document.location.href='admin.php?option=com_vikbooking&view=gotopro';">
514 <?php VikBookingIcons::e('rocket'); ?>
515 <span><?php echo JText::translate('VBOGOTOPROBTN'); ?></span>
516 </button>
517 <?php
518 } elseif ($vbo_auth_global) {
519 ?>
520 <button type="button" class="vbo-alreadypro" title="<?php echo addslashes(JText::translate('VBOISPROBTN')); ?>" onclick="document.location.href='admin.php?option=com_vikbooking&view=gotopro';">
521 <?php VikBookingIcons::e('trophy'); ?>
522 <span><?php echo JText::translate('VBOISPROBTN'); ?></span>
523 </button>
524 <?php
525 }
526 } else {
527 /**
528 * @joomlaonly
529 */
530 if (($highlight == '18' || $highlight == '11') && method_exists($app, 'triggerEvent')) {
531 // VikUpdater
532 JPluginHelper::importPlugin('e4j');
533 $callable = $app->triggerEvent('onUpdaterSupported');
534 if (count($callable) && $callable[0]) {
535 //Plugin enabled
536 $params = new stdClass;
537 $params->version = E4J_SOFTWARE_VERSION;
538 $params->alias = 'com_vikbooking';
539
540 $upd_btn_text = strrev('setadpU kcehC');
541 $ready_jsfun = '';
542 $result = $app->triggerEvent('onGetVersionContents', array(&$params));
543 if (count($result) && $result[0]) {
544 $upd_btn_text = $result[0]->response->shortTitle;
545 } else {
546 $ready_jsfun = 'jQuery("#vik-update-btn").trigger("click");';
547 }
548 ?>
549 <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);'; ?>">
550 <i class="vboicn-cloud"></i>
551 <span><?php echo $upd_btn_text; ?></span>
552 </button>
553 <script type="text/javascript">
554 function checkVersion(button) {
555 jQuery(button).find('span').text('Checking...');
556 jQuery.ajax({
557 type: 'POST',
558 url: 'index.php?option=com_vikbooking&task=checkversion&tmpl=component',
559 data: {}
560 }).done(function(resp) {
561 var obj = typeof resp === 'string' ? JSON.parse(resp) : resp;
562 console.log(obj);
563 if (obj.status == 1 && obj.response.status == 1) {
564 jQuery(button).find('span').text(obj.response.shortTitle);
565 if (obj.response.compare == 1) {
566 jQuery(button).attr('onclick', 'document.location.href="index.php?option=com_vikbooking&task=updateprogram"');
567 }
568 }
569 }).fail(function(resp) {
570 console.log(resp);
571 });
572 }
573 jQuery(function() {
574 <?php echo $ready_jsfun; ?>
575 });
576 </script>
577 <?php
578 } else {
579 /**
580 * When Vik Updater is not available or disabled, we now
581 * render a modal for the automated installation of the plugin.
582 *
583 * @since 1.15.1
584 */
585
586 $data = [
587 'hn' => getenv('HTTP_HOST'),
588 'sn' => getenv('SERVER_NAME'),
589 'app' => CREATIVIKAPP,
590 'ver' => VIKBOOKING_SOFTWARE_VERSION,
591 ];
592
593 $vikupdater_url = 'https://extensionsforjoomla.com/vikcheck/vikupdater.php?' . http_build_query($data);
594
595 echo JHtml::fetch(
596 'bootstrap.renderModal',
597 'jmodal-version-check',
598 array(
599 'title' => 'Install VikUpdater',
600 'closeButton' => true,
601 'keyboard' => true,
602 'bodyHeight' => 80,
603 'url' => $vikupdater_url,
604 'footer' => '<button type="button" class="btn btn-success" id="version-check-install">' . JText::translate('JTOOLBAR_INSTALL') . '</button>',
605 )
606 );
607 ?>
608 <button type="button" id="vik-update-btn">
609 <i class="vboicn-cloud"></i>
610 <span></span>
611 </button>
612
613 <?php echo VikBooking::getVboApplication()->getJmodalScript(); ?>
614
615 <script>
616 (function($) {
617 'use strict';
618
619 $(function() {
620 $('#vik-update-btn').on('click', () => {
621 vboOpenJModal('version-check');
622 });
623
624 $('#version-check-install').on('click', () => {
625 const form = $('<form action="index.php?option=com_installer&task=install.install" method="post"></form>');
626
627 form.append('<input type="hidden" name="installtype" value="url" />');
628 form.append('<input type="hidden" name="install_url" value="https://extensionsforjoomla.com/vikapi/?task=products.freedownload&sku=vup" />');
629 form.append('<input type="hidden" name="return" value="<?php echo base64_encode(JUri::getInstance()); ?>" />');
630 form.append('<?php echo JHtml::fetch('form.token'); ?>');
631
632 $('body').append(form);
633
634 form.submit();
635 });
636 });
637 })(jQuery);
638 </script>
639 <?php
640 }
641 }
642 }
643
644 if ($vbo_auth_management && in_array($highlight, array('18', '11'))) {
645 // VCM Opportunities
646 $opp = VikBooking::getVcmOpportunityInstance();
647 if (!is_null($opp)) {
648 // download opportunities if it's time to do it
649 if ($opp->shouldRequestOpportunities()) {
650 $opp->downloadOpportunities();
651 }
652 // count opportunities
653 $opp_filters = array(
654 'status' => 0,
655 'action' => 0,
656 );
657 $new_opp_count = count($opp->loadOpportunities($opp_filters, null, null));
658 if ($new_opp_count > 0) {
659 ?>
660 <!-- <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); ?>';">
661 <?php VikBookingIcons::e('crown'); ?>
662 <span><?php echo JText::translate('VBOGOTOOPPORTUNITIES'); ?></span>
663 </button> -->
664 <?php
665 }
666 }
667
668 // Guest Reviews
669 $reviews_dld = VikBooking::shouldDownloadReviews();
670 $base_lnk = VBOFactory::getPlatform()->getUri()->admin('index.php?option=com_vikchannelmanager&task=reviews', false);
671 if ($highlight == '18') {
672 ?>
673 <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'));"; ?>">
674 <?php VikBookingIcons::e('star'); ?>
675 <span><?php echo JText::translate('VBOPANELREVIEWS'); ?></span>
676 </button>
677 <?php
678 }
679 }
680
681 /**
682 * Admin widgets multitasking side panel.
683 *
684 * @since 1.15.0 (J) - 1.5.0 (WP)
685 */
686 if ($view != 'dashboard') {
687 ?>
688 <button type="button" class="vbo-multitasking-apps" title="<?php echo htmlspecialchars(JText::translate('VBO_MULTITASK_PANEL'), ENT_QUOTES, 'UTF-8'); ?>">
689 <?php VikBookingIcons::e('grip'); ?>
690 </button>
691
692 <?php
693 // prepare the layout data array
694 $layout_data = [
695 'vbo_page' => (empty($view) ? VikRequest::getString('task', '') : $view),
696 'btn_trigger' => '.vbo-multitasking-apps',
697 ];
698 // render the multitasking layout
699 echo JLayoutHelper::render('sidepanel.multitasking', $layout_data);
700 ?>
701 <?php
702 }
703
704 /**
705 * Notifications Center.
706 *
707 * @since 1.16.8 (J) - 1.6.8 (WP)
708 */
709 $ncInstance = VBOFactory::getNotificationCenter();
710
711 // read "old" notifications
712 $ncInstance->readOldNotifications();
713
714 // check if notifications should be downloaded
715 $ncInstance->downloadNotifications();
716
717 // count unread notifications
718 $unreadNotifs = $ncInstance->countUnread();
719 $unreadNotifsRead = $unreadNotifs > 99 ? '99+' : $unreadNotifs;
720 $unreadNotifsRead = !$unreadNotifsRead ? '' : $unreadNotifsRead;
721 ?>
722 <div class="vbo-notifications-center-container">
723 <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'); ?>">
724 <?php VikBookingIcons::e('bell', 'can-shake'); ?>
725 </button>
726 <?php
727 // prepare the layout data array
728 $layout_data = [
729 'vbo_page' => (empty($view) ? VikRequest::getString('task', '') : $view),
730 'btn_trigger' => '.vbo-notifications-center-handler',
731 'badge_c_attr' => 'data-badge-count',
732 'badge_r_attr' => 'data-badge-read',
733 'badge_count' => $unreadNotifs,
734 ];
735 // render the notificationscenter layout
736 echo JLayoutHelper::render('sidepanel.notificationscenter', $layout_data);
737 ?>
738 </div>
739
740 </div>
741 </div>
742 </div>
743
744 <script type="text/javascript">
745 jQuery(function() {
746 jQuery('.vbo-menu-parent-li').hover(
747 function() {
748 jQuery(this).addClass('vbo-menu-parent-li-opened');
749 jQuery(this).find('.vbo-submenu-wrap').addClass('vbo-submenu-wrap-active');
750 },function() {
751 jQuery(this).removeClass('vbo-menu-parent-li-opened');
752 jQuery(this).find('.vbo-submenu-wrap').removeClass('vbo-submenu-wrap-active');
753 }
754 );
755
756 if (jQuery('.vmenulinkactive').length) {
757 // set active class to current menu block
758 jQuery('.vmenulinkactive').closest('.vbo-submenu-wrap').parent('li').addClass('vbo-menu-parent-li-active');
759 }
760
761 if (<?php echo $reviews_dld; ?> > 0) {
762 // download new reviews
763 VBOCore.doAjax(
764 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=reviews_download'); ?>",
765 {
766 return: 1,
767 everywhere: 1,
768 tmpl: 'component'
769 },
770 (resp) => {
771 try {
772 if (resp.indexOf('e4j.ok') >= 0) {
773 var tot_reviews = resp.replace('e4j.ok.', '');
774 tot_reviews = parseInt(tot_reviews);
775 if (!isNaN(tot_reviews) && tot_reviews > 0) {
776 // update button badge
777 jQuery('.vbo-reviews-btnbadge').attr('data-reviews-count', tot_reviews).addClass('vbo-reviews-btnbadge-alert');
778 }
779 }
780 } catch(err) {
781 console.error('Error in decoding response', err, resp);
782 }
783 },
784 (err) => {
785 console.error('Could not download new reviews from Channel Manager', err);
786 }
787 );
788 }
789
790 // handle quick actions storage
791 jQuery('.vbo-menu-right').find('.vbo-submenu-ul').find('a').on('click', function(e) {
792 if (!jQuery(this).find('.vbo-submenu-item-txt').length) {
793 // nothing to do
794 return true;
795 }
796
797 // handle the clicked menu entry
798 e.preventDefault();
799
800 try {
801 // register clicked page
802 VBOCore.registerAdminMenuAction({
803 name: jQuery(this).find('.vbo-submenu-item-txt').text(),
804 href: jQuery(this).attr('href'),
805 });
806 } catch(e) {
807 console.error(e);
808 }
809
810 if (e.metaKey) {
811 // open link on new window
812 window.open(jQuery(this).attr('href'), '_blank').focus();
813 } else {
814 // proceed with the navigation
815 window.location.href = jQuery(this).attr('href');
816 }
817
818 return true;
819 });
820
821 // register event to populate quick actions sub-menu helpers
822 document.addEventListener('vbo-adminmenu-quickactions-create', () => {
823 // load the action from the "widgets" scope to be used as fallback
824 let menu_widgets_actions = VBOCore.getAdminMenuActions('widgets');
825
826 // scan all menu scopes
827 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
828 let menu_ul = jQuery(this);
829 let scope = menu_ul.attr('data-menu-scope');
830 if (!scope) {
831 return;
832 }
833
834 let orig_scope = scope;
835 let wrapper = menu_ul.closest('.vbo-submenu-wrap');
836 if (!wrapper || !wrapper.length || wrapper.hasClass('vbo-submenu-wrap-multi') || wrapper.find('.vbo-submenu-helper-ul').length) {
837 return;
838 }
839
840 let menu_scope_actions = VBOCore.getAdminMenuActions(scope);
841 if (!Array.isArray(menu_scope_actions) || !menu_scope_actions.length) {
842 // check if we can fallback on the "widgets" scope
843 if (Array.isArray(menu_widgets_actions) && menu_widgets_actions.length) {
844 // overwrite scope values
845 scope = 'widgets';
846 menu_scope_actions = menu_widgets_actions;
847 } else {
848 // do not proceed with this scope
849 return;
850 }
851 }
852
853 // check if menu actions should be merged with the fallback scope
854 if (scope != 'widgets' && menu_scope_actions[0].hasOwnProperty('fallback')) {
855 let before_fill_length = menu_scope_actions.length;
856 menu_scope_actions = VBOCore.fillAdminMenuActions(menu_scope_actions, menu_widgets_actions, scope);
857 let after_fill_length = menu_scope_actions.length;
858 if (before_fill_length && after_fill_length > before_fill_length) {
859 // update scope for the filled entries
860 VBOCore.storageSetItem(VBOCore.getStorageScopeName(scope), menu_scope_actions);
861 }
862 }
863
864 wrapper.addClass('vbo-submenu-wrap-multi');
865 let quick_actions = jQuery('<ul></ul>').addClass('vbo-submenu-helper-ul');
866 quick_actions.append('<li class="vbo-submenu-helper-lbl-li"><span class="vbo-submenu-helper-lbl-txt">' + Joomla.JText._('VBO_QUICK_ACTIONS') + '</span></li>');
867
868 // scan all menu actions
869 menu_scope_actions.forEach((action, index) => {
870 let is_pinned = action.hasOwnProperty('pinned') && action['pinned'];
871 let quick_actions_entry = jQuery('<li></li>').addClass((is_pinned ? 'vbo-submenu-item-helper-pinned' : 'vbo-submenu-item-helper-unpinned'));
872 let quick_actions_div = jQuery('<div></div>').addClass('vmenulink');
873 let quick_action_link = jQuery('<a></a>').attr('href', action['href']).addClass('vbo-submenu-item-helper-link');
874
875 if (action.hasOwnProperty('target') && action['target']) {
876 quick_action_link.attr('target', action['target']);
877 }
878
879 if (action.hasOwnProperty('widget') && action['widget']) {
880 quick_action_link.on('click', () => {
881 VBOCore.handleDisplayWidgetNotification({widget_id: action['widget']});
882 });
883 }
884
885 if (action.hasOwnProperty('img') && action['img']) {
886 let quick_action_img = jQuery('<span></span>').addClass('vbo-submenu-item-helper-avatar');
887 quick_action_img.append('<img src="' + action['img'] + '" />');
888 quick_action_link.append(quick_action_img);
889 } else if (action.hasOwnProperty('icon') && action['icon']) {
890 let quick_action_icon = jQuery('<span></span>').addClass('vbo-submenu-item-helper-avatar');
891 quick_action_icon.append(action['icon']);
892 quick_action_link.append(quick_action_icon);
893 }
894
895 let quick_action_name = jQuery('<span></span>').addClass('vbo-submenu-item-helper-txt').text(action['name']);
896 quick_action_link.append(quick_action_name);
897 quick_actions_div.append(quick_action_link);
898
899 let quick_action_pin = jQuery('<span></span>').addClass('vbo-submenu-item-helper-setpin').on('click', function() {
900 // toggle pinned status and update admin menu action
901 if (!action.hasOwnProperty('pinned')) {
902 action['pinned'] = !is_pinned;
903 } else {
904 action['pinned'] = !action['pinned'];
905 }
906 try {
907 // register/unregister pin
908 if (orig_scope != scope && !VBOCore.getAdminMenuActions(orig_scope).length) {
909 // set fallbacked scope
910 action['fallback'] = scope;
911
912 // register scope on local storage with the fallbacked scope
913 VBOCore.registerAdminMenuAction(action, orig_scope);
914 } else {
915 // update local storage regularly on this scope
916 VBOCore.updateAdminMenuAction(action, scope);
917 }
918
919 // trigger event
920 VBOCore.emitEvent('vbo-adminmenu-quickactions-update');
921 } catch(e) {
922 console.error(e);
923 }
924 // update action status
925 if (action['pinned']) {
926 jQuery(this).closest('li').removeClass('vbo-submenu-item-helper-unpinned').addClass('vbo-submenu-item-helper-pinned');
927 } else {
928 jQuery(this).closest('li').removeClass('vbo-submenu-item-helper-pinned').addClass('vbo-submenu-item-helper-unpinned');
929 }
930 });
931
932 quick_action_pin.html('<?php VikBookingIcons::e('thumbtack'); ?>');
933 quick_actions_div.append(quick_action_pin);
934 quick_actions_entry.append(quick_actions_div);
935 quick_actions.append(quick_actions_entry);
936 });
937
938 // append to DOM element
939 wrapper.append(quick_actions);
940 });
941 });
942
943 // register event to update the pinned quick actions
944 document.addEventListener('vbo-adminmenu-quickactions-update', VBOCore.debounceEvent(() => {
945 let menu_scopes = [];
946 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
947 let menu_ul = jQuery(this);
948 let scope = menu_ul.attr('data-menu-scope');
949 if (!scope) {
950 scope = '';
951 }
952 if (menu_scopes.indexOf(scope) < 0) {
953 menu_scopes.push(scope);
954 }
955 });
956 let admin_menu_actions = [];
957 menu_scopes.forEach((scope) => {
958 let menu_actions = VBOCore.getAdminMenuActions(scope);
959 admin_menu_actions.push({
960 scope: scope,
961 actions: menu_actions,
962 });
963 });
964 VBOCore.doAjax(
965 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=menuactions.update'); ?>",
966 {
967 actions: admin_menu_actions,
968 },
969 (resp) => {
970 // do nothing
971 },
972 (err) => {
973 // log the error
974 console.error(err.responseText);
975 }
976 );
977 }, 300));
978
979 // append shortcut to title
980 jQuery('.vbo-multitasking-apps').attr('title',
981 jQuery('.vbo-multitasking-apps').attr('title') + ' '
982 + (navigator.platform.toUpperCase().indexOf('MAC') === 0 ? '' : '') + ''
983 );
984
985 // register shortcuts
986 var vbo_menu_last_keydown = null;
987 window.addEventListener('keydown', (e) => {
988 e = e || window.event;
989 if (!e.key) {
990 return;
991 }
992
993 let modifier = 'ctrl';
994
995 // change the modifier depending on the platform
996 if (navigator.platform.toUpperCase().indexOf('MAC') === 0) {
997 modifier = 'meta';
998 }
999
1000 if (e.shortcut([modifier, 13])) {
1001 // toggle multitask panel
1002 VBOCore.emitEvent(VBOCore.multitask_shortcut_event);
1003 return;
1004 }
1005
1006 if (VBOCore.side_panel_on && e.shortcut([modifier, 'F'])) {
1007 // focus search admin widget in multitask panel
1008 VBOCore.emitEvent(VBOCore.multitask_searchfs_event);
1009 e.preventDefault();
1010
1011 return;
1012 }
1013
1014 if (e.shortcut([modifier, 'K'])) {
1015 // set special key listener for sequences of combos
1016 e.preventDefault();
1017 vbo_menu_last_keydown = 'k';
1018 return;
1019 }
1020
1021 if (vbo_menu_last_keydown === 'k' && (e.shortcut([modifier, 'A']) || e.shortcut([modifier, 'D']) || e.shortcut([modifier, 'L']))) {
1022 // trigger event to change color scheme preferences
1023 e.preventDefault();
1024 // unset special key
1025 vbo_menu_last_keydown = '';
1026 // activate requested color scheme preference
1027 let color_schemes = {
1028 a: 'auto',
1029 d: 'dark',
1030 l: 'light',
1031 };
1032 jQuery('.vbo-sidepanel-colorscheme-option[data-scheme="' + color_schemes[e.key] + '"]').trigger('click');
1033 return;
1034 }
1035
1036 // always unset last key if this point gets reached
1037 vbo_menu_last_keydown = '';
1038 }, true);
1039
1040 // populate quick actions sub-menu helpers on page load
1041 VBOCore.emitEvent('vbo-adminmenu-quickactions-create');
1042
1043 // check (only once) if the quick actions should be imported from the db
1044 if (<?php echo !$admin_menu_actions_checked ? 'true' : 'false'; ?>) {
1045 setTimeout(() => {
1046 // count admin menu actions populated from local storage
1047 let tot_admin_menu_actions = 0;
1048 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
1049 let menu_ul = jQuery(this);
1050 let scope = menu_ul.attr('data-menu-scope');
1051 if (!scope) {
1052 return;
1053 }
1054 let menu_scope_actions = VBOCore.getAdminMenuActions(scope);
1055 if (!Array.isArray(menu_scope_actions) || !menu_scope_actions.length) {
1056 return;
1057 }
1058 tot_admin_menu_actions++;
1059 return false;
1060 });
1061
1062 if (tot_admin_menu_actions) {
1063 return;
1064 }
1065
1066 // request for any previously stored quick actions for this admin
1067 VBOCore.doAjax(
1068 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=menuactions.retrieve'); ?>",
1069 {},
1070 (resp) => {
1071 // store to local storage the quick actions just retrieved
1072 let obj_res = typeof resp === 'string' ? JSON.parse(resp) : resp;
1073 if (Array.isArray(obj_res) && obj_res.length) {
1074 obj_res.forEach((menu_actions) => {
1075 let storage_scope_name = VBOCore.options.admin_menu_actions_nm;
1076 if (menu_actions['scope']) {
1077 storage_scope_name += '.' + menu_actions['scope'];
1078 }
1079 VBOCore.storageSetItem(storage_scope_name, menu_actions['actions']);
1080 });
1081 }
1082 // trigger the event to populate the quick actions
1083 VBOCore.emitEvent('vbo-adminmenu-quickactions-create');
1084 },
1085 (err) => {
1086 // log the error
1087 console.error(err.responseText);
1088 }
1089 );
1090 }, 300);
1091 }
1092
1093 // declare window resize handler for setting the position of sub-menus
1094 const subMenuStylesPositioning = () => {
1095 // get window width
1096 let windowWidth = window.innerWidth;
1097
1098 // scan all sub-menu entries
1099 document.querySelectorAll('.vbo-submenu-wrap').forEach((submenu) => {
1100 // remove the class to style the sub-menu "to left"
1101 submenu.classList.remove('vbo-submenu-wrap-toleft');
1102
1103 // get sub-menu width and offset left position values
1104 let elemWidth = submenu.offsetWidth;
1105 let elemOffLeft = submenu.getBoundingClientRect().left;
1106
1107 if (elemWidth) {
1108 // sub-menu visibility is hidden, but width has been computed
1109 if ((elemWidth + elemOffLeft) > windowWidth) {
1110 // add "to left" positioning class or the sub-menu would exceed the window
1111 submenu.classList.add('vbo-submenu-wrap-toleft');
1112 }
1113 } else {
1114 // on small screens, the sub-menu may be hidden, hence with no width
1115 let parentmenu = submenu.closest('.vbo-menu-parent-li');
1116
1117 // register listener for mouseover event
1118 parentmenu.addEventListener('mouseover', (e) => {
1119 setTimeout(() => {
1120 let now_submenu = e.target.querySelector('.vbo-submenu-wrap');
1121 if (!now_submenu) {
1122 return;
1123 }
1124 if ((now_submenu.offsetWidth + now_submenu.getBoundingClientRect().left) > window.innerWidth) {
1125 // add "to left" positioning class or the sub-menu would exceed the window
1126 now_submenu.classList.add('vbo-submenu-wrap-toleft');
1127 }
1128 }, 0);
1129 });
1130
1131 // register listener for touchstart event
1132 parentmenu.addEventListener('touchstart', (e) => {
1133 let limenu = e.target;
1134 if (!limenu.matches('.vbo-menu-parent-li')) {
1135 limenu = limenu.closest('.vbo-menu-parent-li');
1136 }
1137 // propagate the mouseover event
1138 limenu.dispatchEvent(new Event('mouseover'));
1139 });
1140 }
1141 });
1142 };
1143
1144 // register listener for window resize event
1145 window.addEventListener('resize', subMenuStylesPositioning);
1146
1147 // trigger sub-menus styles positioning function on page load
1148 setTimeout(() => {
1149 subMenuStylesPositioning();
1150 }, 0);
1151
1152 // populate admin-dock
1153 VBOAdminDock.getInstance();
1154 });
1155 </script>
1156 <?php
1157
1158 // handle subscription expiration reminder modal
1159 if (is_array($vcm_expiration_reminder) && $vcm_expiration_reminder['days_to_exp'] >= 0) {
1160 // subscription is expiring, but it's not expired yet, display a modal-reminder
1161 ?>
1162 <div class="vbo-info-overlay-block vbo-info-overlay-expiration-reminder">
1163 <div class="vbo-info-overlay-content">
1164 <h3 style="color: var(--vbo-red-color);"><i class="vboicn-warning"></i> <?php echo JText::translate('VCM_EXPIRATION_REMINDERS'); ?></h3>
1165 <div>
1166 <h4><?php echo JText::sprintf('VCM_EXPIRATION_REMINDER_DAYS', $vcm_expiration_reminder['days_to_exp'], $vcm_expiration_reminder['expiration_ymd']); ?></h4>
1167 </div>
1168 <div class="vbo-info-overlay-footer">
1169 <div class="vbo-info-overlay-footer-right">
1170 <button type="button" class="btn btn-danger" onclick="jQuery('.vbo-info-overlay-expiration-reminder').fadeOut();"><?php echo JText::translate('VBOBTNKEEPREMIND'); ?></button>
1171 </div>
1172 </div>
1173 </div>
1174 </div>
1175
1176 <script type="text/javascript">
1177 jQuery(function() {
1178 jQuery('.vbo-info-overlay-expiration-reminder').fadeIn();
1179 });
1180 </script>
1181 <?php
1182 }
1183
1184 $helpWizardAjaxUrl = VBOFactory::getPlatform()->getUri()->ajax('index.php?option=com_vikbooking');
1185 JHtml::fetch('script', VBO_ADMIN_URI . 'resources/helpwizard.js', ['version' => VIKBOOKING_SOFTWARE_VERSION]);
1186 JText::script('VBSAVE');
1187 JText::script('VBDISMISS');
1188 JFactory::getDocument()->addScriptDeclaration(
1189 <<<JAVASCRIPT
1190 (function(w) {
1191 window.VBO_HELP_WIZARD_AJAX_URL = '{$helpWizardAjaxUrl}';
1192 })(window);
1193 JAVASCRIPT
1194 );
1195 }
1196
1197 public static function printFooter()
1198 {
1199 $tmpl = VikRequest::getVar('tmpl');
1200 if ($tmpl == 'component') return;
1201 /**
1202 * @wponly "Powered by" is VikWP.com
1203 */
1204 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>';
1205 }
1206
1207 public static function pUpdateProgram($version)
1208 {
1209 /**
1210 * @wponly do nothing
1211 */
1212 }
1213
1214 /**
1215 * Method to add parameters to the update extra query.
1216 *
1217 * @joomlaonly this class is automatically loaded by Joomla
1218 * to invoke this method when updating the component.
1219 *
1220 * @param Update &$update An update definition
1221 * @param JTable &$table The update instance from the database
1222 *
1223 * @return void
1224 *
1225 * @since 1.16.0 (J) - 1.6.0 (WP)
1226 */
1227 public static function prepareUpdate(&$update, &$table)
1228 {
1229 // get current domain
1230 $server = JFactory::getApplication()->input->server;
1231
1232 // build query array
1233 $query = [
1234 'domain' => base64_encode($server->getString('HTTP_HOST')),
1235 'ip' => $server->getString('REMOTE_ADDR'),
1236 ];
1237
1238 // get license key
1239 $license_key = VBOFactory::getConfig()->get('licensekey');
1240 if ($license_key)
1241 {
1242 $query['key'] = $license_key;
1243 }
1244
1245 // always refresh the extra query before an update
1246 $update->set('extra_query', http_build_query($query, '', '&amp;'));
1247 }
1248
1249 /**
1250 * Returns the information about the first setup metrics and minimum requirements.
1251 *
1252 * @return array associative list of metrics.
1253 *
1254 * @since 1.16.4 (J) - 1.6.4 (WP)
1255 */
1256 public static function getFirstSetupMetrics()
1257 {
1258 $dbo = JFactory::getDbo();
1259
1260 $q = "SELECT COUNT(*) FROM `#__vikbooking_prices`;";
1261 $dbo->setQuery($q);
1262 $totprices = $dbo->loadResult();
1263
1264 $q = "SELECT COUNT(*) FROM `#__vikbooking_rooms`;";
1265 $dbo->setQuery($q);
1266 $totrooms = $dbo->loadResult();
1267
1268 $q = "SELECT COUNT(*) FROM `#__vikbooking_dispcost`;";
1269 $dbo->setQuery($q);
1270 $totdailyfares = $dbo->loadResult();
1271
1272 $metrics = [
1273 'totprices' => $totprices,
1274 'totrooms' => $totrooms,
1275 'totdailyfares' => $totdailyfares,
1276 'completed' => ($totprices && $totrooms && $totdailyfares),
1277 ];
1278
1279 // shortcodes (if platform-supported)
1280 if (VBOPlatformDetection::isWordPress()) {
1281 /**
1282 * @wponly - check if some shortcodes have been defined before showing the Dashboard
1283 */
1284 $model = JModel::getInstance('vikbooking', 'shortcodes');
1285 $metrics['shortcodes'] = $model->all('post_id');
1286
1287 // calculate again the completed status
1288 $metrics['completed'] = ($metrics['completed'] && $metrics['shortcodes']);
1289 }
1290
1291 return $metrics;
1292 }
1293 }
1294