template.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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", "practice"];
  6. // Object methods
  7. public function getCustomer() {
  8. return Customer::get($this->customer_id);
  9. }
  10. public function getProcessingFilePath($file) {
  11. if(!$this->folder) throw new Exception("Template processing folder not set.");
  12. $folder_path = ROOT_DIR . "/template_processing/" . $this->folder;
  13. if(!file_exists($folder_path)) throw new Exception("Template processing folder does not exist.");
  14. $file_path = $folder_path . "/" . $file;
  15. if(!file_exists($file_path)) throw new Exception("Template processing file does not exist.");
  16. return $file_path;
  17. }
  18. public function renderBeforeTestForm() {
  19. $json = json_decode($this->json);
  20. $fields = $json->beforeTest;
  21. ?>
  22. <form method="post" enctype="multipart/form-data" id="before-test-form">
  23. <div class="alert alert-info">
  24. <i class="fal fa-fw fa-info-circle"></i>
  25. Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes.
  26. </div>
  27. <?php
  28. foreach($fields as $field) {
  29. Form::renderField($field);
  30. }
  31. ?>
  32. <input type="hidden" name="submit" value="<?=$_SESSION["csrf_token"]?>" />
  33. <span class="text-danger">Please note that it may take a while for photos to upload. Please do not refresh the page when it is uploading.</span><br />
  34. <button class="btn btn-primary mt-3" type="submit">
  35. Submit Info &amp; Photos
  36. </button>
  37. </form>
  38. <?php
  39. }
  40. public function renderDuringTestForm() {
  41. $json = json_decode($this->json);
  42. $fields = $json->duringTest;
  43. ?>
  44. <form method="post" id="test-form">
  45. <input type="hidden" name="duration" id="duration" value="" required />
  46. <div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 104px; z-index: 1000;" id="test-stop-button-container">
  47. <div>
  48. <button class="btn btn-block btn-success mb-3" type="button" id="test-start-button">
  49. Start Timer
  50. </button>
  51. <button class="btn btn-block btn-danger mb-3" type="button" id="test-stop-button" style="display: none;">
  52. Stop Timer
  53. </button>
  54. <small><span id="test-duration-span">Photos uploaded successfully.<br />Please use the timer to record the duration that you were in the venue.<br /> Alternatively press <span class="text-danger">Stop Timer</span> immediately to skip the timer and note the duration in Additional Notes.</span></small>
  55. </div>
  56. </div>
  57. <div class="collapse" id="test-main-form-container">
  58. <div class="alert alert-info">
  59. <i class="fal fa-fw fa-info-circle"></i>
  60. Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes.
  61. </div>
  62. <?php
  63. foreach($fields as $field) {
  64. Form::renderField($field);
  65. }
  66. ?>
  67. <div class="bg-light text-center p-3 mt-3">
  68. <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
  69. <button class="btn btn-block btn-primary" type="submit" id="test-submit-button">Submit Test Results</button>
  70. <small class="form-text text-muted d-none" id="test-no-internet-text">
  71. <span class="text-danger">No Internet Connectivity</span><br />
  72. Please check your Internet connectivity and try again.
  73. </small>
  74. <small id="test-submit-status">
  75. </small>
  76. </div>
  77. </div>
  78. </form>
  79. <?php
  80. }
  81. }
  82. ?>