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 / locwdays.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
locwdays.php
138 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 assign the locations to the
16 * related working days.
17 *
18 * @since 1.7.1
19 */
20 class VAPWizardStepLocwdays 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('VAP_WIZARD_STEP_LOCWDAYS');
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_LOCWDAYS_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-calendar-check"></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 APPOINTMENTS group
61 return JText::translate('VAPMENUTITLEHEADER2');
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 // check whether at least an assignment was created
72 return (bool) $this->getAssignments();
73 }
74
75 /**
76 * Returns the button used to process the step.
77 *
78 * @return string The HTML of the button.
79 */
80 public function getExecuteButton()
81 {
82 // load employees step from dependencies
83 $step = $this->getDependency('employees');
84
85 if (!$step)
86 {
87 return '';
88 }
89
90 // fetch the available employees
91 $employees = $step->getEmployees();
92
93 // point to the view used to assign the locations to the working days
94 return '<a href="index.php?option=com_vikappointments&view=locations&id_employee=' . $employees[0]->id . '" class="btn btn-success">' . JText::translate('VAPEDIT') . '</a>';
95 }
96
97 /**
98 * Checks whether the specified step can be skipped.
99 * By default, all the steps are mandatory.
100 *
101 * @return boolean True if skippable, false otherwise.
102 */
103 public function canIgnore()
104 {
105 return true;
106 }
107
108 /**
109 * Returns a list of created assignments.
110 *
111 * @return array A list of assignments.
112 */
113 public function getAssignments()
114 {
115 static $assoc = null;
116
117 // get assigments only once
118 if (is_null($assoc))
119 {
120 $dbo = JFactory::getDbo();
121
122 $q = $dbo->getQuery(true)
123 ->select('w.*')
124 ->select($dbo->qn('l.name'))
125 ->from($dbo->qn('#__vikappointments_emp_worktime', 'w'))
126 ->leftjoin($dbo->qn('#__vikappointments_employee_location', 'l') . ' ON ' . $dbo->qn('w.id_location') . ' = ' . $dbo->qn('l.id'))
127 ->where($dbo->qn('l.id') . ' > 0')
128 ->where($dbo->qn('w.id_service') . ' <= 0')
129 ->order($dbo->qn('w.id') . ' ASC');
130
131 $dbo->setQuery($q);
132 $assoc = $dbo->loadObjectList();
133 }
134
135 return $assoc;
136 }
137 }
138