template.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. class Template extends Model {
  3. protected static $table = "template";
  4. protected static $id_field = "id";
  5. protected static $fillable_fields = ["customer_id", "name", "json"];
  6. protected static $field_map = [
  7. ];
  8. // Object methods
  9. public function getCustomer() {
  10. return Customer::get($this->customer_id);
  11. }
  12. public function renderBeforeTestForm() {
  13. $json = json_decode($this->json);
  14. $fields = $json->beforeTest;
  15. ?>
  16. <form method="post" enctype="multipart/form-data" id="before-test-form">
  17. <div class="alert alert-info">
  18. <i class="fal fa-fw fa-info-circle"></i>
  19. Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes.
  20. </div>
  21. <?php
  22. foreach($fields as $field) {
  23. Form::renderField($field);
  24. }
  25. ?>
  26. <button class="btn btn-primary" type="submit" name="submit" value="<?=$_SESSION["csrf_token"]?>">Start Test</button><br />
  27. <div class="d-none mt-3" data-submitting-div>
  28. <i class="fal fa-fw fa-pulse fa-spinner"></i> Please wait a moment while the form submits.
  29. </div>
  30. </form>
  31. <?php
  32. }
  33. public function renderDuringTestForm() {
  34. $json = json_decode($this->json);
  35. $fields = $json->duringTest;
  36. ?>
  37. <form method="post" id="test-form">
  38. <input type="hidden" name="duration" id="duration" value="" required />
  39. <div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 104px; z-index: 1000;" id="test-stop-button-container">
  40. <div>
  41. <button class="btn btn-block btn-success" type="button" id="test-start-button">
  42. Start Test
  43. </button>
  44. <button class="btn btn-block btn-danger" type="button" id="test-stop-button" style="display: none;">
  45. Stop Test
  46. </button>
  47. <small><span id="test-duration-span">0 min. 0 sec.</span></small>
  48. </div>
  49. </div>
  50. <div class="alert alert-info">
  51. <i class="fal fa-fw fa-info-circle"></i>
  52. Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes.
  53. </div>
  54. <?php
  55. foreach($fields as $field) {
  56. Form::renderField($field);
  57. }
  58. ?>
  59. <div class="bg-light text-center p-3 mt-3 d-none" id="test-submit-button-container">
  60. <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
  61. <button class="btn btn-block btn-primary" type="submit" id="test-submit-button">Submit Test Results</button>
  62. <small class="form-text text-muted d-none" id="test-no-internet-text">
  63. <span class="text-danger">No Internet Connectivity</span><br />
  64. Please check your Internet connectivity and try again.
  65. </small>
  66. <small id="test-submit-status">
  67. </small>
  68. </div>
  69. </form>
  70. <?php
  71. }
  72. }
  73. ?>