PluginProbe
ShiftController Employee Shift Scheduling / 4.9.60
ShiftController Employee Shift Scheduling v4.9.60
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 / shifttypes / presenter.php

presenter.php in ShiftController Employee Shift Scheduling 4.9.60, at sh4/shifttypes/presenter.php

129 lines 3.3 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_ShiftTypes_Presenter
3 {
4 public $settings, $ui, $t;
5
6 public function __construct(
7 HC3_Hooks $hooks,
8 HC3_Settings $settings,
9 HC3_Time $t,
10 HC3_Ui $ui
11 )
12 {
13 $this->settings = $hooks->wrap($settings);
14 $this->ui = $ui;
15 $this->t = $t;
16 }
17
18 public function presentTitleTime( SH4_ShiftTypes_Model $model )
19 {
20 if( $model->getId() ){
21 $titleView = $this->presentTitle( $model );
22 $timeView = $this->presentTime( $model );
23 $timeView = $this->ui->makeSpan($timeView)
24 ->tag('font-size', 2)
25 ;
26 $return = $this->ui->makeList( array($titleView, $timeView) )
27 ->gutter(0)
28 ;
29 }
30 else {
31 $return = $this->presentTime( $model );
32 }
33 return $return;
34 }
35
36 public function presentTitle( SH4_ShiftTypes_Model $model )
37 {
38 $return = $model->getTitle();
39 return $return;
40 }
41
42 public function presentDuration( $duration )
43 {
44 $return = $duration;
45 $return = HC3_Time::formatPeriodInHours( $return );
46 return $return;
47 }
48
49 public function presentTime( SH4_ShiftTypes_Model $e, $start = NULL, $end = NULL )
50 {
51 $return = NULL;
52
53 $noBreak = $this->settings->get( 'shifttypes_nobreak' );
54
55 $start = (NULL === $start) ? $e->getStart() : $start;
56 $end = (NULL === $end) ? $e->getEnd() : $end;
57 $breakStart = $e->getBreakStart();
58 $breakEnd = $e->getBreakEnd();
59
60 $range = $e->getRange();
61
62 switch( $range ){
63 case SH4_ShiftTypes_Model::RANGE_DAYS:
64 if( $start != $end ){
65 $return = $start . ' - ' . $end . ' (' . '__Days__' . ')';
66 }
67 else {
68 $return = $start . ' (' . '__Days__' . ')';
69 }
70
71 break;
72
73 case SH4_ShiftTypes_Model::RANGE_HOURS:
74 if( (NULL === $start) && (NULL === $end) ){
75 $return = NULL;
76 // $return = '__Custom Time__';
77 }
78 elseif( (0 == $start) && (24*60*60 == $end) ){
79 $return = '__All Day__';
80 }
81 else {
82 $this->t->setDateDb( 20180102 );
83 $this->t->modify('+' . $start . ' seconds');
84 $startView = $this->t->formatTime();
85
86 $this->t->setDateDb( 20180102 );
87 $this->t->modify('+' . $end . ' seconds');
88 $endView = $this->t->formatTime();
89 if( $end > 24 * 60 * 60 ){
90 $endView = '&gt;' . $endView;
91 }
92
93 $return = $this->ui->makeListInline( array($startView, '-', $endView) )->gutter(1);
94
95 if( ! $noBreak ){
96 if( ! ((NULL === $breakStart) && (NULL === $breakEnd)) ){
97 if( $breakStart OR $breakEnd ){
98 $this->t->setDateDb( 20180102 );
99 if( $breakStart ){
100 $this->t->modify('+' . $breakStart . ' seconds');
101 }
102 $breakStartView = $this->t->formatTime();
103
104 $this->t->setDateDb( 20180102 );
105 if( $breakEnd ){
106 $this->t->modify('+' . $breakEnd . ' seconds');
107 }
108 $breakEndView = $this->t->formatTime();
109
110 $breakView = $this->ui->makeListInline( array('__Break__', $breakStartView, '-', $breakEndView) )
111 ->gutter(1)
112 ;
113 $breakView = $this->ui->makeSpan( $breakView )
114 ->tag('font-size', 2)
115 ->tag('muted', 2)
116 ;
117 $return = $this->ui->makeList( array($return, $breakView) )->gutter(0);
118 }
119 }
120 }
121
122 // $return = $startView . ' - ' . $endView;
123 }
124 break;
125 }
126
127 return $return;
128 }
129 }