| @@ -4,9 +4,8 @@ | ||
| 4 | 4 | { |
| 5 | 5 | protected $ui = NULL; |
| 6 | 6 | protected $t = NULL; |
| 7 | 7 | protected $shiftTemplates = array(); |
| 8 | - protected $minimalisticWidget = 0; | |
| 9 | 8 | |
| 10 | 9 | public function __construct( |
| 11 | 10 | HC3_Hooks $hooks, |
| 12 | 11 | HC3_Ui $ui, |
| @@ -46,10 +45,8 @@ | ||
| 46 | 45 | if( $settings->get('shifttypes_show_title') ){ |
| 47 | 46 | $this->shiftTypes = $hooks->wrap( $shiftTypes )->findAll(); |
| 48 | 47 | } |
| 49 | 48 | $this->appQuery = $hooks->wrap($appQuery); |
| 50 | - | |
| 51 | - $this->minimalisticWidget = $settings->get('datetime_minimalistic_week'); | |
| 52 | 49 | } |
| 53 | 50 | |
| 54 | 51 | public function prepare( SH4_Shifts_Model $model, $iknow = array() ) |
| 55 | 52 | { |
| @@ -82,8 +79,10 @@ | ||
| 82 | 79 | |
| 83 | 80 | $end = $model->getEnd(); |
| 84 | 81 | $endView = $this->t->setDateTimeDb($end)->formatTime(); |
| 85 | 82 | |
| 83 | + $timeInDay = $startInDay . '-' . $endInDay; | |
| 84 | + | |
| 86 | 85 | $breakStartInDay = NULL; |
| 87 | 86 | $breakEndInDay = NULL; |
| 88 | 87 | $breakStart = $model->getBreakStart(); |
| 89 | 88 | $breakEnd = $model->getBreakEnd(); |
| @@ -126,8 +125,14 @@ | ||
| 126 | 125 | if( '0-86400' == $thisTimeInDay ){ |
| 127 | 126 | $hasAllDayType = $shiftType->getTitle(); |
| 128 | 127 | } |
| 129 | 128 | |
| 129 | + // if( $thisTimeInDay == $timeInDay ){ | |
| 130 | + // $timeView = $shiftType->getTitle(); | |
| 131 | + // $timeMiscView = $startView . ' - ' . $endView; | |
| 132 | + // break; | |
| 133 | + // } | |
| 134 | + | |
| 130 | 135 | $thisKey = $shiftType->getStart() . '-' . $shiftType->getEnd() . '-' . $shiftType->getBreakStart() . '-' . $shiftType->getBreakEnd(); |
| 131 | 136 | if( $thisKey == $shiftKey ){ |
| 132 | 137 | // $timeView = $shiftType->getTitle(); |
| 133 | 138 | $timeView = $this->shiftTypesPresenter->presentTitle( $shiftType ); |
| @@ -193,15 +198,10 @@ | ||
| 193 | 198 | |
| 194 | 199 | public function render( SH4_Shifts_Model $model, $iknow = array(), $hori = FALSE, $noLink = FALSE, $groupedQty = NULL ) |
| 195 | 200 | { |
| 196 | 201 | $out = $this->self->prepare( $model, $iknow ); |
| 197 | - if( $this->minimalisticWidget ){ | |
| 198 | - $ret = $this->self->renderPreparedMinimalistic( $model, $out, $iknow, $hori, $noLink, $groupedQty ); | |
| 199 | - } | |
| 200 | - else { | |
| 201 | - $ret = $this->self->renderPrepared( $model, $out, $iknow, $hori, $noLink, $groupedQty ); | |
| 202 | - } | |
| 203 | - return $ret; | |
| 202 | + $return = $this->self->renderPrepared( $model, $out, $iknow, $hori, $noLink, $groupedQty ); | |
| 203 | + return $return; | |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | public function renderCompact( SH4_Shifts_Model $model, $iknow = array(), $groupedQty = NULL ) |
| 207 | 207 | { |
| @@ -213,56 +213,19 @@ | ||
| 213 | 213 | $out = ' '; |
| 214 | 214 | |
| 215 | 215 | $label = null; |
| 216 | 216 | |
| 217 | + if( ! in_array('calendar', $iknow) ){ | |
| 218 | + $label = $calendar->getTitle(); | |
| 219 | + } | |
| 220 | + elseif( ! in_array('employee', $iknow) ){ | |
| 221 | + $label = $employee->getTitle(); | |
| 222 | + } | |
| 223 | + | |
| 217 | 224 | $what = $this->settings->get( 'datetime_compact_shift_label' ); |
| 218 | - if( 'abbr2' == $what ){ | |
| 219 | - $startInDay = $model->getStartInDay(); | |
| 220 | - $endInDay = $model->getEndInDay(); | |
| 221 | - | |
| 222 | - $breakStartInDay = NULL; | |
| 223 | - $breakEndInDay = NULL; | |
| 224 | - $breakStart = $model->getBreakStart(); | |
| 225 | - $breakEnd = $model->getBreakEnd(); | |
| 226 | - if( $breakStart && $breakEnd ){ | |
| 227 | - $this->t->setDateTimeDb( $breakStart ); | |
| 228 | - $breakStartTs = $this->t->getTimestamp(); | |
| 229 | - $this->t->setStartDay(); | |
| 230 | - $startDay = $this->t->getTimestamp(); | |
| 231 | - $breakStartInDay = $breakStartTs - $startDay; | |
| 232 | - | |
| 233 | - $this->t->setDateTimeDb( $breakEnd ); | |
| 234 | - $breakEndTs = $this->t->getTimestamp(); | |
| 235 | - $breakEndInDay = $breakEndTs - $startDay; | |
| 236 | - } | |
| 237 | - $shiftKey = $startInDay . '-' . $endInDay . '-' . $breakStartInDay . '-' . $breakEndInDay; | |
| 238 | - | |
| 239 | - reset( $this->shiftTypes ); | |
| 240 | - foreach( $this->shiftTypes as $shiftType ){ | |
| 241 | - $thisTimeInDay = $shiftType->getStart() . '-' . $shiftType->getEnd(); | |
| 242 | - | |
| 243 | - if( '0-86400' == $thisTimeInDay ){ | |
| 244 | - $hasAllDayType = $shiftType->getTitle(); | |
| 245 | - } | |
| 246 | - | |
| 247 | - $thisKey = $shiftType->getStart() . '-' . $shiftType->getEnd() . '-' . $shiftType->getBreakStart() . '-' . $shiftType->getBreakEnd(); | |
| 248 | - if( $thisKey == $shiftKey ){ | |
| 249 | - $label = $this->shiftTypesPresenter->presentTitle( $shiftType ); | |
| 250 | - break; | |
| 251 | - } | |
| 252 | - } | |
| 225 | + if( 'none' == $what ){ | |
| 226 | + $label = null; | |
| 253 | 227 | } |
| 254 | - else { | |
| 255 | - if( ! in_array('calendar', $iknow) ){ | |
| 256 | - $label = $calendar->getTitle(); | |
| 257 | - } | |
| 258 | - elseif( ! in_array('employee', $iknow) ){ | |
| 259 | - $label = $employee->getTitle(); | |
| 260 | - } | |
| 261 | - if( 'none' == $what ){ | |
| 262 | - $label = null; | |
| 263 | - } | |
| 264 | - } | |
| 265 | 228 | |
| 266 | 229 | if( null !== $label ){ |
| 267 | 230 | // abbreviation |
| 268 | 231 | $label = str_replace( '-', ' ', $label ); |
| @@ -301,8 +264,9 @@ | ||
| 301 | 264 | $out |
| 302 | 265 | ->tag('border') |
| 303 | 266 | ; |
| 304 | 267 | |
| 268 | + | |
| 305 | 269 | $conflicts = array(); |
| 306 | 270 | $currentUser = $this->auth->getCurrentUser(); |
| 307 | 271 | $currentUserId = $currentUser->getId(); |
| 308 | 272 | if( $currentUserId ){ |
| @@ -535,179 +499,9 @@ | ||
| 535 | 499 | |
| 536 | 500 | $title = $this->self->renderTitle( $model ); |
| 537 | 501 | $out |
| 538 | 502 | ->addAttr('title', $title) |
| 539 | - ; | |
| 540 | - | |
| 541 | - return $out; | |
| 542 | - } | |
| 543 | - | |
| 544 | - public function renderPreparedMinimalistic( SH4_Shifts_Model $model, $out, $iknow = array(), $hori = FALSE, $noLink = FALSE, $groupedQty = NULL ) | |
| 545 | - { | |
| 546 | - $colorFont = false; | |
| 547 | - $title = $this->self->renderTitle( $model ); | |
| 548 | - | |
| 549 | - $id = $model->getId(); | |
| 550 | - $calendar = $model->getCalendar(); | |
| 551 | - | |
| 552 | - $color = $calendar->getColor(); | |
| 553 | - $icons = $this->shiftsViewCommon->icons( $model, $iknow ); | |
| 554 | - | |
| 555 | - // conflicts | |
| 556 | - $conflicts = array(); | |
| 557 | - if( ! in_array('conflicts', $iknow) ){ | |
| 558 | - $currentUser = $this->auth->getCurrentUser(); | |
| 559 | - $currentUserId = $currentUser->getId(); | |
| 560 | - if( $currentUserId ){ | |
| 561 | - $conflicts = $this->conflicts->get( $model ); | |
| 562 | - } | |
| 563 | - } | |
| 564 | - | |
| 565 | - // highlight | |
| 566 | - $highlight = array('employee', 'time'); | |
| 567 | - | |
| 568 | - if( $calendar->isShift() ){ | |
| 569 | - foreach( $highlight as $hl ){ | |
| 570 | - if( ! array_key_exists($hl, $out) ){ | |
| 571 | - continue; | |
| 572 | - } | |
| 573 | - $out[$hl] = $this->ui->makeSpan( $out[$hl] ) | |
| 574 | - // ->tag('font-size', 4) | |
| 575 | - ->tag('font-style', 'bold') | |
| 576 | - ; | |
| 577 | - } | |
| 578 | - } | |
| 579 | - | |
| 580 | - $mute = array('timemisc'); | |
| 581 | - foreach( $mute as $mt ){ | |
| 582 | - if( ! array_key_exists($mt, $out) ){ | |
| 583 | - continue; | |
| 584 | - } | |
| 585 | - $out[$mt] = $this->ui->makeSpan( $out[$mt] ) | |
| 586 | - ->tag('font-size', 2) | |
| 587 | - ->tag('muted') | |
| 588 | - ; | |
| 589 | - } | |
| 590 | - | |
| 591 | - // $filter = array( 'time' => true, 'calendar' => true, 'employee' => true ); | |
| 592 | - // $out = array_intersect_key( $out, $filter ); | |
| 593 | - // if( isset($out['time']) && isset($out['calendar']) ){ | |
| 594 | - // $out['calendar'] = $this->ui->makeListInline( array($out['calendar'], $out['time']) )->gutter(1); | |
| 595 | - // unset( $out['time'] ); | |
| 596 | - // } | |
| 597 | - | |
| 598 | - $filter = array( 'calendar' => true, 'employee' => true ); | |
| 599 | - $out = array_intersect_key( $out, $filter ); | |
| 600 | - | |
| 601 | - $keys = array_keys($out); | |
| 602 | - $firstKey = array_shift($keys); | |
| 603 | - | |
| 604 | - if( NULL !== $groupedQty ){ | |
| 605 | - $out[$firstKey] = $groupedQty . ' x ' . $out[$firstKey]; | |
| 606 | - } | |
| 607 | - | |
| 608 | - // LINK | |
| 609 | - if( $id < 0 ) $noLink = TRUE; | |
| 610 | - | |
| 611 | - if( ! $noLink ){ | |
| 612 | - $to = 'shifts/' . $id; | |
| 613 | - $out[$firstKey] = $this->ui->makeAhref( $to, $out[$firstKey] ) | |
| 614 | - // ->tag('unstyled-link') | |
| 615 | - ->tag('block') | |
| 616 | - ->tag('print') | |
| 617 | - ->addAttr('class', 'sh4-widget-loader') | |
| 618 | - ->setAttr('title', $title) | |
| 619 | - ; | |
| 620 | - } | |
| 621 | - | |
| 622 | - $hori = true; | |
| 623 | - if( $hori ){ | |
| 624 | - $return = $this->ui->makeGrid(); | |
| 625 | - $width = '1-' . count($out); | |
| 626 | - foreach( $out as $o ){ | |
| 627 | - $return->add( $o, $width, 12 ); | |
| 628 | - } | |
| 629 | - $out = $return; | |
| 630 | - } | |
| 631 | - else { | |
| 632 | - $out = $this->ui->makeList($out)->gutter(0); | |
| 633 | - } | |
| 634 | - | |
| 635 | - $out = $this->ui->makeBlock( $out ) | |
| 636 | - ->padding(1) | |
| 637 | - // ->tag('font-size', 2); | |
| 638 | - ->tag('nowrap') | |
| 639 | - ; | |
| 640 | - | |
| 641 | - $out | |
| 642 | - ->tag('border') | |
| 643 | - ; | |
| 644 | - | |
| 645 | -// return $out; | |
| 646 | - | |
| 647 | - if( $conflicts ){ | |
| 648 | - $out | |
| 649 | - ->tag('border-color', 'red') | |
| 650 | - ; | |
| 651 | - } | |
| 652 | - else { | |
| 653 | - $out | |
| 654 | - ->tag('border-color', $color) | |
| 655 | - ; | |
| 656 | - } | |
| 657 | - | |
| 658 | - if( $model->isDraft() ){ | |
| 659 | - $out | |
| 660 | - ->addAttr('style', 'border-style: dashed;') | |
| 661 | - ; | |
| 662 | - } | |
| 663 | - | |
| 664 | - $finalOut = array(); | |
| 665 | - | |
| 666 | - if( $icons ){ | |
| 667 | - $iconsList = array(); | |
| 668 | - foreach( $icons as $field => $thisIcons ){ | |
| 669 | - $iconsList = array_merge( $iconsList, $thisIcons ); | |
| 670 | - } | |
| 671 | - | |
| 672 | - $icons = $this->ui->makeListInline( $iconsList )->gutter(1); | |
| 673 | - $icons = $this->ui->makeBlock($icons) | |
| 674 | - ->addAttr('style', 'position: absolute; right:.2em; top:.2em; z-index: 100;') | |
| 675 | - ; | |
| 676 | - $finalOut[] = $icons; | |
| 677 | - } | |
| 678 | - | |
| 679 | - $finalOut[] = $out; | |
| 680 | - | |
| 681 | - $out = $this->ui->makeBlock( $this->ui->makeCollection($finalOut) ) | |
| 682 | - ->addAttr('style', 'position: relative;') | |
| 683 | - ; | |
| 684 | - | |
| 685 | - $out | |
| 686 | - ->addAttr('class', 'hc-bg-lighten-2') | |
| 687 | - ; | |
| 688 | - | |
| 689 | - $out = $this->ui->makeBlock( $out ) | |
| 690 | - // ->tag('bgcolor', $color) | |
| 691 | - ; | |
| 692 | - | |
| 693 | - $out | |
| 694 | - ->tag('bgcolor', $color) | |
| 695 | - ; | |
| 696 | - | |
| 697 | - if( $model->isDraft() ){ | |
| 698 | - $out | |
| 699 | - ->addAttr('class', 'hc-bg-striped') | |
| 700 | - ; | |
| 701 | - $out | |
| 702 | - ->tag('muted', 1) | |
| 703 | - ; | |
| 704 | - } | |
| 705 | - | |
| 706 | - $out | |
| 707 | - // ->tag('font-size', 2) | |
| 708 | - ->setAttr('title', $title) | |
| 709 | 503 | ; |
| 710 | 504 | |
| 711 | 505 | return $out; |
| 712 | 506 | } |
| 713 | 507 | } |