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

795 lines 20.5 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 class SH4_Schedule_Html_View_FourWeeks
3 {
4 protected $borderColor = 'gray';
5 protected $allCombos = array();
6 protected $allCombosShift = array();
7 protected $allCombosTimeoff = array();
8 protected $nWeeks = 4;
9
10 public function __construct(
11 HC3_Hooks $hooks,
12 HC3_Ui $ui,
13 HC3_Request $request,
14 HC3_Time $t,
15 HC3_Enqueuer $enqueuer,
16 HC3_Settings $settings,
17
18 HC3_Uri $uri,
19
20 SH4_New_Acl $newAcl,
21
22 SH4_Shifts_Duration $shiftsDuration,
23 SH4_Schedule_Html_View_Week $viewWeek,
24 SH4_Schedule_Html_View_Month $viewMonth,
25 SH4_Shifts_View_Widget $widget,
26 SH4_Calendars_Presenter $calendarsPresenter,
27 SH4_Employees_Presenter $employeesPresenter,
28 SH4_Schedule_Html_View_Common $common,
29 SH4_Shifts_View_Common $shiftsCommon
30 )
31 {
32 $this->self = $hooks->wrap($this);
33 $enqueuer->addScript('schedule', 'sh4/schedule/assets/js/calendar.js?hcver=' . SH4_VERSION);
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 }
61
62 public function renderDateLabel( $date )
63 {
64 $slug = $this->request->getSlug();
65 $today = $this->t->setNow()->formatDateDb();
66
67 $this->t->setDateDb( $date );
68 $weekdayView = $this->t->getWeekdayName();
69 $weekdayView = $this->ui->makeBlock( $weekdayView )->tag('muted')->tag('font-size', 1);
70
71 $ret = $this->t->getDay() . ' ' . $this->t->getMonthName();
72
73 $ret = $this->ui->makeListInline( array($weekdayView, $ret) )
74 ->tag('align', 'center')
75 ;
76
77 $toDateParams = array();
78 $toDateParams['type'] = 'day';
79 $toDateParams['start'] = $date;
80 $toDate = array( $slug, $toDateParams );
81
82 $weekLabel = $this->t->getWeekNo();
83 $weekLabel = ' [' . '__Week__' . ' #' . $weekLabel . ']';
84
85 $ret = $this->ui->makeAhref( $toDate, $ret )
86 ->tag('print')
87 ->addAttr( 'title', $weekLabel )
88 ;
89
90 if( $date == $today ){
91 $ret = $this->ui->makeBlock( $ret )
92 ->tag('border')
93 ->tag('border-color', 'gray')
94 ;
95 }
96
97 return $ret;
98 }
99
100 public function render()
101 {
102 $slug = $this->request->getSlug();
103 $today = $this->t->setNow()->formatDateDb();
104
105 $disabledWeekdays = $this->settings->get( 'skip_weekdays', TRUE );
106
107 $shifts = $this->common->getShifts();
108
109 $params = $this->request->getParams();
110 $startDate = $params['start'];
111
112 $startDate = $this->t->setDateDb( $startDate )->setStartWeek()->formatDateDb();
113 $endDate = $this->t->modify('+' . $this->nWeeks . ' weeks')->modify('-1 day')->formatDateDb();
114
115 $this->t->setDateDb( $startDate );
116 $dates = array();
117 $rexDate = $startDate;
118 while( $rexDate <= $endDate ){
119 if( $disabledWeekdays ){
120 $wkd = $this->t->getWeekday();
121 if( in_array($wkd, $disabledWeekdays) ){
122 $rexDate = $this->t->modify('+1 day')->formatDateDb();
123 continue;
124 }
125 }
126
127 $dates[] = $rexDate;
128 $rexDate = $this->t->modify('+1 day')->formatDateDb();
129 }
130
131 $viewShifts = array();
132 $iknow = array('date');
133
134 $allCalendars = $this->common->findAllCalendars();
135 if( count($allCalendars) <= 1 ) $iknow[] = 'calendar';
136
137 $this->shiftsDuration->reset();
138 foreach( $shifts as $shift ){
139 $this->shiftsDuration->add( $shift );
140 $start = $shift->getStart();
141 $end = $shift->getEnd();
142
143 $startDayTime = substr($start, 8, 4);
144 $endDayTime = substr($end, 8, 4);
145 $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE;
146
147 $this->t->setDateTimeDb( $end )->modify('-1 second');
148 $shiftEndDate = $this->t->formatDateDb();
149
150 $this->t->setDateTimeDb( $start );
151 $shiftStartDate = $this->t->formatDateDb();
152
153 $rexDate = $shiftStartDate;
154 while( $rexDate <= $shiftEndDate ){
155 if( in_array($rexDate, $dates) ){
156 if( ! array_key_exists($rexDate, $viewShifts) ){
157 $viewShifts[$rexDate] = array();
158 }
159 $viewShifts[$rexDate][] = $shift;
160 }
161
162 if( ! $shiftAllDay ){
163 break;
164 }
165 $this->t->modify( '+1 day' );
166 $rexDate = $this->t->formatDateDb();
167 }
168 }
169
170 $this->t->setDateDb( $startDate );
171 // $monthMatrix = $this->t->getMonthMatrix( $disabledWeekdays );
172 $monthMatrix = $this->t->getWeeksMatrix( $this->nWeeks, $disabledWeekdays );
173 $rows = array();
174 foreach( $monthMatrix as $week => $days ){
175 $row = array();
176
177 foreach( $days as $date ){
178 if( ! $date ){
179 $row[] = NULL;
180 continue;
181 }
182
183 $cell = array();
184
185 $this->t->setDateDb( $date );
186 $dateView = $this->self->renderDateLabel( $date );
187
188 $cell[] = $dateView;
189
190 if( isset($viewShifts[$date]) ){
191 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$date], $iknow );
192 $cell[] = $shiftsView;
193 }
194
195 $to = 'new';
196 $toParams = array(
197 'date' => $date
198 );
199 if( array_key_exists('employee', $params) && (count($params['employee']) == 1) ){
200 if( ! in_array(-1, $params['employee']) ){
201 $toParams['employee'] = $params['employee'][0];
202 }
203 }
204
205 $links = array();
206
207 if( $this->allCombosShift ){
208 $label = '+' . ' ' . '__Shift__';
209 $thisTo = 'new/shift';
210 $thisTo = array( $thisTo, $toParams );
211 $link = $this->ui->makeAhref( $thisTo, $label )
212 ->tag('tab-link')
213 ->tag('align', 'center')
214 // ->addAttr('title', '__Add New__')
215 ;
216 if( $today > $date ){
217 $link->tag('muted', 3);
218 }
219 $links[] = $link;
220 }
221
222 if( $this->allCombosTimeoff ){
223 $label = '+' . ' ' . '__Time Off__';
224 $thisTo = 'new/timeoff';
225 $thisTo = array( $thisTo, $toParams );
226 $link = $this->ui->makeAhref( $thisTo, $label )
227 ->tag('tab-link')
228 ->tag('align', 'center')
229 // ->addAttr('title', '__Add New__')
230 ;
231 if( $today > $date ){
232 $link->tag('muted', 3);
233 }
234 $links[] = $link;
235 }
236
237 $links = $this->ui->makeList( $links )->gutter(0);
238
239 $cell[] = $links;
240
241
242 $cell = $this->ui->makeList( $cell )
243 ->gutter(1)
244 ->tag('margin', 1)
245 ;
246
247 $row[] = $cell;
248 }
249
250 $rows[] = $row;
251 }
252
253 $out = $this->ui->makeTable( NULL, $rows, FALSE )
254 ->gutter(0)
255 ->setBordered( $this->borderColor )
256 // ->setSegments( $weekSegments )
257 ;
258
259 return $out;
260 }
261
262 public function renderByCalendar()
263 {
264 $slug = $this->request->getSlug();
265 $today = $this->t->setNow()->formatDateDb();
266
267 $disabledWeekdays = $this->settings->get( 'skip_weekdays', TRUE );
268
269 $calendars = $this->common->getCalendars();
270 $employees = $this->common->getEmployees();
271 $shifts = $this->common->getShifts();
272
273 $params = $this->request->getParams();
274 $startDate = $params['start'];
275
276 $startDate = $this->t->setDateDb( $startDate )->setStartWeek()->formatDateDb();
277 $endDate = $this->t->modify('+' . $this->nWeeks . ' weeks')->modify('-1 day')->formatDateDb();
278
279 $this->t->setDateDb( $startDate );
280 $dates = array();
281 $rexDate = $startDate;
282 while( $rexDate <= $endDate ){
283 if( $disabledWeekdays ){
284 $wkd = $this->t->getWeekday();
285 if( in_array($wkd, $disabledWeekdays) ){
286 $rexDate = $this->t->modify('+1 day')->formatDateDb();
287 continue;
288 }
289 }
290
291 $dates[] = $rexDate;
292 $rexDate = $this->t->modify('+1 day')->formatDateDb();
293 }
294
295 $viewCalendars = array();
296 foreach( $calendars as $calendar ){
297 $label = $calendar->getTitle();
298
299 $title = htmlspecialchars( $label );
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 $this->t->setDateDb( $date );
372
373 $dateView = array();
374 $weekdayView = $this->t->getWeekdayName();
375 $weekdayView = $this->ui->makeBlock( $weekdayView )->tag('muted')->tag('font-size', 1);
376 $dateView[] = $weekdayView;
377
378 $dayView = $this->t->getDay();
379 $dateView[] = $dayView;
380 $dateView[] = $this->t->getMonthName();
381
382 $dateView = $this->ui->makeList($dateView)
383 ->gutter(0)
384 ->tag('align', 'center')
385 ;
386
387 $toDateParams = array();
388 $toDateParams['type'] = 'day';
389 $toDateParams['start'] = $date;
390 $toDate = array( $slug, $toDateParams );
391
392 $weekLabel = $this->t->getWeekNo();
393 $weekLabel = ' [' . '__Week__' . ' #' . $weekLabel . ']';
394
395 $dateView = $this->ui->makeAhref( $toDate, $dateView )
396 ->tag('print')
397 ->addAttr( 'title', $weekLabel )
398 ;
399
400 if( $date == $today ){
401 $dateView = $this->ui->makeBlock( $dateView )
402 ->tag('border')
403 ->tag('border-color', 'gray')
404 ;
405 }
406
407 $header[] = $dateView;
408
409 if( ! $wdi ){
410 $weekSegments[] = count($header);
411 }
412
413 $wdi++;
414 }
415 }
416
417 // while( count($header) < 32 ){
418 // $header[] = NULL;
419 // }
420
421 $rows = array();
422 foreach( $viewCalendars as $id => $calendarView ){
423 $row = array();
424
425 $this->shiftsDuration->reset();
426 if( isset($viewShifts[$id]) ){
427 foreach( $viewShifts[$id] as $date => $dateShifts ){
428 foreach( $dateShifts as $shift ){
429 $this->shiftsDuration->add( $shift );
430 }
431 }
432
433 $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE );
434 $outReport = $this->ui->makeSpan( $outReport )
435 ->tag('font-size', 2)
436 ;
437 $calendarView = $this->ui->makeList( array($calendarView, $outReport) )
438 ->gutter(1)
439 ;
440 }
441
442 $calendarView = $this->ui->makeBlock( $calendarView )
443 ->tag('padding', array('x1', 'y2'))
444 ->tag('nowrap')
445 ;
446 $row[] = $calendarView;
447
448 $countDates = count( $dates );
449 foreach( $dates as $date ){
450 $cell = array();
451
452 if( isset($viewShifts[$id][$date]) ){
453 if( $countDates <= 10 ){
454 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$id][$date], $iknow );
455 }
456 else {
457 $shiftsView = $this->viewMonth->renderDay( $viewShifts[$id][$date], $iknow );
458 }
459 $cell[] = $shiftsView;
460 }
461
462 $label = '+';
463
464 $to = 'new';
465 $toParams = array(
466 'date' => $date,
467 'calendar' => $id,
468 );
469 if( array_key_exists('employee', $params) && (count($params['employee']) == 1) ){
470 if( ! in_array(-1, $params['employee']) ){
471 $toParams['employee'] = $params['employee'][0];
472 }
473 }
474 $to = array( $to, $toParams );
475
476 $addOk = FALSE;
477 if( isset($toParams['employee']) ){
478 $testComboId = $id . '-' . $toParams['employee'];
479 if( isset($this->allCombos[$testComboId]) ){
480 $addOk = TRUE;
481 }
482 }
483 else {
484 $testComboId = $id . '-';
485 reset( $this->allCombos );
486 foreach( $this->allCombos as $comboId ){
487 if( $testComboId == substr($comboId, 0, strlen($testComboId)) ){
488 $addOk = TRUE;
489 break;
490 }
491 }
492 }
493
494 if( $addOk ){
495 $link = $this->ui->makeAhref( $to, $label )
496 ->tag('tab-link')
497 ->tag('align', 'center')
498 ->addAttr('title', '__Add New__')
499 ;
500
501 if( $today > $date ){
502 $link->tag('muted', 3);
503 }
504
505 $cell[] = $link;
506 }
507
508 $cell = $this->ui->makeList( $cell )
509 ->gutter(1)
510 ->tag('margin', '05')
511 ;
512
513 $row[] = $cell;
514 }
515
516 // while( count($row) < 32 ){
517 // $row[] = NULL;
518 // }
519 $rows[] = $row;
520 }
521
522 $out = $this->ui->makeTable( $header, $rows, FALSE )
523 ->gutter(0)
524 ->setBordered( $this->borderColor )
525 ->setSegments( $weekSegments )
526 ->setLabelled( TRUE )
527 ;
528
529 return $out;
530 }
531
532 public function renderByEmployee()
533 {
534 $slug = $this->request->getSlug();
535 $today = $this->t->setNow()->formatDateDb();
536
537 $disabledWeekdays = $this->settings->get( 'skip_weekdays', TRUE );
538
539 $calendars = $this->common->getCalendars();
540 $employees = $this->common->getEmployees();
541 $shifts = $this->common->getShifts();
542
543 $params = $this->request->getParams();
544 $startDate = $params['start'];
545
546 $startDate = $this->t->setDateDb( $startDate )->setStartWeek()->formatDateDb();
547 $endDate = $this->t->modify('+' . $this->nWeeks . ' weeks')->modify('-1 day')->formatDateDb();
548
549 $this->t->setDateDb( $startDate );
550 $dates = array();
551 $rexDate = $startDate;
552 while( $rexDate <= $endDate ){
553 if( $disabledWeekdays ){
554 $wkd = $this->t->getWeekday();
555 if( in_array($wkd, $disabledWeekdays) ){
556 $rexDate = $this->t->modify('+1 day')->formatDateDb();
557 continue;
558 }
559 }
560
561 $dates[] = $rexDate;
562 $rexDate = $this->t->modify('+1 day')->formatDateDb();
563 }
564
565 $viewEmployees = array();
566 foreach( $employees as $employee ){
567 $label = $this->employeesPresenter->presentTitle( $employee );
568
569 $title = htmlspecialchars( $label );
570 $description = $employee->getDescription();
571 if( strlen($description) ){
572 $description = htmlspecialchars( $description );
573 $title .= "\n" . $description;
574 }
575
576 $label = $this->ui->makeSpan( $label )
577 ->tag( 'font-size', 4 )
578 ->addAttr( 'title', $title )
579 ;
580
581 $viewEmployees[ $employee->getId() ] = $label;
582 }
583
584 $viewShifts = array();
585
586 $iknow = array('employee', 'date');
587
588 $allCalendars = $this->common->findAllCalendars();
589 if( count($allCalendars) <= 1 ) $iknow[] = 'calendar';
590
591 foreach( $shifts as $shift ){
592 $employee = $shift->getEmployee();
593 $id = $employee ? $employee->getId() : 0;
594
595 if( ! array_key_exists($id, $viewShifts) ){
596 $viewShifts[$id] = array();
597 }
598
599 $start = $shift->getStart();
600 $end = $shift->getEnd();
601
602 $startDayTime = substr($start, 8, 4);
603 $endDayTime = substr($end, 8, 4);
604 $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE;
605
606 $this->t->setDateTimeDb( $end )->modify('-1 second');
607 $shiftEndDate = $this->t->formatDateDb();
608
609 $this->t->setDateTimeDb( $start );
610 $shiftStartDate = $this->t->formatDateDb();
611
612 $rexDate = $shiftStartDate;
613 while( $rexDate <= $shiftEndDate ){
614 if( in_array($rexDate, $dates) ){
615 if( ! array_key_exists($rexDate, $viewShifts[$id]) ){
616 $viewShifts[$id][$rexDate] = array();
617 }
618 $viewShifts[$id][$rexDate][] = $shift;
619 }
620
621 if( ! $shiftAllDay ){
622 break;
623 }
624 $this->t->modify( '+1 day' );
625 $rexDate = $this->t->formatDateDb();
626 }
627 }
628
629 $header = array();
630 $header[] = NULL;
631
632 $weekStartsOn = $this->t->getWeekStartsOn();
633 $weekSegments = array();
634
635 $this->t->setDateDb( $startDate );
636 // $monthMatrix = $this->t->getMonthMatrix( $disabledWeekdays );
637 $monthMatrix = $this->t->getWeeksMatrix( $this->nWeeks, $disabledWeekdays );
638
639 foreach( $monthMatrix as $week => $days ){
640 $wdi = 0;
641 foreach( $days as $date ){
642 if( ! $date ){
643 continue;
644 }
645 $this->t->setDateDb( $date );
646
647 $dateView = array();
648 $weekdayView = $this->t->getWeekdayName();
649 $weekdayView = $this->ui->makeBlock( $weekdayView )->tag('muted')->tag('font-size', 1);
650 $dateView[] = $weekdayView;
651
652 $dayView = $this->t->getDay();
653 $dateView[] = $dayView;
654 $dateView[] = $this->t->getMonthName();
655
656 $dateView = $this->ui->makeList($dateView)
657 ->gutter(0)
658 ->tag('align', 'center')
659 ;
660
661 $toDateParams = array();
662 $toDateParams['type'] = 'day';
663 $toDateParams['start'] = $date;
664 $toDate = array( $slug, $toDateParams );
665
666 $weekLabel = $this->t->getWeekNo();
667 $weekLabel = ' [' . '__Week__' . ' #' . $weekLabel . ']';
668
669 $dateView = $this->ui->makeAhref( $toDate, $dateView )
670 ->tag('print')
671 ->addAttr( 'title', $weekLabel )
672 ;
673
674 if( $date == $today ){
675 $dateView = $this->ui->makeBlock( $dateView )
676 ->tag('border')
677 ->tag('border-color', 'gray')
678 ;
679 }
680
681 $header[] = $dateView;
682
683 if( ! $wdi ){
684 $weekSegments[] = count($header);
685 }
686
687 $wdi++;
688 }
689 }
690
691 // while( count($header) < 32 ){
692 // $header[] = NULL;
693 // }
694
695 $rows = array();
696
697 foreach( $viewEmployees as $id => $employeeView ){
698 $row = array();
699
700 $this->shiftsDuration->reset();
701 if( isset($viewShifts[$id]) ){
702 $counted = 0;
703 foreach( $viewShifts[$id] as $date => $dateShifts ){
704 foreach( $dateShifts as $shift ){
705 $shiftCalendar = $shift->getCalendar();
706 // if( $shiftCalendar->isTimeoff() ){
707 // continue;
708 // }
709 $this->shiftsDuration->add( $shift );
710 $counted++;
711 }
712 }
713
714 if( $counted ){
715 $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE );
716 $outReport = $this->ui->makeSpan( $outReport )
717 ->tag('font-size', 2)
718 ;
719 $employeeView = $this->ui->makeList( array($employeeView, $outReport) )
720 ->gutter(1)
721 ;
722 }
723 }
724
725 $thisShifts = isset($viewShifts[$id]) ? $viewShifts[$id] : array();
726 $employeeView = $this->common->employeeRowLabel( $employeeView, $id, '4weeks', $dates, $thisShifts );
727
728 $employeeView = $this->ui->makeBlock( $employeeView )
729 ->tag('padding', array('x1', 'y2'))
730 ->tag('nowrap')
731 ;
732 $row[] = $employeeView;
733
734 $countDates = count( $dates );
735 foreach( $dates as $date ){
736 $cell = array();
737
738 if( isset($viewShifts[$id][$date]) ){
739 if( $countDates <= 10 ){
740 $shiftsView = $this->viewWeek->renderDay( $viewShifts[$id][$date], $iknow );
741 }
742 else {
743 $shiftsView = $this->viewMonth->renderDay( $viewShifts[$id][$date], $iknow );
744 }
745 $cell[] = $shiftsView;
746 }
747
748 $comboId = 0 . '-' . $id;
749 if( isset($this->allCombos[$comboId]) ){
750 $label = '+';
751
752 $to = 'new';
753 $toParams = array(
754 'date' => $date,
755 'employee' => $id,
756 );
757 $to = array( $to, $toParams );
758
759 $link = $this->ui->makeAhref( $to, $label )
760 ->tag('tab-link')
761 ->tag('align', 'center')
762 ->addAttr('title', '__Add New__')
763 ;
764
765 if( $today > $date ){
766 $link->tag('muted', 3);
767 }
768
769 $cell[] = $link;
770 }
771
772 $cell = $this->ui->makeList( $cell )
773 ->gutter(1)
774 ->tag('margin', '05')
775 ;
776
777 $row[] = $cell;
778 }
779
780 // while( count($row) < 32 ){
781 // $row[] = NULL;
782 // }
783 $rows[] = $row;
784 }
785
786 $out = $this->ui->makeTable( $header, $rows, FALSE )
787 ->gutter(0)
788 ->setBordered( $this->borderColor )
789 ->setSegments( $weekSegments )
790 ->setLabelled( TRUE )
791 ;
792
793 return $out;
794 }
795 }