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 / admin / controllers / findreservation.php
vikappointments / admin / controllers Last commit date
analytics.php 2 days ago apiban.php 2 days ago apilog.php 2 days ago apiplugin.php 2 days ago apiuser.php 2 days ago backup.php 2 days ago calendar.php 2 days ago city.php 2 days ago closure.php 2 days ago configapp.php 2 days ago configcldays.php 2 days ago configcron.php 2 days ago configemp.php 2 days ago configsmsapi.php 2 days ago configuration.php 2 days ago conversion.php 2 days ago country.php 2 days ago coupon.php 2 days ago coupongroup.php 2 days ago cronjob.php 2 days ago cronjoblog.php 2 days ago customer.php 2 days ago customf.php 2 days ago dashboard.php 2 days ago emplocwdays.php 2 days ago employee.php 2 days ago emprates.php 2 days ago export.php 2 days ago exportres.php 2 days ago file.php 2 days ago findreservation.php 2 days ago group.php 2 days ago import.php 2 days ago index.html 2 days ago invoice.php 2 days ago langcustomf.php 2 days ago langemployee.php 2 days ago langgroup.php 2 days ago langmedia.php 2 days ago langoption.php 2 days ago langoptiongroup.php 2 days ago langpackage.php 2 days ago langpackgroup.php 2 days ago langpayment.php 2 days ago langservice.php 2 days ago langstatuscode.php 2 days ago langsubscr.php 2 days ago langtax.php 2 days ago location.php 2 days ago mailtext.php 2 days ago makerecurrence.php 2 days ago media.php 2 days ago multiorder.php 2 days ago option.php 2 days ago optiongroup.php 2 days ago package.php 2 days ago packgroup.php 2 days ago packorder.php 2 days ago payment.php 2 days ago rate.php 2 days ago reportsemp.php 2 days ago reportsser.php 2 days ago reservation.php 2 days ago restriction.php 2 days ago review.php 2 days ago service.php 2 days ago serworkday.php 2 days ago state.php 2 days ago statuscode.php 2 days ago subscription.php 2 days ago subscrorder.php 2 days ago tag.php 2 days ago tax.php 2 days ago usernote.php 2 days ago waitinglist.php 2 days ago webhook.php 2 days ago wizard.php 2 days ago
findreservation.php
173 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 VAPLoader::import('libraries.mvc.controllers.admin');
15
16 /**
17 * VikAppointments find reservation controller.
18 *
19 * @since 1.7
20 */
21 class VikAppointmentsControllerFindreservation extends VAPControllerAdmin
22 {
23 /**
24 * Task used to access the management page of an existing record.
25 *
26 * @return boolean
27 */
28 public function edit()
29 {
30 $app = JFactory::getApplication();
31 $user = JFactory::getUser();
32
33 // check user permissions
34 if (!$user->authorise('core.edit', 'com_vikappointments') || !$user->authorise('core.access.reservations', 'com_vikappointments'))
35 {
36 // back to main list, not authorised to edit records
37 $app->enqueueMessage(JText::translate('JERROR_ALERTNOAUTHOR'), 'error');
38 $this->setRedirect('index.php?option=com_vikappointments&view=reservations');
39
40 return false;
41 }
42
43 $args = array();
44 $args['id_emp'] = $app->input->getUint('id_employee', 0);
45 $args['id_ser'] = $app->input->getUint('id_service', 0);
46
47 $args['id_res'] = $app->input->getUint('id', 0);
48 $args['people'] = $app->input->getUint('people', 1);
49 $args['day'] = $app->input->getString('checkin_ts', '');
50
51 $this->setRedirect('index.php?option=com_vikappointments&view=findreservation&' . http_build_query(array_filter($args)));
52
53 return true;
54 }
55
56 /**
57 * AJAX end-point used to fetch the availability timeline.
58 * This task expects the following arguments set in request.
59 *
60 * @param integer $id_ser The service ID.
61 * @param integer $id_emp The employee ID.
62 * @param string $daty The check-in date.
63 * @param integer $id_res The selected appointment ID.
64 * @param integer $people The number of participants.
65 *
66 * @return void
67 */
68 public function timelineajax()
69 {
70 $input = JFactory::getApplication()->input;
71
72 /**
73 * Added token validation.
74 *
75 * @since 1.7
76 */
77 if (!JSession::checkToken())
78 {
79 // missing CSRF-proof token
80 UIErrorFactory::raiseError(403, JText::translate('JINVALID_TOKEN'));
81 }
82
83 $args = array();
84 $args['id_ser'] = $input->getUint('id_ser', 0);
85 $args['id_emp'] = $input->getUint('id_emp', 0);
86 $args['date'] = $input->getString('day', '');
87 $args['id_res'] = $input->getUint('id_res', 0);
88 $args['people'] = $input->getUint('people', 1);
89
90 // get model
91 $model = $this->getModel();
92 // use model to create the timeline
93 $timeline = $model->getTimeline($args);
94
95 $result = new stdClass;
96
97 if ($timeline)
98 {
99 // create timeline response
100 $result->html = $timeline->display();
101 $result->timeline = $timeline->getTimeline();
102 }
103 else
104 {
105 // raise error message
106 $result->error = $model->getError($index = null, $string = false);
107 $result->timeline = array();
108
109 $vik = VAPApplication::getInstance();
110
111 if ($result->error instanceof Exception)
112 {
113 // exception found, use critical alert
114 $result->html = $vik->alert($result->error->getMessage(), 'error');
115 }
116 else
117 {
118 // default availability error, use warning alert
119 $result->html = $vik->alert($result->error);
120 }
121 }
122
123 // send timeline to caller
124 $this->sendJSON($result);
125 }
126
127 /**
128 * AJAX end-point used to load a list of appointments for
129 * the specified date and time.
130 *
131 * @param integer $id_emp The employee ID.
132 * @param string $date The check-in date.
133 * @param integer $hour The check-in hour.
134 * @param integer $min The check-in minute.
135 *
136 * @return void
137 */
138 public function appointmentsajax()
139 {
140 $input = JFactory::getApplication()->input;
141
142 /**
143 * Added token validation.
144 *
145 * @since 1.7
146 */
147 if (!JSession::checkToken())
148 {
149 // missing CSRF-proof token
150 UIErrorFactory::raiseError(403, JText::translate('JINVALID_TOKEN'));
151 }
152
153 $id_emp = $input->getUint('id_emp', 0);
154 $date = $input->getString('date', '');
155 $hour = $input->getUint('hour', 0);
156 $min = $input->getUint('min', 0);
157
158 // create date instance
159 $date = JFactory::getDate($date);
160 // modify time
161 $date->modify("{$hour}:{$min}:00");
162
163 // get appointments model
164 $model = $this->getModel('reservation');
165
166 // find appointments list
167 $list = $model->getAppointmentsAt($date->format('Y-m-d H:i:s'), $id_emp);
168
169 // return list to caller
170 $this->sendJSON($list);
171 }
172 }
173