PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4
Booking for Appointments and Events Calendar – Amelia v2.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Application / Controller / Booking / Appointment / GetTimeSlotsController.php
ameliabooking / src / Application / Controller / Booking / Appointment Last commit date
AddAppointmentController.php 4 months ago AddBookingController.php 2 years ago ApproveBookingRemotelyController.php 1 year ago CancelBookingController.php 1 year ago CancelBookingRemotelyController.php 1 year ago DeleteAppointmentController.php 1 year ago DeleteBookingController.php 4 years ago DeleteBookingRemotelyController.php 10 months ago GetAppointmentBookingsController.php 6 months ago GetAppointmentController.php 5 years ago GetAppointmentsController.php 1 year ago GetIcsController.php 4 years ago GetTimeSlotsController.php 10 months ago ReassignBookingController.php 11 months ago RejectBookingRemotelyController.php 1 year ago SuccessfulBookingController.php 1 year ago UpdateAppointmentController.php 6 months ago UpdateAppointmentNoteController.php 3 months ago UpdateAppointmentStatusController.php 10 months ago UpdateAppointmentTimeController.php 1 year ago UpdateBookingStatusController.php 1 year ago
GetTimeSlotsController.php
108 lines
1 <?php
2
3 namespace AmeliaBooking\Application\Controller\Booking\Appointment;
4
5 use AmeliaBooking\Application\Commands\Booking\Appointment\GetTimeSlotsCommand;
6 use AmeliaBooking\Application\Controller\Controller;
7 use Slim\Http\Request;
8
9 /**
10 * Class GetTimeSlotsController
11 *
12 * @package AmeliaBooking\Application\Controller\Booking\Appointment
13 */
14 class GetTimeSlotsController extends Controller
15 {
16 /**
17 * Fields for calendar service that can be received from front-end
18 *
19 * @var array
20 */
21 protected $allowedFields = [
22 'serviceId',
23 'serviceDuration',
24 'weekDays',
25 'startDateTime',
26 'providerIds',
27 'extras',
28 'excludeAppointmentId',
29 'persons',
30 'group',
31 'page',
32 'monthsLoad',
33 'queryTimeZone',
34 'timeZone',
35 'allowAdminBookAtAnyTime',
36 'allowBookingIfPending',
37 'allowBookingIfNotMin',
38 'timeSlotLength',
39 'serviceDurationAsSlot',
40 'bufferTimeInSlot',
41 'structured',
42 ];
43
44 /**
45 * Instantiates the Get Time Slots command to hand it over to the Command Handler
46 *
47 * @param Request $request
48 * @param $args
49 *
50 * @return mixed
51 * @throws \RuntimeException
52 */
53 protected function instantiateCommand(Request $request, $args)
54 {
55 $command = new GetTimeSlotsCommand($args);
56
57 $params = (array)$request->getQueryParams();
58
59 if (!empty($params['extras'])) {
60 if (($arrayExtras = json_decode($params['extras'], true)) !== null) {
61 $params['extras'] = $arrayExtras;
62 } else {
63 $arrayExtras = [];
64
65 foreach (explode(',', $params['extras']) as $item) {
66 $extrasData = explode('-', $item);
67
68 $arrayExtras[] = ['id' => $extrasData[0], 'quantity' => $extrasData[1]];
69 }
70
71 $params['extras'] = $arrayExtras;
72 }
73 }
74
75 $this->setArrayParams($params);
76
77 $command->setField('serviceId', (int)$request->getQueryParam('serviceId', 0));
78 $command->setField('locationId', (int)$request->getQueryParam('locationId', 0));
79 $command->setField('locationIds', !empty($params['locationIds']) ? $params['locationIds'] : []);
80 $command->setField('serviceDuration', (int)$request->getQueryParam('serviceDuration', 0));
81 $command->setField('weekDays', (array)$request->getQueryParam('weekDays', [1, 2, 3, 4, 5, 6, 7]));
82 $command->setField('startDateTime', (string)$request->getQueryParam('startDateTime', ''));
83 $command->setField('endDateTime', (string)$request->getQueryParam('endDateTime', ''));
84 $command->setField('providerIds', !empty($params['providerIds']) ? $params['providerIds'] : []);
85 $command->setField('extras', !empty($params['extras']) ? $params['extras'] : []);
86 $command->setField('excludeAppointmentId', (int)$request->getQueryParam('excludeAppointmentId', []));
87 $command->setField('persons', (int)$request->getQueryParam('persons', 1));
88 $command->setField('group', (int)$request->getQueryParam('group', 0));
89 $command->setField('page', (string)$request->getQueryParam('page', ''));
90 $command->setField('monthsLoad', (int)$request->getQueryParam('monthsLoad', 0));
91 $command->setField('queryTimeZone', (string)$request->getQueryParam('queryTimeZone', ''));
92 $command->setField('timeZone', (string)$request->getQueryParam('timeZone', ''));
93
94 $command->setField('allowAdminBookAtAnyTime', $request->getQueryParam('allowAdminBookAtAnyTime'));
95 $command->setField('allowBookingIfPending', $request->getQueryParam('allowBookingIfPending'));
96 $command->setField('allowBookingIfNotMin', $request->getQueryParam('allowBookingIfNotMin'));
97 $command->setField('timeSlotLength', $request->getQueryParam('timeSlotLength'));
98 $command->setField('serviceDurationAsSlot', $request->getQueryParam('serviceDurationAsSlot'));
99 $command->setField('bufferTimeInSlot', $request->getQueryParam('bufferTimeInSlot'));
100 $command->setField('structured', $request->getQueryParam('structured'));
101
102 $requestBody = $request->getParsedBody();
103 $this->setCommandFields($command, $requestBody);
104
105 return $command;
106 }
107 }
108