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

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

770 lines 14.9 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
96 $cfields = array();
97 ?>
98 <?php if( class_exists('SH4_CFields_Model') or class_exists('SH4_CFields2_Model') ) : ?>
99 <?php
100 $f = ShiftController4::$instance->root();
101 $cfieldsQuery = $f->make('SH4_CFields_Query');
102 $cfields = $cfieldsQuery->read();
103 ?>
104 <?php if( $cfields ) : ?>
105 <p>
106 <strong>__Optional Arguments__</strong>
107 </p>
108
109 <p>
110 <?php foreach( $cfields as $cfield ) : ?>
111 <em><?php echo $cfield->getName(); ?></em> (<?php echo $cfield->getLabel(); ?>)<br>
112 <?php endforeach; ?>
113 </p>
114 <?php endif; ?>
115 <?php endif; ?>
116
117 <?php
118 $today = date( 'Ymd' );
119 ?>
120
121 <p>
122 <strong>__Examples__</strong>
123 </p>
124
125 <pre class="sh4-code">
126 GET <?php echo $fullUrl; ?>
127 </pre>
128
129 <pre class="sh4-code">
130 GET <?php echo $fullUrl; ?>?calendar_id=11&from=<?php echo $today; ?>
131 </pre>
132
133 <pre class="sh4-code">
134 GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>0900&to=<?php echo $today; ?>1430&status_id=draft
135 </pre>
136
137 <h3 class="hc-underline">__Get Shift__</h3>
138 <?php
139 $url = $startUrl . 'shifts/&lt;id&gt;';
140 $fullUrl = get_rest_url( NULL, $url );
141
142 $url2 = $startUrl . 'shifts';
143 $fullUrl2 = get_rest_url( NULL, $url2 );
144 ?>
145
146 <p>
147 <strong>
148 GET <?php echo $url; ?>
149 </strong>
150 </p>
151
152 <p>
153 <strong>__Headers__</strong>
154 </p>
155
156 <p>
157 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
158 </p>
159
160 <p>
161 <strong>__Examples__</strong>
162 </p>
163
164 <pre class="sh4-code">
165 GET <?php echo $fullUrl2; ?>/123
166 </pre>
167
168 <h3 class="hc-underline">__Delete Shift__</h3>
169 <?php
170 $url = $startUrl . 'shifts/&lt;id&gt;';
171 $fullUrl = get_rest_url( NULL, $url );
172
173 $url2 = $startUrl . 'shifts';
174 $fullUrl2 = get_rest_url( NULL, $url2 );
175 ?>
176
177 <p>
178 <strong>
179 DELETE <?php echo $url; ?>
180 </strong>
181 </p>
182
183 <p>
184 <strong>__Headers__</strong>
185 </p>
186
187 <p>
188 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
189 </p>
190
191 <p>
192 <strong>__Examples__</strong>
193 </p>
194
195 <pre class="sh4-code">
196 DELETE <?php echo $fullUrl2; ?>/123
197 </pre>
198
199 <h3 class="hc-underline">__Create Shift__</h3>
200 <?php
201 $url = $startUrl . 'shifts';
202 $fullUrl = get_rest_url( NULL, $url );
203 ?>
204
205 <p>
206 <strong>
207 POST <?php echo $url; ?>
208 </strong>
209 </p>
210
211 <p>
212 <strong>__Headers__</strong>
213 </p>
214
215 <p>
216 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
217 </p>
218
219 <p>
220 <strong>__Arguments__</strong>
221 </p>
222
223 <p>
224 <strong>calendar_id</strong> (__Calendar Id__)<br>
225 <strong>employee_id</strong> (__Employee Id__)<br>
226 <strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM)<br>
227 <strong>end</strong> (__End Date Time__, YYYYMMDDHHMM)<br>
228 <strong>status_id</strong> (publish, draft)<br>
229 <strong>conflict</strong> (__Set to 1 to allow creation of shifts with conflicts__) <em>__optional__</em><br>
230 <?php foreach( $cfields as $cfield ) : ?>
231 <strong><?php echo $cfield->getName(); ?></strong> (<?php echo $cfield->getLabel(); ?>)<br>
232 <?php endforeach; ?>
233 </p>
234
235 <p>
236 <strong>__Examples__</strong>
237 </p>
238
239 <pre class="sh4-code">
240 POST <?php echo $fullUrl; ?>
241
242 calendar_id: 11
243 employee_id: 22
244 start: <?php echo $today; ?>0800
245 end: <?php echo $today; ?>1430
246 status_id: publish
247 </pre>
248
249 <p>
250 __If success, it returns the id of the new shift. Otherwise error messages will be given.__
251 </p>
252
253 <h3 class="hc-underline">__Update Shift__</h3>
254 <?php
255 $url = $startUrl . 'shifts/&lt;id&gt;';
256 $fullUrl = get_rest_url( NULL, $url );
257
258 $url2 = $startUrl . 'shifts/';
259 $fullUrl2 = get_rest_url( NULL, $url2 );
260 if( '/' == substr($fullUrl2, -1) ){
261 $fullUrl2 = substr( $fullUrl2, 0, -1 );
262 }
263 ?>
264
265 <p>
266 <strong>
267 PUT <?php echo $url; ?>
268 </strong>
269 </p>
270
271 <p>
272 <strong>__Headers__</strong>
273 </p>
274
275 <p>
276 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
277 </p>
278
279 <p>
280 <strong>__Arguments__</strong>
281 </p>
282
283 <p>
284 <strong>calendar_id</strong> (__Calendar Id__) <em>__optional__</em><br>
285 <strong>employee_id</strong> (__Employee Id__) <em>__optional__</em><br>
286 <strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br>
287 <strong>end</strong> (__End Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br>
288 <strong>status_id</strong> (publish, draft) <em>__optional__</em><br>
289 <strong>conflict</strong> (__Set to 1 to allow creation of shifts with conflicts__) <em>__optional__</em><br>
290 <?php foreach( $cfields as $cfield ) : ?>
291 <strong><?php echo $cfield->getName(); ?></strong> (<?php echo $cfield->getLabel(); ?>)<br>
292 <?php endforeach; ?>
293 </p>
294
295 <p>
296 <strong>__Examples__</strong>
297 </p>
298
299 <pre class="sh4-code">
300 PUT <?php echo $fullUrl2; ?>/123
301 start: <?php echo $today; ?>0900
302 end: <?php echo $today; ?>1530
303 </pre>
304
305 <pre class="sh4-code">
306 PUT <?php echo $fullUrl2; ?>/123
307 employee_id: 22
308 </pre>
309
310 <pre class="sh4-code">
311 PUT <?php echo $fullUrl2; ?>/123
312 status_id: publish
313 </pre>
314
315 <h3 class="hc-underline">__Get Available Employees__</h3>
316 <?php
317 $url = $startUrl . 'available-employees';
318 $fullUrl = get_rest_url( NULL, $url );
319 ?>
320
321 <p>
322 <strong>
323 GET <?php echo $url; ?>
324 </strong>
325 </p>
326
327 <p>
328 <strong>__Headers__</strong>
329 </p>
330
331 <p>
332 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
333 </p>
334
335 <p>
336 <strong>__Arguments__</strong>
337 </p>
338
339 <p>
340 <strong>calendar_id</strong> (__Calendar Id__) <em>__optional__</em><br>
341 <em>__default value__</em>: __all shift-type calendars__<br>
342
343 <strong>from</strong> (__Start Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br>
344 <em>__default value__</em>: __beginning of today__<br>
345
346 <strong>to</strong> (__End Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br>
347 <em>__default value__</em>: __one day from the start__<br>
348
349 </p>
350
351 <p>
352 <strong>__Examples__</strong>
353 </p>
354
355 <pre class="sh4-code">
356 GET <?php echo $fullUrl; ?>
357 </pre>
358
359 <pre class="sh4-code">
360 GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>0900&to=<?php echo $today; ?>1430
361 </pre>
362
363 <pre class="sh4-code">
364 GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>&calendar_id=123
365 </pre>
366
367 <pre class="sh4-code">
368 GET <?php echo $fullUrl; ?>?calendar_id[]=123&calendar_id[]=456
369 </pre>
370
371 <p>
372 <strong>__Example return__</strong>
373 </p>
374
375 <pre class="sh4-code">
376 {
377 "from": "<?php echo $today; ?>0900",
378 "to": "<?php echo $today; ?>1430",
379 "employees": [
380 {
381 "id": "523",
382 "title": "Alice",
383 "email": "alice@host.local",
384 "username": "alice"
385 },
386 {
387 "id": "527",
388 "title": "Eve",
389 "email": "eve@host.local",
390 "username": "eve"
391 }
392 ]
393 }
394 </pre>
395
396 <h3 class="hc-underline">__Get All Calendars__</h3>
397 <?php
398 $url = $startUrl . 'calendars';
399 $fullUrl = get_rest_url( NULL, $url );
400 ?>
401
402 <p>
403 <strong>
404 GET <?php echo $url; ?>
405 </strong>
406 </p>
407
408 <p>
409 <strong>__Headers__</strong>
410 </p>
411
412 <p>
413 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
414 </p>
415
416 <p>
417 <strong>__Examples__</strong>
418 </p>
419
420 <pre class="sh4-code">
421 GET <?php echo $fullUrl; ?>
422 </pre>
423
424 <p>
425 <strong>__Example return__</strong>
426 </p>
427
428 <pre class="sh4-code">
429 [
430 {
431 "id": "12",
432 "title": "Barista",
433 "type": "shift",
434 "active": "1"
435 },
436 {
437 "id": "13",
438 "title": "Server",
439 "type": "shift",
440 "active": "0"
441 },
442 {
443 "id": "14",
444 "title": "Holidays",
445 "type": "timeoff",
446 "active": "0"
447 }
448 ]
449 </pre>
450
451 <h3 class="hc-underline">__Get All Employees__</h3>
452 <?php
453 $url = $startUrl . 'employees';
454 $fullUrl = get_rest_url( NULL, $url );
455 ?>
456
457 <p>
458 <strong>
459 GET <?php echo $url; ?>
460 </strong>
461 </p>
462
463 <p>
464 <strong>__Headers__</strong>
465 </p>
466
467 <p>
468 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
469 </p>
470
471 <p>
472 <strong>__Examples__</strong>
473 </p>
474
475 <pre class="sh4-code">
476 GET <?php echo $fullUrl; ?>
477 </pre>
478
479 <p>
480 <strong>__Example return__</strong>
481 </p>
482
483 <pre class="sh4-code">
484 [
485 {
486 "id": "523",
487 "title": "Alice",
488 "email": "alice@host.local",
489 "username": "alice"
490 },
491 {
492 "id": "527",
493 "title": "Eve",
494 "email": "eve@host.local",
495 "username": "eve"
496 }
497 ]
498 </pre>
499
500 <h3 class="hc-underline">__Get Calendars For Employee__</h3>
501 <?php
502 $url = $startUrl . 'employees/&lt;id&gt;/calendars';
503 $fullUrl = get_rest_url( null, $url );
504
505 $url2 = $startUrl . 'employees';
506 $fullUrl2 = get_rest_url( null, $url2 );
507 ?>
508
509 <p>
510 <strong>
511 GET <?php echo $url; ?>
512 </strong>
513 </p>
514
515 <p>
516 <strong>__Headers__</strong>
517 </p>
518
519 <p>
520 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
521 </p>
522
523 <p>
524 <strong>__Examples__</strong>
525 </p>
526
527 <pre class="sh4-code">
528 GET <?php echo $fullUrl2; ?>/123/calendars
529 </pre>
530
531 <h3 class="hc-underline">__Get Employees Eligible For Calendar__</h3>
532 <?php
533 $url = $startUrl . 'calendars/&lt;id&gt;/employees';
534 $fullUrl = get_rest_url( null, $url );
535
536 $url2 = $startUrl . 'calendars';
537 $fullUrl2 = get_rest_url( null, $url2 );
538 ?>
539
540 <p>
541 <strong>
542 GET <?php echo $url; ?>
543 </strong>
544 </p>
545
546 <p>
547 <strong>__Headers__</strong>
548 </p>
549
550 <p>
551 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
552 </p>
553
554 <p>
555 <strong>__Examples__</strong>
556 </p>
557
558 <pre class="sh4-code">
559 GET <?php echo $fullUrl2; ?>/654/employees
560 </pre>
561
562 <h3 class="hc-underline">__Add Employee To Calendar__</h3>
563 <?php
564 $url = $startUrl . 'calendars/&lt;cid&gt;/employees/&lt;eid&gt;';
565 $fullUrl = get_rest_url( null, $url );
566
567 $url2 = $startUrl . 'calendars';
568 $fullUrl2 = get_rest_url( null, $url2 );
569 ?>
570
571 <p>
572 <strong>
573 POST <?php echo $url; ?>
574 </strong>
575 </p>
576
577 <?php
578 $url = $startUrl . 'employees/&lt;eid&gt;/calendars/&lt;cid&gt;';
579 $fullUrl = get_rest_url( null, $url );
580
581 $url3 = $startUrl . 'employees';
582 $fullUrl3 = get_rest_url( null, $url3 );
583 ?>
584
585 <p>
586 <strong>
587 POST <?php echo $url; ?>
588 </strong>
589 </p>
590
591 <p>
592 <strong>__Headers__</strong>
593 </p>
594
595 <p>
596 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
597 </p>
598
599 <p>
600 <strong>__Examples__</strong>
601 </p>
602
603 <pre class="sh4-code">
604 POST <?php echo $fullUrl2; ?>/654/employees/123
605 </pre>
606
607 <pre class="sh4-code">
608 POST <?php echo $fullUrl3; ?>/123/calendars/654
609 </pre>
610
611 <h3 class="hc-underline">__Remove Employee From Calendar__</h3>
612 <?php
613 $url = $startUrl . 'calendars/&lt;cid&gt;/employees/&lt;eid&gt;';
614 $fullUrl = get_rest_url( null, $url );
615
616 $url2 = $startUrl . 'calendars';
617 $fullUrl2 = get_rest_url( null, $url2 );
618 ?>
619
620 <p>
621 <strong>
622 DELETE <?php echo $url; ?>
623 </strong>
624 </p>
625
626 <?php
627 $url = $startUrl . 'employees/&lt;eid&gt;/calendars/&lt;cid&gt;';
628 $fullUrl = get_rest_url( null, $url );
629
630 $url3 = $startUrl . 'employees';
631 $fullUrl3 = get_rest_url( null, $url3 );
632 ?>
633
634 <p>
635 <strong>
636 DELETE <?php echo $url; ?>
637 </strong>
638 </p>
639
640 <p>
641 <strong>__Headers__</strong>
642 </p>
643
644 <p>
645 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
646 </p>
647
648 <p>
649 <strong>__Examples__</strong>
650 </p>
651
652 <pre class="sh4-code">
653 DELETE <?php echo $fullUrl2; ?>/654/employees/123
654 </pre>
655
656 <pre class="sh4-code">
657 DELETE <?php echo $fullUrl3; ?>/123/calendars/654
658 </pre>
659
660 <h3 class="hc-underline">__Get Employee__</h3>
661 <?php
662 $url = $startUrl . 'employees/&lt;id&gt;';
663 $fullUrl = get_rest_url( null, $url );
664
665 $url2 = $startUrl . 'employees';
666 $fullUrl2 = get_rest_url( null, $url2 );
667 ?>
668
669 <p>
670 <strong>
671 GET <?php echo $url; ?>
672 </strong>
673 </p>
674
675 <p>
676 <strong>__Headers__</strong>
677 </p>
678
679 <p>
680 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
681 </p>
682
683 <p>
684 <strong>__Examples__</strong>
685 </p>
686
687 <pre class="sh4-code">
688 GET <?php echo $fullUrl2; ?>/123
689 </pre>
690
691 <h3 class="hc-underline">__Get Employee By User Id__</h3>
692 <?php
693 $url = $startUrl . 'users/&lt;id&gt;/employee';
694 $fullUrl = get_rest_url( null, $url );
695
696 $url2 = $startUrl . 'users';
697 $fullUrl2 = get_rest_url( null, $url2 );
698 ?>
699
700 <p>
701 <strong>
702 GET <?php echo $url; ?>
703 </strong>
704 </p>
705
706 <p>
707 <strong>__Headers__</strong>
708 </p>
709
710 <p>
711 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
712 </p>
713
714 <p>
715 <strong>__Examples__</strong>
716 </p>
717
718 <pre class="sh4-code">
719 GET <?php echo $fullUrl2; ?>/321/employee
720 </pre>
721
722 <h3 class="hc-underline">__Create Employee__</h3>
723 <?php
724 $url = $startUrl . 'employees';
725 $fullUrl = get_rest_url( NULL, $url );
726 ?>
727
728 <p>
729 <strong>
730 POST <?php echo $url; ?>
731 </strong>
732 </p>
733
734 <p>
735 <strong>__Headers__</strong>
736 </p>
737
738 <p>
739 X-WP-ShiftController-AuthCode: <?php echo $current['auth_code']; ?>
740 </p>
741
742 <p>
743 <strong>__Arguments__</strong>
744 </p>
745
746 <p>
747 <strong>title</strong><br>
748 <strong>user_id</strong> <em>__optional__</em><br>
749 <strong>description</strong> <em>__optional__</em><br>
750 </p>
751
752 <p>
753 __Either title or user_id required.__ __If user_id is given, it will link the new employee to this WordPress user.__
754 __If user_id is given without the title, it will create a new employee with this WordPress user's full name as employee's title and link this employee to this user.__
755 </p>
756
757 <p>
758 <strong>__Examples__</strong>
759 </p>
760
761 <pre class="sh4-code">
762 POST <?php echo $fullUrl; ?>
763
764 title: James
765 </pre>
766
767 <p>
768 __If success, it returns the id of the new employee. Otherwise error messages will be given.__
769 </p>
770