PluginProbe
ShiftController Employee Shift Scheduling / 4.9.65
ShiftController Employee Shift Scheduling v4.9.65
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.65, at sh4/api/html/view.html.php

387 lines 8.0 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 <?php
115 $today = date( 'Ymd' );
116 ?>
117
118 <p>
119 <strong>__Examples__</strong>
120 </p>
121
122 <pre class="sh4-code">
123 GET <?php echo $fullUrl; ?>
124 </pre>
125
126 <pre class="sh4-code">
127 GET <?php echo $fullUrl; ?>?calendar_id=11&from=<?php echo $today; ?>
128 </pre>
129
130 <pre class="sh4-code">
131 GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>0900&to=<?php echo $today; ?>1430&status_id=draft
132 </pre>
133
134
135 <h3 class="hc-underline">__Get Shift__</h3>
136 <?php
137 $url = $startUrl . 'shifts/&lt;id&gt;';
138 $fullUrl = get_rest_url( NULL, $url );
139
140 $url2 = $startUrl . 'shifts';
141 $fullUrl2 = get_rest_url( NULL, $url2 );
142 ?>
143
144 <p>
145 <strong>
146 GET <?php echo $url; ?>
147 </strong>
148 </p>
149
150 <p>
151 <strong>__Headers__</strong>
152 </p>
153
154 <p>
155 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
156 </p>
157
158 <p>
159 <strong>__Examples__</strong>
160 </p>
161
162 <pre class="sh4-code">
163 GET <?php echo $fullUrl2; ?>/123
164 </pre>
165
166 <h3 class="hc-underline">__Delete Shift__</h3>
167 <?php
168 $url = $startUrl . 'shifts/&lt;id&gt;';
169 $fullUrl = get_rest_url( NULL, $url );
170
171 $url2 = $startUrl . 'shifts';
172 $fullUrl2 = get_rest_url( NULL, $url2 );
173 ?>
174
175 <p>
176 <strong>
177 DELETE <?php echo $url; ?>
178 </strong>
179 </p>
180
181 <p>
182 <strong>__Headers__</strong>
183 </p>
184
185 <p>
186 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
187 </p>
188
189 <p>
190 <strong>__Examples__</strong>
191 </p>
192
193 <pre class="sh4-code">
194 DELETE <?php echo $fullUrl2; ?>/123
195 </pre>
196
197 <h3 class="hc-underline">__Create Shift__</h3>
198 <?php
199 $url = $startUrl . 'shifts';
200 $fullUrl = get_rest_url( NULL, $url );
201 ?>
202
203 <p>
204 <strong>
205 POST <?php echo $url; ?>
206 </strong>
207 </p>
208
209 <p>
210 <strong>__Headers__</strong>
211 </p>
212
213 <p>
214 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
215 </p>
216
217 <p>
218 <strong>__Arguments__</strong>
219 </p>
220
221 <p>
222 <strong>calendar_id</strong> (__Calendar Id__)<br>
223 <strong>employee_id</strong> (__Employee Id__)<br>
224 <strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM)<br>
225 <strong>end</strong> (__End Date Time__, YYYYMMDDHHMM)<br>
226 <strong>status_id</strong> (publish, draft)<br>
227 <strong>conflict</strong> (__Set to 1 to allow creation of shifts with conflicts__) <em>__optional__</em><br>
228 </p>
229
230 <p>
231 <strong>__Examples__</strong>
232 </p>
233
234 <pre class="sh4-code">
235 POST <?php echo $fullUrl; ?>
236
237 calendar_id: 11
238 employee_id: 22
239 start: <?php echo $today; ?>0800
240 end: <?php echo $today; ?>1430
241 status_id: publish
242 </pre>
243
244 <p>
245 __If success, it returns the id of the new shift. Otherwise error messages will be given.__
246 </p>
247
248 <h3 class="hc-underline">__Update Shift__</h3>
249 <?php
250 $url = $startUrl . 'shifts/&lt;id&gt;';
251 $fullUrl = get_rest_url( NULL, $url );
252
253 $url2 = $startUrl . 'shifts/';
254 $fullUrl2 = get_rest_url( NULL, $url2 );
255 if( '/' == substr($fullUrl2, -1) ){
256 $fullUrl2 = substr( $fullUrl2, 0, -1 );
257 }
258 ?>
259
260 <p>
261 <strong>
262 PUT <?php echo $url; ?>
263 </strong>
264 </p>
265
266 <p>
267 <strong>__Headers__</strong>
268 </p>
269
270 <p>
271 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
272 </p>
273
274 <p>
275 <strong>__Arguments__</strong>
276 </p>
277
278 <p>
279 <strong>calendar_id</strong> (__Calendar Id__) <em>__optional__</em><br>
280 <strong>employee_id</strong> (__Employee Id__) <em>__optional__</em><br>
281 <strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br>
282 <strong>end</strong> (__End Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br>
283 <strong>status_id</strong> (publish, draft) <em>__optional__</em><br>
284 <strong>conflict</strong> (__Set to 1 to allow creation of shifts with conflicts__) <em>__optional__</em><br>
285 </p>
286
287 <p>
288 <strong>__Examples__</strong>
289 </p>
290
291 <pre class="sh4-code">
292 PUT <?php echo $fullUrl2; ?>/123
293 start: <?php echo $today; ?>0900
294 end: <?php echo $today; ?>1530
295 </pre>
296
297 <pre class="sh4-code">
298 PUT <?php echo $fullUrl2; ?>/123
299 employee_id: 22
300 </pre>
301
302 <pre class="sh4-code">
303 PUT <?php echo $fullUrl2; ?>/123
304 status_id: publish
305 </pre>
306
307 <h3 class="hc-underline">__Get Available Employees__</h3>
308 <?php
309 $url = $startUrl . 'available-employees';
310 $fullUrl = get_rest_url( NULL, $url );
311 ?>
312
313 <p>
314 <strong>
315 GET <?php echo $url; ?>
316 </strong>
317 </p>
318
319 <p>
320 <strong>__Headers__</strong>
321 </p>
322
323 <p>
324 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
325 </p>
326
327 <p>
328 <strong>__Arguments__</strong>
329 </p>
330
331 <p>
332 <strong>calendar_id</strong> (__Calendar Id__) <em>__optional__</em><br>
333 <em>__default value__</em>: __all shift-type calendars__<br>
334
335 <strong>from</strong> (__Start Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br>
336 <em>__default value__</em>: __beginning of today__<br>
337
338 <strong>to</strong> (__End Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br>
339 <em>__default value__</em>: __one day from the start__<br>
340
341 </p>
342
343 <p>
344 <strong>__Examples__</strong>
345 </p>
346
347 <pre class="sh4-code">
348 GET <?php echo $fullUrl; ?>
349 </pre>
350
351 <pre class="sh4-code">
352 GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>0900&to=<?php echo $today; ?>1430
353 </pre>
354
355 <pre class="sh4-code">
356 GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>&calendar_id=123
357 </pre>
358
359 <pre class="sh4-code">
360 GET <?php echo $fullUrl; ?>?calendar_id[]=123&calendar_id[]=456
361 </pre>
362
363 <p>
364 <strong>__Example return__</strong>
365 </p>
366
367 <pre class="sh4-code">
368 {
369 "from": "<?php echo $today; ?>0900",
370 "to": "<?php echo $today; ?>1430",
371 "employees": [
372 {
373 "id": "523",
374 "title": "Alice",
375 "email": "alice@host.local",
376 "username": "alice"
377 },
378 {
379 "id": "527",
380 "title": "Eve",
381 "email": "eve@host.local",
382 "username": "eve"
383 }
384 ]
385 }
386 </pre>
387