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
subscriptions.php
146 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 |
| 16 | * the subscriptions for the customers. |
| 17 | * |
| 18 | * @since 1.7.1 |
| 19 | */ |
| 20 | class VAPWizardStepSubscriptions extends VAPWizardStep |
| 21 | { |
| 22 | /** |
| 23 | * Returns the step title. |
| 24 | * Used as a very-short description. |
| 25 | * |
| 26 | * @return string The step title. |
| 27 | */ |
| 28 | public function getTitle() |
| 29 | { |
| 30 | return JText::translate('VAPMENUSUBSCRIPTIONS'); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Returns the step description. |
| 35 | * |
| 36 | * @return string The step description. |
| 37 | */ |
| 38 | public function getDescription() |
| 39 | { |
| 40 | return JText::translate('VAP_WIZARD_STEP_SUBSCR_DESC'); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Returns an optional step icon. |
| 45 | * |
| 46 | * @return string The step icon. |
| 47 | */ |
| 48 | public function getIcon() |
| 49 | { |
| 50 | return '<i class="fas fa-ticket-alt"></i>'; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Return the group to which the step belongs. |
| 55 | * |
| 56 | * @return string The group name. |
| 57 | */ |
| 58 | public function getGroup() |
| 59 | { |
| 60 | // belongs to SUBSCRIPTIONS group |
| 61 | return JText::translate('VAPMENUSUBSCRIPTIONS'); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Checks whether the specified step can be skipped. |
| 66 | * By default, all the steps are mandatory. |
| 67 | * |
| 68 | * @return boolean True if skippable, false otherwise. |
| 69 | */ |
| 70 | public function canIgnore() |
| 71 | { |
| 72 | return true; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Checks whether the step has been ignored. |
| 77 | * |
| 78 | * @return boolean True if ignored, false otherwise. |
| 79 | */ |
| 80 | public function isIgnored() |
| 81 | { |
| 82 | // get system subscriptions dependency |
| 83 | $system = $this->getDependency('syssubscr'); |
| 84 | |
| 85 | // make sure the subscriptions section is enabled |
| 86 | if ($system && $system->isCompleted() && $system->isEnabled() === false) |
| 87 | { |
| 88 | // subscriptions disabled, auto-ignore this step |
| 89 | return true; |
| 90 | } |
| 91 | |
| 92 | // otherwise lean on parent method |
| 93 | return parent::isIgnored(); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Checks whether the step has been completed. |
| 98 | * |
| 99 | * @return boolean True if completed, false otherwise. |
| 100 | */ |
| 101 | public function isCompleted() |
| 102 | { |
| 103 | // check whether at least a subscription has been created |
| 104 | return (bool) $this->getSubscriptions(); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Returns the button used to process the step. |
| 109 | * |
| 110 | * @return string The HTML of the button. |
| 111 | */ |
| 112 | public function getExecuteButton() |
| 113 | { |
| 114 | // point to the (customers) subscriptions view |
| 115 | return '<a href="index.php?option=com_vikappointments&view=subscriptions&group=0" class="btn btn-success">' . JText::translate('VAPNEW') . '</a>'; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Returns a list of created subscriptions. |
| 120 | * |
| 121 | * @return array A list of subscriptions. |
| 122 | */ |
| 123 | public function getSubscriptions() |
| 124 | { |
| 125 | static $subscr = null; |
| 126 | |
| 127 | // get subscriptions only once |
| 128 | if (is_null($subscr)) |
| 129 | { |
| 130 | $dbo = JFactory::getDbo(); |
| 131 | |
| 132 | $q = $dbo->getQuery(true) |
| 133 | ->select($dbo->qn(array('id', 'name'))) |
| 134 | ->from($dbo->qn('#__vikappointments_subscription')) |
| 135 | ->where($dbo->qn('group') . ' = 0') |
| 136 | ->where($dbo->qn('published') . ' = 1') |
| 137 | ->order($dbo->qn('id') . ' ASC'); |
| 138 | |
| 139 | $dbo->setQuery($q); |
| 140 | $subscr = $dbo->loadObjectList(); |
| 141 | } |
| 142 | |
| 143 | return $subscr; |
| 144 | } |
| 145 | } |
| 146 |