PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.8
VikBooking Hotel Booking Engine & PMS v1.6.8
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / admin / helpers / vikbooking.php

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

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