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 / api / html / view.html.php

view.html.php in ShiftController Employee Shift Scheduling 4.9.26, at sh4/api/html/view.html.php

300 lines 6.2 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
3 $app = 'sh4-rest';
4
5 if( isset($_POST[$app . '_submit']) ){
6 if( isset($_POST[$app]) ){
7 foreach( (array)$_POST[$app] as $key => $value ){
8 $option_name = $app . '_' . $key;
9 $value = sanitize_text_field( $value );
10 update_option( $option_name, $value );
11 }
12 }
13
14 if( ! isset($_POST[$app]['enabled']) ){
15 $k = $app . '_enabled';
16 $value = 0;
17 update_option( $k, $value );
18 }
19 }
20
21 // $this->initOption();
22
23 $current = array();
24 $current['enabled'] = get_option( $app . '_enabled', 1 );
25 $current['auth_code'] = get_option( $app . '_auth_code', '' );
26
27 $startUrl = '/shiftcontroller/v4/';
28
29 // spaghetti starts here
30 ?>
31
32 <form method="post" action="">
33 <?php settings_fields( $app ); ?>
34 <?php //do_settings_sections( $this->app ); ?>
35
36 <label>
37 <?php $checked = $current['enabled'] ? ' checked' : ''; ?>
38 <input type="checkbox" name="<?php echo $app; ?>[enabled]" value="1" <?php echo $checked; ?>/>
39 Enable
40 </label>
41 </br/>
42
43 <label>
44 AuthCode<br>
45 <input type="text" name="<?php echo $app; ?>[auth_code]" value="<?php echo esc_attr( $current['auth_code'] ); ?>" />
46 </label>
47 </br/>
48
49 <p>
50 <input name="<?php echo $app; ?>_submit" type="submit" class="button-primary" value="Save" />
51 </p>
52 </form>
53
54 <?php if( ! $current['enabled'] ) return; ?>
55
56
57 <style>
58 .sh4-code {
59 display: block; padding: 1em; border: #999 1px solid; margin-bottom: 1em;
60 }
61 </style>
62
63 <h3 class="hc-underline">Get Shifts</h3>
64 <?php
65 $url = $startUrl . 'shifts';
66 $fullUrl = get_rest_url( NULL, $url );
67 ?>
68
69 <p>
70 <strong>
71 GET <?php echo $url; ?>
72 </strong>
73 </p>
74
75 <p>
76 <strong>__Headers__</strong>
77 </p>
78
79 <p>
80 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
81 </p>
82
83 <p>
84 <strong>__Arguments__</strong>
85 </p>
86
87 <p>
88 <strong>calendar_id</strong> (__Calendar Id__)<br>
89 <strong>employee_id</strong> (__Employee Id__)<br>
90 <strong>from</strong> (__From Date__, YYYYMMDD / __From Date Time__, YYYYMMDDHHMM)<br>
91 <strong>to</strong> (__To Date__, YYYYMMDD / __To Date Time__, YYYYMMDDHHMM)<br>
92 <strong>status_id</strong> (publish, draft)<br>
93 </p>
94
95 <?php if( class_exists('SH4_CFields_Model') ) : ?>
96 <?php
97 $f = ShiftController4::$instance->root();
98 $cfieldsQuery = $f->make('SH4_CFields_Query');
99 $cfields = $cfieldsQuery->read();
100 ?>
101 <?php if( $cfields ) : ?>
102 <p>
103 <strong>__Optional Arguments__</strong>
104 </p>
105
106 <p>
107 <?php foreach( $cfields as $cfield ) : ?>
108 <em><?php echo $cfield->getName(); ?></em> (<?php echo $cfield->getLabel(); ?>)<br>
109 <?php endforeach; ?>
110 </p>
111 <?php endif; ?>
112 <?php endif; ?>
113
114 <p>
115 <strong>__Examples__</strong>
116 </p>
117
118 <pre class="sh4-code">
119 GET <?php echo $fullUrl; ?>
120 </pre>
121
122 <pre class="sh4-code">
123 GET <?php echo $fullUrl; ?>?calendar_id=11&from=20210224
124 </pre>
125
126 <pre class="sh4-code">
127 GET <?php echo $fullUrl; ?>?from=202102240900&to=202102241430&status_id=draft
128 </pre>
129
130
131 <h3 class="hc-underline">__Get Shift__</h3>
132 <?php
133 $url = $startUrl . 'shifts/&lt;id&gt;';
134 $fullUrl = get_rest_url( NULL, $url );
135
136 $url2 = $startUrl . 'shifts';
137 $fullUrl2 = get_rest_url( NULL, $url2 );
138 ?>
139
140 <p>
141 <strong>
142 GET <?php echo $url; ?>
143 </strong>
144 </p>
145
146 <p>
147 <strong>__Headers__</strong>
148 </p>
149
150 <p>
151 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
152 </p>
153
154 <p>
155 <strong>__Examples__</strong>
156 </p>
157
158 <pre class="sh4-code">
159 GET <?php echo $fullUrl2; ?>/123
160 </pre>
161
162 <h3 class="hc-underline">__Delete Shift__</h3>
163 <?php
164 $url = $startUrl . 'shifts/&lt;id&gt;';
165 $fullUrl = get_rest_url( NULL, $url );
166
167 $url2 = $startUrl . 'shifts';
168 $fullUrl2 = get_rest_url( NULL, $url2 );
169 ?>
170
171 <p>
172 <strong>
173 DELETE <?php echo $url; ?>
174 </strong>
175 </p>
176
177 <p>
178 <strong>__Headers__</strong>
179 </p>
180
181 <p>
182 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
183 </p>
184
185 <p>
186 <strong>__Examples__</strong>
187 </p>
188
189 <pre class="sh4-code">
190 DELETE <?php echo $fullUrl2; ?>/123
191 </pre>
192
193 <h3 class="hc-underline">__Create Shift__</h3>
194 <?php
195 $url = $startUrl . 'shifts';
196 $fullUrl = get_rest_url( NULL, $url );
197 ?>
198
199 <p>
200 <strong>
201 POST <?php echo $url; ?>
202 </strong>
203 </p>
204
205 <p>
206 <strong>__Headers__</strong>
207 </p>
208
209 <p>
210 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
211 </p>
212
213 <p>
214 <strong>__Arguments__</strong>
215 </p>
216
217 <p>
218 <strong>calendar_id</strong> (__Calendar Id__)<br>
219 <strong>employee_id</strong> (__Employee Id__)<br>
220 <strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM)<br>
221 <strong>end</strong> (__End Date Time__, YYYYMMDDHHMM)<br>
222 <strong>status_id</strong> (publish, draft)<br>
223 <strong>conflict</strong> (__Set to 1 to allow creation of shifts with conflicts__) <em>optional</em><br>
224 </p>
225
226 <p>
227 <strong>Examples</strong>
228 </p>
229
230 <pre class="sh4-code">
231 POST <?php echo $fullUrl; ?>
232
233 calendar_id: 11
234 employee_id: 22
235 start: 202102240800
236 end: 202102241430
237 status_id: publish
238 </pre>
239
240 <p>
241 __If success, it returns the id of the new shift. Otherwise error messages will be given.__
242 </p>
243
244
245 <h3 class="hc-underline">__Update Shift__</h3>
246 <?php
247 $url = $startUrl . 'shifts/&lt;id&gt;';
248 $fullUrl = get_rest_url( NULL, $url );
249
250 $url2 = $startUrl . 'shifts/';
251 $fullUrl2 = get_rest_url( NULL, $url2 );
252 ?>
253
254 <p>
255 <strong>
256 PUT <?php echo $url; ?>
257 </strong>
258 </p>
259
260 <p>
261 <strong>__Headers__</strong>
262 </p>
263
264 <p>
265 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
266 </p>
267
268 <p>
269 <strong>__Arguments__</strong>
270 </p>
271
272 <p>
273 <strong>calendar_id</strong> (__Calendar Id__) <em>optional</em><br>
274 <strong>employee_id</strong> (__Employee Id__) <em>optional</em><br>
275 <strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM) <em>optional</em><br>
276 <strong>end</strong> (__End Date Time__, YYYYMMDDHHMM) <em>optional</em><br>
277 <strong>status_id</strong> (publish, draft) <em>optional</em><br>
278 <strong>conflict</strong> (__Set to 1 to allow creation of shifts with conflicts__) <em>optional</em><br>
279 </p>
280
281 <p>
282 <strong>Examples</strong>
283 </p>
284
285 <pre class="sh4-code">
286 PUT <?php echo $fullUrl2; ?>/123
287 start: 202102240900
288 end: 202102241530
289 </pre>
290
291 <pre class="sh4-code">
292 PUT <?php echo $fullUrl2; ?>/123
293 employee_id: 22
294 </pre>
295
296 <pre class="sh4-code">
297 PUT <?php echo $fullUrl2; ?>/123
298 status_id: publish
299 </pre>
300