PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
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 / shifts / view / common.php

common.php in ShiftController Employee Shift Scheduling 4.9.85, at sh4/shifts/view/common.php

216 lines 5.9 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 interface SH4_Shifts_View_ICommon
3 {
4 public function breadcrumb( SH4_Shifts_Model $model );
5 public function menu( SH4_Shifts_Model $model );
6 public function icons( SH4_Shifts_Model $model, $iknow = array() );
7 }
8
9 #[AllowDynamicProperties]
10 class SH4_Shifts_View_Common implements SH4_Shifts_View_ICommon
11 {
12 public function __construct(
13 HC3_Hooks $hooks,
14 HC3_Settings $settings,
15 HC3_Auth $auth,
16 HC3_Ui $ui,
17 SH4_Shifts_Presenter $presenter,
18 SH4_Shifts_Conflicts $conflicts
19 )
20 {
21 $this->self = $hooks->wrap($this);
22 $this->ui = $ui;
23 $this->presenter = $hooks->wrap($presenter);
24 $this->auth = $hooks->wrap( $auth );
25 $this->conflicts = $hooks->wrap( $conflicts );
26 $this->settings = $hooks->wrap( $settings );
27 }
28
29 public function breadcrumb( SH4_Shifts_Model $model )
30 {
31 $id = $model->getId();
32
33 $return = array();
34
35 // schedule link
36 $scheduleLink = HC3_Session::instance()->getUserdata( 'scheduleLink' );
37 if( ! $scheduleLink ){
38 $scheduleLink = array( 'schedule', array() );
39 }
40 // $return['schedule'] = array( $scheduleLink, '__Schedule__' );
41
42 $label = $this->presenter->presentTitle($model);
43 $return['schedule/' . $id ] = array( 'shifts/' . $id , $label );
44 // $return['schedule/' . $id ] = $label;
45
46 return $return;
47 }
48
49 public function bulkMenu( array $models )
50 {
51 $ret = null;
52
53 $menu = array();
54 $skipMulti = array(
55 'employee_pickup',
56 'employee_assign',
57 // 'employee_pickup/reset',
58 // 'employee_pickup/request'
59 );
60
61 foreach( $models as $m ){
62 $fullMenu = $this->self->menu( $m );
63 foreach( $fullMenu as $k0 => $thisMenu ){
64 foreach( $thisMenu as $k1 => $actionArray ){
65 $k = $k0 . '_' . $k1;
66 if( (count($models) > 1) && (! in_array($k, $skipMulti)) ){
67 $thisK = $k . ':' . $m->getId();
68 }
69 else {
70 $thisK = $k;
71 }
72 $menu[$thisK] = $actionArray;
73 }
74 }
75 }
76
77 if( ! $menu ) return $ret;
78
79 $id = $m->getId();
80
81 $menu = $this->ui->helperActionsFromArray( $menu, true );
82 $menu = $this->ui->makeCollection( $menu );
83
84 $checkbox = $this->ui->makeInputCheckbox( 'id[]', null, $id, true );
85 $checkbox = $this->ui->makeBlock( $checkbox )
86 ->addAttr('class', 'sh4-shift-checker')
87 ->addAttr('style', 'display: none;')
88 ;
89 $ret = $this->ui->makeCollection( array($checkbox, $menu) );
90
91 return $ret;
92 }
93
94 public function menu( SH4_Shifts_Model $model )
95 {
96 $id = $model->getId();
97
98 $return = array();
99
100 $conflicts = $this->conflicts->get( $model );
101 if( $conflicts ){
102 $label = '__View Conflicts__';
103 $return['datetime']['conflicts'] = array( 'shifts/' . $id . '/conflicts', $label );
104 }
105 $return['datetime']['time'] = array( 'shifts/' . $id . '/time', '__Change Time__' );
106 $return['datetime']['date'] = array( 'shifts/' . $id . '/date', '__Change Date__' );
107
108 if( $model->isOpen() ){
109 $return['employee']['assign'] = array(
110 array( 'shifts/--ID--/employee', $id ),
111 '__Assign__'
112 );
113 }
114 else {
115 $return['employee']['change'] = array(
116 array( 'shifts/--ID--/employee', $id ),
117 '__Change Employee__'
118 );
119 $return['employee']['change2'] = array(
120 array( 'shifts/--ID--/employeecopy', $id ),
121 '__Copy To Another Employee__'
122 );
123 $return['employee']['unassign'] = array(
124 'shifts/' . $id . '/employee/0',
125 null,
126 '__Unassign__'
127 );
128 }
129
130 if( $model->isDraft() ){
131 $confirm = $this->settings->get('shifts_confirm_publish') ? true : false;
132 $return['status']['publish'] = array( 'shifts/' . $id . '/publish', NULL, '__Publish__', $confirm );
133 }
134 else {
135 $noDraft = $this->settings->get('shifts_no_draft') ? TRUE : FALSE;
136 if( ! $noDraft ){
137 $return['status']['unpublish'] = array( 'shifts/' . $id . '/unpublish', NULL, '__Unpublish__' );
138 // $return['status']['unpublish2'] = array( 'shifts/' . $id . '/unpublish','<input type="text"><button type="submit">unbub</button', '' );
139 }
140 }
141 $return['status']['delete'] = array( 'shifts/' . $id . '/delete', NULL, '__Delete__' );
142
143 return $return;
144 }
145
146 public function icons( SH4_Shifts_Model $model, $iknow = array() )
147 {
148 $return = array();
149 $calendar = $model->getCalendar();
150
151 if( $model->isDraft() ){
152 if( ! $calendar->isAvailability() ){
153 $sign = $this->ui->makeBlock('?')
154 ->tag('align', 'center')
155 ->addAttr('style', 'width: 1em;')
156 ->tag('border')
157 // ->tag('border-color', 'gray' )
158 // ->tag('bgcolor', 'silver')
159 ->tag('bgcolor', 'gray')
160 ->tag('color', 'white')
161 ->tag('muted', 1)
162 ->addAttr('title', '__Draft__')
163 ;
164 if( ! isset($return['status']) ){
165 $return['status'] = array();
166 }
167 $return['status'][] = $sign;
168 }
169 }
170
171 if( ! in_array('conflicts', $iknow) ){
172 $conflicts = array();
173 $currentUser = $this->auth->getCurrentUser();
174 $currentUserId = $currentUser->getId();
175 if( $currentUserId ){
176 $conflicts = $this->conflicts->get( $model );
177 }
178
179 if( $conflicts ){
180 $sign = $this->ui->makeBlock('!')
181 ->tag('align', 'center')
182 ->addAttr('style', 'width: 1em;')
183 ->tag('border')
184 ->tag('border-color', 'red' )
185 ->tag('bgcolor', 'lightred')
186 ->tag('muted', 1)
187 ->addAttr('title', '__Conflicts__')
188 ;
189 if( ! isset($return['datetime']) ){
190 $return['datetime'] = array();
191 }
192 $return['datetime'][] = $sign;
193 }
194 }
195
196 if( $model->isOpen() ){
197 $sign = $this->ui->makeBlock('!')
198 ->tag('align', 'center')
199 ->addAttr('style', 'width: 1em;')
200 ->tag('border')
201 // ->tag('border-color', 'orange' )
202 // ->tag('bgcolor', 'yellow')
203 ->tag('bgcolor', 'orange')
204 ->tag('color', 'white')
205 ->tag('muted', 1)
206 ->addAttr('title', '__Open Shift__')
207 ;
208 if( ! isset($return['employee']) ){
209 $return['employee'] = array();
210 }
211 $return['employee'][] = $sign;
212 }
213
214 return $return;
215 }
216 }