|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JhFlexiTime\Controller; |
|
4
|
|
|
|
|
5
|
|
|
use JhFlexiTime\Repository\UserSettingsRepositoryInterface; |
|
6
|
|
|
use JhFlexiTime\Service\BookingService; |
|
7
|
|
|
use JhFlexiTime\Service\TimeCalculatorService; |
|
8
|
|
|
use JhFlexiTime\Validator\UniqueBooking; |
|
9
|
|
|
use Zend\Form\FormInterface; |
|
10
|
|
|
use Zend\Mvc\Controller\AbstractActionController; |
|
11
|
|
|
use Zend\View\Model\ViewModel; |
|
12
|
|
|
use Zend\Validator\Date as DateValidator; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class BookingController |
|
16
|
|
|
* @package JhFlexiTime\Controller |
|
17
|
|
|
* @author Aydin Hassan <[email protected]>s |
|
18
|
|
|
*/ |
|
19
|
|
|
class BookingController extends AbstractActionController |
|
20
|
|
|
{ |
|
21
|
|
|
use GetSetDateTrait; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var \JhFlexiTime\Form\BookingForm |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $bookingForm; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var \JhFlexiTime\Service\BookingService |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $bookingService; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var \JhFlexiTime\Service\TimeCalculatorService |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $timeCalculatorService; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var UserSettingsRepositoryInterface |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $userSettingsRepository; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param BookingService $bookingService |
|
45
|
|
|
* @param TimeCalculatorService $timeCalculatorService |
|
46
|
|
|
* @param FormInterface $bookingForm |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct( |
|
49
|
|
|
BookingService $bookingService, |
|
50
|
|
|
TimeCalculatorService $timeCalculatorService, |
|
51
|
|
|
FormInterface $bookingForm, |
|
52
|
|
|
UserSettingsRepositoryInterface $userSettingsRepository |
|
53
|
|
|
) { |
|
54
|
|
|
$this->bookingService = $bookingService; |
|
55
|
|
|
$this->bookingForm = $bookingForm; |
|
|
|
|
|
|
56
|
|
|
$this->timeCalculatorService = $timeCalculatorService; |
|
57
|
|
|
$this->userSettingsRepository = $userSettingsRepository; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @return ViewModel |
|
62
|
|
|
*/ |
|
63
|
|
|
public function listAction() |
|
64
|
|
|
{ |
|
65
|
|
|
|
|
66
|
|
|
$month = (string) $this->params()->fromQuery('m'); |
|
67
|
|
|
$year = (string) $this->params()->fromQuery('y'); |
|
68
|
|
|
$period = $this->getDate($month, $year); |
|
69
|
|
|
|
|
70
|
|
|
$user = $this->zfcUserAuthentication()->getIdentity(); |
|
|
|
|
|
|
71
|
|
|
$userSettings = $this->userSettingsRepository->findOneByUser($user); |
|
72
|
|
|
$records = $this->bookingService->getUserBookingsForMonth($user, $period); |
|
73
|
|
|
$pagination = $this->bookingService->getPagination($period); |
|
74
|
|
|
$totals = $this->timeCalculatorService->getTotals($user, $userSettings->getFlexStartDate(), $period); |
|
75
|
|
|
|
|
76
|
|
|
return new ViewModel([ |
|
77
|
|
|
'bookings' => [ |
|
78
|
|
|
'records' => $records, |
|
79
|
|
|
'totals' => $totals, |
|
80
|
|
|
'user' => $user, |
|
81
|
|
|
], |
|
82
|
|
|
'pagination' => $pagination, |
|
83
|
|
|
'date' => $period, |
|
84
|
|
|
'today' => new \DateTime("today"), |
|
85
|
|
|
'form' => $this->bookingForm, |
|
86
|
|
|
]); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.