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 / calendars / html / admin / view / sort.php

sort.php in ShiftController Employee Shift Scheduling 4.9.85, at sh4/calendars/html/admin/view/sort.php

168 lines 3.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_Calendars_Html_Admin_View_Sort
4 {
5 public function __construct(
6 HC3_Hooks $hooks,
7
8 HC3_Post $post,
9 HC3_Ui $ui,
10 HC3_Ui_Layout1 $layout,
11 HC3_Request $request,
12
13 SH4_Calendars_Presenter $presenter,
14 SH4_Calendars_Query $query,
15 SH4_Calendars_Command $command
16 )
17 {
18 $this->request = $request;
19 $this->ui = $ui;
20 $this->layout = $layout;
21 $this->post = $hooks->wrap($post);
22
23 $this->presenter = $hooks->wrap($presenter);
24 $this->command = $hooks->wrap($command);
25 $this->query = $hooks->wrap($query);
26
27 $this->self = $hooks->wrap($this);
28 }
29
30 public function post()
31 {
32 $entries = $this->query->findActive();
33
34 $action = $this->post->get( 'action' );
35
36 foreach( $entries as $e ){
37 $id = $e->getId();
38 if( ! $id ){
39 continue;
40 }
41
42 if( 'reset' == $action ){
43 $thisSortOrder = 0;
44 }
45 else {
46 $thisSortOrder = $this->post->get( 'sortorder_' . $id );
47 }
48
49 $this->command->changeSortOrder( $e, $thisSortOrder );
50 }
51
52 $ret = array( 'admin/calendars', '__Sort Order Updated__' );
53 return $ret;
54 }
55
56 public function get()
57 {
58 $entries = $this->query->findActive();
59
60 $tableColumns = $this->self->listingColumns();
61
62 $tableRows = array();
63 foreach( $entries as $e ){
64 $row = $this->self->listingCell($e);
65 $tableRows[] = $row;
66 }
67
68 $buttons = array();
69 $buttons[] = $this->ui->makeInputSubmit( '__Save Sort Order__', 'action' )
70 ->setAttr( 'value', 'set' )
71 ->tag('primary')
72 ;
73 $buttons[] = $this->ui->makeInputSubmit( '__Reset To Defaults__', 'action' )
74 ->setAttr( 'value', 'reset' )
75 ->tag('secondary')
76 ;
77 $buttons = $this->ui->makeListInline( $buttons );
78
79 $rowSubmit = array();
80 $rowSubmit['sortorder'] = $buttons;
81
82 $tableRows[] = $rowSubmit;
83
84 $content = $this->ui->makeTable( $tableColumns, $tableRows );
85
86 $form = $this->ui->makeForm(
87 'admin/calendars/sort',
88 $content
89 );
90
91 $this->layout
92 ->setContent( $form )
93 ->setBreadcrumb( $this->self->breadcrumb() )
94 ->setHeader( $this->self->header() )
95 ->setMenu( $this->self->menu() )
96 ;
97
98 $out = $this->layout->render();
99 return $out;
100 }
101
102 public function breadcrumb()
103 {
104 $return = array();
105 $return['admin'] = array( 'admin', '__Administration__' );
106 $return['admin/calendars'] = array( 'admin/calendars', '__Calendars__' );
107 return $return;
108 }
109
110 public function menu()
111 {
112 $return = array();
113 return $return;
114 }
115
116 public function header()
117 {
118 $out = '__Sort Order__';
119 return $out;
120 }
121
122 public function listingColumns()
123 {
124 $return = array(
125 'title' => '__Name__',
126 'sortorder' => '__Sort Order__',
127 );
128 return $return;
129 }
130
131 public function listingCell( $model )
132 {
133 $return = array();
134 $id = $model->getId();
135
136 // $titleView = $model->getTitle();
137 $titleView = $this->presenter->presentTitle( $model );
138
139 if( $model->isArchived() ){
140 $titleView = $this->ui->makeSpan($titleView)
141 ->tag('font-style', 'line-through')
142 ;
143 }
144
145 // $titleView = $this->ui->makeSpan( $titleView )
146 // ->tag('font-size', 4)
147 // ->tag('font-style', 'bold')
148 // ;
149 $return['title'] = $titleView;
150
151 if( $id ){
152 $sortOrder = $model->getSortOrder();
153 $sortOrderView = $this->ui->makeInputText( 'sortorder_' . $id, NULL, $sortOrder );
154 $sortOrderView = $this->ui->makeBlock( $sortOrderView )
155 ->addAttr( 'style', 'width: 4em;' )
156 ;
157 $return['sortorder'] = $sortOrderView;
158 }
159
160 return $return;
161 }
162
163 public function listingCellMenu( $model )
164 {
165 $return = array();
166 return $return;
167 }
168 }