PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.9
VikBooking Hotel Booking Engine & PMS v1.6.9
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.9, at admin/helpers/vikbooking.php

1,170 lines 43.6 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 // read "old" notifications
684 $ncInstance->readOldNotifications();
685
686 // check if notifications should be downloaded
687 $ncInstance->downloadNotifications();
688
689 // count unread notifications
690 $unreadNotifs = $ncInstance->countUnread();
691 $unreadNotifsRead = $unreadNotifs > 99 ? '99+' : $unreadNotifs;
692 $unreadNotifsRead = !$unreadNotifsRead ? '' : $unreadNotifsRead;
693 ?>
694 <div class="vbo-notifications-center-container">
695 <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'); ?>">
696 <?php VikBookingIcons::e('bell', 'can-shake'); ?>
697 </button>
698 <?php
699 // prepare the layout data array
700 $layout_data = [
701 'vbo_page' => (empty($view) ? VikRequest::getString('task', '') : $view),
702 'btn_trigger' => '.vbo-notifications-center-handler',
703 'badge_c_attr' => 'data-badge-count',
704 'badge_r_attr' => 'data-badge-read',
705 'badge_count' => $unreadNotifs,
706 ];
707 // render the notificationscenter layout
708 echo JLayoutHelper::render('sidepanel.notificationscenter', $layout_data, null, [
709 'component' => 'com_vikbooking',
710 'client' => 'administrator',
711 ]);
712 ?>
713 </div>
714
715 </div>
716 </div>
717 </div>
718
719 <script type="text/javascript">
720 jQuery(function() {
721 jQuery('.vbo-menu-parent-li').hover(
722 function() {
723 jQuery(this).addClass('vbo-menu-parent-li-opened');
724 jQuery(this).find('.vbo-submenu-wrap').addClass('vbo-submenu-wrap-active');
725 },function() {
726 jQuery(this).removeClass('vbo-menu-parent-li-opened');
727 jQuery(this).find('.vbo-submenu-wrap').removeClass('vbo-submenu-wrap-active');
728 }
729 );
730
731 if (jQuery('.vmenulinkactive').length) {
732 // set active class to current menu block
733 jQuery('.vmenulinkactive').closest('.vbo-submenu-wrap').parent('li').addClass('vbo-menu-parent-li-active');
734 }
735
736 if (<?php echo $reviews_dld; ?> > 0) {
737 // download new reviews
738 VBOCore.doAjax(
739 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikchannelmanager&task=reviews_download'); ?>",
740 {
741 return: 1,
742 everywhere: 1,
743 tmpl: 'component'
744 },
745 (resp) => {
746 try {
747 if (resp.indexOf('e4j.ok') >= 0) {
748 var tot_reviews = resp.replace('e4j.ok.', '');
749 tot_reviews = parseInt(tot_reviews);
750 if (!isNaN(tot_reviews) && tot_reviews > 0) {
751 // update button badge
752 jQuery('.vbo-reviews-btnbadge').attr('data-reviews-count', tot_reviews).addClass('vbo-reviews-btnbadge-alert');
753 }
754 }
755 } catch(err) {
756 console.error('Error in decoding response', err, resp);
757 }
758 },
759 (err) => {
760 console.error('Could not download new reviews from Channel Manager', err);
761 }
762 );
763 }
764
765 // handle quick actions storage
766 jQuery('.vbo-menu-right').find('.vbo-submenu-ul').find('a').on('click', function(e) {
767 if (!jQuery(this).find('.vbo-submenu-item-txt').length) {
768 // nothing to do
769 return true;
770 }
771
772 // handle the clicked menu entry
773 e.preventDefault();
774
775 try {
776 // register clicked page
777 VBOCore.registerAdminMenuAction({
778 name: jQuery(this).find('.vbo-submenu-item-txt').text(),
779 href: jQuery(this).attr('href'),
780 });
781 } catch(e) {
782 console.error(e);
783 }
784
785 if (e.metaKey) {
786 // open link on new window
787 window.open(jQuery(this).attr('href'), '_blank').focus();
788 } else {
789 // proceed with the navigation
790 window.location.href = jQuery(this).attr('href');
791 }
792
793 return true;
794 });
795
796 // register event to populate quick actions sub-menu helpers
797 document.addEventListener('vbo-adminmenu-quickactions-create', () => {
798 // load the action from the "widgets" scope to be used as fallback
799 let menu_widgets_actions = VBOCore.getAdminMenuActions('widgets');
800
801 // scan all menu scopes
802 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
803 let menu_ul = jQuery(this);
804 let scope = menu_ul.attr('data-menu-scope');
805 if (!scope) {
806 return;
807 }
808
809 let orig_scope = scope;
810 let wrapper = menu_ul.closest('.vbo-submenu-wrap');
811 if (!wrapper || !wrapper.length || wrapper.hasClass('vbo-submenu-wrap-multi') || wrapper.find('.vbo-submenu-helper-ul').length) {
812 return;
813 }
814
815 let menu_scope_actions = VBOCore.getAdminMenuActions(scope);
816 if (!Array.isArray(menu_scope_actions) || !menu_scope_actions.length) {
817 // check if we can fallback on the "widgets" scope
818 if (Array.isArray(menu_widgets_actions) && menu_widgets_actions.length) {
819 // overwrite scope values
820 scope = 'widgets';
821 menu_scope_actions = menu_widgets_actions;
822 } else {
823 // do not proceed with this scope
824 return;
825 }
826 }
827
828 // check if menu actions should be merged with the fallback scope
829 if (scope != 'widgets' && menu_scope_actions[0].hasOwnProperty('fallback')) {
830 menu_scope_actions = VBOCore.fillAdminMenuActions(menu_scope_actions, menu_widgets_actions, scope);
831 }
832
833 wrapper.addClass('vbo-submenu-wrap-multi');
834 let quick_actions = jQuery('<ul></ul>').addClass('vbo-submenu-helper-ul');
835 quick_actions.append('<li class="vbo-submenu-helper-lbl-li"><span class="vbo-submenu-helper-lbl-txt">' + Joomla.JText._('VBO_QUICK_ACTIONS') + '</span></li>');
836
837 // scan all menu actions
838 menu_scope_actions.forEach((action, index) => {
839 let is_pinned = action.hasOwnProperty('pinned') && action['pinned'];
840 let quick_actions_entry = jQuery('<li></li>').addClass((is_pinned ? 'vbo-submenu-item-helper-pinned' : 'vbo-submenu-item-helper-unpinned'));
841 let quick_actions_div = jQuery('<div></div>').addClass('vmenulink');
842 let quick_action_link = jQuery('<a></a>').attr('href', action['href']).addClass('vbo-submenu-item-helper-link');
843
844 if (action.hasOwnProperty('target') && action['target']) {
845 quick_action_link.attr('target', action['target']);
846 }
847
848 if (action.hasOwnProperty('widget') && action['widget']) {
849 quick_action_link.on('click', () => {
850 VBOCore.handleDisplayWidgetNotification({widget_id: action['widget']});
851 });
852 }
853
854 if (action.hasOwnProperty('img') && action['img']) {
855 let quick_action_img = jQuery('<span></span>').addClass('vbo-submenu-item-helper-avatar');
856 quick_action_img.append('<img src="' + action['img'] + '" />');
857 quick_action_link.append(quick_action_img);
858 } else if (action.hasOwnProperty('icon') && action['icon']) {
859 let quick_action_icon = jQuery('<span></span>').addClass('vbo-submenu-item-helper-avatar');
860 quick_action_icon.append(action['icon']);
861 quick_action_link.append(quick_action_icon);
862 }
863
864 let quick_action_name = jQuery('<span></span>').addClass('vbo-submenu-item-helper-txt').text(action['name']);
865 quick_action_link.append(quick_action_name);
866 quick_actions_div.append(quick_action_link);
867
868 let quick_action_pin = jQuery('<span></span>').addClass('vbo-submenu-item-helper-setpin').on('click', function() {
869 // toggle pinned status and update admin menu action
870 if (!action.hasOwnProperty('pinned')) {
871 action['pinned'] = !is_pinned;
872 } else {
873 action['pinned'] = !action['pinned'];
874 }
875 try {
876 // register/unregister pin
877 if (orig_scope != scope && !VBOCore.getAdminMenuActions(orig_scope).length) {
878 // set fallbacked scope
879 action['fallback'] = scope;
880
881 // register scope on local storage with the fallbacked scope
882 VBOCore.registerAdminMenuAction(action, orig_scope);
883 } else {
884 // update local storage regularly on this scope
885 VBOCore.updateAdminMenuAction(action, scope);
886 }
887
888 // trigger event
889 VBOCore.emitEvent('vbo-adminmenu-quickactions-update');
890 } catch(e) {
891 console.error(e);
892 }
893 // update action status
894 if (action['pinned']) {
895 jQuery(this).closest('li').removeClass('vbo-submenu-item-helper-unpinned').addClass('vbo-submenu-item-helper-pinned');
896 } else {
897 jQuery(this).closest('li').removeClass('vbo-submenu-item-helper-pinned').addClass('vbo-submenu-item-helper-unpinned');
898 }
899 });
900
901 quick_action_pin.html('<?php VikBookingIcons::e('thumbtack'); ?>');
902 quick_actions_div.append(quick_action_pin);
903 quick_actions_entry.append(quick_actions_div);
904 quick_actions.append(quick_actions_entry);
905 });
906
907 // append to DOM element
908 wrapper.append(quick_actions);
909 });
910 });
911
912 // register event to update the pinned quick actions
913 document.addEventListener('vbo-adminmenu-quickactions-update', VBOCore.debounceEvent(() => {
914 let menu_scopes = [];
915 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
916 let menu_ul = jQuery(this);
917 let scope = menu_ul.attr('data-menu-scope');
918 if (!scope) {
919 scope = '';
920 }
921 if (menu_scopes.indexOf(scope) < 0) {
922 menu_scopes.push(scope);
923 }
924 });
925 let admin_menu_actions = [];
926 menu_scopes.forEach((scope) => {
927 let menu_actions = VBOCore.getAdminMenuActions(scope);
928 admin_menu_actions.push({
929 scope: scope,
930 actions: menu_actions,
931 });
932 });
933 VBOCore.doAjax(
934 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=menuactions.update'); ?>",
935 {
936 actions: admin_menu_actions,
937 },
938 (resp) => {
939 // do nothing
940 },
941 (err) => {
942 // log the error
943 console.error(err.responseText);
944 }
945 );
946 }, 300));
947
948 // register shortcuts
949 var vbo_menu_last_keydown = null;
950 window.addEventListener('keydown', (e) => {
951 e = e || window.event;
952 if (!e.key) {
953 return;
954 }
955 if (e.key === 'Enter' && e.metaKey) {
956 // toggle multitask panel
957 VBOCore.emitEvent(VBOCore.multitask_shortcut_event);
958 return;
959 }
960 if (VBOCore.side_panel_on && e.key === 'f' && e.metaKey) {
961 // focus search admin widget in multitask panel
962 VBOCore.emitEvent(VBOCore.multitask_searchfs_event);
963 e.preventDefault();
964 return;
965 }
966 if (e.key === 'k' && e.metaKey) {
967 // set special key listener for sequences of combos
968 e.preventDefault();
969 vbo_menu_last_keydown = 'k';
970 return;
971 }
972 if (vbo_menu_last_keydown === 'k' && e.metaKey && ['a', 'd', 'l'].includes(e.key)) {
973 // trigger event to change color scheme preferences
974 e.preventDefault();
975 // unset special key
976 vbo_menu_last_keydown = '';
977 // activate requested color scheme preference
978 let color_schemes = {
979 a: 'auto',
980 d: 'dark',
981 l: 'light',
982 };
983 jQuery('.vbo-sidepanel-colorscheme-option[data-scheme="' + color_schemes[e.key] + '"]').trigger('click');
984 return;
985 }
986 // always unset last key if this point gets reached
987 vbo_menu_last_keydown = '';
988 }, true);
989
990 // populate quick actions sub-menu helpers on page load
991 VBOCore.emitEvent('vbo-adminmenu-quickactions-create');
992
993 // check (only once) if the quick actions should be imported from the db
994 if (<?php echo !$admin_menu_actions_checked ? 'true' : 'false'; ?>) {
995 setTimeout(() => {
996 // count admin menu actions populated from local storage
997 let tot_admin_menu_actions = 0;
998 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
999 let menu_ul = jQuery(this);
1000 let scope = menu_ul.attr('data-menu-scope');
1001 if (!scope) {
1002 return;
1003 }
1004 let menu_scope_actions = VBOCore.getAdminMenuActions(scope);
1005 if (!Array.isArray(menu_scope_actions) || !menu_scope_actions.length) {
1006 return;
1007 }
1008 tot_admin_menu_actions++;
1009 return false;
1010 });
1011
1012 if (tot_admin_menu_actions) {
1013 return;
1014 }
1015
1016 // request for any previously stored quick actions for this admin
1017 VBOCore.doAjax(
1018 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=menuactions.retrieve'); ?>",
1019 {},
1020 (resp) => {
1021 // store to local storage the quick actions just retrieved
1022 let obj_res = typeof resp === 'string' ? JSON.parse(resp) : resp;
1023 if (Array.isArray(obj_res) && obj_res.length) {
1024 obj_res.forEach((menu_actions) => {
1025 let storage_scope_name = VBOCore.options.admin_menu_actions_nm;
1026 if (menu_actions['scope']) {
1027 storage_scope_name += '.' + menu_actions['scope'];
1028 }
1029 VBOCore.storageSetItem(storage_scope_name, menu_actions['actions']);
1030 });
1031 }
1032 // trigger the event to populate the quick actions
1033 VBOCore.emitEvent('vbo-adminmenu-quickactions-create');
1034 },
1035 (err) => {
1036 // log the error
1037 console.error(err.responseText);
1038 }
1039 );
1040 }, 300);
1041 }
1042 });
1043 </script>
1044 <?php
1045
1046 // handle subscription expiration reminder modal
1047 if (is_array($vcm_expiration_reminder) && $vcm_expiration_reminder['days_to_exp'] >= 0) {
1048 // subscription is expiring, but it's not expired yet, display a modal-reminder
1049 ?>
1050 <div class="vbo-info-overlay-block vbo-info-overlay-expiration-reminder">
1051 <div class="vbo-info-overlay-content">
1052 <h3 style="color: var(--vbo-red-color);"><i class="vboicn-warning"></i> <?php echo JText::translate('VCM_EXPIRATION_REMINDERS'); ?></h3>
1053 <div>
1054 <h4><?php echo JText::sprintf('VCM_EXPIRATION_REMINDER_DAYS', $vcm_expiration_reminder['days_to_exp'], $vcm_expiration_reminder['expiration_ymd']); ?></h4>
1055 </div>
1056 <div class="vbo-info-overlay-footer">
1057 <div class="vbo-info-overlay-footer-right">
1058 <button type="button" class="btn btn-danger" onclick="jQuery('.vbo-info-overlay-expiration-reminder').fadeOut();"><?php echo JText::translate('VBOBTNKEEPREMIND'); ?></button>
1059 </div>
1060 </div>
1061 </div>
1062 </div>
1063
1064 <script type="text/javascript">
1065 jQuery(function() {
1066 jQuery('.vbo-info-overlay-expiration-reminder').fadeIn();
1067 });
1068 </script>
1069 <?php
1070 }
1071 }
1072
1073 public static function printFooter()
1074 {
1075 $tmpl = VikRequest::getVar('tmpl');
1076 if ($tmpl == 'component') return;
1077 /**
1078 * @wponly "Powered by" is VikWP.com
1079 */
1080 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>';
1081 }
1082
1083 public static function pUpdateProgram($version)
1084 {
1085 /**
1086 * @wponly do nothing
1087 */
1088 }
1089
1090 /**
1091 * Method to add parameters to the update extra query.
1092 *
1093 * @joomlaonly this class is automatically loaded by Joomla
1094 * to invoke this method when updating the component.
1095 *
1096 * @param Update &$update An update definition
1097 * @param JTable &$table The update instance from the database
1098 *
1099 * @return void
1100 *
1101 * @since 1.16.0 (J) - 1.6.0 (WP)
1102 */
1103 public static function prepareUpdate(&$update, &$table)
1104 {
1105 // get current domain
1106 $server = JFactory::getApplication()->input->server;
1107
1108 // build query array
1109 $query = [
1110 'domain' => base64_encode($server->getString('HTTP_HOST')),
1111 'ip' => $server->getString('REMOTE_ADDR'),
1112 ];
1113
1114 // get license key
1115 $license_key = VBOFactory::getConfig()->get('licensekey');
1116 if ($license_key)
1117 {
1118 $query['key'] = $license_key;
1119 }
1120
1121 // always refresh the extra query before an update
1122 $update->set('extra_query', http_build_query($query, '', '&amp;'));
1123 }
1124
1125 /**
1126 * Returns the information about the first setup metrics and minimum requirements.
1127 *
1128 * @return array associative list of metrics.
1129 *
1130 * @since 1.16.4 (J) - 1.6.4 (WP)
1131 */
1132 public static function getFirstSetupMetrics()
1133 {
1134 $dbo = JFactory::getDbo();
1135
1136 $q = "SELECT COUNT(*) FROM `#__vikbooking_prices`;";
1137 $dbo->setQuery($q);
1138 $totprices = $dbo->loadResult();
1139
1140 $q = "SELECT COUNT(*) FROM `#__vikbooking_rooms`;";
1141 $dbo->setQuery($q);
1142 $totrooms = $dbo->loadResult();
1143
1144 $q = "SELECT COUNT(*) FROM `#__vikbooking_dispcost`;";
1145 $dbo->setQuery($q);
1146 $totdailyfares = $dbo->loadResult();
1147
1148 $metrics = [
1149 'totprices' => $totprices,
1150 'totrooms' => $totrooms,
1151 'totdailyfares' => $totdailyfares,
1152 'completed' => ($totprices && $totrooms && $totdailyfares),
1153 ];
1154
1155 // shortcodes (if platform-supported)
1156 if (VBOPlatformDetection::isWordPress()) {
1157 /**
1158 * @wponly - check if some shortcodes have been defined before showing the Dashboard
1159 */
1160 $model = JModel::getInstance('vikbooking', 'shortcodes');
1161 $metrics['shortcodes'] = $model->all('post_id');
1162
1163 // calculate again the completed status
1164 $metrics['completed'] = ($metrics['completed'] && $metrics['shortcodes']);
1165 }
1166
1167 return $metrics;
1168 }
1169 }
1170