Sfoglia il codice sorgente

Add "Venue Was Closed" field to test form

Alan Lam 5 anni fa
parent
commit
6d541e70cd

+ 2 - 0
controllers/test_tester_form.php

@@ -196,6 +196,8 @@ if($submit) {
 
 			if($void) {
 				$test->void = 1;
+				$test->void_notes = HTTP::value("void_notes", "trim");
+				if(empty($test->void_notes)) throw new Exception(__("Venue Closed Notes is required."));
 			}
 			else {
 				$test->pass = 1;

+ 3 - 0
controllers/test_verify_form.php

@@ -124,6 +124,9 @@ if($submit) {
 				}
 			}
 		}
+		else {
+			$test->void_notes = HTTP::value("void_notes", "trim");
+		}
 
 		// Accept test as completed
 		if($accept) {

+ 11 - 0
db/migrations/20210916171333_add_void_notes_field_to_test_table.php

@@ -0,0 +1,11 @@
+<?php
+
+use Phinx\Migration\AbstractMigration;
+
+class AddVoidNotesFieldToTestTable extends AbstractMigration {
+	public function change() {
+		$this->table("test")
+			->addColumn("void_notes", "text", ["after" => "void", "null" => true])
+			->update();
+	}
+}

+ 7 - 1
engine/template.php

@@ -304,8 +304,14 @@ class Template extends Model {
 					</button>
 				</div>
 
+				<p><?=htmlspecialchars(__("If the venue was closed, please enter notes and then click the button below."))?></p>
+
+				<div class="form-group">
+					<label for="void-notes"><?=htmlspecialchars(__("Venue Closed Notes"))?></label>
+					<textarea class="form-control" type="text" name="void_notes" id="void-notes" rows="4" placeholder="<?=htmlspecialchars(__("Enter venue closed notes"))?>"></textarea>
+				</div>
+
 				<div class="form-group">
-					<p><?=htmlspecialchars(__("If the venue was closed, please click the button below."))?></p>
 					<button class="btn btn-block btn-secondary" type="submit" id="test-void-button">
 						<?=htmlspecialchars(__("Venue Was Closed"))?>
 					</button>

+ 2 - 1
engine/test.php

@@ -35,6 +35,7 @@ use Mpdf\Mpdf;
  * @property bool $pass
  * @property bool $retest
  * @property bool $void
+ * @property string $void_notes
  * @property string $dts_created
  * @property string $dts_updated
  * @property string $dts_assigned
@@ -45,7 +46,7 @@ class Test extends Model {
 
 	protected static $table = "test";
 	protected static $id_field = "id";
-	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "status_tester_invoice", "customer_fee", "test_fee", "test_time", "test_travel_cost", "test_travel_cost_description", "shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes", "dts_due", "dts_start", "dts_end", "dts_tester_invoice_generated", "dts_tester_invoice_paid", "verifier_id", "verifier_notes", "pass", "retest", "void", "dts_created", "dts_updated", "dts_assigned", "dts_verified"];
+	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "status_tester_invoice", "customer_fee", "test_fee", "test_time", "test_travel_cost", "test_travel_cost_description", "shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes", "dts_due", "dts_start", "dts_end", "dts_tester_invoice_generated", "dts_tester_invoice_paid", "verifier_id", "verifier_notes", "pass", "retest", "void", "void_notes", "dts_created", "dts_updated", "dts_assigned", "dts_verified"];
 
 	public const TEST_FIELDS = ["shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes"];
 

+ 6 - 0
public/js/app-test.js

@@ -29,6 +29,12 @@ function initialiseTestForm() {
 		$submitButton.trigger("click");
 	});
 
+	const $voidNotes = $("#void-notes");
+	$voidNotes.on("input", () => {
+		const hasText = $voidNotes.val().length > 0;
+		$voidButton.prop("disabled", !hasText);
+	}).trigger("input");
+
 	const $noInternetText = $("#test-no-internet-text");
 
 	const $submitStatus = $("#test-submit-status");

+ 7 - 1
views/test_form.php

@@ -51,8 +51,14 @@ else if($test->isPendingVerification()) {
 			</button>
 		</div>
 
+		<p><?=htmlspecialchars(__("If the venue was closed, please enter notes and then click the button below."))?></p>
+
+		<div class="form-group">
+			<label for="void-notes"><?=htmlspecialchars(__("Venue Closed Notes"))?></label>
+			<textarea class="form-control" type="text" name="void_notes" id="void-notes" rows="4" placeholder="<?=htmlspecialchars(__("Enter venue closed notes"))?>"></textarea>
+		</div>
+
 		<div class="form-group">
-			<p><?=htmlspecialchars(__("If the venue was closed, please click the button below."))?></p>
 			<button class="btn btn-block btn-secondary" type="submit" id="test-void-button">
 				<?=htmlspecialchars(__("Venue Was Closed"))?>
 			</button>

+ 8 - 0
views/test_verify_form.php

@@ -197,6 +197,14 @@ function render_card_list_group($details) {
 							$header_count++;
 						}
 					}
+
+					if($test->void) {
+						?>
+						<label for="void-notes">Venue Closed Notes</label>
+						<textarea class="form-control" name="void_notes" id="void-notes" rows="4" placeholder="Enter venue closed notes"><?=htmlspecialchars($test->void_notes)?></textarea>
+						<?php
+					}
+
 					?>
 					</div>
 				</div>