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 / feed / html / admin / feed.php

feed.php in ShiftController Employee Shift Scheduling 4.9.26, at sh4/feed/html/admin/feed.php

198 lines 6.1 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_Feed_Html_Admin_Feed
3 {
4 public function __construct(
5 HC3_Hooks $hooks,
6 HC3_Ui $ui,
7 HC3_Ui_Layout1 $layout,
8
9 HC3_Time $t,
10
11 HC3_Auth $auth,
12 HC3_IPermission $permission,
13 HC3_UriAction $uriAction,
14
15 SH4_Calendars_Permissions $calendarsPermissions,
16 SH4_Calendars_Query $calendarsQuery,
17 SH4_Calendars_Presenter $calendarsPresenter,
18 SH4_Employees_Presenter $employeesPresenter,
19 SH4_App_Query $appQuery,
20
21 SH4_Schedule_Html_View_Common $scheduleViewCommon
22 )
23 {
24 $this->self = $hooks->wrap($this);
25
26 $this->ui = $ui;
27 $this->layout = $layout;
28 $this->uriAction = $uriAction;
29 $this->t = $t;
30
31 $this->auth = $hooks->wrap( $auth );
32 $this->permission = $hooks->wrap($permission);
33 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
34 $this->employeesPresenter = $hooks->wrap( $employeesPresenter );
35
36 $this->calendarsPermissions = $hooks->wrap( $calendarsPermissions );
37 $this->calendarsQuery = $hooks->wrap( $calendarsQuery );
38
39 $this->appQuery = $hooks->wrap( $appQuery );
40 $this->scheduleViewCommon = $hooks->wrap( $scheduleViewCommon );
41 }
42
43 public function render()
44 {
45 $currentUser = $this->auth->getCurrentUser();
46 $token = $this->auth->getTokenByUser( $currentUser );
47
48 $out = array();
49
50 $calendarsAsManager = $this->appQuery->findCalendarsManagedByUser( $currentUser );
51 $calendarsAsViewer = $this->appQuery->findCalendarsViewedByUser( $currentUser );
52
53 $calendarsAsEmployee = array();
54 $meEmployee = $this->appQuery->findEmployeeByUser( $currentUser );
55 if( $meEmployee ){
56 $employeeCalendars = $this->appQuery->findCalendarsForEmployee( $meEmployee );
57 foreach( $employeeCalendars as $thisCalendar ){
58 $thisCalendarId = $thisCalendar->getId();
59 $perms = array(
60 'employee_view_own_publish',
61 'employee_view_own_draft',
62 'employee_view_others_publish',
63 'employee_view_others_draft',
64 'employee_view_open_publish',
65 'employee_view_open_draft'
66 );
67
68 reset( $perms );
69 foreach( $perms as $perm ){
70 $thisPerm = $this->calendarsPermissions->get($thisCalendar, $perm);
71 if( $thisPerm ){
72 $calendarsAsEmployee[ $thisCalendarId ] = $thisCalendar;
73 break;
74 }
75 }
76 }
77 }
78
79 // links
80 $links = array();
81
82 $allCalendars = $calendarsAsManager + $calendarsAsViewer + $calendarsAsEmployee;
83 $allCalendarsIds = array_keys( $allCalendars );
84 $calendars = $this->calendarsQuery->findManyActiveById( $allCalendarsIds );
85
86 // if( $meEmployee ){
87 // $meEmployeeId = $meEmployee->getId();
88 // $links[] = array( 'feed/' . $token . '/x/' . $meEmployeeId, '__My Schedule__' );
89 // }
90
91 if( $calendarsAsManager ){
92 $links[] = array( 'feed/' . $token, '__All From Today__' );
93 $links[] = array( 'json/' . $token, '__All From Today__' );
94
95 $links[] = array( 'feed/' . $token . '/s', '__All From Today__' . ': ' . '__Shifts__' );
96 $links[] = array( 'json/' . $token . '/t', '__All From Today__' . ': ' . '__Time Off__' );
97
98 $links[] = array( 'feed/' . $token . '/x/x/20181123/20190101', '__From Date__' . ' / ' . '__To Date__' );
99 $links[] = array( 'json/' . $token . '/x/x/20181123/20190101', '__From Date__' . ' / ' . '__To Date__' );
100
101 foreach( $calendars as $calendar ){
102 $calendarId = $calendar->getId();
103 $calendarTitle = $this->calendarsPresenter->presentTitle( $calendar );
104 $links[] = array( 'feed/' . $token . '/' . $calendarId, $calendarTitle );
105 $links[] = array( 'json/' . $token . '/' . $calendarId, $calendarTitle );
106 }
107
108 $employees = $this->scheduleViewCommon->findAllEmployees();
109 if( count($employees) > 1 ){
110 foreach( $employees as $employee ){
111 $employeeId = $employee->getId();
112 $employeeTitle = $this->employeesPresenter->presentTitle( $employee );
113 $links[] = array( 'feed/' . $token . '/x/' . $employeeId, $employeeTitle );
114 $links[] = array( 'json/' . $token . '/x/' . $employeeId, $employeeTitle );
115 }
116 }
117 }
118
119 $note = '__Here is the automatic CSV/JSON feed of the shifts that can be used with other 3rd party applications.__';
120 $out[] = $note;
121
122 $timezone = $this->t->getTimezone();
123 $timezoneView = $timezone->getName();
124
125 $timezoneLabel = '__Timezone__';
126 $timezoneLabel = $this->ui->makeBlock( $timezoneLabel )
127 ->tag('muted')
128 ->tag('font-size', 2)
129 ;
130 $timezoneView = $this->ui->makeListInline( array($timezoneLabel, $timezoneView) );
131 $timezoneView = $this->ui->makeBlock( $timezoneView )
132 ->tag('border')
133 ->tag('padding', 2)
134 ;
135
136 $out[] = $timezoneView;
137
138 // online
139 $thisOut = array();
140
141 $linksView = array();
142 reset( $links );
143 foreach( $links as $linkArray ){
144 list( $to, $linkLabel ) = $linkArray;
145 // $link = $this->uriAction->makeUrl( $to );
146 $link = site_url( '/?hcs=sh4&hca=' . $to );
147 $linkView = $this->ui->makeInputText( NULL, $linkLabel, $link )
148 ->addAttr( 'onclick', 'this.focus(); this.select();' )
149 ;
150 $linksView[] = $linkView;
151 }
152 $linksView = $this->ui->makeList( $linksView );
153 $thisOut[] = $linksView;
154
155
156 $thisOut = $this->ui->makeList( $thisOut );
157 $out[] = $thisOut;
158
159 if( class_exists('SH4_CFields_Model') ){
160 $f = ShiftController4::$instance->root();
161 $cfieldsQuery = $f->make('SH4_CFields_Query');
162 $cfields = $cfieldsQuery->read();
163 if( $cfields ){
164 $moreOut = '<p><strong>__Optional Arguments__</strong></p>';
165 $moreOut .= '<p>';
166 foreach( $cfields as $cfield ){
167 $moreOut .= '<em>' . $cfield->getName() . '</em> (' . $cfield->getLabel() . ')<br>';
168 }
169 $moreOut .= '</p>';
170 }
171 $out[] = $moreOut;
172 }
173
174 $out = $this->ui->makeList( $out )->gutter(3);
175
176 $this->layout
177 ->setContent( $out )
178 ->setBreadcrumb( $this->self->breadcrumb() )
179 ->setHeader( $this->self->header() )
180 ;
181
182 $out = $this->layout->render();
183 return $out;
184 }
185
186 public function header()
187 {
188 $out = '__Shifts Feed__';
189 return $out;
190 }
191
192 public function breadcrumb()
193 {
194 $return = array();
195 $return['admin'] = array( 'admin', '__Administration__' );
196 return $return;
197 }
198 }