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

774 lines 20.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_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
577 $title = htmlspecialchars( $label );
578 $description = $employee->getDescription();
579 if( strlen($description) ){
580 $description = htmlspecialchars( $description );
581 $title .= "\n" . $description;
582 }
583
584 $label = $this->ui->makeSpan( $label )
585 ->tag( 'font-size', 4 )
586 ->addAttr( 'title', $title )
587 ;
588
589 $viewEmployees[ $employee->getId() ] = $label;
590 }
591
592 $viewShifts = array();
593
594 $iknow = array('employee', 'date');
595
596 $allCalendars = $this->common->findAllCalendars();
597 if( count($allCalendars) <= 1 ) $iknow[] = 'calendar';
598
599 foreach( $shifts as $shift ){
600 $employee = $shift->getEmployee();
601 $id = $employee ? $employee->getId() : 0;
602
603 if( ! array_key_exists($id, $viewShifts) ){
604 $viewShifts[$id] = array();
605 }
606
607 $start = $shift->getStart();
608 $end = $shift->getEnd();
609
610 $startDayTime = substr($start, 8, 4);
611 $endDayTime = substr($end, 8, 4);
612 $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE;
613
614 $this->t->setDateTimeDb( $end )->modify('-1 second');
615 $shiftEndDate = $this->t->formatDateDb();
616
617 $this->t->setDateTimeDb( $start );
618 $shiftStartDate = $this->t->formatDateDb();
619
620 $rexDate = $shiftStartDate;
621 while( $rexDate <= $shiftEndDate ){
622 if( in_array($rexDate, $dates) ){
623 if( ! array_key_exists($rexDate, $viewShifts[$id]) ){
624 $viewShifts[$id][$rexDate] = array();
625 }
626 $viewShifts[$id][$rexDate][] = $shift;
627 }
628
629 if( ! $shiftAllDay ){
630 break;
631 }
632 $this->t->modify( '+1 day' );
633 $rexDate = $this->t->formatDateDb();
634 }
635 }
636
637 $header = array();
638 $header[] = NULL;
639
640 $weekStartsOn = $this->t->getWeekStartsOn();
641 $weekSegments = array();
642
643 $this->t->setDateDb( $startDate );
644 // $monthMatrix = $this->t->getMonthMatrix( $disabledWeekdays );
645 $monthMatrix = $this->t->getWeeksMatrix( $this->nWeeks, $disabledWeekdays );
646
647 foreach( $monthMatrix as $week => $days ){
648 $wdi = 0;
649 foreach( $days as $date ){
650 if( ! $date ){
651 continue;
652 }
653 $this->t->setDateDb( $date );
654
655 $dateView = $this->common->renderDateLabelGrouped( $date );
656 $header[] = $dateView;
657
658 if( ! $wdi ){
659 $weekSegments[] = count($header);
660 }
661
662 $wdi++;
663 }
664 }
665
666 // while( count($header) < 32 ){
667 // $header[] = NULL;
668 // }
669
670 $rows = array();
671 foreach( $viewEmployees as $id => $employeeView ){
672 $row = array();
673
674 $this->shiftsDuration->reset();
675 if( isset($viewShifts[$id]) ){
676 $counted = 0;
677 foreach( $viewShifts[$id] as $date => $dateShifts ){
678 foreach( $dateShifts as $shift ){
679 $shiftCalendar = $shift->getCalendar();
680 // if( $shiftCalendar->isTimeoff() ){
681 // continue;
682 // }
683 $this->shiftsDuration->add( $shift );
684 $counted++;
685 }
686 }
687
688 if( $counted ){
689 $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE );
690 $outReport = $this->ui->makeSpan( $outReport )
691 ->tag('font-size', 2)
692 ;
693 $employeeView = $this->ui->makeList( array($employeeView, $outReport) )
694 ->gutter(1)
695 ;
696 }
697 }
698
699 $thisShifts = isset($viewShifts[$id]) ? $viewShifts[$id] : array();
700 $employeeView = $this->common->employeeRowLabel( $employeeView, $id, '4weeks', $dates, $thisShifts );
701
702 $employeeView = $this->ui->makeBlock( $employeeView )
703 ->tag('padding', array('x1', 'y2'))
704 ->tag('nowrap')
705 ;
706 $row[] = $employeeView;
707
708 $countDates = count( $dates );
709 foreach( $dates as $date ){
710 $cell = array();
711
712 if( isset($viewShifts[$id][$date]) ){
713 if( ($countDates > 10) && ($this->slimView) ){
714 $shiftsView = $this->viewMonth->renderDay( $viewShifts[$id][$date], $iknow );
715 }
716 else {
717 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$id][$date], $iknow );
718 }
719 $cell[] = $shiftsView;
720 }
721
722 $comboId = 0 . '-' . $id;
723 if( isset($this->allCombos[$comboId]) ){
724 $label = '+';
725
726 $to = 'new';
727 $toParams = array(
728 'date' => $date,
729 'employee' => $id,
730 );
731 $to = array( $to, $toParams );
732
733 $link = $this->ui->makeAhref( $to, $label )
734 ->tag('tab-link')
735 ->tag('align', 'center')
736 ->addAttr('title', '__Add New__')
737 ;
738
739 if( $today > $date ){
740 $link->tag('muted', 3);
741 }
742
743 $cell[] = $link;
744 }
745
746 $cell = $this->ui->makeList( $cell )
747 ->gutter(1)
748 ->tag('margin', '05')
749 ;
750
751 $row[] = $cell;
752 }
753
754 // while( count($row) < 32 ){
755 // $row[] = NULL;
756 // }
757 $rows[] = $row;
758 }
759
760 $out = $this->ui->makeTable( $header, $rows, FALSE )
761 ->gutter(0)
762 ->setBordered( $this->borderColor )
763 ->setSegments( $weekSegments )
764 ->setLabelled( TRUE )
765 ;
766
767 if( ! $this->slimView ){
768 $out->forceColWidth( '6rem' );
769 $out->forceRowHeaderWidth( '10rem' );
770 }
771
772 return $out;
773 }
774 }