| @@ -23,9 +23,8 @@ | ||
| 23 | 23 | SH4_Shifts_Duration $shiftsDuration, |
| 24 | 24 | SH4_Schedule_Html_View_Week $viewWeek, |
| 25 | 25 | SH4_Schedule_Html_View_Month $viewMonth, |
| 26 | 26 | SH4_Shifts_View_Widget $widget, |
| 27 | - SH4_Calendars_Query $calendarsQuery, | |
| 28 | 27 | SH4_Calendars_Presenter $calendarsPresenter, |
| 29 | 28 | SH4_Employees_Presenter $employeesPresenter, |
| 30 | 29 | SH4_Schedule_Html_View_Common $common, |
| 31 | 30 | SH4_Shifts_View_Common $shiftsCommon |
| @@ -44,9 +43,8 @@ | ||
| 44 | 43 | |
| 45 | 44 | $this->viewWeek = $hooks->wrap( $viewWeek ); |
| 46 | 45 | $this->viewMonth = $hooks->wrap( $viewMonth ); |
| 47 | 46 | $this->shiftsDuration = $hooks->wrap( $shiftsDuration ); |
| 48 | - $this->calendarsQuery = $hooks->wrap( $calendarsQuery ); | |
| 49 | 47 | $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter ); |
| 50 | 48 | $this->employeesPresenter = $hooks->wrap( $employeesPresenter ); |
| 51 | 49 | |
| 52 | 50 | $this->widget = $hooks->wrap( $widget ); |
| @@ -132,8 +130,9 @@ | ||
| 132 | 130 | } |
| 133 | 131 | } |
| 134 | 132 | |
| 135 | 133 | $this->t->setDateDb( $startDate ); |
| 134 | + // $monthMatrix = $this->t->getMonthMatrix( $disabledWeekdays ); | |
| 136 | 135 | $monthMatrix = $this->t->getWeeksMatrix( $this->nWeeks, $disabledWeekdays ); |
| 137 | 136 | $rows = array(); |
| 138 | 137 | foreach( $monthMatrix as $week => $days ){ |
| 139 | 138 | $row = array(); |
| @@ -384,22 +383,8 @@ | ||
| 384 | 383 | // $header[] = NULL; |
| 385 | 384 | // } |
| 386 | 385 | |
| 387 | 386 | $rows = array(); |
| 388 | - | |
| 389 | -// link templates to speed things up | |
| 390 | -$toParams = array( | |
| 391 | - 'calendar' => '{CID}', | |
| 392 | - 'date' => '{DATE}' | |
| 393 | -); | |
| 394 | -$thisTo = 'new/calendar'; | |
| 395 | -$thisTo = array( $thisTo, $toParams ); | |
| 396 | -$thisHref = $this->uri->makeUrl( $thisTo ); | |
| 397 | - | |
| 398 | -$linkTemplateShift = '<a title="__Add New__" class="hc-block hc-theme-tab-link hc-align-center" href="' . $thisHref . '">+</a>'; | |
| 399 | -$linkTemplateShiftMuted = '<a title="__Add New__" class="hc-block hc-theme-tab-link hc-align-center hc-muted3" href="' . $thisHref . '">+</a>'; | |
| 400 | -$isPrintView = $this->request->isPrintView(); | |
| 401 | - | |
| 402 | 387 | foreach( $viewCalendars as $id => $calendarView ){ |
| 403 | 388 | $row = array(); |
| 404 | 389 | |
| 405 | 390 | $this->shiftsDuration->reset(); |
| @@ -470,12 +455,9 @@ | ||
| 470 | 455 | } |
| 471 | 456 | } |
| 472 | 457 | } |
| 473 | 458 | |
| 474 | - if( $isPrintView ) $addOk = false; | |
| 475 | - | |
| 476 | 459 | if( $addOk ){ |
| 477 | -/* | |
| 478 | 460 | $link = $this->ui->makeAhref( $to, $label ) |
| 479 | 461 | ->tag('tab-link') |
| 480 | 462 | ->tag('align', 'center') |
| 481 | 463 | ->addAttr('title', '__Add New__') |
| @@ -483,15 +465,8 @@ | ||
| 483 | 465 | |
| 484 | 466 | if( $today > $date ){ |
| 485 | 467 | $link->tag('muted', 3); |
| 486 | 468 | } |
| 487 | -*/ | |
| 488 | - if( $today > $date ){ | |
| 489 | - $link = str_replace( array('{CID}', '{DATE}'), array($id, $date), $linkTemplateShiftMuted ); | |
| 490 | - } | |
| 491 | - else { | |
| 492 | - $link = str_replace( array('{CID}', '{DATE}'), array($id, $date), $linkTemplateShift ); | |
| 493 | - } | |
| 494 | 469 | |
| 495 | 470 | $cell[] = $link; |
| 496 | 471 | } |
| 497 | 472 | |
| @@ -597,19 +572,14 @@ | ||
| 597 | 572 | |
| 598 | 573 | $viewEmployees = array(); |
| 599 | 574 | foreach( $employees as $employee ){ |
| 600 | 575 | $label = $this->employeesPresenter->presentTitle( $employee ); |
| 576 | + | |
| 601 | 577 | $title = htmlspecialchars( $label ); |
| 602 | - | |
| 603 | 578 | $description = $employee->getDescription(); |
| 604 | 579 | if( strlen($description) ){ |
| 605 | - $imgpos = strpos( $description, '<img' ); | |
| 606 | - if( false !== $imgpos ){ | |
| 607 | - $label = $this->ui->makeList( array($label, $description) ); | |
| 608 | - } | |
| 609 | - else { | |
| 610 | - $title .= "\n" . htmlspecialchars( $description ); | |
| 611 | - } | |
| 580 | + $description = htmlspecialchars( $description ); | |
| 581 | + $title .= "\n" . $description; | |
| 612 | 582 | } |
| 613 | 583 | |
| 614 | 584 | $label = $this->ui->makeSpan( $label ) |
| 615 | 585 | ->tag( 'font-size', 4 ) |
| @@ -697,22 +667,8 @@ | ||
| 697 | 667 | // $header[] = NULL; |
| 698 | 668 | // } |
| 699 | 669 | |
| 700 | 670 | $rows = array(); |
| 701 | - | |
| 702 | -// link templates to speed things up | |
| 703 | -$toParams = array( | |
| 704 | - 'employee' => '{EID}', | |
| 705 | - 'date' => '{DATE}' | |
| 706 | -); | |
| 707 | -$thisTo = 'new'; | |
| 708 | -$thisTo = array( $thisTo, $toParams ); | |
| 709 | -$thisHref = $this->uri->makeUrl( $thisTo ); | |
| 710 | - | |
| 711 | -$linkTemplateShift = '<a title="__Add New__" class="hc-block hc-theme-tab-link hc-align-center" href="' . $thisHref . '">+</a>'; | |
| 712 | -$linkTemplateShiftMuted = '<a title="__Add New__" class="hc-block hc-theme-tab-link hc-align-center hc-muted3" href="' . $thisHref . '">+</a>'; | |
| 713 | -$isPrintView = $this->request->isPrintView(); | |
| 714 | - | |
| 715 | 671 | foreach( $viewEmployees as $id => $employeeView ){ |
| 716 | 672 | $row = array(); |
| 717 | 673 | |
| 718 | 674 | $this->shiftsDuration->reset(); |
| @@ -764,18 +720,28 @@ | ||
| 764 | 720 | } |
| 765 | 721 | |
| 766 | 722 | $comboId = 0 . '-' . $id; |
| 767 | 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 | + | |
| 768 | 739 | if( $today > $date ){ |
| 769 | - $link = str_replace( array('{EID}', '{DATE}'), array($id, $date), $linkTemplateShiftMuted ); | |
| 740 | + $link->tag('muted', 3); | |
| 770 | 741 | } |
| 771 | - else { | |
| 772 | - $link = str_replace( array('{EID}', '{DATE}'), array($id, $date), $linkTemplateShift ); | |
| 773 | - } | |
| 774 | 742 | |
| 775 | - if( ! $isPrintView ){ | |
| 776 | - $cell[] = $link; | |
| 777 | - } | |
| 743 | + $cell[] = $link; | |
| 778 | 744 | } |
| 779 | 745 | |
| 780 | 746 | $cell = $this->ui->makeList( $cell ) |
| 781 | 747 | ->gutter(1) |
| @@ -788,109 +754,8 @@ | ||
| 788 | 754 | // while( count($row) < 32 ){ |
| 789 | 755 | // $row[] = NULL; |
| 790 | 756 | // } |
| 791 | 757 | $rows[] = $row; |
| 792 | - } | |
| 793 | - | |
| 794 | - /* append calendars summary */ | |
| 795 | - $appendCalendars = $this->settings->get('datetime_summary_by_calendar'); | |
| 796 | - if( $appendCalendars && $shifts ){ | |
| 797 | - $calendarIds = array(); | |
| 798 | - foreach( $shifts as $shift ){ | |
| 799 | - $calendar = $shift->getCalendar(); | |
| 800 | - $calendarId = $calendar ? $calendar->getId() : 0; | |
| 801 | - if( ! $calendarId ) continue; | |
| 802 | - $calendarIds[ $calendarId ] = $calendarId; | |
| 803 | - } | |
| 804 | - | |
| 805 | - $calendars = $this->calendarsQuery->findManyById( $calendarIds ); | |
| 806 | - | |
| 807 | - $shiftsByCalendar = $shiftsByDate = array(); | |
| 808 | - foreach( $shifts as $shift ){ | |
| 809 | - $thisCalendar = $shift->getCalendar(); | |
| 810 | - if( ! $thisCalendar ) continue; | |
| 811 | - $shiftId = $shift->getId(); | |
| 812 | - $thisCalendarId = $thisCalendar->getId(); | |
| 813 | - $shiftsByCalendar[ $thisCalendarId ][ $shiftId ] = $shift; | |
| 814 | - | |
| 815 | - $start = $shift->getStart(); | |
| 816 | - $end = $shift->getEnd(); | |
| 817 | - | |
| 818 | - $startDayTime = substr($start, 8, 4); | |
| 819 | - $endDayTime = substr($end, 8, 4); | |
| 820 | - $shiftAllDay = ( (0 == $startDayTime) && (0 == $endDayTime) ) ? TRUE : FALSE; | |
| 821 | - | |
| 822 | - $this->t->setDateTimeDb( $end )->modify('-1 second'); | |
| 823 | - $shiftEndDate = $this->t->formatDateDb(); | |
| 824 | - | |
| 825 | - $this->t->setDateTimeDb( $start ); | |
| 826 | - $shiftStartDate = $this->t->formatDateDb(); | |
| 827 | - | |
| 828 | - $rexDate = $shiftStartDate; | |
| 829 | - while( $rexDate <= $shiftEndDate ){ | |
| 830 | - if( in_array($rexDate, $dates) ){ | |
| 831 | - $shiftsByDate[ $rexDate ][ $shiftId ] = $shift; | |
| 832 | - } | |
| 833 | - | |
| 834 | - if( ! $shiftAllDay ){ | |
| 835 | - break; | |
| 836 | - } | |
| 837 | - $this->t->modify( '+1 day' ); | |
| 838 | - $rexDate = $this->t->formatDateDb(); | |
| 839 | - } | |
| 840 | - } | |
| 841 | - | |
| 842 | - foreach( $calendars as $calendarId => $calendar ){ | |
| 843 | - $row = array(); | |
| 844 | - | |
| 845 | - $calendarView = $this->calendarsPresenter->presentTitle( $calendar ); | |
| 846 | - $title = htmlspecialchars( $calendar->getTitle() ); | |
| 847 | - $calendarView = $this->ui->makeSpan( $calendarView ) | |
| 848 | - ->addAttr( 'title', $title ) | |
| 849 | - ; | |
| 850 | - | |
| 851 | - $this->shiftsDuration->reset(); | |
| 852 | - foreach( $shiftsByCalendar[$calendarId] as $shift ){ | |
| 853 | - $this->shiftsDuration->add( $shift ); | |
| 854 | - } | |
| 855 | - | |
| 856 | - $outReport = $this->common->renderReport( $this->shiftsDuration, FALSE ); | |
| 857 | - $outReport = $this->ui->makeSpan( $outReport ) | |
| 858 | - ->tag('font-size', 2) | |
| 859 | - ; | |
| 860 | - $calendarView = $this->ui->makeList( array($calendarView, $outReport) ) | |
| 861 | - ->gutter(1) | |
| 862 | - ; | |
| 863 | - | |
| 864 | - $calendarView = $this->ui->makeBlock( $calendarView ) | |
| 865 | - ->tag('padding', 2) | |
| 866 | - ->tag('nowrap') | |
| 867 | - ; | |
| 868 | - $row[] = $calendarView; | |
| 869 | - | |
| 870 | - foreach( $dates as $date ){ | |
| 871 | - $cell = ''; | |
| 872 | - if( isset($shiftsByDate[$date]) ){ | |
| 873 | - $thisShifts = array_intersect_key( $shiftsByDate[$date], $shiftsByCalendar[$calendarId] ); | |
| 874 | - if( $thisShifts ){ | |
| 875 | - $this->shiftsDuration->reset(); | |
| 876 | - foreach( $thisShifts as $shift ){ | |
| 877 | - $this->shiftsDuration->add( $shift ); | |
| 878 | - } | |
| 879 | - $outReport = $this->common->renderReport( $this->shiftsDuration, false, true ); | |
| 880 | - $outReport = $this->ui->makeSpan( $outReport ) | |
| 881 | - ->tag('font-size', 2) | |
| 882 | - ; | |
| 883 | - $outReport = $this->ui->makeBlock( $outReport ) | |
| 884 | - ->tag('align', 'center') | |
| 885 | - ; | |
| 886 | - $cell = $outReport; | |
| 887 | - } | |
| 888 | - } | |
| 889 | - $row[] = $cell; | |
| 890 | - } | |
| 891 | - $rows[] = $row; | |
| 892 | - } | |
| 893 | 758 | } |
| 894 | 759 | |
| 895 | 760 | $out = $this->ui->makeTable( $header, $rows, FALSE ) |
| 896 | 761 | ->gutter(0) |