template.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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">
  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. <div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 0px;">
  27. <button class="btn btn-block btn-success" type="submit" name="submit" value="<?=$_SESSION["csrf_token"]?>">Start Test</button>
  28. <small data-test-no-internet-text class="form-text text-success">
  29. Tap this button just before you enter the venue and wait for the form to submit.
  30. </small>
  31. </div>
  32. </form>
  33. <?php
  34. }
  35. public function renderDuringTestForm() {
  36. $json = json_decode($this->json);
  37. $fields = $json->duringTest;
  38. ?>
  39. <form method="post" id="test-form">
  40. <input type="hidden" name="duration" id="duration" value="" required />
  41. <div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 104px; z-index: 1000;">
  42. <div class="" id="test-stop-button-container">
  43. <button class="btn btn-block btn-danger" type="button" id="test-stop-button">Stop Test</button>
  44. <small data-test-no-internet-text class="form-text text-danger">
  45. Tap this button when you are outside of the venue.
  46. </small>
  47. </div>
  48. <div class="d-none" id="test-submit-button-container">
  49. <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
  50. <button class="btn btn-block btn-primary" type="submit" id="test-submit-button">Submit Test Results</button>
  51. <small class="form-text text-muted d-none" id="test-no-internet-text">
  52. <span class="text-danger">No Internet Connectivity</span><br />
  53. Please check your Internet connectivity and try again.
  54. </small>
  55. <small id="test-submit-status">
  56. </small>
  57. </div>
  58. </div>
  59. <div class="alert alert-info">
  60. <i class="fal fa-fw fa-info-circle"></i>
  61. Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes.
  62. </div>
  63. <?php
  64. foreach($fields as $field) {
  65. Form::renderField($field);
  66. }
  67. ?>
  68. </form>
  69. <?php
  70. }
  71. }
  72. ?>