| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- class Template extends Model {
- protected static $table = "template";
- protected static $id_field = "id";
- protected static $fillable_fields = ["customer_id", "name", "json", "practice"];
- // Object methods
- public function getCustomer() {
- return Customer::get($this->customer_id);
- }
- public function getProcessingFilePath($file) {
- if(!$this->folder) throw new Exception("Template processing folder not set.");
- $folder_path = ROOT_DIR . "/template_processing/" . $this->folder;
- if(!file_exists($folder_path)) throw new Exception("Template processing folder does not exist.");
- $file_path = $folder_path . "/" . $file;
- if(!file_exists($file_path)) throw new Exception("Template processing file does not exist.");
- return $file_path;
- }
- public function getURL() {
- return "/account/templates/" . $this->id;
- }
- public function renderBeforeTestForm() {
- $json = json_decode($this->json);
- $fields = $json->beforeTest;
- ?>
- <form method="post" enctype="multipart/form-data" id="before-test-form">
- <div class="alert alert-info">
- <i class="fal fa-fw fa-info-circle"></i>
- Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes.
- </div>
- <?php
- foreach($fields as $field) {
- Form::renderField($field);
- }
- ?>
- <input type="hidden" name="submit" value="<?=$_SESSION["csrf_token"]?>" />
- <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 />
- <button class="btn btn-primary mt-3" type="submit">
- Submit Info & Photos
- </button>
- </form>
- <?php
- }
- public function renderDuringTestForm() {
- $json = json_decode($this->json);
- $fields = $json->duringTest;
- ?>
- <form method="post" id="test-form">
- <input type="hidden" name="duration" id="duration" value="" required />
- <div class="bg-light text-center p-3 mb-3" style="position: sticky; top: 104px; z-index: 1000;" id="test-stop-button-container">
- <div>
- <button class="btn btn-block btn-success mb-3" type="button" id="test-start-button">
- Start Timer
- </button>
- <button class="btn btn-block btn-danger mb-3" type="button" id="test-stop-button" style="display: none;">
- Stop Timer
- </button>
- <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>
- </div>
- </div>
- <div class="collapse" id="test-main-form-container">
- <div class="alert alert-info">
- <i class="fal fa-fw fa-info-circle"></i>
- Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes.
- </div>
- <?php
- foreach($fields as $field) {
- Form::renderField($field);
- }
- ?>
- <div class="bg-light text-center p-3 mt-3">
- <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
- <button class="btn btn-block btn-primary" type="submit" id="test-submit-button">Submit Test Results</button>
- <small class="form-text text-muted d-none" id="test-no-internet-text">
- <span class="text-danger">No Internet Connectivity</span><br />
- Please check your Internet connectivity and try again.
- </small>
- <small id="test-submit-status">
- </small>
- </div>
- </div>
- </form>
- <?php
- }
- }
- ?>
|