PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / controllers / findreservation.php
vikappointments / admin / controllers Last commit date
analytics.php 4 years ago apiban.php 4 years ago apilog.php 4 years ago apiplugin.php 4 years ago apiuser.php 4 years ago backup.php 4 years ago calendar.php 4 years ago city.php 4 years ago closure.php 1 month ago configapp.php 4 years ago configcldays.php 2 years ago configcron.php 4 years ago configemp.php 4 years ago configsmsapi.php 4 years ago configuration.php 1 month ago conversion.php 1 year ago country.php 4 years ago coupon.php 4 years ago coupongroup.php 4 years ago cronjob.php 2 years ago cronjoblog.php 4 years ago customer.php 5 months ago customf.php 1 year ago dashboard.php 4 years ago emplocwdays.php 4 years ago employee.php 1 year ago emprates.php 4 years ago export.php 4 years ago exportres.php 4 years ago file.php 5 months ago findreservation.php 1 month ago group.php 4 years ago import.php 4 years ago index.html 4 years ago invoice.php 1 month ago langcustomf.php 4 years ago langemployee.php 4 years ago langgroup.php 4 years ago langmedia.php 4 years ago langoption.php 4 years ago langoptiongroup.php 4 years ago langpackage.php 4 years ago langpackgroup.php 4 years ago langpayment.php 4 years ago langservice.php 4 years ago langstatuscode.php 4 years ago langsubscr.php 4 years ago langtax.php 4 years ago location.php 4 years ago mailtext.php 2 years ago makerecurrence.php 1 month ago media.php 4 years ago multiorder.php 4 years ago option.php 5 months ago optiongroup.php 4 years ago package.php 2 years ago packgroup.php 4 years ago packorder.php 1 year ago payment.php 4 years ago rate.php 4 years ago reportsemp.php 4 years ago reportsser.php 4 years ago reservation.php 1 month ago restriction.php 4 years ago review.php 4 years ago service.php 1 year ago serworkday.php 5 months ago state.php 4 years ago statuscode.php 4 years ago subscription.php 4 years ago subscrorder.php 4 years ago tag.php 4 years ago tax.php 4 years ago usernote.php 4 years ago waitinglist.php 4 years ago webhook.php 4 years ago wizard.php 1 year 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