Browse Source

Add support for marking tests as retest on verify

Alan Lam 8 years ago
parent
commit
842a60f630

+ 2 - 0
controllers/test.php

@@ -328,6 +328,8 @@ else if(Core::$user->level >= User::LEVEL_ADMIN) {
 
 			if($form_exception->hasErrors()) throw $form_exception;
 
+			$test->retest |= http::value("retest", "int");
+
 			$test->dts_updated = Util::getDateTime();
 			$success = $test->commit();
 			if(!$success) throw new Exception("Failed to update the test. Please try again later.");

+ 0 - 2
controllers/test_pdf.php

@@ -72,8 +72,6 @@ $pdf->SetAutoPageBreak(false);
 $pdf->Image("public/img/logo.png", 11, 10, 60);
 
 // Right contact info
-$y = 10;
-
 $pdf->SetFont("Arial", "B", $tiny_font_size);
 $pdf->SetTextColor(255, 0, 0);
 

+ 18 - 1
engine/test.php

@@ -4,7 +4,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", "test_fee", "test_time", "test_travel_cost", "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", "verifier_id", "verifier_notes", "pass", "dts_created", "dts_updated", "dts_assigned", "dts_verified"];
+	protected static $fillable_fields = ["project_id", "location_id", "tester_id", "status", "test_fee", "test_time", "test_travel_cost", "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", "verifier_id", "verifier_notes", "pass", "retest", "dts_created", "dts_updated", "dts_assigned", "dts_verified"];
 
 	const TEST_FIELDS = ["shop_left", "shop_right", "attire", "challenge_stage", "challenge_description", "challenger_name", "challenger_description", "challenger_gender", "challenger_eye_contact", "additional_notes"];
 
@@ -339,6 +339,23 @@ class Test extends Model {
 
 	}
 
+	public function getPreviousTest() {
+
+		$nvp = [
+			"dts_start" => (new Constraint("LESS_THAN"))->setValues($this->dts_start),
+			"location_id" => $this->location_id,
+			"status" => Test::STATUS_COMPLETED,
+		];
+
+		$tests = Test::query($nvp, [
+			"sort" => "dts_start",
+			"order" => "desc",
+		]);
+
+		return $tests ? $tests[0] : false;
+
+	}
+
 	public function unassignTester() {
 		$this->status = Test::STATUS_UNASSIGNED;
 		$this->tester_id = null;

+ 34 - 0
template_processing/age_verification/test_pdf.php

@@ -1,5 +1,39 @@
 <?php
 
+$main_y = $pdf->GetY();
+
+// Retest info
+if($test->retest) {
+	$pdf->SetLeftMargin(83);
+	$pdf->SetY(10);
+
+	$pdf->SetFont("Arial", "B", $header_font_size);
+	$pdf->SetTextColor(0, 0, 255);
+	$pdf->Cell(43, 4, "RETEST", 0, 1);
+
+	$pdf->SetY($pdf->GetY() + 2);
+
+	// Find previous test
+	$previous_test = $test->getPreviousTest();
+	if($previous_test) {
+
+		$previous_test_pass_text = $previous_test->pass ? "PASS" : "FAIL";
+		$previous_test_unix_start = Util::getUnixTimeFromUTC($previous_test->dts_start);
+
+		$previous_test_date = date("d/m/Y", $previous_test_unix_start);
+
+		$pdf->SetFont("Arial", "", $normal_font_size);
+		$pdf->SetTextColor(0, 0, 0);
+		$pdf->Cell(43, 4, "Prev. Test Date: $previous_test_date", 0, 1);
+		$pdf->Cell(43, 4, "Prev. Test Result: $previous_test_pass_text", 0, 1);
+
+	}
+
+}
+
+$pdf->SetLeftMargin(10);
+$pdf->SetY($main_y);
+
 // Header
 $pdf->SetTextColor(56, 87, 35);
 $pdf->SetFont("Arial", "B", $header_font_size);

+ 23 - 3
views/test_verify_form.php

@@ -295,7 +295,9 @@ function render_card_list_group($details) {
 							if($customer->email) {
 								?>
 								<div class="row mb-1">
-									<div class="col-sm-4">Email Headquarters</div>
+									<div class="col-sm-4">
+										<label class="form-check-label" for="email-customer">Email Headquarters</label>
+									</div>
 									<div class="col-sm">
 										<div class="form-check">
 											<input class="form-check-input" type="checkbox" name="email_customer" id="email-customer" value="1" <?=Form::checked($customer->email_after_test)?> />
@@ -308,7 +310,9 @@ function render_card_list_group($details) {
 							if($location->email) {
 								?>
 								<div class="row mb-1">
-									<div class="col-sm-4">Email Venue</div>
+									<div class="col-sm-4">
+										<label class="form-check-label" for="email-location">Email Venue</label>
+									</div>
 									<div class="col-sm">
 										<div class="form-check">
 											<input class="form-check-input" type="checkbox" name="email_location" id="email-location" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
@@ -321,7 +325,9 @@ function render_card_list_group($details) {
 							if($location->area_manager_email) {
 								?>
 								<div class="row mb-1">
-									<div class="col-sm-4">Email Area Manager</div>
+									<div class="col-sm-4">
+										<label class="form-check-label" for="email-location-area-manager">Email Area Manager</label>
+									</div>
 									<div class="col-sm">
 										<div class="form-check">
 											<input class="form-check-input" type="checkbox" name="email_location_area_manager" id="email-location-area-manager" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
@@ -332,6 +338,20 @@ function render_card_list_group($details) {
 								<?php
 							}
 							?>
+
+							<div class="row mb-1">
+								<div class="col-sm-4">Retest</div>
+								<div class="col-sm">
+									<div class="form-check">
+										<input class="form-check-input" type="checkbox" name="retest" id="retest" value="1" <?=Form::checked($test->retest)?> />
+										<label class="form-check-label" for="retest">Retest</label>
+									</div>
+									<small class="form-text text-muted">
+										If this test was a retest, please check the box above. Once the test is accepted or rejected, this flag cannot be changed.
+									</small>
+								</div>
+							</div>
+
 							<div class="row mb-1">
 								<label class="col-sm-4 col-form-label" for="tester-message">Message to Tester (if rejecting)</label>
 								<div class="col-sm">