PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / helpers / libraries / wizard / classes / packages.php
vikappointments / site / helpers / libraries / wizard / classes Last commit date
employees.php 3 days ago index.html 3 days ago locations.php 3 days ago locwdays.php 3 days ago options.php 3 days ago packages.php 3 days ago payments.php 3 days ago services.php 3 days ago subscriptions.php 3 days ago syspack.php 3 days ago syssubscr.php 3 days ago system.php 3 days ago taxes.php 3 days ago
packages.php
143 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Implement the wizard step used to configure the packages.
16 *
17 * @since 1.7.1
18 */
19 class VAPWizardStepPackages extends VAPWizardStep
20 {
21 /**
22 * Returns the step title.
23 * Used as a very-short description.
24 *
25 * @return string The step title.
26 */
27 public function getTitle()
28 {
29 return JText::translate('VAPMENUPACKAGES');
30 }
31
32 /**
33 * Returns the step description.
34 *
35 * @return string The step description.
36 */
37 public function getDescription()
38 {
39 return JText::translate('VAP_WIZARD_STEP_PACKAGES_DESC');
40 }
41
42 /**
43 * Returns an optional step icon.
44 *
45 * @return string The step icon.
46 */
47 public function getIcon()
48 {
49 return '<i class="fas fa-gift"></i>';
50 }
51
52 /**
53 * Return the group to which the step belongs.
54 *
55 * @return string The group name.
56 */
57 public function getGroup()
58 {
59 // belongs to PACKAGES group
60 return JText::translate('VAPMENUPACKAGES');
61 }
62
63 /**
64 * Checks whether the specified step can be skipped.
65 * By default, all the steps are mandatory.
66 *
67 * @return boolean True if skippable, false otherwise.
68 */
69 public function canIgnore()
70 {
71 return true;
72 }
73
74 /**
75 * Checks whether the step has been ignored.
76 *
77 * @return boolean True if ignored, false otherwise.
78 */
79 public function isIgnored()
80 {
81 // get system packages dependency
82 $system = $this->getDependency('syspack');
83
84 // make sure the packages section is enabled
85 if ($system && $system->isCompleted() && $system->isEnabled() === false)
86 {
87 // packages disabled, auto-ignore this step
88 return true;
89 }
90
91 // otherwise lean on parent method
92 return parent::isIgnored();
93 }
94
95 /**
96 * Checks whether the step has been completed.
97 *
98 * @return boolean True if completed, false otherwise.
99 */
100 public function isCompleted()
101 {
102 // check whether at least a package has been created
103 return (bool) $this->getPackages();
104 }
105
106 /**
107 * Returns the button used to process the step.
108 *
109 * @return string The HTML of the button.
110 */
111 public function getExecuteButton()
112 {
113 // point to the controller for creating a new package
114 return '<a href="index.php?option=com_vikappointments&task=package.add" class="btn btn-success">' . JText::translate('VAPNEW') . '</a>';
115 }
116
117 /**
118 * Returns a list of created packages.
119 *
120 * @return array A list of packages.
121 */
122 public function getPackages()
123 {
124 static $packages = null;
125
126 // get packages only once
127 if (is_null($packages))
128 {
129 $dbo = JFactory::getDbo();
130
131 $q = $dbo->getQuery(true)
132 ->select($dbo->qn(array('id', 'name', 'published')))
133 ->from($dbo->qn('#__vikappointments_package'))
134 ->order($dbo->qn('id') . ' ASC');
135
136 $dbo->setQuery($q);
137 $packages = $dbo->loadObjectList();
138 }
139
140 return $packages;
141 }
142 }
143