| @@ -91,13 +91,10 @@ | ||
| 91 | 91 | <strong>to</strong> (__To Date__, YYYYMMDD / __To Date Time__, YYYYMMDDHHMM)<br> |
| 92 | 92 | <strong>status_id</strong> (publish, draft)<br> |
| 93 | 93 | </p> |
| 94 | 94 | |
| 95 | +<?php if( class_exists('SH4_CFields_Model') ) : ?> | |
| 95 | 96 | <?php |
| 96 | -$cfields = array(); | |
| 97 | -?> | |
| 98 | -<?php if( class_exists('SH4_CFields_Model') or class_exists('SH4_CFields2_Model') ) : ?> | |
| 99 | -<?php | |
| 100 | 97 | $f = ShiftController4::$instance->root(); |
| 101 | 98 | $cfieldsQuery = $f->make('SH4_CFields_Query'); |
| 102 | 99 | $cfields = $cfieldsQuery->read(); |
| 103 | 100 | ?> |
| @@ -133,8 +130,9 @@ | ||
| 133 | 130 | <pre class="sh4-code"> |
| 134 | 131 | GET <?php echo $fullUrl; ?>?from=<?php echo $today; ?>0900&to=<?php echo $today; ?>1430&status_id=draft |
| 135 | 132 | </pre> |
| 136 | 133 | |
| 134 | + | |
| 137 | 135 | <h3 class="hc-underline">__Get Shift__</h3> |
| 138 | 136 | <?php |
| 139 | 137 | $url = $startUrl . 'shifts/<id>'; |
| 140 | 138 | $fullUrl = get_rest_url( NULL, $url ); |
| @@ -226,11 +224,8 @@ | ||
| 226 | 224 | <strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM)<br> |
| 227 | 225 | <strong>end</strong> (__End Date Time__, YYYYMMDDHHMM)<br> |
| 228 | 226 | <strong>status_id</strong> (publish, draft)<br> |
| 229 | 227 | <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 | 228 | </p> |
| 234 | 229 | |
| 235 | 230 | <p> |
| 236 | 231 | <strong>__Examples__</strong> |
| @@ -286,11 +281,8 @@ | ||
| 286 | 281 | <strong>start</strong> (__Start Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br> |
| 287 | 282 | <strong>end</strong> (__End Date Time__, YYYYMMDDHHMM) <em>__optional__</em><br> |
| 288 | 283 | <strong>status_id</strong> (publish, draft) <em>__optional__</em><br> |
| 289 | 284 | <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 | 285 | </p> |
| 294 | 286 | |
| 295 | 287 | <p> |
| 296 | 288 | <strong>__Examples__</strong> |
| @@ -391,379 +383,4 @@ | ||
| 391 | 383 | } |
| 392 | 384 | ] |
| 393 | 385 | } |
| 394 | 386 | </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/<id>/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/<id>/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/<cid>/employees/<eid>'; | |
| 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/<eid>/calendars/<cid>'; | |
| 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/<cid>/employees/<eid>'; | |
| 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/<eid>/calendars/<cid>'; | |
| 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/<id>'; | |
| 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/<id>/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> | |