PluginProbe
ShiftController Employee Shift Scheduling / 4.9.95
ShiftController Employee Shift Scheduling v4.9.95
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 / notifications / html / admin / view / index.php

index.php in ShiftController Employee Shift Scheduling 4.9.95, at sh4/notifications/html/admin/view/index.php

182 lines 4.6 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 #[AllowDynamicProperties]
3 class SH4_Notifications_Html_Admin_View_Index
4 {
5 public function __construct(
6 HC3_Hooks $hooks,
7
8 HC3_Ui $ui,
9 HC3_Ui_Layout1 $layout,
10
11 SH4_Calendars_Query $calendarsQuery,
12 SH4_Calendars_Presenter $calendarsPresenter,
13
14 SH4_Notifications_Service $notificationsService
15 )
16 {
17 $this->ui = $ui;
18 $this->layout = $layout;
19
20 $this->calendarsQuery = $hooks->wrap( $calendarsQuery );
21 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
22
23 $this->notificationsService = $hooks->wrap( $notificationsService );
24 $this->self = $hooks->wrap($this);
25 }
26
27 public function render( $calendarId )
28 {
29 $calendar = $this->calendarsQuery->findById( $calendarId );
30
31 $entries = $this->notificationsService->findAll();
32
33 $tableColumns = $this->listingColumns();
34
35 $keys = array_keys( $tableColumns );
36 $firstKey = array_shift( $keys );
37
38 $tableRows = array();
39 foreach( $entries as $id => $e ){
40 $row = $this->listingCell( $calendar, $id, $e );
41
42 // actions for first cell
43 $actions = array();
44 $itemMenu = $this->listingCellMenu( $calendar, $id, $e );
45 foreach( $itemMenu as $item ){
46 // form
47 if( count($item) == 3 ){
48 list( $href, $formContent, $btnLabel ) = $item;
49 $btn = $this->ui->makeInputSubmit($btnLabel)
50 ->tag('nice-link')
51 ;
52 $formContent = $formContent ? $this->ui->makeListInline( array($formContent, $btn) ) : $btn;
53 $item = $this->ui->makeForm( $href, $formContent );
54 if( ! $item ){
55 continue;
56 }
57 }
58 // link
59 else {
60 list( $href, $label ) = $item;
61 $item = $this->ui->makeAhref( $href, $label );
62 if( ! $item ){
63 continue;
64 }
65 $item->tag('nice-link');
66 }
67 $actions[] = $item;
68 }
69
70 if( $actions ){
71 $actions = $this->ui->makeListInline($actions)
72 ->gutter(1)
73 ->separated()
74 ;
75 $row[$firstKey] = $this->ui->makeList( array($row[$firstKey], $actions) )->gutter(1);
76
77 $row[$firstKey] = $this->ui->makeBlock( $row[$firstKey] )
78 ->tag('padding', 2)
79 ->tag('border')
80 ;
81 }
82
83 $tableRows[] = $row;
84 }
85
86 // $content = $this->ui->makeTable( $tableColumns, $tableRows );
87
88 $content = $this->ui->makeGrid();
89 foreach( $tableRows as $r ){
90 $r = array_shift( $r );
91 $content->add( $r, 4, 12 );
92 }
93
94 $this->layout
95 ->setContent( $content )
96 ->setBreadcrumb( $this->self->breadcrumb($calendar) )
97 ->setHeader( $this->self->header($calendar) )
98 ->setMenu( $this->self->menu($calendar) )
99 ;
100
101 $out = $this->layout->render();
102 return $out;
103 }
104
105 public function menu( $calendar )
106 {
107 $return = array();
108 return $return;
109 }
110
111 public function header( $calendar )
112 {
113 $out = '__Notifications__';
114 return $out;
115 }
116
117 public function breadcrumb( SH4_Calendars_Model $calendar )
118 {
119 $calendarId = $calendar->getId();
120 $calendarTitle = $this->calendarsPresenter->presentTitle( $calendar );
121
122 $return = array();
123 $return['admin'] = array( 'admin', '__Administration__' );
124 $return['calendars'] = array( 'admin/calendars', '__Calendars__' );
125 $return['calendars/edit'] = array( 'admin/calendars/' . $calendarId, $calendarTitle );
126
127 return $return;
128 }
129
130 public function listingColumns()
131 {
132 $return = array(
133 'title' => '__Notification__',
134 );
135 return $return;
136 }
137
138 public function listingCell( SH4_Calendars_Model $calendar, $notificationId, $model )
139 {
140 $return = array();
141
142 $titleView = $model->getTitle();
143 // $titleView = $notificationId;
144
145 $titleView = $this->ui->makeSpan( $titleView )
146 ->tag('font-size', 4)
147 // ->tag('font-style', 'bold')
148 ;
149
150 if( $this->notificationsService->isOn($calendar, $notificationId) ){
151 $titleView
152 ->tag('font-style', 'bold')
153 ;
154 }
155 else {
156 $titleView
157 ->tag('font-style', 'line-through')
158 ;
159 }
160
161 $return['title'] = $titleView;
162
163 return $return;
164 }
165
166 public function listingCellMenu( SH4_Calendars_Model $calendar, $notificationId, $model )
167 {
168 $return = array();
169 $calendarId = $calendar->getId();
170
171 $return['edit'] = array( 'admin/notifications/' . $calendarId . '/' . $notificationId, '__Edit__' );
172
173 if( $this->notificationsService->isOn($calendar, $notificationId) ){
174 $return['disable'] = array( 'admin/notifications/' . $calendarId . '/' . $notificationId . '/disable', NULL, '__Disable__' );
175 }
176 else {
177 $return['enable'] = array( 'admin/notifications/' . $calendarId . '/' . $notificationId . '/enable', NULL, '__Enable__' );
178 }
179
180 return $return;
181 }
182 }