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

1,195 lines 44.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 = VBOFactory::getNotificationCenter();
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 let before_fill_length = menu_scope_actions.length;
831 menu_scope_actions = VBOCore.fillAdminMenuActions(menu_scope_actions, menu_widgets_actions, scope);
832 let after_fill_length = menu_scope_actions.length;
833 if (before_fill_length && after_fill_length > before_fill_length) {
834 // update scope for the filled entries
835 VBOCore.storageSetItem(VBOCore.getStorageScopeName(scope), menu_scope_actions);
836 }
837 }
838
839 wrapper.addClass('vbo-submenu-wrap-multi');
840 let quick_actions = jQuery('<ul></ul>').addClass('vbo-submenu-helper-ul');
841 quick_actions.append('<li class="vbo-submenu-helper-lbl-li"><span class="vbo-submenu-helper-lbl-txt">' + Joomla.JText._('VBO_QUICK_ACTIONS') + '</span></li>');
842
843 // scan all menu actions
844 menu_scope_actions.forEach((action, index) => {
845 let is_pinned = action.hasOwnProperty('pinned') && action['pinned'];
846 let quick_actions_entry = jQuery('<li></li>').addClass((is_pinned ? 'vbo-submenu-item-helper-pinned' : 'vbo-submenu-item-helper-unpinned'));
847 let quick_actions_div = jQuery('<div></div>').addClass('vmenulink');
848 let quick_action_link = jQuery('<a></a>').attr('href', action['href']).addClass('vbo-submenu-item-helper-link');
849
850 if (action.hasOwnProperty('target') && action['target']) {
851 quick_action_link.attr('target', action['target']);
852 }
853
854 if (action.hasOwnProperty('widget') && action['widget']) {
855 quick_action_link.on('click', () => {
856 VBOCore.handleDisplayWidgetNotification({widget_id: action['widget']});
857 });
858 }
859
860 if (action.hasOwnProperty('img') && action['img']) {
861 let quick_action_img = jQuery('<span></span>').addClass('vbo-submenu-item-helper-avatar');
862 quick_action_img.append('<img src="' + action['img'] + '" />');
863 quick_action_link.append(quick_action_img);
864 } else if (action.hasOwnProperty('icon') && action['icon']) {
865 let quick_action_icon = jQuery('<span></span>').addClass('vbo-submenu-item-helper-avatar');
866 quick_action_icon.append(action['icon']);
867 quick_action_link.append(quick_action_icon);
868 }
869
870 let quick_action_name = jQuery('<span></span>').addClass('vbo-submenu-item-helper-txt').text(action['name']);
871 quick_action_link.append(quick_action_name);
872 quick_actions_div.append(quick_action_link);
873
874 let quick_action_pin = jQuery('<span></span>').addClass('vbo-submenu-item-helper-setpin').on('click', function() {
875 // toggle pinned status and update admin menu action
876 if (!action.hasOwnProperty('pinned')) {
877 action['pinned'] = !is_pinned;
878 } else {
879 action['pinned'] = !action['pinned'];
880 }
881 try {
882 // register/unregister pin
883 if (orig_scope != scope && !VBOCore.getAdminMenuActions(orig_scope).length) {
884 // set fallbacked scope
885 action['fallback'] = scope;
886
887 // register scope on local storage with the fallbacked scope
888 VBOCore.registerAdminMenuAction(action, orig_scope);
889 } else {
890 // update local storage regularly on this scope
891 VBOCore.updateAdminMenuAction(action, scope);
892 }
893
894 // trigger event
895 VBOCore.emitEvent('vbo-adminmenu-quickactions-update');
896 } catch(e) {
897 console.error(e);
898 }
899 // update action status
900 if (action['pinned']) {
901 jQuery(this).closest('li').removeClass('vbo-submenu-item-helper-unpinned').addClass('vbo-submenu-item-helper-pinned');
902 } else {
903 jQuery(this).closest('li').removeClass('vbo-submenu-item-helper-pinned').addClass('vbo-submenu-item-helper-unpinned');
904 }
905 });
906
907 quick_action_pin.html('<?php VikBookingIcons::e('thumbtack'); ?>');
908 quick_actions_div.append(quick_action_pin);
909 quick_actions_entry.append(quick_actions_div);
910 quick_actions.append(quick_actions_entry);
911 });
912
913 // append to DOM element
914 wrapper.append(quick_actions);
915 });
916 });
917
918 // register event to update the pinned quick actions
919 document.addEventListener('vbo-adminmenu-quickactions-update', VBOCore.debounceEvent(() => {
920 let menu_scopes = [];
921 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
922 let menu_ul = jQuery(this);
923 let scope = menu_ul.attr('data-menu-scope');
924 if (!scope) {
925 scope = '';
926 }
927 if (menu_scopes.indexOf(scope) < 0) {
928 menu_scopes.push(scope);
929 }
930 });
931 let admin_menu_actions = [];
932 menu_scopes.forEach((scope) => {
933 let menu_actions = VBOCore.getAdminMenuActions(scope);
934 admin_menu_actions.push({
935 scope: scope,
936 actions: menu_actions,
937 });
938 });
939 VBOCore.doAjax(
940 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=menuactions.update'); ?>",
941 {
942 actions: admin_menu_actions,
943 },
944 (resp) => {
945 // do nothing
946 },
947 (err) => {
948 // log the error
949 console.error(err.responseText);
950 }
951 );
952 }, 300));
953
954 // append shortcut to title
955 jQuery('.vbo-multitasking-apps').attr('title',
956 jQuery('.vbo-multitasking-apps').attr('title') + ' '
957 + (navigator.platform.toUpperCase().indexOf('MAC') === 0 ? '⌘' : '⌃') + '⏎'
958 );
959
960 // register shortcuts
961 var vbo_menu_last_keydown = null;
962 window.addEventListener('keydown', (e) => {
963 e = e || window.event;
964 if (!e.key) {
965 return;
966 }
967
968 let modifier = 'ctrl';
969
970 // change the modifier depending on the platform
971 if (navigator.platform.toUpperCase().indexOf('MAC') === 0) {
972 modifier = 'meta';
973 }
974
975 if (e.shortcut([modifier, 13])) {
976 // toggle multitask panel
977 VBOCore.emitEvent(VBOCore.multitask_shortcut_event);
978 return;
979 }
980
981 if (VBOCore.side_panel_on && e.shortcut([modifier, 'F'])) {
982 // focus search admin widget in multitask panel
983 VBOCore.emitEvent(VBOCore.multitask_searchfs_event);
984 e.preventDefault();
985
986 return;
987 }
988
989 if (e.shortcut([modifier, 'K'])) {
990 // set special key listener for sequences of combos
991 e.preventDefault();
992 vbo_menu_last_keydown = 'k';
993 return;
994 }
995
996 if (vbo_menu_last_keydown === 'k' && (e.shortcut([modifier, 'A']) || e.shortcut([modifier, 'D']) || e.shortcut([modifier, 'L']))) {
997 // trigger event to change color scheme preferences
998 e.preventDefault();
999 // unset special key
1000 vbo_menu_last_keydown = '';
1001 // activate requested color scheme preference
1002 let color_schemes = {
1003 a: 'auto',
1004 d: 'dark',
1005 l: 'light',
1006 };
1007 jQuery('.vbo-sidepanel-colorscheme-option[data-scheme="' + color_schemes[e.key] + '"]').trigger('click');
1008 return;
1009 }
1010
1011 // always unset last key if this point gets reached
1012 vbo_menu_last_keydown = '';
1013 }, true);
1014
1015 // populate quick actions sub-menu helpers on page load
1016 VBOCore.emitEvent('vbo-adminmenu-quickactions-create');
1017
1018 // check (only once) if the quick actions should be imported from the db
1019 if (<?php echo !$admin_menu_actions_checked ? 'true' : 'false'; ?>) {
1020 setTimeout(() => {
1021 // count admin menu actions populated from local storage
1022 let tot_admin_menu_actions = 0;
1023 jQuery('.vbo-submenu-ul[data-menu-scope]').each(function() {
1024 let menu_ul = jQuery(this);
1025 let scope = menu_ul.attr('data-menu-scope');
1026 if (!scope) {
1027 return;
1028 }
1029 let menu_scope_actions = VBOCore.getAdminMenuActions(scope);
1030 if (!Array.isArray(menu_scope_actions) || !menu_scope_actions.length) {
1031 return;
1032 }
1033 tot_admin_menu_actions++;
1034 return false;
1035 });
1036
1037 if (tot_admin_menu_actions) {
1038 return;
1039 }
1040
1041 // request for any previously stored quick actions for this admin
1042 VBOCore.doAjax(
1043 "<?php echo VikBooking::ajaxUrl('index.php?option=com_vikbooking&task=menuactions.retrieve'); ?>",
1044 {},
1045 (resp) => {
1046 // store to local storage the quick actions just retrieved
1047 let obj_res = typeof resp === 'string' ? JSON.parse(resp) : resp;
1048 if (Array.isArray(obj_res) && obj_res.length) {
1049 obj_res.forEach((menu_actions) => {
1050 let storage_scope_name = VBOCore.options.admin_menu_actions_nm;
1051 if (menu_actions['scope']) {
1052 storage_scope_name += '.' + menu_actions['scope'];
1053 }
1054 VBOCore.storageSetItem(storage_scope_name, menu_actions['actions']);
1055 });
1056 }
1057 // trigger the event to populate the quick actions
1058 VBOCore.emitEvent('vbo-adminmenu-quickactions-create');
1059 },
1060 (err) => {
1061 // log the error
1062 console.error(err.responseText);
1063 }
1064 );
1065 }, 300);
1066 }
1067 });
1068 </script>
1069 <?php
1070
1071 // handle subscription expiration reminder modal
1072 if (is_array($vcm_expiration_reminder) && $vcm_expiration_reminder['days_to_exp'] >= 0) {
1073 // subscription is expiring, but it's not expired yet, display a modal-reminder
1074 ?>
1075 <div class="vbo-info-overlay-block vbo-info-overlay-expiration-reminder">
1076 <div class="vbo-info-overlay-content">
1077 <h3 style="color: var(--vbo-red-color);"><i class="vboicn-warning"></i> <?php echo JText::translate('VCM_EXPIRATION_REMINDERS'); ?></h3>
1078 <div>
1079 <h4><?php echo JText::sprintf('VCM_EXPIRATION_REMINDER_DAYS', $vcm_expiration_reminder['days_to_exp'], $vcm_expiration_reminder['expiration_ymd']); ?></h4>
1080 </div>
1081 <div class="vbo-info-overlay-footer">
1082 <div class="vbo-info-overlay-footer-right">
1083 <button type="button" class="btn btn-danger" onclick="jQuery('.vbo-info-overlay-expiration-reminder').fadeOut();"><?php echo JText::translate('VBOBTNKEEPREMIND'); ?></button>
1084 </div>
1085 </div>
1086 </div>
1087 </div>
1088
1089 <script type="text/javascript">
1090 jQuery(function() {
1091 jQuery('.vbo-info-overlay-expiration-reminder').fadeIn();
1092 });
1093 </script>
1094 <?php
1095 }
1096 }
1097
1098 public static function printFooter()
1099 {
1100 $tmpl = VikRequest::getVar('tmpl');
1101 if ($tmpl == 'component') return;
1102 /**
1103 * @wponly "Powered by" is VikWP.com
1104 */
1105 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>';
1106 }
1107
1108 public static function pUpdateProgram($version)
1109 {
1110 /**
1111 * @wponly do nothing
1112 */
1113 }
1114
1115 /**
1116 * Method to add parameters to the update extra query.
1117 *
1118 * @joomlaonly this class is automatically loaded by Joomla
1119 * to invoke this method when updating the component.
1120 *
1121 * @param Update &$update An update definition
1122 * @param JTable &$table The update instance from the database
1123 *
1124 * @return void
1125 *
1126 * @since 1.16.0 (J) - 1.6.0 (WP)
1127 */
1128 public static function prepareUpdate(&$update, &$table)
1129 {
1130 // get current domain
1131 $server = JFactory::getApplication()->input->server;
1132
1133 // build query array
1134 $query = [
1135 'domain' => base64_encode($server->getString('HTTP_HOST')),
1136 'ip' => $server->getString('REMOTE_ADDR'),
1137 ];
1138
1139 // get license key
1140 $license_key = VBOFactory::getConfig()->get('licensekey');
1141 if ($license_key)
1142 {
1143 $query['key'] = $license_key;
1144 }
1145
1146 // always refresh the extra query before an update
1147 $update->set('extra_query', http_build_query($query, '', '&amp;'));
1148 }
1149
1150 /**
1151 * Returns the information about the first setup metrics and minimum requirements.
1152 *
1153 * @return array associative list of metrics.
1154 *
1155 * @since 1.16.4 (J) - 1.6.4 (WP)
1156 */
1157 public static function getFirstSetupMetrics()
1158 {
1159 $dbo = JFactory::getDbo();
1160
1161 $q = "SELECT COUNT(*) FROM `#__vikbooking_prices`;";
1162 $dbo->setQuery($q);
1163 $totprices = $dbo->loadResult();
1164
1165 $q = "SELECT COUNT(*) FROM `#__vikbooking_rooms`;";
1166 $dbo->setQuery($q);
1167 $totrooms = $dbo->loadResult();
1168
1169 $q = "SELECT COUNT(*) FROM `#__vikbooking_dispcost`;";
1170 $dbo->setQuery($q);
1171 $totdailyfares = $dbo->loadResult();
1172
1173 $metrics = [
1174 'totprices' => $totprices,
1175 'totrooms' => $totrooms,
1176 'totdailyfares' => $totdailyfares,
1177 'completed' => ($totprices && $totrooms && $totdailyfares),
1178 ];
1179
1180 // shortcodes (if platform-supported)
1181 if (VBOPlatformDetection::isWordPress()) {
1182 /**
1183 * @wponly - check if some shortcodes have been defined before showing the Dashboard
1184 */
1185 $model = JModel::getInstance('vikbooking', 'shortcodes');
1186 $metrics['shortcodes'] = $model->all('post_id');
1187
1188 // calculate again the completed status
1189 $metrics['completed'] = ($metrics['completed'] && $metrics['shortcodes']);
1190 }
1191
1192 return $metrics;
1193 }
1194 }
1195