Просмотр исходного кода

Add ability to void a test if the venue is closed

Alan Lam 5 лет назад
Родитель
Сommit
a2b7f5c5e5

+ 38 - 23
controllers/reports.php

@@ -50,7 +50,7 @@ $all_projects = Project::query([
 
 if(Core::$user->isCustomer()) {
 	// Filter to only projects that have past the deadline
-	$all_projects = array_filter($all_projects, function(Project $project) {
+	$all_projects = array_filter($all_projects, static function(Project $project) {
 		return $project->isFinished();
 	});
 }
@@ -72,6 +72,9 @@ $locations_missing_area_manager = [];
 
 $charts = [];
 
+$key_labels = [];
+$has_pass_fail = false;
+
 $submit = http::value("submit");
 if($submit) {
 	try {
@@ -152,16 +155,16 @@ if($submit) {
 			case "custom":
 				$check = strcmp($date_start, $date_end);
 				if($check > 0) {
-					$temp = $date_end;
+					$temp = $date_start;
 					$date_start = $date_end;
-					$date_start = $temp;
+					$date_end = $temp;
 				}
 
-				list($min_year, $min_month, $min_day) = explode("-", $date_start);
-				list($max_year, $max_month, $max_day) = explode("-", $date_end);
+				[$min_year, $min_month, $min_day] = explode("-", $date_start);
+				[$max_year, $max_month, $max_day] = explode("-", $date_end);
 
-				$min_dts = "{$date_start} 00:00:00";
-				$max_dts = "{$date_end} 23:59:59";
+				$min_dts = "$date_start 00:00:00";
+				$max_dts = "$date_end 23:59:59";
 
 				$min_time = strtotime($min_dts);
 				$max_time = strtotime($max_dts);
@@ -169,7 +172,7 @@ if($submit) {
 				$date_range_label = sprintf("%s - %s", date("j M y", $min_time), date("j M y", $max_time));
 
 				if(preg_match("/01-01$/", $date_start) && preg_match("/12-31$/", $date_end)) {
-					$date_range_label = $min_year == $max_year ? $min_year : "{$min_year} - {$max_year}";
+					$date_range_label = $min_year === $max_year ? $min_year : "$min_year - $max_year";
 				}
 
 				break;
@@ -225,7 +228,7 @@ if($submit) {
 		}
 
 		// Check if date range is same year
-		$same_year = ($min_year == $max_year);
+		$same_year = ($min_year === $max_year);
 
 		// Empty data objects hook
 		require $template->getProcessingFilePath("reports_create_empty_objects.php");
@@ -236,6 +239,8 @@ if($submit) {
 		$keys = [];
 		$key_labels = [];
 
+		$resolution_name = "Quarter";
+
 		for($year = $min_year; $year <= $max_year; $year++) {
 			switch($date_resolution) {
 				case "monthly":
@@ -276,6 +281,7 @@ if($submit) {
 		foreach($keys as $index => $key) {
 			$label = $key_labels[$index];
 
+			/** @var object $empty_data */
 			$data[$key] = clone $empty_data;
 			$data[$key]->label = $label;
 
@@ -283,11 +289,13 @@ if($submit) {
 				$r[$key] = clone $empty_data;
 				$r[$key]->label = $label;
 			}
+			unset($r);
 
 			foreach($area_manager_data as &$a) {
 				$a[$key] = clone $empty_data;
 				$a[$key]->label = $label;
 			}
+			unset($a);
 		}
 
 		$max_unix = 0;
@@ -327,22 +335,29 @@ if($submit) {
 					break;
 			}
 
-			$total_data->testCount++;
-			$data[$key]->testCount++;
-			if($region) $region_data[$region][$key]->testCount++;
-			if($area_manager) $area_manager_data[$area_manager][$key]->testCount++;
-
-			if($tester->gender == "M") {
-				$data[$key]->maleTesterCount++;
-				$total_data->maleTesterCount++;
-			}
-			if($tester->gender == "F") {
-				$data[$key]->femaleTesterCount++;
-				$total_data->femaleTesterCount++;
+			// Skip processing if test is void
+			if($test->isVoid()) {
+				$data[$key]->voidCount++;
+				$total_data->voidCount++;
 			}
+			else {
+				$total_data->testCount++;
+				$data[$key]->testCount++;
+				if($region) $region_data[$region][$key]->testCount++;
+				if($area_manager) $area_manager_data[$area_manager][$key]->testCount++;
+
+				if($tester->gender === "M") {
+					$data[$key]->maleTesterCount++;
+					$total_data->maleTesterCount++;
+				}
+				if($tester->gender === "F") {
+					$data[$key]->femaleTesterCount++;
+					$total_data->femaleTesterCount++;
+				}
 
-			// Process test hook
-			require $template->getProcessingFilePath("reports_process_test.php");
+				// Process test hook
+				require $template->getProcessingFilePath("reports_process_test.php");
+			}
 		}
 
 		$current_month = date("m", $max_unix);

+ 96 - 82
controllers/test_tester_form.php

@@ -10,17 +10,17 @@
  * @var string[] $template_keys
  */
 
-$is_confirmed = $test->status == Test::STATUS_CONFIRMED;
-$is_started = $test->status == Test::STATUS_STARTED;
-$is_unverified = $test->status == Test::STATUS_PENDING_VERIFICATION;
+$is_confirmed = $test->isConfirmed();
+$is_started = $test->hasStarted();
+$is_unverified = $test->isPendingVerification();
 
 Core::$show_footer_content = false;
 
-if(Core::$user->id != $test->tester_id) throw new Exception(__("You do not have permission to view this page."));
-if($test->status == Test::STATUS_ASSIGNED) throw new Exception(__("You do not have permission to view this page as you have not accepted the test yet."));
+if(Core::$user->getId() != $test->getTesterId()) throw new Exception(__("You do not have permission to view this page."));
+if($test->getStatus() === Test::STATUS_ASSIGNED) throw new Exception(__("You do not have permission to view this page as you have not accepted the test yet."));
 
 // Show completed message
-if($test->status > Test::STATUS_PENDING_VERIFICATION) {
+if($test->getStatus() > Test::STATUS_PENDING_VERIFICATION) {
 	View::includeOnce("header", compact("page_title"));
 	View::include("test_form", compact("test", "location", "project", "template"));
 	View::includeOnce("footer");
@@ -39,110 +39,117 @@ if($submit) {
 
 		$form_exception = new FormException;
 
+		$void = HTTP::value("void", "int");
+
+		// Parse before the test form
 		if($is_confirmed) {
-			// Parse before the test form
 			$fields = $json->beforeTest;
-
 		}
 
+		// Parse after the test form
 		if($is_started || $is_unverified) {
-			// Parse after the test form
 			$fields = $json->duringTest;
 
 			// Start/End times
-			if($is_started) {
-				$start_override = http::getDateTimeFromFields("start_override");
-				$end_override = http::getDateTimeFromFields("end_override");
-
-				$start_unix = null;
-				$end_unix = null;
 
-				if($start_override && $end_override) {
-					$start_unix = strtotime($start_override);
-					$end_unix = strtotime($end_override);
-
-					if($start_unix > $end_unix) $form_exception->addError(__("Entry Time must not be after Exit Time."));
-					if(!$start_unix && $end_unix && $test->dts_start) {
-						$recorded_start_unix = Util::getUnixTimeFromUTC($test->dts_start);
-						if($end_unix < $recorded_start_unix) $form_exception->addError(__("Exit Time cannot be later than the recorded Entry Time."));
+			if($void) {
+				$start_unix = time();
+				$end_unix = time();
+			}
+			else {
+				if($is_started) {
+					$start_override = http::getDateTimeFromFields("start_override");
+					$end_override = http::getDateTimeFromFields("end_override");
+
+					$start_unix = null;
+					$end_unix = null;
+
+					if($start_override && $end_override) {
+						$start_unix = strtotime($start_override);
+						$end_unix = strtotime($end_override);
+
+						if($start_unix > $end_unix) $form_exception->addError(__("Entry Time must not be after Exit Time."));
+						if(!$start_unix && $end_unix && $test->dts_start) {
+							$recorded_start_unix = Util::getUnixTimeFromUTC($test->dts_start);
+							if($end_unix < $recorded_start_unix) $form_exception->addError(__("Exit Time cannot be later than the recorded Entry Time."));
+						}
+					}
+					else {
+						$form_exception->addError(__("Entry Time and Exit Time must be filled in."));
 					}
-				}
-				else {
-					$form_exception->addError(__("Entry Time and Exit Time must be filled in."));
-				}
 
+				}
 			}
-
 		}
 
 		if(empty($fields)) throw new LogicException(__("No fields can be shown."));
 
-		foreach($fields as $field) {
-
-			$name = $field->name ?? false;
-			if(empty($name)) continue; // Not a field
+		if(!$void) {
+			foreach($fields as $field) {
+				$name = $field->name ?? false;
+				if(empty($name)) continue; // Not a field
 
-			$required_key = $field->requiredKey ?? null;
-			if($required_key && !in_array($required_key, $template_keys)) continue;
+				$required_key = $field->requiredKey ?? null;
+				if($required_key && !in_array($required_key, $template_keys)) continue;
 
-			$label = $field->label ?? "";
-			$type = $field->type;
-			$required = $field->required ?? false;
-			$values = $field->values ?? [];
+				$label = $field->label ?? "";
+				$type = $field->type;
+				$required = $field->required ?? false;
+				$values = $field->values ?? [];
 
-			if($type == "file") {
-				$file = (object) $_FILES[$name];
+				if($type === "file") {
+					$file = (object) $_FILES[$name];
 
-				try {
-					if(!$required && $file->error == UPLOAD_ERR_NO_FILE) continue;
-					if($required && $file->error == UPLOAD_ERR_NO_FILE) {
-						throw new Exception("$label is required.");
-					}
+					try {
+						if(!$required && $file->error === UPLOAD_ERR_NO_FILE) continue;
+						if($required && $file->error === UPLOAD_ERR_NO_FILE) {
+							throw new Exception("$label is required.");
+						}
 
-					// Detect upload error
-					if($file->error != UPLOAD_ERR_OK) throw new Exception(HTTP::getUploadErrorString($file->error));
+						// Detect upload error
+						if($file->error !== UPLOAD_ERR_OK) throw new Exception(HTTP::getUploadErrorString($file->error));
 
-					// Get image details
-					$size = @getimagesize($file->tmp_name);
-					if(!$size) throw new Exception(sprintf(__("The uploaded file for %s is not an image."), $label));
-					[$width, $height, $type] = $size;
-					if($type != IMAGETYPE_JPEG) throw new Exception(sprintf(__("The uploaded file for %s is not a JPEG."), $label));
+						// Get image details
+						$size = @getimagesize($file->tmp_name);
+						if(!$size) throw new Exception(sprintf(__("The uploaded file for %s is not an image."), $label));
+						[$width, $height, $type] = $size;
+						if($type !== IMAGETYPE_JPEG) throw new Exception(sprintf(__("The uploaded file for %s is not a JPEG."), $label));
 
-					// Resize image
-					$output_image = Image::normalise($file->tmp_name);
+						// Resize image
+						$output_image = Image::normalise($file->tmp_name);
 
-					// Write image to disk
-					$output_path = $test->getDirectory() . "/" . $name . ".jpg";
+						// Write image to disk
+						$output_path = $test->getDirectory() . "/" . $name . ".jpg";
 
-					imagejpeg($output_image, $output_path, 60);
-					imagedestroy($output_image);
-				}
-				catch(Exception $e) {
-					$form_exception->addError($e->getMessage());
+						imagejpeg($output_image, $output_path, 60);
+						imagedestroy($output_image);
+					}
+					catch(Exception $e) {
+						$form_exception->addError($e->getMessage());
+					}
 				}
-			}
-			else {
-				$value = http::value($name, "trim");
+				else {
+					$value = http::value($name, "trim");
 
-				if($required && $value === null) $form_exception->addError(sprintf(__("%s is required."), $label));
-				if($values && !in_array($value, $values)) $form_exception->addError(sprintf(__("Value for %s is invalid."), $label));
+					if($required && $value === null) $form_exception->addError(sprintf(__("%s is required."), $label));
+					if($values && !in_array($value, $values)) $form_exception->addError(sprintf(__("Value for %s is invalid."), $label));
 
-				if(in_array($name, Test::TEST_FIELDS)) {
-					$test->$name = $value;
-				}
-				else {
-					$test_value = TestValue::get($test->id, $name);
-					if(!$test_value) {
-						$test_value = new TestValue;
-						$test_value->test_id = $test->id;
-						$test_value->name = $name;
+					if(in_array($name, Test::TEST_FIELDS)) {
+						$test->$name = $value;
+					}
+					else {
+						$test_value = TestValue::get($test->id, $name);
+						if(!$test_value) {
+							$test_value = new TestValue;
+							$test_value->test_id = $test->id;
+							$test_value->name = $name;
+						}
+						$test_value->value = $value;
+						$success = $test_value->commit();
+						if(!$success) $form_exception->addError(sprintf(__("Failed to save value for %s."), $label));
 					}
-					$test_value->value = $value;
-					$success = $test_value->commit();
-					if(!$success) $form_exception->addError(sprintf(__("Failed to save value for %s."), $label));
 				}
 			}
-
 		}
 
 		if($form_exception->hasErrors()) throw $form_exception;
@@ -164,7 +171,9 @@ if($submit) {
 		}
 
 		// During the test
+
 		if($is_started || $is_unverified) {
+
 			$test->status = Test::STATUS_PENDING_VERIFICATION;
 
 			if($is_started) {
@@ -183,9 +192,14 @@ if($submit) {
 				}
 			}
 
-			$test->pass = 1;
-			if($template->hasPassFail()) {
-				$test->pass = ($test->challenge_stage <= $template->getPassStage()) ? 1 : 0; // Pass = Challenged during browsing or before
+			if($void) {
+				$test->void = 1;
+			}
+			else {
+				$test->pass = 1;
+				if($template->hasPassFail()) {
+					$test->pass = ($test->challenge_stage <= $template->getPassStage()) ? 1 : 0; // Pass = Challenged during browsing or before
+				}
 			}
 
 			$test->dts_updated = Util::getDateTime();

+ 21 - 19
controllers/test_verify_form.php

@@ -105,28 +105,30 @@ if($submit) {
 		if($test->test_travel_cost < 0 || $test->test_travel_cost > 999.99) $form_exception->addError("Travel costs must be between 0 and 999.99.");
 
 		// Test forms
-		foreach($fields as $field) {
-			if($field->type == "header") continue;
-			if($field->type == "file") continue;
-			if(empty($field->name)) continue;
+		if($test->isVoid() === false) {
+			foreach($fields as $field) {
+				if($field->type === "header") continue;
+				if($field->type === "file") continue;
+				if(empty($field->name)) continue;
 
-			$required_key = $field->requiredKey ?? null;
-			if($required_key && !in_array($required_key, $template_keys)) continue;
+				$required_key = $field->requiredKey ?? null;
+				if($required_key && !in_array($required_key, $template_keys)) continue;
 
-			$value = http::value($field->name, "trim");
+				$value = http::value($field->name, "trim");
 
-			if(in_array($field->name, Test::TEST_FIELDS)) {
-				$test->{$field->name} = $value;
-			}
-			else {
-				$test_value = TestValue::get($id, $field->name);
-				if(!$test_value) {
-					$test_value = new TestValue;
-					$test_value->test_id = $id;
-					$test_value->name = $field->name;
+				if(in_array($field->name, Test::TEST_FIELDS)) {
+					$test->{$field->name} = $value;
+				}
+				else {
+					$test_value = TestValue::get($id, $field->name);
+					if(!$test_value) {
+						$test_value = new TestValue;
+						$test_value->test_id = $id;
+						$test_value->name = $field->name;
+					}
+					$test_value->value = $value;
+					$test_value->commit();
 				}
-				$test_value->value = $value;
-				$test_value->commit();
 			}
 		}
 
@@ -142,7 +144,7 @@ if($submit) {
 
 		if($form_exception->hasErrors()) throw $form_exception;
 
-		$test->retest = http::value("retest", "int");
+		$test->retest = (int) http::value("retest", "int");
 
 		$test->dts_updated = Util::getDateTime();
 		$success = $test->commit();

+ 5 - 5
controllers/tests_tester_list.php

@@ -32,17 +32,17 @@ if(HTTP::isAJAX()) {
 				$location = $test->getLocation();
 				$icon = null;
 
-				switch($test->status) {
-					case 2:
+				switch($test->getStatus()) {
+					case Test::STATUS_ASSIGNED:
 						$icon = "building-orange";
 						break;
-					case 3:
+					case Test::STATUS_CONFIRMED:
 						$icon = "building-green";
 						break;
-					case 4:
+					case Test::STATUS_STARTED:
 						$icon = "building-pink";
 						break;
-					case 8:
+					case Test::STATUS_PENDING_VERIFICATION:
 						$icon = "building-grey";
 						break;
 				}

+ 11 - 0
db/migrations/20210704223322_add_void_field_to_test_table.php

@@ -0,0 +1,11 @@
+<?php
+
+use Phinx\Migration\AbstractMigration;
+
+class AddVoidFieldToTestTable extends AbstractMigration {
+	public function change() {
+		$this->table("test")
+			->addColumn("void", "boolean", ["signed" => false, "default" => 0, "after" => "retest"])
+			->update();
+	}
+}

+ 15 - 9
engine/chart_generator.php

@@ -147,18 +147,24 @@ class ChartGenerator {
 	}
 
 	public function getPassFailCountChart(): Chart {
+		$data = $this->totalData;
+
+		$dataset = [$data->passCount, $data->failCount];
+		$labels = ["Pass", "Fail"];
+		$colours = [self::COLOUR_GREEN, self::COLOUR_RED];
+
+		if($data->voidCount > 0) {
+			$dataset[] = $data->voidCount;
+			$labels[] = "Void";
+			$colours[] = self::COLOUR_GREY;
+		}
+
 		$chart = new Chart;
 		$chart->setType("pie");
 		$chart->setTitle("Pass / Fail ({$this->dateRangeLabel})");
-		$chart->setLabels(["Pass", "Fail"]);
-		$chart->addDataset("Counts", [
-			$this->totalData->passCount,
-			$this->totalData->failCount,
-		], [
-			"background_colours" => [
-				self::COLOUR_GREEN,
-				self::COLOUR_RED,
-			],
+		$chart->setLabels($labels);
+		$chart->addDataset("Counts", $dataset, [
+			"background_colours" => $colours,
 			"datalabels" => Chart::DATALABELS_BOX,
 		]);
 		return $chart;

+ 4 - 5
engine/http.php

@@ -138,7 +138,6 @@ class HTTP {
 				break;
 			default:
 				trigger_error("http::value called with \"$request_type\" request_type", E_USER_ERROR);
-				break;
 		}
 
 		if(!isset($array[$key])) return null;
@@ -148,14 +147,14 @@ class HTTP {
 		switch($validation) {
 
 			case "int": {
-				if(!is_array($value) && strlen($value)===0) return null;
-				return is_array($value) ? array_map("intval", $value) : intval($value);
+				if(!is_array($value) && $value === '') return null;
+				return is_array($value) ? array_map("intval", $value) : (int) $value;
 			}
 
 			case "double":
 			case "float": {
-				if(strlen($value)===0) return null;
-				return floatval($value);
+				if($value === '') return null;
+				return (float) $value;
 			}
 
 			// Return database escaped string

+ 10 - 11
engine/model.php

@@ -378,7 +378,7 @@ abstract class Model {
 
 		$this->model_data = $model_data;
 
-		$this->in_db = !is_null($this->getID());
+		$this->in_db = !is_null($this->getId());
 
 	}
 
@@ -397,7 +397,7 @@ abstract class Model {
 	private final function getIDWhere() {
 
 		$id_field = static::$id_field;
-		$id = $this->getID();
+		$id = $this->getId();
 
 		$nvp = [];
 		if(is_array($id) && is_array($id_field)) {
@@ -507,10 +507,10 @@ abstract class Model {
 	 * @return bool
 	 * @throws Exception
 	 */
-	public function delete() {
+	public function delete(): bool {
 		$table = static::$table;
 
-		$id = $this->getID();
+		$id = $this->getId();
 
 		if(is_null($id)) return false;
 
@@ -519,20 +519,20 @@ abstract class Model {
 		$sql = "DELETE FROM `$table` WHERE $where";
 		$result = db::query($sql);
 
-		return empty($result) ? false : (db::affected_rows() ? true : false);
+		return !empty($result) && db::affected_rows();
 	}
 
 	/**
 	 * @return bool
 	 * @throws Exception
 	 */
-	public final function deleteOrException() {
+	final public function deleteOrException(): bool {
 		$success = $this->delete();
 		if(!$success) throw new Exception("Database error.");
-		return $success;
+		return true;
 	}
 
-	public final function getID() {
+	final public function getId() {
 		$id_field = static::$id_field;
 		if(is_array($id_field)) {
 			$values = [];
@@ -544,9 +544,8 @@ abstract class Model {
 			}
 			return $values;
 		}
-		else {
-			return $this->model_data->$id_field ?? null;
-		}
+
+		return $this->model_data->$id_field ?? null;
 	}
 
 	public final function getModelData() {

+ 36 - 8
engine/test.php

@@ -34,6 +34,7 @@ use Mpdf\Mpdf;
  * @property string $verifier_notes
  * @property bool $pass
  * @property bool $retest
+ * @property bool $void
  * @property string $dts_created
  * @property string $dts_updated
  * @property string $dts_assigned
@@ -44,7 +45,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", "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", "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"];
 
@@ -450,10 +451,10 @@ class Test extends Model {
 	}
 
 	/**
-	 * @return Project|null
+	 * @return Project
 	 * @throws Exception
 	 */
-	public function getProject(): ?Project {
+	public function getProject(): Project {
 		return Project::get($this->project_id);
 	}
 
@@ -637,15 +638,15 @@ class Test extends Model {
 	/**
 	 * @return bool
 	 */
-	public function isCompleted() {
-		return $this->status == Test::STATUS_COMPLETED;
+	public function isCompleted(): bool {
+		return $this->getStatus() === self::STATUS_COMPLETED;
 	}
 
 	/**
 	 * @return bool
 	 */
-	public function isPendingVerification() {
-		return $this->status == Test::STATUS_PENDING_VERIFICATION;
+	public function isPendingVerification(): bool {
+		return $this->getStatus() === self::STATUS_PENDING_VERIFICATION;
 	}
 
 	public function getPDFPath() {
@@ -768,10 +769,37 @@ class Test extends Model {
 		// Additional tester invoice fields
 		$tester_invoice_fields = $template->getTesterInvoiceFields();
 		foreach($tester_invoice_fields as $field) {
-			$invoice_total += (float) $values[$field->name] ?? 0;
+			$invoice_total += (float) ($values[$field->name] ?? 0);
 		}
 
 		return $invoice_total;
 	}
 
+	public function isVoid(): bool {
+		return (bool) $this->void;
+	}
+
+	public function getStatus(): int {
+		return $this->status;
+	}
+
+	public function getTesterId(): int {
+		return $this->tester_id;
+	}
+
+	/**
+	 * @return bool Whether the tester has accepted the test
+	 */
+	public function isConfirmed(): bool {
+		return $this->getStatus() === self::STATUS_CONFIRMED;
+	}
+
+	public function hasStarted(): bool {
+		return $this->getStatus() === self::STATUS_STARTED;
+	}
+
+	public function isAssigned(): bool {
+		return $this->getStatus() === self::STATUS_ASSIGNED;
+	}
+
 }

+ 2 - 1
engine/test_result_set.php

@@ -27,12 +27,13 @@ class TestResultSet {
 	 * @param string $dts_start Start date/time in local time
 	 * @param string $dts_end End date/time in local time
 	 * @return Test[]
+	 * @throws Exception
 	 */
 	public function filterByDateRange(string $dts_start, string $dts_end): array {
 		$min_unix = strtotime($dts_start);
 		$max_unix = strtotime($dts_end);
 
-		$tests = array_filter($this->tests, function(Test $test) use ($min_unix, $max_unix) {
+		$tests = array_filter($this->tests, static function(Test $test) use ($min_unix, $max_unix) {
 
 			$project = $test->getProject();
 

+ 23 - 12
public/js/app-test.js

@@ -17,14 +17,21 @@ function initialiseBeforeTestForm() {
 
 function initialiseTestForm() {
 
-	$form = $("#test-form");
+	const $form = $("#test-form");
 
-	$testMainFormContainer = $("#test-main-form-container");
-	$submitButton = $("#test-submit-button");
+	const $testMainFormContainer = $("#test-main-form-container");
 
-	$noInternetText = $("#test-no-internet-text");
+	const $submitButton = $("#test-submit-button");
 
-	$submitStatus = $("#test-submit-status");
+	const $voidButton = $("#test-void-button");
+	$voidButton.on("click", () => {
+		$("#void").val("1");
+		$submitButton.trigger("click");
+	});
+
+	const $noInternetText = $("#test-no-internet-text");
+
+	const $submitStatus = $("#test-submit-status");
 
 	$form.on("submit", function(event) {
 
@@ -32,18 +39,20 @@ function initialiseTestForm() {
 
 		$noInternetText.addClass("d-none");
 		$submitStatus.html("Submitting...");
-		$submitButton.attr("disabled", "");
 
-		var data = $form.serialize();
+		$submitButton.prop("disabled", true);
+		$voidButton.prop("disabled", true);
+
+		const data = $form.serialize();
 
 		$.ajax({
 			type: "post",
 			url: window.location,
 			data: data,
-			success: function(data, text) {
+			success: (response) => {
 				try {
-					if(!data.success && data.message) throw data.message;
-					else if(!data.success) throw "Please try again later.";
+					if(!response.success && response.message) throw response.message;
+					else if(!response.success) throw "Please try again later.";
 
 					$submitStatus.html("Submitted. Thank you for participating in this test. You will be redirected to the Tests page in three seconds.");
 					setTimeout(function() {
@@ -52,14 +61,16 @@ function initialiseTestForm() {
 				}
 				catch(err) {
 					$submitStatus.html("Error: " + err);
-					$submitButton.removeAttr("disabled");
+					$submitButton.prop("disabled", false);
+					$voidButton.prop("disabled", false);
 				}
 			},
 			error: function(request, status, error) {
 				console.log(request, status, error);
 				$submitStatus.html("");
 				$noInternetText.removeClass("d-none");
-				$submitButton.removeAttr("disabled");
+				$submitButton.prop("disabled", false);
+				$voidButton.prop("disabled", false);
 			}
 		});
 

+ 9 - 2
template_processing/age_verification/project_csv.php

@@ -1,10 +1,16 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
+/**
+ * @var resource $handle
+ * @var object[] $fields
+ * @var Test[] $tests
+ * @var Template $template
+ */
 
 $field_names = [
 	"Project ID", "Project Name",
 	"Template Name",
-	"Test ID", "Test Status", "Test Result",
+	"Test ID", "Test Status", "Test Void", "Test Result",
 	"Location Name", "Legal Entity", "Address", "Email", "Phone", "Region", "Internal ID", "Area Manager",
 	"Tester Age", "Tester Gender", "Travel Costs",
 
@@ -41,6 +47,7 @@ foreach($tests as $test) {
 	$output[] = $template->name;
 	$output[] = $test->id;
 	$output[] = $test->getStatusText();
+	$output[] = $test->isVoid() ? "Y" : "N";
 
 	if(!is_null($test->pass)) {
 

+ 2 - 1
template_processing/age_verification/project_customer_csv.php

@@ -1,7 +1,7 @@
 <?php
 
 $field_names = [
-	"Test Result",
+	"Test Result", "Test Void",
 	"Location Name", "Address", "Region", "Internal ID", "Area Manager",
 
 	"Date",
@@ -59,6 +59,7 @@ foreach($tests as $test) {
 	}
 
 	$output[] = $result;
+	$output[] = $test->isVoid() ? "Y" : "N";
 	$output[] = $location->name;
 	$output[] = $location->getDisplayAddress();
 	$output[] = $location->region;

+ 2 - 2
template_processing/age_verification/reports_create_empty_objects.php

@@ -5,6 +5,7 @@ $empty_data = (object) [
 	"testCount" => 0,
 	"passCount" => 0,
 	"failCount" => 0,
+	"voidCount" => 0,
 
 	"eyeContactCounts" => [0, 0, 0],
 
@@ -61,6 +62,7 @@ $total_data = (object) [
 	"testCount" => 0,
 	"passCount" => 0,
 	"failCount" => 0,
+	"voidCount" => 0,
 
 	"stage1Count" => 0,
 	"stage2Count" => 0,
@@ -68,5 +70,3 @@ $total_data = (object) [
 	"stage4Count" => 0,
 	"stage5Count" => 0,
 ];
-
-?>

+ 8 - 0
template_processing/age_verification/reports_process_test.php

@@ -2,14 +2,22 @@
 
 /**
  * @var object $total_data Total data
+ * @var object $region_data
+ * @var object $area_manager_data
  * @var array $data Periodic data
  * @var string $key Current period key
  * @var string $region
  * @var string $area_manager
  * @var Test $test
+ * @var User $tester
  * @var array $test_values
  */
 
+/**
+ * @param int|null $value Yes / No / Don't Know
+ * @param bool $pass Test passed
+ * @param string $prefix
+ */
 $booleanPassFieldIncrementor = function($value, $pass, $prefix) use (&$data, $key) {
 
 	if($pass) {

+ 2 - 2
template_processing/age_verification_mitchells_butlers/reports_create_empty_objects.php

@@ -5,6 +5,7 @@ $empty_data = (object) [
 	"testCount" => 0,
 	"passCount" => 0,
 	"failCount" => 0,
+	"voidCount" => 0,
 
 	"eyeContactCounts" => [0, 0, 0],
 
@@ -67,6 +68,7 @@ $total_data = (object) [
 	"testCount" => 0,
 	"passCount" => 0,
 	"failCount" => 0,
+	"voidCount" => 0,
 
 	"stage1Count" => 0,
 	"stage2Count" => 0,
@@ -74,5 +76,3 @@ $total_data = (object) [
 	"stage4Count" => 0,
 	"stage5Count" => 0,
 ];
-
-?>

+ 3 - 0
template_processing/age_verification_mitchells_butlers/reports_process_test.php

@@ -2,11 +2,14 @@
 
 /**
  * @var object $total_data Total data
+ * @var object $region_data
+ * @var object $area_manager_data
  * @var array $data Periodic data
  * @var string $key Current period key
  * @var string $region
  * @var string $area_manager
  * @var Test $test
+ * @var User $tester
  * @var array $test_values
  */
 

+ 2 - 2
template_processing/mystery_shop/reports_create_empty_objects.php

@@ -3,6 +3,7 @@
 $empty_data = (object) [
 	"label" => "",
 	"testCount" => 0,
+	"voidCount" => 0,
 
 	"cleanlinessCounts" => [0, 0, 0, 0, 0],
 	"staffBadgeWornCounts" => [0, 0, 0],
@@ -23,6 +24,5 @@ $total_data = (object) [
 	"femaleTesterCount" => 0,
 
 	"testCount" => 0,
+	"voidCount" => 0,
 ];
-
-?>

+ 14 - 9
template_processing/mystery_shop/reports_process_test.php

@@ -1,27 +1,32 @@
 <?php
 
+/**
+ * @var array $data
+ * @var array $total_data
+ * @var object $test_values
+ * @var string $key
+ */
+
 $cleanliness = $test_values->cleanliness;
 $data[$key]->cleanlinessCounts[$cleanliness - 1]++;
 $total_data->cleanlinessCounts[$cleanliness - 1]++;
 
 $staff_badge_worn = $test_values->staff_badge_worn ?? null;
-if(is_null($staff_badge_worn)) $data[$key]->staffBadgeWornCounts[0]++;
-else $data[$key]->staffBadgeWornCounts[$staff_badge_worn + 1]++;
+if($staff_badge_worn === null) $data[$key]->staffBadgeWornCounts[0]++;
+else $data[$key]->staffBadgeWornCounts[(int) $staff_badge_worn + 1]++;
 
 $staff_offered_drink = $test_values->staff_offered_drink ?? 0;
-$data[$key]->staffOfferedDrinkCounts[$staff_offered_drink]++;
+$data[$key]->staffOfferedDrinkCounts[(int) $staff_offered_drink]++;
 
 $staff_offered_promotion = $test_values->staff_offered_promotion ?? 0;
-$data[$key]->staffOfferedPromotionCounts[$staff_offered_promotion]++;
+$data[$key]->staffOfferedPromotionCounts[(int) $staff_offered_promotion]++;
 
 $staff_help = $test_values->staff_help ?? 0;
-$data[$key]->staffOfferedHelpCounts[$staff_help]++;
+$data[$key]->staffOfferedHelpCounts[(int) $staff_help]++;
 
 $staff_behaviour = $test_values->staff_behaviour ?? null;
 if(is_null($staff_behaviour)) $data[$key]->staffBehaviourCounts[0]++;
-else $data[$key]->staffBehaviourCounts[$staff_behaviour]++;
+else $data[$key]->staffBehaviourCounts[(int) $staff_behaviour]++;
 
 $staff_uniform = $test_values->staff_uniform ?? 0;
-$data[$key]->staffUniformCounts[$staff_uniform]++;
-
-?>
+$data[$key]->staffUniformCounts[(int) $staff_uniform]++;

+ 2 - 2
views/project_form.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 
 /**
  * @var Project $project
@@ -31,9 +31,9 @@ $name_readonly = $project->id ? "" : "readonly";
 $autogen_checked = $project->id ? "" : "checked";
 
 $tests = [];
+$location_test = [];
 if($project->id) {
 	$tests = $project->getTests();
-	$location_test = [];
 	foreach($tests as $test) {
 		$location_test[$test->location_id] = $test;
 	}

+ 77 - 97
views/reports.php

@@ -1,8 +1,27 @@
 <?php
 
 /**
+ * @var Customer $customer
  * @var Chart[] $charts
  * @var string[] $key_labels
+ * @var bool $has_pass_fail
+ *
+ * @var string $date_range
+ * @var string $date_resolution
+ * @var string $date_start
+ * @var string $date_end
+ *
+ * @var int[] $location_ids
+ * @var int $retests
+ * @var int[] $exclude_project_ids
+ *
+ * @var array $project_table_data
+ * @var Location[] $locations_missing_region
+ * @var Location[] $locations_missing_area_manager
+ *
+ * @var array $total_data
+ * @var array $region_data
+ * @var array $area_manager_data
  */
 
 $date_resolutions = [
@@ -17,23 +36,22 @@ $date_ranges = [
 ];
 
 $retests_options = [
-	"0" => "Exclude",
-	"1" => "Retests Only"
+	0 => "Exclude",
+	1 => "Retests Only"
 ];
 
 $years = range(2018, date("Y"));
 
-$date_range_custom_style = ($date_range == "custom") ? "" : "display: none";
+$date_range_custom_style = ($date_range === "custom") ? "" : "display: none";
 $date_range_value = "";
 
 if($date_start && $date_end) {
 	list($min_year, $min_month, $min_day) = explode("-", $date_start);
 	list($max_year, $max_month, $max_day) = explode("-", $date_end);
 
-	$date_range_value = "{$min_day}/{$min_month}/{$min_year} - {$max_day}/{$max_month}/{$max_year}";
+	$date_range_value = "$min_day/$min_month/$min_year - $max_day/$max_month/$max_year";
 }
 
-
 ?>
 <script>
 let selectedProjectIds = <?=json_encode($exclude_project_ids)?>;
@@ -75,7 +93,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 					</label><br / >
 					<?php
 					foreach($date_ranges as $value => $display) {
-						$checked = ($value == $date_range) ? "checked" : "";
+						$checked = ($value === $date_range) ? "checked" : "";
 						?>
 						<div class="form-check form-check-inline">
 							<input class="form-check-input" type="radio" name="date_range" id="date-range-<?=htmlspecialchars($value)?>" value="<?=htmlspecialchars($value)?>" <?=$checked?> data-date-range-radio-input />
@@ -99,7 +117,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 					<select class="form-control" name="date_resolution" id="date-resolution">
 					<?php
 					foreach($date_resolutions as $value => $display) {
-						$selected = ($value == $date_resolution) ? "selected" : "";
+						$selected = ($value === $date_resolution) ? "selected" : "";
 						?>
 						<option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
 						<?php
@@ -348,28 +366,42 @@ let projectData = <?=json_encode($project_table_data)?>;
 		}
 
 		if($has_pass_fail) {
+
+			$tables = [
+				(object) [
+					"name" => "Region",
+					"data" => $region_data
+				],
+				(object) [
+					"name" => "Area Manager",
+					"data" => $area_manager_data
+				],
+			]
+
 			?>
 			<div class="d-print-none">
 				<h2>Extra Information</h2>
 
-				<h3>Region Data</h3>
-
 				<?php
-
-				foreach($region_data as $region => $rows) {
-
+				foreach($tables as $table) {
+					$title = $table->name . " Data";
+					$entity_type = $table->name;
 					?>
-					<h4>Region: <?=htmlspecialchars($region)?></h4>
-
-					<table class="table">
-						<colgroup>
-							<col style="width: 20%" />
-							<col style="width: 20%" />
-							<col style="width: 20%" />
-							<col style="width: 20%" />
-							<col style="width: 20%" />
-						</colgroup>
-						<thead>
+					<h3><?=htmlspecialchars($title)?></h3>
+					<?php
+					foreach($table->data as $entity_name => $rows) {
+						?>
+						<h4><?=htmlspecialchars($entity_type)?>: <?=htmlspecialchars($entity_name)?></h4>
+
+						<table class="table">
+							<colgroup>
+								<col style="width: 20%" />
+								<col style="width: 20%" />
+								<col style="width: 20%" />
+								<col style="width: 20%" />
+								<col style="width: 20%" />
+							</colgroup>
+							<thead>
 							<tr>
 								<th>Period</th>
 								<th>Tests</th>
@@ -377,93 +409,41 @@ let projectData = <?=json_encode($project_table_data)?>;
 								<th>Fails</th>
 								<th>Rate</th>
 							</tr>
-						</thead>
-						<tbody>
-						<?php
-
-						$index = 0;
-
-						foreach($rows as $key => $data) {
-							$rate = ($data->testCount == 0) ? "0.00" : number_format(($data->passCount * 100) / $data->testCount, 2);
-							$label = $key_labels[$index];
-							?>
-							<tr>
-								<td><?=htmlspecialchars($label)?></td>
-								<td><?=number_format($data->testCount)?></td>
-								<td><?=number_format($data->passCount)?></td>
-								<td><?=number_format($data->failCount)?></td>
-								<td><?=$rate?>%</td>
-							</tr>
+							</thead>
+							<tbody>
 							<?php
-							$index++;
-						}
-						?>
-						</tbody>
-					</table>
-
-					<?php
-
-				}
-
-				?>
-				<h3>Area Manager Data</h3>
-				<?php
 
-				foreach($area_manager_data as $area_manager => $rows) {
+							$index = 0;
 
-					?>
-					<h4>Area Manager: <?=htmlspecialchars($area_manager)?></h4>
-
-					<table class="table">
-						<colgroup>
-							<col style="width: 20%" />
-							<col style="width: 20%" />
-							<col style="width: 20%" />
-							<col style="width: 20%" />
-							<col style="width: 20%" />
-						</colgroup>
-						<thead>
-							<tr>
-								<th>Period</th>
-								<th>Tests</th>
-								<th>Passes</th>
-								<th>Fails</th>
-								<th>Rate</th>
-							</tr>
-						</thead>
-						<tbody>
-						<?php
-						$index = 0;
-						foreach($rows as $key => $data) {
-							$rate = ($data->testCount == 0) ? "0.00" : number_format(($data->passCount * 100) / $data->testCount, 2);
-							$label = $key_labels[$index];
+							foreach($rows as $key => $data) {
+								$rate = ($data->testCount == 0) ? "0.00" : number_format(($data->passCount * 100) / $data->testCount, 2);
+								$label = $key_labels[$index];
+								?>
+								<tr>
+									<td><?=htmlspecialchars($label)?></td>
+									<td><?=number_format($data->testCount)?></td>
+									<td><?=number_format($data->passCount)?></td>
+									<td><?=number_format($data->failCount)?></td>
+									<td><?=$rate?>%</td>
+								</tr>
+								<?php
+								$index++;
+							}
 							?>
-							<tr>
-								<td><?=htmlspecialchars($label)?></td>
-								<td><?=number_format($data->testCount)?></td>
-								<td><?=number_format($data->passCount)?></td>
-								<td><?=number_format($data->failCount)?></td>
-								<td><?=$rate?>%</td>
-							</tr>
-							<?php
-							$index++;
-						}
-						?>
-						</tbody>
-					</table>
+							</tbody>
+						</table>
 
-					<?php
+						<?php
 
+					}
 				}
+				?>
 			?>
 			</div>
 			<?php
 		}
-
 		?>
 		<?php
-
 	}
 	?>
-
 </div>

+ 22 - 7
views/test_form.php

@@ -1,4 +1,4 @@
-<?php
+<?php /** @noinspection PhpUnhandledExceptionInspection */
 /**
  * @controller test.php
  *
@@ -10,13 +10,13 @@
 ?>
 <div class="container mt-3 py-4">
 <?php
-if($test->status == Test::STATUS_CONFIRMED) {
+if($test->isConfirmed()) {
 	$template->renderBeforeTestForm();
 }
-else if($test->status == Test::STATUS_STARTED) {
+else if($test->hasStarted()) {
 	$template->renderDuringTestForm();
 }
-else if($test->status == Test::STATUS_PENDING_VERIFICATION) {
+else if($test->isPendingVerification()) {
 
 	$json = json_decode($template->getJSON());
 	$fields = $json->duringTest;
@@ -42,9 +42,23 @@ else if($test->status == Test::STATUS_PENDING_VERIFICATION) {
 		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"><?=htmlspecialchars(__("Submit Test Results"))?></button>
+		<input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
+		<input type="hidden" name="void" id="void" value="0" />
+
+		<div class="form-row">
+			<div class="col-lg-8">
+				<button class="btn btn-block btn-success" type="submit" id="test-submit-button">
+					<?=htmlspecialchars(__("Submit Test Results"))?>
+				</button>
+			</div>
+			<div class="col-lg-4">
+				<button class="btn btn-block btn-secondary" type="submit" id="test-void-button">
+					<?=htmlspecialchars(__("Venue Was Closed"))?>
+				</button>
+			</div>
+		</div>
+
+		<div class="text-center">
 			<small class="form-text text-muted d-none" id="test-no-internet-text">
 				<span class="text-danger"><?=htmlspecialchars(__("No Internet Connectivity"))?></span><br />
 				<?=htmlspecialchars(__("Please check your Internet connectivity and try again."))?>
@@ -53,6 +67,7 @@ else if($test->status == Test::STATUS_PENDING_VERIFICATION) {
 
 			</small>
 		</div>
+
 	</form>
 	<?php
 }

+ 19 - 10
views/test_list_assigned.php

@@ -1,3 +1,12 @@
+<?php /** @noinspection PhpUnhandledExceptionInspection */
+
+/**
+ * @var Test[] $tests
+ * @var float $latitude
+ * @var float $longitude
+ */
+
+?>
 <div class="container mt-3 py-4">
 
 	<div class="row">
@@ -58,13 +67,8 @@
 			$date_due = explode(" ", $dts_due)[0];
 			$date_due = date("d/m/Y", strtotime($date_due));
 
-			$is_assigned = $test->status == Test::STATUS_ASSIGNED;
-			$is_confirmed = $test->status == Test::STATUS_CONFIRMED;
-			$is_started = $test->status == Test::STATUS_STARTED;
-			$is_unverified = $test->status == Test::STATUS_PENDING_VERIFICATION;
-
 			$status_text = $test->getStatusText();
-			if($is_unverified) $status_text = "Unverified";
+			if($test->isPendingVerification()) $status_text = "Unverified";
 
 			?>
 			<div class="list-group-item" id="test-<?=$test->id?>">
@@ -86,23 +90,28 @@
 							</div>
 							<div class="col-sm-5 text-sm-right align-self-center mt-1 mt-sm-0">
 							<?php
-							if($is_assigned) {
+							if($test->isAssigned()) {
 								?>
 								<a class="btn btn-success" href="/account/tests/<?=$test->id?>/accept"><?=htmlspecialchars(__("Accept"))?></a>
 								<a class="btn btn-danger" href="/account/tests/<?=$test->id?>/decline"><?=htmlspecialchars(__("Decline"))?></a>
 								<?php
 							}
-							else if($is_confirmed) {
+							else if($test->isConfirmed()) {
 								?>
 								<a class="btn btn-primary" href="/account/tests/<?=$test->id?>"><?=htmlspecialchars(__("Begin"))?></a>
 								<?php
 							}
-							else if($is_started) {
+							else if($test->hasStarted()) {
 								?>
 								<a class="btn btn-primary" href="/account/tests/<?=$test->id?>"><?=htmlspecialchars(__("Continue"))?></a>
 								<?php
 							}
-							else if($is_unverified) {
+							else if($test->isVoid()) {
+								?>
+								<?=htmlspecialchars(__("No further actions are available for this test as you have said the venue was closed."))?>
+								<?php
+							}
+							else if($test->isPendingVerification()) {
 								?>
 								<a class="btn btn-primary" href="/account/tests/<?=$test->id?>"><?=htmlspecialchars(__("Amend"))?></a>
 								<?php

+ 18 - 9
views/test_verify_form.php

@@ -15,14 +15,23 @@
  * @var string $tester_message
  */
 
-$test_details = [
-	"Status" => "<span class=\"badge badge-lg badge-" . $test->getStatusClass() . "\">" . $test->getStatusText() . "</span>",
-	"Result" => "<span class=\"badge badge-lg badge-" . $test->getPassClass() . "\">" . $test->getPassText() . "</span>",
-	"Location" => "<a href=\"/account/locations/$location->id\" target=\"_blank\">" . htmlspecialchars($location->name) . "</a>",
-	"Address" => htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"])),
-];
+$test_details = [];
+
+$test_details["Project"] = sprintf('<a href="/account/projects/%d">%s</a>', $test->project_id, $project->getNameHtml());
+
+$test_details["Status"] = "<span class=\"badge badge-lg badge-" . $test->getStatusClass() . "\">" . $test->getStatusText() . "</span>";
+
+if($test->isVoid()) {
+	$test_details["Result"] = "<span class=\"badge badge-lg badge-secondary\">Void</span>";
+}
+else {
+	$test_details["Result"] = "<span class=\"badge badge-lg badge-" . $test->getPassClass() . "\">" . $test->getPassText() . "</span>";
+}
+
+$test_details["Location"] = "<a href=\"/account/locations/$location->id\" target=\"_blank\">" . htmlspecialchars($location->name) . "</a>";
+$test_details["Address"] = htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]));
 
-if(!is_null($test->dts_end)) {
+if($test->dts_end) {
 	$test_details = array_merge($test_details, [
 		"Duration" => $test->getDisplayDuration(),
 		"Start" => Util::getDisplayDateTime(strtotime($test->dts_start . " UTC")),
@@ -158,7 +167,7 @@ function render_card_list_group($details) {
 
 						$field = $template->applyOverridesToField($field);
 
-						if($field->type == "file") {
+						if($field->type === "file") {
 							$path = $test->getDirectory() . "/" . $field->name . ".jpg";
 
 							?>
@@ -183,7 +192,7 @@ function render_card_list_group($details) {
 						$field->template = $template;
 						Form::renderField($field);
 
-						if($field->type == "header") {
+						if($field->type === "header") {
 							$header_count++;
 						}
 					}