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
← All changes | sh4/schedule/html/view/week.php +10 -212 4.9.774.9.66 View file →
@@ -18,9 +18,8 @@
18 18 SH4_New_Acl $newAcl,
19 19
20 20 SH4_Shifts_Duration $shiftsDuration,
21 21 SH4_Shifts_View_Widget $widget,
22 - SH4_Calendars_Query $calendarsQuery,
23 22 SH4_Calendars_Presenter $calendarsPresenter,
24 23 SH4_Employees_Presenter $employeesPresenter,
25 24 SH4_Schedule_Html_View_Common $common,
26 25 SH4_Shifts_View_Common $shiftsCommon
@@ -37,9 +36,8 @@
37 36 $this->settings = $hooks->wrap( $settings );
38 37 $this->newAcl = $hooks->wrap( $newAcl );
39 38
40 39 $this->shiftsDuration = $hooks->wrap( $shiftsDuration );
41 - $this->calendarsQuery = $hooks->wrap( $calendarsQuery );
42 40 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
43 41 $this->employeesPresenter = $hooks->wrap( $employeesPresenter );
44 42
45 43 $this->widget = $hooks->wrap( $widget );
@@ -474,32 +472,8 @@
474 472 }
475 473
476 474 $rows = array();
477 475
478 -// link templates to speed things up
479 -$toParams = array(
480 - 'calendar' => '{CID}',
481 - 'date' => '{DATE}'
482 -);
483 -$thisTo = 'new/shift';
484 -$thisTo = array( $thisTo, $toParams );
485 -$thisHref = $this->uri->makeUrl( $thisTo );
486 -
487 -$linkTemplateShift = '<a title="+ __Shift__" class="hc-block hc-theme-tab-link hc-align-center" href="' . $thisHref . '">+ __Shift__</a>';
488 -$linkTemplateShiftMuted = '<a title="+ __Shift__" class="hc-block hc-theme-tab-link hc-align-center hc-muted3" href="' . $thisHref . '">+ __Shift__</a>';
489 -
490 -$toParams = array(
491 - 'calendar' => '{CID}',
492 - 'date' => '{DATE}'
493 -);
494 -$thisTo = 'new/timeoff';
495 -$thisTo = array( $thisTo, $toParams );
496 -$thisHref = $this->uri->makeUrl( $thisTo );
497 -
498 -$linkTemplateTimeoff = '<a title="+ __Time Off__" class="hc-block hc-theme-tab-link hc-align-center" href="' . $thisHref . '">+ __Time Off__</a>';
499 -$linkTemplateTimeoffMuted = '<a title="+ __Time Off__" class="hc-block hc-theme-tab-link hc-align-center hc-muted3" href="' . $thisHref . '">+ __Time Off__</a>';
500 -$isPrintView = $this->request->isPrintView();
501 -
502 476 foreach( $view_calendars as $id => $calendarView ){
503 477 $row = array();
504 478
505 479 $thisCalendar = $calendars[$id];
@@ -613,12 +587,9 @@
613 587 $toParams['employee'] = $params['employee'][0];
614 588 }
615 589 }
616 590
617 - if( $isPrintView ) $addOk = false;
618 -
619 591 if( $addOk ){
620 -/*
621 592 $to = array( $to, $toParams );
622 593
623 594 $link = $this->ui->makeAhref( $to, $label )
624 595 ->tag('tab-link')
@@ -626,25 +597,8 @@
626 597 ;
627 598 if( $today > $date ){
628 599 $link->tag('muted', 3);
629 600 }
630 -*/
631 - if( $today > $date ){
632 - if( $thisCalendar->isTimeoff() ){
633 - $link = str_replace( array('{CID}', '{DATE}'), array($id, $date), $linkTemplateTimeoffMuted );
634 - }
635 - else {
636 - $link = str_replace( array('{CID}', '{DATE}'), array($id, $date), $linkTemplateShiftMuted );
637 - }
638 - }
639 - else {
640 - if( $thisCalendar->isTimeoff() ){
641 - $link = str_replace( array('{CID}', '{DATE}'), array($id, $date), $linkTemplateTimeoff );
642 - }
643 - else {
644 - $link = str_replace( array('{CID}', '{DATE}'), array($id, $date), $linkTemplateShift );
645 - }
646 - }
647 601
648 602 $cell[] = $link;
649 603 }
650 604
@@ -739,19 +693,14 @@
739 693
740 694 $view_employees = array();
741 695 foreach( $employees as $employee ){
742 696 $label = $this->employeesPresenter->presentTitle( $employee );
697 +
743 698 $title = htmlspecialchars( $label );
744 -
745 699 $description = $employee->getDescription();
746 700 if( strlen($description) ){
747 - $imgpos = strpos( $description, '<img' );
748 - if( false !== $imgpos ){
749 - $label = $this->ui->makeList( array($label, $description) );
750 - }
751 - else {
752 - $title .= "\n" . htmlspecialchars( $description );
753 - }
701 + $description = htmlspecialchars( $description );
702 + $title .= "\n" . $description;
754 703 }
755 704
756 705 $label = $this->ui->makeSpan( $label )
757 706 ->tag( 'font-size', 4 )
@@ -770,9 +719,8 @@
770 719
771 720 $hori = FALSE;
772 721
773 722 foreach( $shifts as $shift ){
774 - $shiftId = $shift->getId();
775 723 $employee = $shift->getEmployee();
776 724 $id = $employee ? $employee->getId() : 0;
777 725
778 726 if( ! array_key_exists($id, $view_shifts) ){
@@ -794,9 +742,8 @@
794 742
795 743 $rexDate = $shiftStartDate;
796 744 while( $rexDate <= $shiftEndDate ){
797 745 if( in_array($rexDate, $dates) ){
798 - $shiftsByDate[ $rexDate ][ $shiftId ] = $shift;
799 746 if( ! array_key_exists($rexDate, $view_shifts[$id]) ){
800 747 $view_shifts[$id][$rexDate] = array();
801 748 }
802 749 $view_shifts[$id][$rexDate][] = $shift;
@@ -865,37 +812,13 @@
865 812 }
866 813
867 814 $rows = array();
868 815
869 -// link templates to speed things up
870 -$toParams = array(
871 - 'employee' => '{EID}',
872 - 'date' => '{DATE}'
873 -);
874 -$thisTo = 'new/shift';
875 -$thisTo = array( $thisTo, $toParams );
876 -$thisHref = $this->uri->makeUrl( $thisTo );
877 -
878 -$linkTemplateShift = '<a title="+ __Shift__" class="hc-block hc-theme-tab-link hc-align-center" href="' . $thisHref . '">+ __Shift__</a>';
879 -$linkTemplateShiftMuted = '<a title="+ __Shift__" class="hc-block hc-theme-tab-link hc-align-center hc-muted3" href="' . $thisHref . '">+ __Shift__</a>';
880 -
881 -$toParams = array(
882 - 'employee' => '{EID}',
883 - 'date' => '{DATE}'
884 -);
885 -$thisTo = 'new/timeoff';
886 -$thisTo = array( $thisTo, $toParams );
887 -$thisHref = $this->uri->makeUrl( $thisTo );
888 -
889 -$linkTemplateTimeoff = '<a title="+ __Time Off__" class="hc-block hc-theme-tab-link hc-align-center" href="' . $thisHref . '">+ __Time Off__</a>';
890 -$linkTemplateTimeoffMuted = '<a title="+ __Time Off__" class="hc-block hc-theme-tab-link hc-align-center hc-muted3" href="' . $thisHref . '">+ __Time Off__</a>';
891 -$isPrintView = $this->request->isPrintView();
892 -
893 816 foreach( $view_employees as $id => $employeeView ){
894 817 $row = array();
895 818
819 + $this->shiftsDuration->reset();
896 820 if( isset($view_shifts[$id]) ){
897 - $this->shiftsDuration->reset();
898 821 $counted = 0;
899 822 foreach( $view_shifts[$id] as $date => $dateShifts ){
900 823 foreach( $dateShifts as $shift ){
901 824 $shiftCalendar = $shift->getCalendar();
@@ -942,10 +865,10 @@
942 865
943 866 $links = array();
944 867
945 868 $comboId = 0 . '-' . $id;
869 +
946 870 if( isset($this->allCombosShift[$comboId]) ){
947 -/*
948 871 $label = '+' . ' ' . '__Shift__';
949 872 $thisTo = 'new/shift';
950 873 $thisTo = array( $thisTo, $toParams );
951 874 $link = $this->ui->makeAhref( $thisTo, $label )
@@ -954,23 +877,12 @@
954 877 ;
955 878 if( $today > $date ){
956 879 $link->tag('muted', 3);
957 880 }
958 -*/
959 - if( $today > $date ){
960 - $link = str_replace( array('{EID}', '{DATE}'), array($id, $date), $linkTemplateShiftMuted );
961 - }
962 - else {
963 - $link = str_replace( array('{EID}', '{DATE}'), array($id, $date), $linkTemplateShift );
964 - }
965 -
966 - if( ! $isPrintView ){
967 - $cell[] = $link;
968 - }
881 + $links[] = $link;
969 882 }
970 883
971 884 if( isset($this->allCombosTimeoff[$comboId]) ){
972 -/*
973 885 $label = '+' . ' ' . '__Time Off__';
974 886 $thisTo = 'new/timeoff';
975 887 $thisTo = array( $thisTo, $toParams );
976 888 $link = $this->ui->makeAhref( $thisTo, $label )
@@ -979,27 +891,14 @@
979 891 ;
980 892 if( $today > $date ){
981 893 $link->tag('muted', 3);
982 894 }
983 -*/
984 -
985 - if( $today > $date ){
986 - $link = str_replace( array('{EID}', '{DATE}'), array($id, $date), $linkTemplateTimeoffMuted );
987 - }
988 - else {
989 - $link = str_replace( array('{EID}', '{DATE}'), array($id, $date), $linkTemplateTimeoff );
990 - }
991 -
992 - if( ! $isPrintView ){
993 - $cell[] = $link;
994 - }
895 + $links[] = $link;
995 896 }
996 897
997 - if( ! $isPrintView ){
998 - if( $links ){
999 - $links = $this->ui->makeList( $links )->gutter(0);
1000 - $cell[] = $links;
1001 - }
898 + if( $links ){
899 + $links = $this->ui->makeList( $links )->gutter(0);
900 + $cell[] = $links;
1002 901 }
1003 902
1004 903 $cell = $this->ui->makeList( $cell )
1005 904 ->gutter(1)
@@ -1009,109 +908,8 @@
1009 908 $row[] = $cell;
1010 909 }
1011 910
1012 911 $rows[] = $row;
1013 - }
1014 -
1015 - /* append calendars summary */
1016 - $appendCalendars = $this->settings->get('datetime_summary_by_calendar');
1017 - if( $appendCalendars && $shifts ){
1018 - $calendarIds = array();
1019 - foreach( $shifts as $shift ){
1020 - $calendar = $shift->getCalendar();
1021 - $calendarId = $calendar ? $calendar->getId() : 0;
1022 - if( ! $calendarId ) continue;
1023 - $calendarIds[ $calendarId ] = $calendarId;
1024 - }
1025 -
1026 - $calendars = $this->calendarsQuery->findManyById( $calendarIds );
1027 -
1028 - $shiftsByCalendar = $shiftsByDate = array();
1029 - foreach( $shifts as $shift ){
1030 - $thisCalendar = $shift->getCalendar();
1031 - if( ! $thisCalendar ) continue;
1032 - $shiftId = $shift->getId();
1033 - $thisCalendarId = $thisCalendar->getId();
1034 - $shiftsByCalendar[ $thisCalendarId ][ $shiftId ] = $shift;
1035 -
1036 - $start = $shift->getStart();
1037 - $end = $shift->getEnd();
1038 -
1039 - $startDayTime = substr($start, 8, 4);
1040 - $endDayTime = substr($end, 8, 4);
1041 - $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE;
1042 -
1043 - $this->t->setDateTimeDb( $end )->modify('-1 second');
1044 - $shiftEndDate = $this->t->formatDateDb();
1045 -
1046 - $this->t->setDateTimeDb( $start );
1047 - $shiftStartDate = $this->t->formatDateDb();
1048 -
1049 - $rexDate = $shiftStartDate;
1050 - while( $rexDate <= $shiftEndDate ){
1051 - if( in_array($rexDate, $dates) ){
1052 - $shiftsByDate[ $rexDate ][ $shiftId ] = $shift;
1053 - }
1054 -
1055 - if( ! $shiftAllDay ){
1056 - break;
1057 - }
1058 - $this->t->modify( '+1 day' );
1059 - $rexDate = $this->t->formatDateDb();
1060 - }
1061 - }
1062 -
1063 - foreach( $calendars as $calendarId => $calendar ){
1064 - $row = array();
1065 -
1066 - $calendarView = $this->calendarsPresenter->presentTitle( $calendar );
1067 - $title = htmlspecialchars( $calendar->getTitle() );
1068 - $calendarView = $this->ui->makeSpan( $calendarView )
1069 - ->addAttr( 'title', $title )
1070 - ;
1071 -
1072 - $this->shiftsDuration->reset();
1073 - foreach( $shiftsByCalendar[$calendarId] as $shift ){
1074 - $this->shiftsDuration->add( $shift );
1075 - }
1076 -
1077 - $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE );
1078 - $outReport = $this->ui->makeSpan( $outReport )
1079 - ->tag('font-size', 2)
1080 - ;
1081 - $calendarView = $this->ui->makeList( array($calendarView, $outReport) )
1082 - ->gutter(1)
1083 - ;
1084 -
1085 - $calendarView = $this->ui->makeBlock( $calendarView )
1086 - ->tag('padding', 2)
1087 - ->tag('nowrap')
1088 - ;
1089 - $row[] = $calendarView;
1090 -
1091 - foreach( $dates as $date ){
1092 - $cell = '';
1093 - if( isset($shiftsByDate[$date]) ){
1094 - $thisShifts = array_intersect_key( $shiftsByDate[$date], $shiftsByCalendar[$calendarId] );
1095 - if( $thisShifts ){
1096 - $this->shiftsDuration->reset();
1097 - foreach( $thisShifts as $shift ){
1098 - $this->shiftsDuration->add( $shift );
1099 - }
1100 - $outReport = $this->common->renderReport( $this->shiftsDuration, false, true );
1101 - $outReport = $this->ui->makeSpan( $outReport )
1102 - ->tag('font-size', 2)
1103 - ;
1104 - $outReport = $this->ui->makeBlock( $outReport )
1105 - ->tag('align', 'center')
1106 - ;
1107 - $cell = $outReport;
1108 - }
1109 - }
1110 - $row[] = $cell;
1111 - }
1112 - $rows[] = $row;
1113 - }
1114 912 }
1115 913
1116 914 $out = $this->ui->makeTable( $header, $rows, FALSE )
1117 915 ->gutter(0)