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
payments.php
142 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 |
| 16 | * payment gateways. |
| 17 | * |
| 18 | * @since 1.7.1 |
| 19 | */ |
| 20 | class VAPWizardStepPayments 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('VAPMENUPAYMENTS'); |
| 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_PAYMENTS_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-credit-card"></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 GLOBAL group |
| 61 | return JText::translate('VAPMENUTITLEHEADER3'); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Checks whether the step has been completed. |
| 66 | * |
| 67 | * @return boolean True if completed, false otherwise. |
| 68 | */ |
| 69 | public function isCompleted() |
| 70 | { |
| 71 | // the step is completed after publishing at least a payment |
| 72 | foreach ($this->getPayments() as $payment) |
| 73 | { |
| 74 | if ($payment->published) |
| 75 | { |
| 76 | // payment published |
| 77 | return true; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // no published payments |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Returns the button used to process the step. |
| 87 | * |
| 88 | * @return string The HTML of the button. |
| 89 | */ |
| 90 | public function getExecuteButton() |
| 91 | { |
| 92 | // get payments list |
| 93 | $payments = $this->getPayments(); |
| 94 | |
| 95 | if ($payments) |
| 96 | { |
| 97 | // point to the controller for editing an existing payment |
| 98 | return '<a href="index.php?option=com_vikappointments&view=payments" class="btn btn-success">' . JText::translate('VAPEDIT') . '</a>'; |
| 99 | } |
| 100 | |
| 101 | // point to the controller for creating a new payment |
| 102 | return '<a href="index.php?option=com_vikappointments&task=payment.add" class="btn btn-success">' . JText::translate('VAPNEW') . '</a>'; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Checks whether the specified step can be skipped. |
| 107 | * By default, all the steps are mandatory. |
| 108 | * |
| 109 | * @return boolean True if skippable, false otherwise. |
| 110 | */ |
| 111 | public function canIgnore() |
| 112 | { |
| 113 | return true; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Returns a list of created payments. |
| 118 | * |
| 119 | * @return array A list of payments. |
| 120 | */ |
| 121 | public function getPayments() |
| 122 | { |
| 123 | static $payments = null; |
| 124 | |
| 125 | // get payments only once |
| 126 | if (is_null($payments)) |
| 127 | { |
| 128 | $dbo = JFactory::getDbo(); |
| 129 | |
| 130 | $q = $dbo->getQuery(true) |
| 131 | ->select($dbo->qn(array('id', 'name', 'file', 'published'))) |
| 132 | ->from($dbo->qn('#__vikappointments_gpayments')) |
| 133 | ->order($dbo->qn('ordering') . ' ASC'); |
| 134 | |
| 135 | $dbo->setQuery($q); |
| 136 | $payments = $dbo->loadObjectList(); |
| 137 | } |
| 138 | |
| 139 | return $payments; |
| 140 | } |
| 141 | } |
| 142 |