PluginProbe
ShiftController Employee Shift Scheduling / 4.9.95
ShiftController Employee Shift Scheduling v4.9.95
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / sh4 / shifts / view / calendar.php

calendar.php in ShiftController Employee Shift Scheduling 4.9.95, at sh4/shifts/view/calendar.php

193 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 #[AllowDynamicProperties]
3 class SH4_Shifts_View_Calendar
4 {
5 public function __construct(
6 HC3_Hooks $hooks,
7 HC3_Auth $auth,
8 HC3_IPermission $permission,
9
10 HC3_Ui $ui,
11 HC3_Ui_Layout1 $layout,
12
13 SH4_Shifts_View_Common $common,
14 SH4_Shifts_Query $shiftsQuery,
15
16 SH4_Calendars_Presenter $calendarsPresenter,
17 SH4_Employees_Query $employees,
18 SH4_App_Query $appQuery,
19
20 SH4_Shifts_Availability $availability,
21 SH4_Shifts_Conflicts $conflicts,
22 SH4_Shifts_View_Zoom $viewZoom
23 )
24 {
25 $this->self = $hooks->wrap( $this );
26 $this->ui = $ui;
27 $this->layout = $layout;
28
29 $this->auth = $hooks->wrap( $auth );
30 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
31 $this->shiftsQuery = $hooks->wrap( $shiftsQuery );
32 $this->common = $hooks->wrap( $common );
33
34 $this->employees = $hooks->wrap($employees);
35 $this->appQuery = $hooks->wrap( $appQuery );
36 $this->conflicts = $hooks->wrap($conflicts);
37 $this->permission = $hooks->wrap( $permission );
38 }
39
40 public function render( $shiftId )
41 {
42 $model = $this->shiftsQuery->findById( $shiftId );
43
44 $employee = $model->getEmployee();
45 $employeeId = $employee->getId();
46
47 $calendar = $model->getCalendar();
48 $calendarId = $calendar->getId();
49
50 $calendars = $this->appQuery->findCalendarsForChange( $model );
51
52 $currentUser = $this->auth->getCurrentUser();
53 if (!$this->permission->isAdmin($currentUser)) {
54 $calendarsAsManager = $this->appQuery->findCalendarsManagedByUser($currentUser);
55 $calendars = array_intersect_key($calendars, $calendarsAsManager);
56 }
57
58 $calendarsView = array();
59 $calendarsWithConflictsView = array();
60
61 foreach( $calendars as $calendar ){
62 $thisCalendarId = $calendar->getId();
63
64 $withConflicts = 0;
65
66 $id = $model->getId();
67 $start = $model->getStart();
68 $end = $model->getEnd();
69
70 $testModel = new SH4_Shifts_Model( $shiftId, $calendar, $start, $end, $employee );
71
72 $conflicts = $this->conflicts->get($testModel);
73 if( $conflicts ){
74 $withConflicts++;
75 }
76
77 $thisView = array();
78 $calendarView = $this->calendarsPresenter->presentTitle( $calendar );
79 $calendarView = $this->ui->makeSpan( $calendarView )
80 ->tag('font-size', 4)
81 ->tag('font-style', 'bold')
82 ;
83
84 $descriptionView = $calendar->getDescription();
85 if( strlen($descriptionView) ){
86 $descriptionView = $this->ui->makeLongText( $descriptionView );
87 $calendarView = $this->ui->makeList( array($calendarView, $descriptionView) )
88 ->gutter(1)
89 ;
90 }
91
92 $thisView[] = $calendarView;
93
94 $conflictsView = array();
95
96 if( $withConflicts ){
97 $sign = '&nbsp;!&nbsp;';
98 $sign = $this->ui->makeBlock( $sign )
99 ->tag('padding', 'x1')
100 ->tag('color', 'white')
101 ->tag('bgcolor', 'maroon')
102 ->addAttr( 'title', '__Conflicts__' )
103 ;
104
105 $conflictsLink = array('conflicts', $shiftId, $thisCalendarId, $start, $end, $employeeId );
106 $conflictsLink = join('/', $conflictsLink);
107
108 $sign = $this->ui->makeAhref( $conflictsLink, $sign )
109 ->newWindow()
110 ;
111
112 $conflictsView[] = $sign;
113 }
114
115 $conflictsView = $this->ui->makeListInline( $conflictsView )
116 ->gutter(1)
117 ;
118 $thisView[] = $conflictsView;
119
120 $thisView = $this->ui->makeBlock( $this->ui->makeListInline($thisView) )
121 ->addAttr('style', 'position: relative;')
122 ;
123
124 $btn = $this->ui->makeInputSubmit('__Select__')
125 ->tag('secondary')
126 ;
127 if( $withConflicts ){
128 $btn
129 ->tag('confirm')
130 ;
131 }
132
133 $to = array( 'shifts', $shiftId, 'calendar', $thisCalendarId );
134 $to = join('/', $to);
135
136 $form = $this->ui->makeForm( $to, $btn );
137
138 $thisView = $this->ui->makeList( array($thisView, $form) )->gutter(2);
139
140 $thisView = $this->ui->makeBlock( $thisView )
141 ->tag('border')
142 ->tag('padding', 2)
143 ;
144
145 if( $withConflicts ){
146 $thisView
147 ->tag('border-color', 'darkred')
148 ;
149 }
150 else {
151 $thisView
152 ->tag('border-color', 'green')
153 ;
154 }
155
156 $calendarsView[] = $thisView;
157 }
158
159 if( $calendarsView OR $calendarsWithConflictsView ){
160
161 $out = $this->ui->makeGrid();
162 foreach( $calendarsView as $ev ){
163 $out->add( $ev, 3, 12 );
164 }
165 }
166 else {
167 $out = array();
168 $out[] = '__No Available Calendars__';
169 $out = $this->ui->makeList( $out );
170 }
171
172 $this->layout
173 ->setContent( $out )
174 ->setHeader( $this->self->header($model) )
175 ;
176
177 $breadcrumb = $this->common->breadcrumb($model);
178 $breadcrumbMultiline = FALSE;
179
180 $this->layout
181 ->setBreadcrumb( $breadcrumb, $breadcrumbMultiline )
182 ;
183
184 $out = $this->layout->render();
185 return $out;
186 }
187
188 public function header( SH4_Shifts_Model $model )
189 {
190 $out = '__Change Calendar__';
191 return $out;
192 }
193 }