PluginProbe
ShiftController Employee Shift Scheduling / 4.9.72
ShiftController Employee Shift Scheduling v4.9.72
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 / schedule / html / view / fourweeks.php

fourweeks.php in ShiftController Employee Shift Scheduling 4.9.72, at sh4/schedule/html/view/fourweeks.php

827 lines 22.4 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_Schedule_Html_View_FourWeeks
4 {
5 protected $borderColor = 'gray';
6 protected $allCombos = array();
7 protected $allCombosShift = array();
8 protected $allCombosTimeoff = array();
9 protected $nWeeks = 4;
10 protected $slimView = true;
11
12 public function __construct(
13 HC3_Hooks $hooks,
14 HC3_Ui $ui,
15 HC3_Request $request,
16 HC3_Time $t,
17 HC3_Settings $settings,
18
19 HC3_Uri $uri,
20
21 SH4_New_Acl $newAcl,
22
23 SH4_Shifts_Duration $shiftsDuration,
24 SH4_Schedule_Html_View_Week $viewWeek,
25 SH4_Schedule_Html_View_Month $viewMonth,
26 SH4_Shifts_View_Widget $widget,
27 SH4_Calendars_Presenter $calendarsPresenter,
28 SH4_Employees_Presenter $employeesPresenter,
29 SH4_Schedule_Html_View_Common $common,
30 SH4_Shifts_View_Common $shiftsCommon
31 )
32 {
33 $this->self = $hooks->wrap($this);
34
35 $this->ui = $ui;
36
37 $this->uri = $uri;
38 $this->t = $t;
39 $this->request = $request;
40
41 $this->settings = $hooks->wrap( $settings );
42 $this->newAcl = $hooks->wrap( $newAcl );
43
44 $this->viewWeek = $hooks->wrap( $viewWeek );
45 $this->viewMonth = $hooks->wrap( $viewMonth );
46 $this->shiftsDuration = $hooks->wrap( $shiftsDuration );
47 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
48 $this->employeesPresenter = $hooks->wrap( $employeesPresenter );
49
50 $this->widget = $hooks->wrap( $widget );
51 $this->common = $hooks->wrap( $common );
52 $this->shiftsCommon = $hooks->wrap( $shiftsCommon );
53
54 $this->allCombos = $this->newAcl->findAllCombos();
55 $this->allCombosShift = $this->newAcl->findAllCombosShift();
56 $this->allCombosTimeoff = $this->newAcl->findAllCombosTimeoff();
57
58 $this->nWeeks = $this->settings->get( 'datetime_n_weeks' );
59 if( ! $this->nWeeks ) $this->nWeeks = 4;
60 $this->slimView = $this->settings->get( 'datetime_month_slim_view' ) ? true : false;
61 }
62
63 public function render()
64 {
65 $slug = $this->request->getSlug();
66 $today = $this->t->setNow()->formatDateDb();
67
68 $disabledWeekdays = $this->settings->get( 'skip_weekdays', TRUE );
69
70 $shifts = $this->common->getShifts();
71
72 $params = $this->request->getParams();
73 $startDate = $params['start'];
74
75 $startDate = $this->t->setDateDb( $startDate )->setStartWeek()->formatDateDb();
76 $endDate = $this->t->modify('+' . $this->nWeeks . ' weeks')->modify('-1 day')->formatDateDb();
77
78 $this->t->setDateDb( $startDate );
79 $dates = array();
80 $rexDate = $startDate;
81 while( $rexDate <= $endDate ){
82 if( $disabledWeekdays ){
83 $wkd = $this->t->getWeekday();
84 if( in_array($wkd, $disabledWeekdays) ){
85 $rexDate = $this->t->modify('+1 day')->formatDateDb();
86 continue;
87 }
88 }
89
90 $dates[] = $rexDate;
91 $rexDate = $this->t->modify('+1 day')->formatDateDb();
92 }
93
94 $viewShifts = array();
95 $iknow = array('date');
96
97 $allCalendars = $this->common->findAllCalendars();
98 if( count($allCalendars) <= 1 ) $iknow[] = 'calendar';
99
100 $this->shiftsDuration->reset();
101 foreach( $shifts as $shift ){
102 $this->shiftsDuration->add( $shift );
103 $start = $shift->getStart();
104 $end = $shift->getEnd();
105
106 $startDayTime = substr($start, 8, 4);
107 $endDayTime = substr($end, 8, 4);
108 $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE;
109
110 $this->t->setDateTimeDb( $end )->modify('-1 second');
111 $shiftEndDate = $this->t->formatDateDb();
112
113 $this->t->setDateTimeDb( $start );
114 $shiftStartDate = $this->t->formatDateDb();
115
116 $rexDate = $shiftStartDate;
117 while( $rexDate <= $shiftEndDate ){
118 if( in_array($rexDate, $dates) ){
119 if( ! array_key_exists($rexDate, $viewShifts) ){
120 $viewShifts[$rexDate] = array();
121 }
122 $viewShifts[$rexDate][] = $shift;
123 }
124
125 if( ! $shiftAllDay ){
126 break;
127 }
128 $this->t->modify( '+1 day' );
129 $rexDate = $this->t->formatDateDb();
130 }
131 }
132
133 $this->t->setDateDb( $startDate );
134 // $monthMatrix = $this->t->getMonthMatrix( $disabledWeekdays );
135 $monthMatrix = $this->t->getWeeksMatrix( $this->nWeeks, $disabledWeekdays );
136 $rows = array();
137 foreach( $monthMatrix as $week => $days ){
138 $row = array();
139
140 foreach( $days as $date ){
141 if( ! $date ){
142 $row[] = NULL;
143 continue;
144 }
145
146 $cell = array();
147
148 $this->t->setDateDb( $date );
149 $dateView = $this->common->renderDateLabel( $date );
150
151 $cell[] = $dateView;
152
153 if( isset($viewShifts[$date]) ){
154 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$date], $iknow );
155 $cell[] = $shiftsView;
156 }
157
158 $to = 'new';
159 $toParams = array(
160 'date' => $date
161 );
162 if( array_key_exists('employee', $params) && (count($params['employee']) == 1) ){
163 if( ! in_array(-1, $params['employee']) ){
164 $toParams['employee'] = $params['employee'][0];
165 }
166 }
167
168 $links = array();
169
170 if( $this->allCombosShift ){
171 $label = '+' . ' ' . '__Shift__';
172 $thisTo = 'new/shift';
173 $thisTo = array( $thisTo, $toParams );
174 $link = $this->ui->makeAhref( $thisTo, $label )
175 ->tag('tab-link')
176 ->tag('align', 'center')
177 // ->addAttr('title', '__Add New__')
178 ;
179 if( $today > $date ){
180 $link->tag('muted', 3);
181 }
182 $links[] = $link;
183 }
184
185 if( $this->allCombosTimeoff ){
186 $label = '+' . ' ' . '__Time Off__';
187 $thisTo = 'new/timeoff';
188 $thisTo = array( $thisTo, $toParams );
189 $link = $this->ui->makeAhref( $thisTo, $label )
190 ->tag('tab-link')
191 ->tag('align', 'center')
192 // ->addAttr('title', '__Add New__')
193 ;
194 if( $today > $date ){
195 $link->tag('muted', 3);
196 }
197 $links[] = $link;
198 }
199
200 $links = $this->ui->makeList( $links )->gutter(0);
201
202 $cell[] = $links;
203
204
205 $cell = $this->ui->makeList( $cell )
206 ->gutter(1)
207 ->tag('margin', 1)
208 ;
209
210 $row[] = $cell;
211 }
212
213 $rows[] = $row;
214 }
215
216 $out = $this->ui->makeTable( NULL, $rows, FALSE )
217 ->gutter(0)
218 ->setBordered( $this->borderColor )
219 // ->setSegments( $weekSegments )
220 ;
221
222 return $out;
223 }
224
225 public function renderByCalendar()
226 {
227 $slug = $this->request->getSlug();
228 $today = $this->t->setNow()->formatDateDb();
229
230 $disabledWeekdays = $this->settings->get( 'skip_weekdays', TRUE );
231
232 $calendars = $this->common->getCalendars();
233 $employees = $this->common->getEmployees();
234 $shifts = $this->common->getShifts();
235
236 // finalize calendars to include those that employee was removed from but still have shifts in
237 $listCalendarId = array_keys( $calendars );
238 $dictCalendarId = array_combine( $listCalendarId, $listCalendarId );
239 foreach( $shifts as $shift ){
240 $calendar = $shift->getCalendar();
241 if( ! $calendar ) continue;
242 $calendarId = $calendar->getId();
243 $dictCalendarId[ $calendarId ] = $calendarId;
244 }
245 if( count($dictCalendarId) > count($calendars) ){
246 $allCalendars = $this->common->findAllCalendars();
247 $calendars = array_intersect_key( $allCalendars, $dictCalendarId );
248 }
249
250 // we can probably have archived calendars so if such calendars have no shifts then skip them
251 $removeArchivedCalendars = array();
252 foreach( $calendars as $calendar ){
253 if( $calendar->isArchived() ){
254 $removeArchivedCalendars[ $calendar->getId() ] = $calendar->getId();
255 }
256 }
257 if( $removeArchivedCalendars ){
258 foreach( $shifts as $shift ){
259 $calendar = $shift->getCalendar();
260 $id = $calendar ? $calendar->getId() : 0;
261 if( isset($removeArchivedCalendars[$id]) ){
262 unset( $removeArchivedCalendars[$id] );
263 }
264 if( ! $removeArchivedCalendars ){
265 break;
266 }
267 }
268 foreach( $removeArchivedCalendars as $id ){
269 unset( $calendars[$id] );
270 }
271 reset( $shifts );
272 }
273
274 $params = $this->request->getParams();
275 $startDate = $params['start'];
276
277 $startDate = $this->t->setDateDb( $startDate )->setStartWeek()->formatDateDb();
278 $endDate = $this->t->modify('+' . $this->nWeeks . ' weeks')->modify('-1 day')->formatDateDb();
279
280 $this->t->setDateDb( $startDate );
281 $dates = array();
282 $rexDate = $startDate;
283 while( $rexDate <= $endDate ){
284 if( $disabledWeekdays ){
285 $wkd = $this->t->getWeekday();
286 if( in_array($wkd, $disabledWeekdays) ){
287 $rexDate = $this->t->modify('+1 day')->formatDateDb();
288 continue;
289 }
290 }
291
292 $dates[] = $rexDate;
293 $rexDate = $this->t->modify('+1 day')->formatDateDb();
294 }
295
296 $viewCalendars = array();
297 foreach( $calendars as $calendar ){
298 $label = $this->calendarsPresenter->presentTitle( $calendar );
299 $title = htmlspecialchars( $calendar->getTitle() );
300 $description = $calendar->getDescription();
301 if( strlen($description) ){
302 $description = htmlspecialchars( $description );
303 $title .= "\n" . $description;
304 }
305
306 $label = $this->ui->makeSpan( $label )
307 ->addAttr( 'title', $title )
308 ;
309
310 $viewCalendars[ $calendar->getId() ] = $label;
311 }
312
313 $viewShifts = array();
314
315 $iknow = array('calendar', 'date');
316 foreach( $shifts as $shift ){
317 $calendar = $shift->getCalendar();
318 $id = $calendar ? $calendar->getId() : 0;
319
320 if( ! array_key_exists($id, $viewShifts) ){
321 $viewShifts[$id] = array();
322 }
323
324 $start = $shift->getStart();
325 $end = $shift->getEnd();
326
327 $startDayTime = substr($start, 8, 4);
328 $endDayTime = substr($end, 8, 4);
329 $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE;
330
331 $this->t->setDateTimeDb( $end )->modify('-1 second');
332 $shiftEndDate = $this->t->formatDateDb();
333
334 $this->t->setDateTimeDb( $start );
335 $shiftStartDate = $this->t->formatDateDb();
336
337 $rexDate = $shiftStartDate;
338 while( $rexDate <= $shiftEndDate ){
339 if( in_array($rexDate, $dates) ){
340 if( ! array_key_exists($rexDate, $viewShifts[$id]) ){
341 $viewShifts[$id][$rexDate] = array();
342 }
343 $viewShifts[$id][$rexDate][] = $shift;
344 }
345
346 if( ! $shiftAllDay ){
347 break;
348 }
349 $this->t->modify( '+1 day' );
350 $rexDate = $this->t->formatDateDb();
351 }
352 }
353
354 $header = array();
355 $header[] = NULL;
356
357 $weekStartsOn = $this->t->getWeekStartsOn();
358 $weekSegments = array();
359
360 $this->t->setDateDb( $startDate );
361 // $monthMatrix = $this->t->getMonthMatrix( $disabledWeekdays );
362 $monthMatrix = $this->t->getWeeksMatrix( $this->nWeeks, $disabledWeekdays );
363
364 foreach( $monthMatrix as $week => $days ){
365 $wdi = 0;
366 foreach( $days as $date ){
367 if( ! $date ){
368 continue;
369 }
370
371 $dateView = $this->common->renderDateLabelGrouped( $date );
372 $header[] = $dateView;
373
374 if( ! $wdi ){
375 $weekSegments[] = count($header);
376 }
377
378 $wdi++;
379 }
380 }
381
382 // while( count($header) < 32 ){
383 // $header[] = NULL;
384 // }
385
386 $rows = array();
387
388 // link templates to speed things up
389 $toParams = array(
390 'calendar' => '{CID}',
391 'date' => '{DATE}'
392 );
393 $thisTo = 'new';
394 $thisTo = array( $thisTo, $toParams );
395 $thisHref = $this->uri->makeUrl( $thisTo );
396
397 $linkTemplateShift = '<a title="__Add New__" class="hc-block hc-theme-tab-link hc-align-center" href="' . $thisHref . '">+</a>';
398 $linkTemplateShiftMuted = '<a title="__Add New__" class="hc-block hc-theme-tab-link hc-align-center hc-muted3" href="' . $thisHref . '">+</a>';
399 $isPrintView = $this->request->isPrintView();
400
401 foreach( $viewCalendars as $id => $calendarView ){
402 $row = array();
403
404 $this->shiftsDuration->reset();
405 if( isset($viewShifts[$id]) ){
406 foreach( $viewShifts[$id] as $date => $dateShifts ){
407 foreach( $dateShifts as $shift ){
408 $this->shiftsDuration->add( $shift );
409 }
410 }
411
412 $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE );
413 $outReport = $this->ui->makeSpan( $outReport )
414 ->tag('font-size', 2)
415 ;
416 $calendarView = $this->ui->makeList( array($calendarView, $outReport) )
417 ->gutter(1)
418 ;
419 }
420
421 $calendarView = $this->ui->makeBlock( $calendarView )
422 ->tag('padding', array('x1', 'y2'))
423 ->tag('nowrap')
424 ;
425 $row[] = $calendarView;
426
427 $countDates = count( $dates );
428 foreach( $dates as $date ){
429 $cell = array();
430
431 if( isset($viewShifts[$id][$date]) ){
432 if( ($countDates > 10) && ($this->slimView) ){
433 $shiftsView = $this->viewMonth->renderDay( $viewShifts[$id][$date], $iknow );
434 }
435 else {
436 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$id][$date], $iknow );
437 }
438 $cell[] = $shiftsView;
439 }
440
441 $label = '+';
442
443 $to = 'new';
444 $toParams = array(
445 'date' => $date,
446 'calendar' => $id,
447 );
448 if( array_key_exists('employee', $params) && (count($params['employee']) == 1) ){
449 if( ! in_array(-1, $params['employee']) ){
450 $toParams['employee'] = $params['employee'][0];
451 }
452 }
453 $to = array( $to, $toParams );
454
455 $addOk = FALSE;
456 if( isset($toParams['employee']) ){
457 $testComboId = $id . '-' . $toParams['employee'];
458 if( isset($this->allCombos[$testComboId]) ){
459 $addOk = TRUE;
460 }
461 }
462 else {
463 $testComboId = $id . '-';
464 reset( $this->allCombos );
465 foreach( $this->allCombos as $comboId ){
466 if( $testComboId == substr($comboId, 0, strlen($testComboId)) ){
467 $addOk = TRUE;
468 break;
469 }
470 }
471 }
472
473 if( $isPrintView ) $addOk = false;
474
475 if( $addOk ){
476 /*
477 $link = $this->ui->makeAhref( $to, $label )
478 ->tag('tab-link')
479 ->tag('align', 'center')
480 ->addAttr('title', '__Add New__')
481 ;
482
483 if( $today > $date ){
484 $link->tag('muted', 3);
485 }
486 */
487 if( $today > $date ){
488 $link = str_replace( array('{CID}', '{DATE}'), array($id, $date), $linkTemplateShiftMuted );
489 }
490 else {
491 $link = str_replace( array('{CID}', '{DATE}'), array($id, $date), $linkTemplateShift );
492 }
493
494 $cell[] = $link;
495 }
496
497 $cell = $this->ui->makeList( $cell )
498 ->gutter(1)
499 ->tag('margin', '05')
500 ;
501
502 $row[] = $cell;
503 }
504
505 // while( count($row) < 32 ){
506 // $row[] = NULL;
507 // }
508 $rows[] = $row;
509 }
510
511 $out = $this->ui->makeTable( $header, $rows, FALSE )
512 ->gutter(0)
513 ->setBordered( $this->borderColor )
514 ->setSegments( $weekSegments )
515 ->setLabelled( TRUE )
516 ;
517
518 if( ! $this->slimView ){
519 $out->forceColWidth( '6rem' );
520 $out->forceRowHeaderWidth( '10rem' );
521 }
522
523 return $out;
524 }
525
526 public function renderByEmployee()
527 {
528 $slug = $this->request->getSlug();
529 $today = $this->t->setNow()->formatDateDb();
530
531 $disabledWeekdays = $this->settings->get( 'skip_weekdays', TRUE );
532
533 $calendars = $this->common->getCalendars();
534 $employees = $this->common->getEmployees();
535 $shifts = $this->common->getShifts();
536
537 // finalize employees to include those that employee was removed from but still have shifts in
538 $listEmployeeId = array_keys( $employees );
539 $dictEmployeeId = array_combine( $listEmployeeId, $listEmployeeId );
540 foreach( $shifts as $shift ){
541 $employee = $shift->getEmployee();
542 if( ! $employee ) continue;
543 $employeeId = $employee->getId();
544 $dictEmployeeId[ $employeeId ] = $employeeId;
545 }
546 if( count($dictEmployeeId) > count($employees) ){
547 $allEmployees = $this->common->findAllEmployees();
548 $employees = array_intersect_key( $allEmployees, $dictEmployeeId );
549 }
550
551 // we can probably have archived employees so if such employees have no shifts then skip them
552 $removeArchivedEmployees = array();
553 foreach( $employees as $employee ){
554 if( $employee->isArchived() ){
555 $removeArchivedEmployees[ $employee->getId() ] = $employee->getId();
556 }
557 }
558 if( $removeArchivedEmployees ){
559 foreach( $shifts as $shift ){
560 $employee = $shift->getEmployee();
561 $id = $employee ? $employee->getId() : 0;
562 if( isset($removeArchivedEmployees[$id]) ){
563 unset( $removeArchivedEmployees[$id] );
564 }
565 if( ! $removeArchivedEmployees ){
566 break;
567 }
568 }
569 foreach( $removeArchivedEmployees as $id ){
570 unset( $employees[$id] );
571 }
572 reset( $shifts );
573 }
574
575 $params = $this->request->getParams();
576 $startDate = $params['start'];
577
578 $startDate = $this->t->setDateDb( $startDate )->setStartWeek()->formatDateDb();
579 $endDate = $this->t->modify('+' . $this->nWeeks . ' weeks')->modify('-1 day')->formatDateDb();
580
581 $this->t->setDateDb( $startDate );
582 $dates = array();
583 $rexDate = $startDate;
584 while( $rexDate <= $endDate ){
585 if( $disabledWeekdays ){
586 $wkd = $this->t->getWeekday();
587 if( in_array($wkd, $disabledWeekdays) ){
588 $rexDate = $this->t->modify('+1 day')->formatDateDb();
589 continue;
590 }
591 }
592
593 $dates[] = $rexDate;
594 $rexDate = $this->t->modify('+1 day')->formatDateDb();
595 }
596
597 $viewEmployees = array();
598 foreach( $employees as $employee ){
599 $label = $this->employeesPresenter->presentTitle( $employee );
600 $title = htmlspecialchars( $label );
601
602 $description = $employee->getDescription();
603 if( strlen($description) ){
604 $imgpos = strpos( $description, '<img' );
605 if( false !== $imgpos ){
606 $label = $this->ui->makeList( array($label, $description) );
607 }
608 else {
609 $title .= "\n" . htmlspecialchars( $description );
610 }
611 }
612
613 $label = $this->ui->makeSpan( $label )
614 ->tag( 'font-size', 4 )
615 ->addAttr( 'title', $title )
616 ;
617
618 $viewEmployees[ $employee->getId() ] = $label;
619 }
620
621 $viewShifts = array();
622
623 $iknow = array('employee', 'date');
624
625 $allCalendars = $this->common->findAllCalendars();
626 if( count($allCalendars) <= 1 ) $iknow[] = 'calendar';
627
628 foreach( $shifts as $shift ){
629 $employee = $shift->getEmployee();
630 $id = $employee ? $employee->getId() : 0;
631
632 if( ! array_key_exists($id, $viewShifts) ){
633 $viewShifts[$id] = array();
634 }
635
636 $start = $shift->getStart();
637 $end = $shift->getEnd();
638
639 $startDayTime = substr($start, 8, 4);
640 $endDayTime = substr($end, 8, 4);
641 $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE;
642
643 $this->t->setDateTimeDb( $end )->modify('-1 second');
644 $shiftEndDate = $this->t->formatDateDb();
645
646 $this->t->setDateTimeDb( $start );
647 $shiftStartDate = $this->t->formatDateDb();
648
649 $rexDate = $shiftStartDate;
650 while( $rexDate <= $shiftEndDate ){
651 if( in_array($rexDate, $dates) ){
652 if( ! array_key_exists($rexDate, $viewShifts[$id]) ){
653 $viewShifts[$id][$rexDate] = array();
654 }
655 $viewShifts[$id][$rexDate][] = $shift;
656 }
657
658 if( ! $shiftAllDay ){
659 break;
660 }
661 $this->t->modify( '+1 day' );
662 $rexDate = $this->t->formatDateDb();
663 }
664 }
665
666 $header = array();
667 $header[] = NULL;
668
669 $weekStartsOn = $this->t->getWeekStartsOn();
670 $weekSegments = array();
671
672 $this->t->setDateDb( $startDate );
673 // $monthMatrix = $this->t->getMonthMatrix( $disabledWeekdays );
674 $monthMatrix = $this->t->getWeeksMatrix( $this->nWeeks, $disabledWeekdays );
675
676 foreach( $monthMatrix as $week => $days ){
677 $wdi = 0;
678 foreach( $days as $date ){
679 if( ! $date ){
680 continue;
681 }
682 $this->t->setDateDb( $date );
683
684 $dateView = $this->common->renderDateLabelGrouped( $date );
685 $header[] = $dateView;
686
687 if( ! $wdi ){
688 $weekSegments[] = count($header);
689 }
690
691 $wdi++;
692 }
693 }
694
695 // while( count($header) < 32 ){
696 // $header[] = NULL;
697 // }
698
699 $rows = array();
700
701 // link templates to speed things up
702 $toParams = array(
703 'employee' => '{EID}',
704 'date' => '{DATE}'
705 );
706 $thisTo = 'new';
707 $thisTo = array( $thisTo, $toParams );
708 $thisHref = $this->uri->makeUrl( $thisTo );
709
710 $linkTemplateShift = '<a title="__Add New__" class="hc-block hc-theme-tab-link hc-align-center" href="' . $thisHref . '">+</a>';
711 $linkTemplateShiftMuted = '<a title="__Add New__" class="hc-block hc-theme-tab-link hc-align-center hc-muted3" href="' . $thisHref . '">+</a>';
712 $isPrintView = $this->request->isPrintView();
713
714 foreach( $viewEmployees as $id => $employeeView ){
715 $row = array();
716
717 $this->shiftsDuration->reset();
718 if( isset($viewShifts[$id]) ){
719 $counted = 0;
720 foreach( $viewShifts[$id] as $date => $dateShifts ){
721 foreach( $dateShifts as $shift ){
722 $shiftCalendar = $shift->getCalendar();
723 // if( $shiftCalendar->isTimeoff() ){
724 // continue;
725 // }
726 $this->shiftsDuration->add( $shift );
727 $counted++;
728 }
729 }
730
731 if( $counted ){
732 $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE );
733 $outReport = $this->ui->makeSpan( $outReport )
734 ->tag('font-size', 2)
735 ;
736 $employeeView = $this->ui->makeList( array($employeeView, $outReport) )
737 ->gutter(1)
738 ;
739 }
740 }
741
742 $thisShifts = isset($viewShifts[$id]) ? $viewShifts[$id] : array();
743 $employeeView = $this->common->employeeRowLabel( $employeeView, $id, '4weeks', $dates, $thisShifts );
744
745 $employeeView = $this->ui->makeBlock( $employeeView )
746 ->tag('padding', array('x1', 'y2'))
747 ->tag('nowrap')
748 ;
749 $row[] = $employeeView;
750
751 $countDates = count( $dates );
752 foreach( $dates as $date ){
753 $cell = array();
754
755 if( isset($viewShifts[$id][$date]) ){
756 if( ($countDates > 10) && ($this->slimView) ){
757 $shiftsView = $this->viewMonth->renderDay( $viewShifts[$id][$date], $iknow );
758 }
759 else {
760 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$id][$date], $iknow );
761 }
762 $cell[] = $shiftsView;
763 }
764
765 $comboId = 0 . '-' . $id;
766 if( isset($this->allCombos[$comboId]) ){
767 /*
768 $label = '+';
769
770 $to = 'new';
771 $toParams = array(
772 'date' => $date,
773 'employee' => $id,
774 );
775 $to = array( $to, $toParams );
776
777 $link = $this->ui->makeAhref( $to, $label )
778 ->tag('tab-link')
779 ->tag('align', 'center')
780 ->addAttr('title', '__Add New__')
781 ;
782
783 if( $today > $date ){
784 $link->tag('muted', 3);
785 }
786 */
787 if( $today > $date ){
788 $link = str_replace( array('{EID}', '{DATE}'), array($id, $date), $linkTemplateShiftMuted );
789 }
790 else {
791 $link = str_replace( array('{EID}', '{DATE}'), array($id, $date), $linkTemplateShift );
792 }
793
794 if( ! $isPrintView ){
795 $cell[] = $link;
796 }
797 }
798
799 $cell = $this->ui->makeList( $cell )
800 ->gutter(1)
801 ->tag('margin', '05')
802 ;
803
804 $row[] = $cell;
805 }
806
807 // while( count($row) < 32 ){
808 // $row[] = NULL;
809 // }
810 $rows[] = $row;
811 }
812
813 $out = $this->ui->makeTable( $header, $rows, FALSE )
814 ->gutter(0)
815 ->setBordered( $this->borderColor )
816 ->setSegments( $weekSegments )
817 ->setLabelled( TRUE )
818 ;
819
820 if( ! $this->slimView ){
821 $out->forceColWidth( '6rem' );
822 $out->forceRowHeaderWidth( '10rem' );
823 }
824
825 return $out;
826 }
827 }