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 / shifttypes / presenter.php

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

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