PluginProbe
ShiftController Employee Shift Scheduling / 4.9.67
ShiftController Employee Shift Scheduling v4.9.67
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.67, at sh4/schedule/html/view/fourweeks.php

779 lines 20.8 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 foreach( $viewCalendars as $id => $calendarView ){
388 $row = array();
389
390 $this->shiftsDuration->reset();
391 if( isset($viewShifts[$id]) ){
392 foreach( $viewShifts[$id] as $date => $dateShifts ){
393 foreach( $dateShifts as $shift ){
394 $this->shiftsDuration->add( $shift );
395 }
396 }
397
398 $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE );
399 $outReport = $this->ui->makeSpan( $outReport )
400 ->tag('font-size', 2)
401 ;
402 $calendarView = $this->ui->makeList( array($calendarView, $outReport) )
403 ->gutter(1)
404 ;
405 }
406
407 $calendarView = $this->ui->makeBlock( $calendarView )
408 ->tag('padding', array('x1', 'y2'))
409 ->tag('nowrap')
410 ;
411 $row[] = $calendarView;
412
413 $countDates = count( $dates );
414 foreach( $dates as $date ){
415 $cell = array();
416
417 if( isset($viewShifts[$id][$date]) ){
418 if( ($countDates > 10) && ($this->slimView) ){
419 $shiftsView = $this->viewMonth->renderDay( $viewShifts[$id][$date], $iknow );
420 }
421 else {
422 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$id][$date], $iknow );
423 }
424 $cell[] = $shiftsView;
425 }
426
427 $label = '+';
428
429 $to = 'new';
430 $toParams = array(
431 'date' => $date,
432 'calendar' => $id,
433 );
434 if( array_key_exists('employee', $params) && (count($params['employee']) == 1) ){
435 if( ! in_array(-1, $params['employee']) ){
436 $toParams['employee'] = $params['employee'][0];
437 }
438 }
439 $to = array( $to, $toParams );
440
441 $addOk = FALSE;
442 if( isset($toParams['employee']) ){
443 $testComboId = $id . '-' . $toParams['employee'];
444 if( isset($this->allCombos[$testComboId]) ){
445 $addOk = TRUE;
446 }
447 }
448 else {
449 $testComboId = $id . '-';
450 reset( $this->allCombos );
451 foreach( $this->allCombos as $comboId ){
452 if( $testComboId == substr($comboId, 0, strlen($testComboId)) ){
453 $addOk = TRUE;
454 break;
455 }
456 }
457 }
458
459 if( $addOk ){
460 $link = $this->ui->makeAhref( $to, $label )
461 ->tag('tab-link')
462 ->tag('align', 'center')
463 ->addAttr('title', '__Add New__')
464 ;
465
466 if( $today > $date ){
467 $link->tag('muted', 3);
468 }
469
470 $cell[] = $link;
471 }
472
473 $cell = $this->ui->makeList( $cell )
474 ->gutter(1)
475 ->tag('margin', '05')
476 ;
477
478 $row[] = $cell;
479 }
480
481 // while( count($row) < 32 ){
482 // $row[] = NULL;
483 // }
484 $rows[] = $row;
485 }
486
487 $out = $this->ui->makeTable( $header, $rows, FALSE )
488 ->gutter(0)
489 ->setBordered( $this->borderColor )
490 ->setSegments( $weekSegments )
491 ->setLabelled( TRUE )
492 ;
493
494 if( ! $this->slimView ){
495 $out->forceColWidth( '6rem' );
496 $out->forceRowHeaderWidth( '10rem' );
497 }
498
499 return $out;
500 }
501
502 public function renderByEmployee()
503 {
504 $slug = $this->request->getSlug();
505 $today = $this->t->setNow()->formatDateDb();
506
507 $disabledWeekdays = $this->settings->get( 'skip_weekdays', TRUE );
508
509 $calendars = $this->common->getCalendars();
510 $employees = $this->common->getEmployees();
511 $shifts = $this->common->getShifts();
512
513 // finalize employees to include those that employee was removed from but still have shifts in
514 $listEmployeeId = array_keys( $employees );
515 $dictEmployeeId = array_combine( $listEmployeeId, $listEmployeeId );
516 foreach( $shifts as $shift ){
517 $employee = $shift->getEmployee();
518 if( ! $employee ) continue;
519 $employeeId = $employee->getId();
520 $dictEmployeeId[ $employeeId ] = $employeeId;
521 }
522 if( count($dictEmployeeId) > count($employees) ){
523 $allEmployees = $this->common->findAllEmployees();
524 $employees = array_intersect_key( $allEmployees, $dictEmployeeId );
525 }
526
527 // we can probably have archived employees so if such employees have no shifts then skip them
528 $removeArchivedEmployees = array();
529 foreach( $employees as $employee ){
530 if( $employee->isArchived() ){
531 $removeArchivedEmployees[ $employee->getId() ] = $employee->getId();
532 }
533 }
534 if( $removeArchivedEmployees ){
535 foreach( $shifts as $shift ){
536 $employee = $shift->getEmployee();
537 $id = $employee ? $employee->getId() : 0;
538 if( isset($removeArchivedEmployees[$id]) ){
539 unset( $removeArchivedEmployees[$id] );
540 }
541 if( ! $removeArchivedEmployees ){
542 break;
543 }
544 }
545 foreach( $removeArchivedEmployees as $id ){
546 unset( $employees[$id] );
547 }
548 reset( $shifts );
549 }
550
551 $params = $this->request->getParams();
552 $startDate = $params['start'];
553
554 $startDate = $this->t->setDateDb( $startDate )->setStartWeek()->formatDateDb();
555 $endDate = $this->t->modify('+' . $this->nWeeks . ' weeks')->modify('-1 day')->formatDateDb();
556
557 $this->t->setDateDb( $startDate );
558 $dates = array();
559 $rexDate = $startDate;
560 while( $rexDate <= $endDate ){
561 if( $disabledWeekdays ){
562 $wkd = $this->t->getWeekday();
563 if( in_array($wkd, $disabledWeekdays) ){
564 $rexDate = $this->t->modify('+1 day')->formatDateDb();
565 continue;
566 }
567 }
568
569 $dates[] = $rexDate;
570 $rexDate = $this->t->modify('+1 day')->formatDateDb();
571 }
572
573 $viewEmployees = array();
574 foreach( $employees as $employee ){
575 $label = $this->employeesPresenter->presentTitle( $employee );
576 $title = htmlspecialchars( $label );
577
578 $description = $employee->getDescription();
579 if( strlen($description) ){
580 $imgpos = strpos( $description, '<img' );
581 if( false !== $imgpos ){
582 $label = $this->ui->makeList( array($label, $description) );
583 }
584 else {
585 $title .= "\n" . htmlspecialchars( $description );
586 }
587 }
588
589 $label = $this->ui->makeSpan( $label )
590 ->tag( 'font-size', 4 )
591 ->addAttr( 'title', $title )
592 ;
593
594 $viewEmployees[ $employee->getId() ] = $label;
595 }
596
597 $viewShifts = array();
598
599 $iknow = array('employee', 'date');
600
601 $allCalendars = $this->common->findAllCalendars();
602 if( count($allCalendars) <= 1 ) $iknow[] = 'calendar';
603
604 foreach( $shifts as $shift ){
605 $employee = $shift->getEmployee();
606 $id = $employee ? $employee->getId() : 0;
607
608 if( ! array_key_exists($id, $viewShifts) ){
609 $viewShifts[$id] = array();
610 }
611
612 $start = $shift->getStart();
613 $end = $shift->getEnd();
614
615 $startDayTime = substr($start, 8, 4);
616 $endDayTime = substr($end, 8, 4);
617 $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE;
618
619 $this->t->setDateTimeDb( $end )->modify('-1 second');
620 $shiftEndDate = $this->t->formatDateDb();
621
622 $this->t->setDateTimeDb( $start );
623 $shiftStartDate = $this->t->formatDateDb();
624
625 $rexDate = $shiftStartDate;
626 while( $rexDate <= $shiftEndDate ){
627 if( in_array($rexDate, $dates) ){
628 if( ! array_key_exists($rexDate, $viewShifts[$id]) ){
629 $viewShifts[$id][$rexDate] = array();
630 }
631 $viewShifts[$id][$rexDate][] = $shift;
632 }
633
634 if( ! $shiftAllDay ){
635 break;
636 }
637 $this->t->modify( '+1 day' );
638 $rexDate = $this->t->formatDateDb();
639 }
640 }
641
642 $header = array();
643 $header[] = NULL;
644
645 $weekStartsOn = $this->t->getWeekStartsOn();
646 $weekSegments = array();
647
648 $this->t->setDateDb( $startDate );
649 // $monthMatrix = $this->t->getMonthMatrix( $disabledWeekdays );
650 $monthMatrix = $this->t->getWeeksMatrix( $this->nWeeks, $disabledWeekdays );
651
652 foreach( $monthMatrix as $week => $days ){
653 $wdi = 0;
654 foreach( $days as $date ){
655 if( ! $date ){
656 continue;
657 }
658 $this->t->setDateDb( $date );
659
660 $dateView = $this->common->renderDateLabelGrouped( $date );
661 $header[] = $dateView;
662
663 if( ! $wdi ){
664 $weekSegments[] = count($header);
665 }
666
667 $wdi++;
668 }
669 }
670
671 // while( count($header) < 32 ){
672 // $header[] = NULL;
673 // }
674
675 $rows = array();
676 foreach( $viewEmployees as $id => $employeeView ){
677 $row = array();
678
679 $this->shiftsDuration->reset();
680 if( isset($viewShifts[$id]) ){
681 $counted = 0;
682 foreach( $viewShifts[$id] as $date => $dateShifts ){
683 foreach( $dateShifts as $shift ){
684 $shiftCalendar = $shift->getCalendar();
685 // if( $shiftCalendar->isTimeoff() ){
686 // continue;
687 // }
688 $this->shiftsDuration->add( $shift );
689 $counted++;
690 }
691 }
692
693 if( $counted ){
694 $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE );
695 $outReport = $this->ui->makeSpan( $outReport )
696 ->tag('font-size', 2)
697 ;
698 $employeeView = $this->ui->makeList( array($employeeView, $outReport) )
699 ->gutter(1)
700 ;
701 }
702 }
703
704 $thisShifts = isset($viewShifts[$id]) ? $viewShifts[$id] : array();
705 $employeeView = $this->common->employeeRowLabel( $employeeView, $id, '4weeks', $dates, $thisShifts );
706
707 $employeeView = $this->ui->makeBlock( $employeeView )
708 ->tag('padding', array('x1', 'y2'))
709 ->tag('nowrap')
710 ;
711 $row[] = $employeeView;
712
713 $countDates = count( $dates );
714 foreach( $dates as $date ){
715 $cell = array();
716
717 if( isset($viewShifts[$id][$date]) ){
718 if( ($countDates > 10) && ($this->slimView) ){
719 $shiftsView = $this->viewMonth->renderDay( $viewShifts[$id][$date], $iknow );
720 }
721 else {
722 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$id][$date], $iknow );
723 }
724 $cell[] = $shiftsView;
725 }
726
727 $comboId = 0 . '-' . $id;
728 if( isset($this->allCombos[$comboId]) ){
729 $label = '+';
730
731 $to = 'new';
732 $toParams = array(
733 'date' => $date,
734 'employee' => $id,
735 );
736 $to = array( $to, $toParams );
737
738 $link = $this->ui->makeAhref( $to, $label )
739 ->tag('tab-link')
740 ->tag('align', 'center')
741 ->addAttr('title', '__Add New__')
742 ;
743
744 if( $today > $date ){
745 $link->tag('muted', 3);
746 }
747
748 $cell[] = $link;
749 }
750
751 $cell = $this->ui->makeList( $cell )
752 ->gutter(1)
753 ->tag('margin', '05')
754 ;
755
756 $row[] = $cell;
757 }
758
759 // while( count($row) < 32 ){
760 // $row[] = NULL;
761 // }
762 $rows[] = $row;
763 }
764
765 $out = $this->ui->makeTable( $header, $rows, FALSE )
766 ->gutter(0)
767 ->setBordered( $this->borderColor )
768 ->setSegments( $weekSegments )
769 ->setLabelled( TRUE )
770 ;
771
772 if( ! $this->slimView ){
773 $out->forceColWidth( '6rem' );
774 $out->forceRowHeaderWidth( '10rem' );
775 }
776
777 return $out;
778 }
779 }