Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
29 / 29 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
AppointmentFormButtons | |
100.00% |
29 / 29 |
|
100.00% |
2 / 2 |
6 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
26 / 26 |
|
100.00% |
1 / 1 |
4 | |||
isNewAppointment | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * @package Zmsadmin |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsadmin; |
9 | |
10 | class AppointmentFormButtons extends BaseController |
11 | { |
12 | /** |
13 | * @SuppressWarnings(Param) |
14 | * @return String |
15 | */ |
16 | public function readResponse( |
17 | \Psr\Http\Message\RequestInterface $request, |
18 | \Psr\Http\Message\ResponseInterface $response, |
19 | array $args |
20 | ) { |
21 | $workstation = \App::$http->readGetResult('/workstation/', [ |
22 | 'resolveReferences' => 2, |
23 | 'gql' => Helper\GraphDefaults::getWorkstation() |
24 | ])->getEntity(); |
25 | $validator = $request->getAttribute('validator'); |
26 | $selectedDate = $validator->getParameter('selecteddate')->isString()->getValue(); |
27 | $selectedTime = $validator->getParameter('selectedtime')->isString()->getValue(); |
28 | $selectedProcessId = $validator->getParameter('selectedprocess')->isNumber()->getValue(); |
29 | $selectedProcess = ($selectedProcessId) ? |
30 | \App::$http->readGetResult('/process/' . $selectedProcessId . '/')->getEntity() : null; |
31 | |
32 | $isNewAppointment = $this->isNewAppointment( |
33 | $selectedProcess, |
34 | $selectedDate, |
35 | str_replace('-', ':', $selectedTime) |
36 | ); |
37 | |
38 | return \BO\Slim\Render::withHtml( |
39 | $response, |
40 | 'block/appointment/formButtons.twig', |
41 | array( |
42 | 'workstation' => $workstation, |
43 | 'selectedProcess' => $selectedProcess, |
44 | 'selectedTime' => $selectedTime = ($selectedTime) ? $selectedTime : '00-00', |
45 | 'selectedDate' => ($selectedDate) ? $selectedDate : \App::$now->format('Y-m-d'), |
46 | 'isNewAppointment' => $isNewAppointment |
47 | ) |
48 | ); |
49 | } |
50 | |
51 | protected function isNewAppointment($process, $selectedDate, $selectedTime) |
52 | { |
53 | $selectedAppointment = new \BO\Zmsentities\Appointment(); |
54 | $selectedAppointment->setTime($selectedDate . ' ' . $selectedTime); |
55 | return ($process) ? ($process->getFirstAppointment()->date != $selectedAppointment->date) : false; |
56 | } |
57 | } |