Bladeren bron

Add Stonegate template and charts

Alan Lam 4 jaren geleden
bovenliggende
commit
c39c0ade64

+ 4 - 0
controllers/test_verify_form.php

@@ -109,6 +109,10 @@ if($submit) {
 
 				$value = http::value($field->name, "trim");
 
+				if($value === "") {
+					$value = null;
+				}
+
 				if(in_array($field->name, Test::TEST_FIELDS, true)) {
 					$test->{$field->name} = $value;
 				}

+ 132 - 77
engine/chart_generator.php

@@ -6,18 +6,18 @@
 
 class ChartGenerator {
 
-	const COLOUR_GREEN = "#4CAF50";
-	const COLOUR_RED = "#F44336";
-	const COLOUR_YELLOW = "#FFEB3B";
-	const COLOUR_LIGHT_GREY = "#CCCCCC";
-	const COLOUR_LIGHT_RED = "#FFAB91";
-	const COLOUR_ORANGE = "#FBC02D";
-	const COLOUR_BLUE = "#2196F3";
-	const COLOUR_MAGENTA = "#E91E63";
-	const COLOUR_DARK_BLUE = "#3F51B5";
-	const COLOUR_PURPLE = "#9C27B0";
-	const COLOUR_GREY = "#9E9E9E";
-	const COLOUR_CYAN = "#00BCD4";
+	public const COLOUR_GREEN = "#4CAF50";
+	public const COLOUR_RED = "#F44336";
+	public const COLOUR_YELLOW = "#FFEB3B";
+	public const COLOUR_LIGHT_GREY = "#CCCCCC";
+	public const COLOUR_LIGHT_RED = "#FFAB91";
+	public const COLOUR_ORANGE = "#FBC02D";
+	public const COLOUR_BLUE = "#2196F3";
+	public const COLOUR_MAGENTA = "#E91E63";
+	public const COLOUR_DARK_BLUE = "#3F51B5";
+	public const COLOUR_PURPLE = "#9C27B0";
+	public const COLOUR_GREY = "#9E9E9E";
+	public const COLOUR_CYAN = "#00BCD4";
 
 	/** @var object $totalData */
 	private $totalData;
@@ -50,30 +50,30 @@ class ChartGenerator {
 		$this->totalData = $total_data;
 		$this->periodicData = $periodic_data;
 
-		$this->xDataLabels = array_values(array_map(function($d) {
+		$this->xDataLabels = array_values(array_map(static function($d) {
 			return $d->label;
 		}, $this->periodicData));
 	}
 
-	public function setDateRangeLabel(string $label) {
+	public function setDateRangeLabel(string $label): void {
 		$this->dateRangeLabel = $label;
 	}
 
-	public function setResolutionName(string $name) {
+	public function setResolutionName(string $name): void {
 		$this->resolutionName = $name;
 	}
 
-	public function setPeriodKeysAndLabels(array $keys, array $labels) {
+	public function setPeriodKeysAndLabels(array $keys, array $labels): void {
 		$this->periodKeys = $keys;
 		$this->periodLabels = $labels;
 	}
 
-	public function setRegionData(array $data) {
+	public function setRegionData(array $data): void {
 		ksort($data, SORT_NATURAL);
 		$this->regionData = $data;
 	}
 
-	public function setAreaManagerData(array $data) {
+	public function setAreaManagerData(array $data): void {
 		ksort($data, SORT_NATURAL);
 		$this->areaManagerData = $data;
 	}
@@ -205,6 +205,34 @@ class ChartGenerator {
 		);
 	}
 
+	public function getPeriodicMachinePowerChart(): Chart {
+		return $this->getPeriodicBooleanChart(
+			"Machines Powered",
+			$this->getMachinePowerRates()
+		);
+	}
+
+	public function getPeriodicMachineSeatChart(): Chart {
+		return $this->getPeriodicBooleanChart(
+			"Machine Seating",
+			$this->getMachineSeatRates()
+		);
+	}
+
+	public function getPeriodicMachineTableChart(): Chart {
+		return $this->getPeriodicBooleanChart(
+			"Machine Table/Shelf",
+			$this->getMachineTableRates()
+		);
+	}
+
+	public function getPeriodicMachineAccessibleChart(): Chart {
+		return $this->getPeriodicBooleanChart(
+			"Machines Accessible",
+			$this->getMachineAccessibleRates()
+		);
+	}
+
 	public function getPeriodicEyeContactPassRateChart(): Chart {
 		return $this->getPeriodicPassRateChart(
 			"Pass Rate by Eye Contact",
@@ -236,10 +264,7 @@ class ChartGenerator {
 
 	}
 
-	public function getPeriodicEyeContactChart(): Chart {
-
-		$rates = $this->getEyeContactRates();
-
+	public function getPeriodicBooleanPassRateChart(array $rates, string $title): Chart {
 		$chart = new Chart;
 		$chart->addXAxis([
 			"type" => "category",
@@ -251,7 +276,7 @@ class ChartGenerator {
 			"stacked" => true,
 		]);
 		$chart->setType("bar");
-		$chart->setTitle("Eye Contact by {$this->resolutionName}");
+		$chart->setTitle($title);
 		$chart->setLabels($this->xDataLabels);
 		$chart->addDataset("Yes (%)", array_column($rates, 0), [
 			"background_colours" => self::COLOUR_GREEN
@@ -263,6 +288,13 @@ class ChartGenerator {
 		return $chart;
 	}
 
+	public function getPeriodicEyeContactChart(): Chart {
+		return $this->getPeriodicBooleanChart(
+			"Eye Contact by {$this->resolutionName}",
+			$this->getEyeContactRates()
+		);
+	}
+
 	public function getPeriodicTotalsChart(): Chart {
 
 		$test_counts = $this->getPeriodicTestCounts();
@@ -336,7 +368,7 @@ class ChartGenerator {
 
 			$period_data = $this->periodicData[$key];
 
-			if($period_data->testCount == 0) continue;
+			if($period_data->testCount === 0) continue;
 
 			$chart = new Chart;
 			$chart->setType("pie");
@@ -369,10 +401,12 @@ class ChartGenerator {
 		$male_counts = $this->getPeriodicMaleTesterCount();
 		$female_counts = $this->getPeriodicFemaleTesterCount();
 
+		$counts = array_merge($male_counts, $female_counts);
+
 		$chart = new Chart;
 		$chart->addYAxis([
 			"id" => "y-axis-1",
-			"tick_config" => ["min" => 0, "max" => ceil(max(max($male_counts), max($female_counts)) / 10) * 10]
+			"tick_config" => ["min" => 0, "max" => ceil(max($counts) / 10) * 10]
 		]);
 
 		$chart->setType("bar");
@@ -401,7 +435,6 @@ class ChartGenerator {
 		$chart->addDataset("Tests", $test_counts, [
 			"background_colours" => self::COLOUR_BLUE
 		]);
-		$charts[] = $chart;
 		return $chart;
 	}
 
@@ -458,10 +491,12 @@ class ChartGenerator {
 		$fcf_counts = array_column($this->periodicData, "femaleChallengeFemaleCount");
 		$ns_counts = array_column($this->periodicData, "unknownChallengeCount");
 
+		$counts = array_merge($mcm_counts, $mcf_counts, $fcm_counts, $fcf_counts);
+
 		$chart = new Chart;
 		$chart->addYAxis([
 			"id" => "y-axis-1",
-			"tick_config" => ["min" => 0, "max" => ceil(max(max($mcm_counts), max($mcf_counts), max($fcm_counts), max($fcf_counts)) / 10) * 10]
+			"tick_config" => ["min" => 0, "max" => ceil(max($counts) / 10) * 10]
 		]);
 		$chart->setType("bar");
 		$chart->setTitle("Gender Comparison by {$this->resolutionName}");
@@ -498,7 +533,7 @@ class ChartGenerator {
 			$test_counts = ${$prefix . "_counts"};
 
 			foreach($test_counts as $index => $test_count) {
-				if($test_count == 0) {
+				if($test_count === 0) {
 					$pass_rates[] = 0;
 					continue;
 				}
@@ -536,7 +571,7 @@ class ChartGenerator {
 				$test_count = $period_data->{$prefix . "Count"};
 				$stage_data = $period_data->{$prefix . "Stages"};
 
-				if($test_count == 0) continue;
+				if($test_count === 0) continue;
 
 				$chart = new Chart;
 				$chart->setType("pie");
@@ -571,7 +606,7 @@ class ChartGenerator {
 		$pass_counts = [];
 		$fail_counts = [];
 
-		foreach($this->regionData as $region => $r_data) {
+		foreach($this->regionData as $r_data) {
 			$total_region_test_count = array_sum(array_column($r_data, "testCount"));
 			$total_region_pass_count = array_sum(array_column($r_data, "passCount"));
 
@@ -579,7 +614,7 @@ class ChartGenerator {
 			$pass_counts[] = $total_region_pass_count;
 			$fail_counts[] = $total_region_test_count - $total_region_pass_count;
 
-			$data_values[] = ($total_region_test_count == 0) ? 0 : round(($total_region_pass_count * 100) / $total_region_test_count);
+			$data_values[] = ($total_region_test_count === 0) ? 0 : round(($total_region_pass_count * 100) / $total_region_test_count);
 		}
 
 		$chart = new Chart;
@@ -618,7 +653,7 @@ class ChartGenerator {
 			$data_values = [];
 			foreach($this->getRegionKeys() as $region) {
 				$r_data = $this->regionData[$region][$key];
-				$data_values[] = ($r_data->testCount == 0) ? 0 : round(($r_data->passCount * 100) / $r_data->testCount);
+				$data_values[] = ($r_data->testCount === 0) ? 0 : round(($r_data->passCount * 100) / $r_data->testCount);
 			}
 			$chart->addDataset($this->periodLabels[$index], $data_values, ["background_colours" => Chart::COLOURS[$index]]);
 		}
@@ -639,7 +674,7 @@ class ChartGenerator {
 		$pass_counts = [];
 		$fail_counts = [];
 
-		foreach($this->areaManagerData as $area_manager => $a_data) {
+		foreach($this->areaManagerData as $a_data) {
 			$total_area_manager_test_count = array_sum(array_column($a_data, "testCount"));
 			$total_area_manager_pass_count = array_sum(array_column($a_data, "passCount"));
 			$total_area_manager_fail_count = array_sum(array_column($a_data, "failCount"));
@@ -648,7 +683,7 @@ class ChartGenerator {
 			$pass_counts[] = $total_area_manager_pass_count;
 			$fail_counts[] = $total_area_manager_fail_count;
 
-			$data_values[] = ($total_area_manager_test_count == 0) ? 0 : round(($total_area_manager_pass_count * 100) / $total_area_manager_test_count);
+			$data_values[] = ($total_area_manager_test_count === 0) ? 0 : round(($total_area_manager_pass_count * 100) / $total_area_manager_test_count);
 		}
 
 		$chart = new Chart;
@@ -700,7 +735,7 @@ class ChartGenerator {
 			$data_values = [];
 			foreach($this->getAreaManagerKeys() as $area_manager) {
 				$a_data = $this->areaManagerData[$area_manager][$key];
-				$data_values[] = ($a_data->testCount == 0) ? 0 : round(($a_data->passCount * 100) / $a_data->testCount);
+				$data_values[] = ($a_data->testCount === 0) ? 0 : round(($a_data->passCount * 100) / $a_data->testCount);
 			}
 			$chart->addDataset($this->periodLabels[$index], $data_values, [
 				"background_colours" => Chart::COLOURS[$index],
@@ -754,7 +789,7 @@ class ChartGenerator {
 
 			$period_data = $this->periodicData[$key];
 
-			if($period_data->testCount == 0) continue;
+			if($period_data->testCount === 0) continue;
 
 			$chart = new Chart;
 			$chart->setType("pie");
@@ -829,7 +864,7 @@ class ChartGenerator {
 
 			$period_data = $this->periodicData[$key];
 
-			if($period_data->testCount == 0) continue;
+			if($period_data->testCount === 0) continue;
 
 			$chart = new Chart;
 			$chart->setType("pie");
@@ -866,59 +901,74 @@ class ChartGenerator {
 
 	// Private methods
 
-	private function getPeriodicPassRates() {
-		return array_values(array_map(function($d) {
-			if($d->testCount == 0) return 0;
+	private function getPeriodicPassRates(): array {
+		return array_values(array_map(static function($d) {
+			if($d->testCount === 0) return 0;
 			return round(($d->passCount / $d->testCount) * 100);
 		}, $this->periodicData));
 	}
 
-	private function getPeriodicFailRates() {
-		return array_values(array_map(function($d) {
-			if($d->testCount == 0) return 0;
+	private function getPeriodicFailRates(): array {
+		return array_values(array_map(static function($d) {
+			if($d->testCount === 0) return 0;
 			$pass_rate = round(($d->passCount / $d->testCount) * 100);
 			return 100 - $pass_rate;
 		}, $this->periodicData));
 	}
 
-	private function getPeriodicPassRateByDoorSensorAlert(int $index) {
-		return array_values(array_map(function($data) use ($index) {
-			$test_count = $data->doorSensorAlertPassCounts[$index] + $data->doorSensorAlertFailCounts[$index];
-			if($test_count == 0) return null;
+	private function getPeriodicPassRate(string $prefix, int $index): array {
+		$pass_field = $prefix . "PassCounts";
+		$fail_field = $prefix . "FailCounts";
+
+		return array_values(array_map(static function($data) use ($pass_field, $fail_field, $index) {
+			$test_count = $data->$pass_field[$index] + $data->$fail_field[$index];
+			if($test_count === 0) {
+				return null;
+			}
 
-			return round(($data->doorSensorAlertPassCounts[$index] / $test_count) * 100);
+			return round(($data->$pass_field[$index] / $test_count) * 100);
 		}, $this->periodicData));
 	}
 
-	private function getPeriodicPassRateByEyeContact(int $index) {
-		return array_values(array_map(function($data) use ($index) {
-			$test_count = $data->eyeContactPassCounts[$index] + $data->eyeContactFailCounts[$index];
-			if($test_count == 0) return null;
-			return round(($data->eyeContactPassCounts[$index] / $test_count) * 100);
-		}, $this->periodicData));
+	private function getPeriodicPassRateByDoorSensorAlert(int $index): array {
+		return $this->getPeriodicPassRate("doorSensor", $index);
 	}
 
-	private function getPeriodicPassRateByLineOfSight(int $index) {
-		return array_values(array_map(function($data) use ($index) {
-			$test_count = $data->lineOfSightPassCounts[$index] + $data->lineOfSightFailCounts[$index];
-			if($test_count == 0) return null;
-			return round(($data->lineOfSightPassCounts[$index] / $test_count) * 100);
-		}, $this->periodicData));
+	private function getPeriodicPassRateByEyeContact(int $index): array {
+		return $this->getPeriodicPassRate("eyeContact", $index);
 	}
 
-	private function getPeriodicPassRateByBarPurchase(int $index) {
-		return array_values(array_map(function($data) use ($index) {
-			$test_count = $data->barPurchasePassCounts[$index] + $data->barPurchaseFailCounts[$index];
-			if($test_count == 0) return null;
-			return round(($data->barPurchasePassCounts[$index] / $test_count) * 100);
-		}, $this->periodicData));
+	private function getPeriodicPassRateByLineOfSight(int $index): array {
+		return $this->getPeriodicPassRate("lineOfSight", $index);
 	}
 
-	private function getEyeContactRates(): array {
-		return array_values(array_map(function($period) {
-			if($period->testCount == 0) return [0, 0, 0];
+	private function getPeriodicPassRateByBarPurchase(int $index): array {
+		return $this->getPeriodicPassRate("barPurchase", $index);
+	}
+
+	private function getMachinePowerRates(): array {
+		return $this->getBooleanRates("machinePowerCounts");
+	}
+
+	private function getMachineSeatRates(): array {
+		return $this->getBooleanRates("machineSeatCounts");
+	}
+
+	private function getMachineTableRates(): array {
+		return $this->getBooleanRates("machineTableCounts");
+	}
+
+	private function getMachineAccessibleRates(): array {
+		return $this->getBooleanRates("machineAccessibleCounts");
+	}
 
-			$yes = round(($period->eyeContactCounts[0] / $period->testCount) * 100);
+	private function getBooleanRates(string $field): array {
+		return array_values(array_map(static function($period) use ($field) {
+			if($period->testCount === 0) {
+				return [0, 0, 0];
+			}
+
+			$yes = round(($period->$field[0] / $period->testCount) * 100);
 			$no = 100 - $yes;
 			$na = 0;
 
@@ -926,6 +976,10 @@ class ChartGenerator {
 		}, $this->periodicData));
 	}
 
+	private function getEyeContactRates(): array {
+		return $this->getBooleanRates("eyeContactCounts");
+	}
+
 	private function getPeriodicTestCounts(): array {
 		return array_column($this->periodicData, "testCount");
 	}
@@ -939,13 +993,13 @@ class ChartGenerator {
 	}
 
 	private function getPeriodicMaleTesterCount(): array {
-		return array_values(array_map(function($d) {
+		return array_values(array_map(static function($d) {
 			return $d->maleTesterCount;
 		}, $this->periodicData));
 	}
 
 	private function getPeriodicFemaleTesterCount(): array {
-		return array_values(array_map(function($d) {
+		return array_values(array_map(static function($d) {
 			return $d->femaleTesterCount;
 		}, $this->periodicData));
 	}
@@ -956,7 +1010,7 @@ class ChartGenerator {
 	}
 
 	private function getRegionXDataLabels(): array {
-		return array_map(function($key) {
+		return array_map(static function($key) {
 			return "Region $key";
 		}, $this->getRegionKeys());
 	}
@@ -979,16 +1033,17 @@ class ChartGenerator {
 		$chart->setType("bar");
 		$chart->setTitle("{$title} by {$this->resolutionName}");
 		$chart->setLabels($this->xDataLabels);
-		$chart->addDataset("No", $no_counts, [
-			"background_colours" => self::COLOUR_RED
-		]);
 		$chart->addDataset("Yes", $yes_counts, [
 			"background_colours" => self::COLOUR_GREEN
 		]);
+		$chart->addDataset("No", $no_counts, [
+			"background_colours" => self::COLOUR_RED
+		]);
+		$chart->setDatalabelSuffixes("%", "%");
 		return $chart;
 	}
 
-	private function getPeriodicPassRateChart(string $title, array $yes_rates, array $no_rates, ?array $null_rates = null) {
+	private function getPeriodicPassRateChart(string $title, array $yes_rates, array $no_rates, ?array $null_rates = null): Chart {
 
 		$chart = new Chart;
 		$chart->addYAxis([

+ 55 - 7
engine/form.php

@@ -191,7 +191,16 @@ class Form {
 		$hidden = !empty($options->hidden) ? "hidden" : "";
 		?>
 		<div class="form-group" <?=$hidden?>>
-			<label for="<?=$id?>"><?=htmlspecialchars($options->label)?></label>
+			<label for="<?=$id?>">
+				<?=htmlspecialchars($options->label)?>
+				<?php
+				if($required) {
+					?>
+					<span class="badge badge-danger"><?=htmlspecialchars(__("Required"))?></span>
+					<?php
+				}
+				?>
+			</label>
 			<input class="form-control" type="text" name="<?=$options->name?>" id="<?=$id?>" placeholder="<?=htmlspecialchars($placeholder)?>" value="<?=htmlspecialchars($value)?>" <?=$required?> <?=$max_length?> />
 			<?php
 			if($help_text) {
@@ -223,7 +232,16 @@ class Form {
 
 		?>
 		<div class="form-group" <?=$hidden?>>
-			<label for="<?=$id?>"><?=htmlspecialchars($options->label)?></label>
+			<label for="<?=$id?>">
+				<?=htmlspecialchars($options->label)?>
+				<?php
+				if($required) {
+					?>
+					<span class="badge badge-danger"><?=htmlspecialchars(__("Required"))?></span>
+					<?php
+				}
+				?>
+			</label>
 			<div class="input-group">
 				<?php
 				if(!empty($prepend_text)) {
@@ -263,7 +281,16 @@ class Form {
 
 		?>
 		<div class="form-group">
-			<label for="<?=$id?>"><?=htmlspecialchars($options->label)?></label>
+			<label for="<?=$id?>">
+				<?=htmlspecialchars($options->label)?>
+				<?php
+				if($required) {
+					?>
+					<span class="badge badge-danger"><?=htmlspecialchars(__("Required"))?></span>
+					<?php
+				}
+				?>
+			</label>
 			<select class="form-control" name="<?=$options->name?>" id="<?=$id?>" <?=$required?>>
 			<?php
 			foreach($options->values as $index => $value) {
@@ -295,7 +322,16 @@ class Form {
 		$help_text = $options->helpText ?? false;
 		?>
 		<div class="form-group">
-			<label for="<?=$id?>"><?=htmlspecialchars($options->label)?></label>
+			<label for="<?=$id?>">
+				<?=htmlspecialchars($options->label)?>
+				<?php
+				if($required) {
+					?>
+					<span class="badge badge-danger"><?=htmlspecialchars(__("Required"))?></span>
+					<?php
+				}
+				?>
+			</label>
 			<input class="form-control-file" type="file" name="<?=$options->name?>" id="<?=$id?>" accept="image/*" <?=$required?> />
 			<?php
 			if($help_text) {
@@ -321,7 +357,16 @@ class Form {
 		$max_length = ($options->maxLength ?? false) ? "maxlength=\"$options->maxLength\"" : "";
 		?>
 		<div class="form-group">
-			<label for="<?=$id?>"><?=htmlspecialchars($options->label)?></label>
+			<label for="<?=$id?>">
+				<?=htmlspecialchars($options->label)?>
+				<?php
+				if($required) {
+					?>
+					<span class="badge badge-danger"><?=htmlspecialchars(__("Required"))?></span>
+					<?php
+				}
+				?>
+			</label>
 			<textarea class="form-control" name="<?=$options->name?>" id="<?=$id?>" placeholder="<?=htmlspecialchars($placeholder)?>" rows="4" <?=$required?> <?=$max_length?>><?=htmlspecialchars($value)?></textarea>
 			<?php
 			if($help_text) {
@@ -387,6 +432,11 @@ class Form {
 			<label>
 				<?=htmlspecialchars($options->label)?>
 				<?php
+				if($required) {
+					?>
+					<span class="badge badge-danger"><?=htmlspecialchars(__("Required"))?></span>
+					<?php
+				}
 				if($help_text) {
 					?>
 					<small class="form-text text-muted"><?=htmlspecialchars($help_text)?></small>
@@ -420,5 +470,3 @@ class Form {
 	}
 
 }
-
-?>

+ 393 - 0
json/age_verification_stonegate.json

@@ -0,0 +1,393 @@
+{
+	"customerInvoiceFields": [
+		{"name": "play_spent", "label": "Money Spent by Testers"}
+	],
+	"testerInvoiceFields": [
+		{"name": "play_spent", "label": "Play Costs"},
+		{"name": "bar_expenditure", "label": "Bar Expenditure"}
+	],
+	"beforeTest": [
+		{
+			"type": "header",
+			"content": "Before the Test"
+		},
+		{
+			"type": "text",
+			"name": "shop_left",
+			"label": "Shop Name (Left)",
+			"maxLength": 32,
+			"required": true,
+			"customerExport": false
+		},
+		{
+			"type": "text",
+			"name": "shop_right",
+			"label": "Shop Name (Right)",
+			"maxLength": 32,
+			"required": true,
+			"customerExport": false
+		},
+		{
+			"type": "text",
+			"name": "attire",
+			"label": "Tester Clothing",
+			"maxLength": 50,
+			"required": true,
+			"customerExport": false
+		},
+		{
+			"type": "file",
+			"label": "Selfie",
+			"name": "selfie",
+			"required": true
+		},
+		{
+			"type": "file",
+			"label": "Location Photo",
+			"name": "location_photo",
+			"required": true
+		}
+	],
+	"duringTest": [
+		{
+			"type": "header",
+			"content": "Machines"
+		},
+		{
+			"type": "inline-radio",
+			"name": "machine_power",
+			"label": "Machines Powered",
+			"values": [
+				"1",
+				"0"
+			],
+			"displayStrings": [
+				"All machines were switched on",
+				"One or more machines were switched off"
+			],
+			"helpText": "Were any machines switched off?",
+			"customerExport": false,
+			"required": true
+		},
+		{
+			"type": "inline-radio",
+			"name": "machine_seat",
+			"label": "Seat",
+			"values": [
+				"1",
+				"0"
+			],
+			"displayStrings": [
+				"Yes",
+				"No"
+			],
+			"helpText": "Was there a seat at the machine?",
+			"customerExport": false,
+			"required": true
+		},
+		{
+			"type": "inline-radio",
+			"name": "machine_table",
+			"label": "Table/Shelf",
+			"values": [
+				"1",
+				"0"
+			],
+			"displayStrings": [
+				"Yes",
+				"No"
+			],
+			"helpText": "Was there a table/shelf to put your drink on?",
+			"customerExport": false,
+			"required": true
+		},
+		{
+			"type": "inline-radio",
+			"name": "machine_accessible",
+			"label": "Machines Accessible",
+			"values": [
+				"1",
+				"0"
+			],
+			"displayStrings": [
+				"All machines were easy to get to",
+				"One or more machines were obstructed or hard to get to"
+			],
+			"helpText": "Were any of the machines obstructed and hard to get to?",
+			"customerExport": false,
+			"required": true
+		},
+
+		{
+			"type": "header",
+			"content": "Venue"
+		},
+		{
+			"type": "inline-radio",
+			"name": "social_distancing_signage",
+			"label": "Signage for Social Distancing",
+			"values": [0, 1],
+			"displayStrings": ["No", "Yes"],
+			"required": true,
+			"requiredKey": "COVID-19"
+		},
+		{
+			"type": "inline-radio",
+			"name": "entrance_hand_sanitiser",
+			"label": "Hand Sanitisers at Entrance",
+			"values": [0, 1],
+			"displayStrings": ["No", "Yes"],
+			"required": true,
+			"requiredKey": "COVID-19"
+		},
+		{
+			"type": "inline-radio",
+			"name": "social_distancing_measures",
+			"label": "Social Distancing Measures",
+			"values": [0, 1],
+			"displayStrings": ["No", "Yes"],
+			"helpText": "Were there social distancing measures in place?",
+			"required": true,
+			"requiredKey": "COVID-19"
+		},
+
+		{
+			"type": "hr"
+		},
+
+		{
+			"type": "header",
+			"content": "Challenge Details"
+		},
+		{
+			"type": "dropdown",
+			"name": "challenge_stage",
+			"label": "Stage",
+			"values": ["", 1, 2, 3, 4, 5],
+			"displayStrings": ["Select stage", "Challenge on bar or entry", "Challenge during browsing", "Challenge during play", "Challenge on exit", "No challenge"],
+			"required": true
+		},
+		{
+			"type": "textarea",
+			"name": "challenge_description",
+			"label": "Description",
+			"maxLength": 400,
+			"helpText": "Describe how the challenge took place. For example: \"While entering I was approached politely and asked for ID.\""
+		},
+
+		{
+			"type": "hr"
+		},
+
+		{
+			"type": "header",
+			"content": "Staff Description"
+		},
+		{
+			"type": "text",
+			"name": "challenger_name",
+			"label": "Name",
+			"maxLength": 32,
+			"customerExport": false
+		},
+		{
+			"type": "textarea",
+			"name": "challenger_description",
+			"label": "Description",
+			"maxLength": 250,
+			"helpText": "Describe ANY members of staff that you saw in the venue and any comments you feel that are relevant. Please add an accurate description of any staff members you saw even if not challenged. For example: \"She was about 150cm tall and had long red hair and glasses. She approached me and asked me if I wanted some water and then asked if I had any ID.\"",
+			"customerExport": false
+		},
+		{
+			"type": "inline-radio",
+			"name": "challenger_gender",
+			"label": "Gender",
+			"values": ["", "M", "F"],
+			"displayStrings": ["No challenge", "Male", "Female"],
+			"customerExport": false
+		},
+		{
+			"type": "inline-radio",
+			"name": "challenger_eye_contact",
+			"label": "Eye Contact",
+			"values": ["", "0", "1"],
+			"displayStrings": ["No challenge", "No", "Yes"],
+			"customerExport": false
+		},
+
+		{
+			"type": "hr",
+			"hidden": true
+		},
+
+		{
+			"type": "header",
+			"content": "Bar Details",
+			"hidden": true
+		},
+		{
+			"type": "inline-radio",
+			"name": "bar_purchase",
+			"label": "Bar Purchase",
+			"values": ["0", "1"],
+			"displayStrings": ["No", "Yes"],
+			"helpText": "Did you buy anything at the bar?",
+			"hidden": true
+		},
+		{
+			"type": "number",
+			"name": "bar_expenditure",
+			"label": "Bar Expenditure",
+			"maxLength": 10,
+			"min": 0,
+			"max": 20,
+			"step": 0.01,
+			"prependText": "£",
+			"helpText": "For example: Enter 1.50 if you have spent £1.50.",
+			"hidden": true
+		},
+		{
+			"type": "inline-radio",
+			"name": "alcohol_purchased",
+			"label": "Alcohol Purchased",
+			"values": ["0", "1"],
+			"displayStrings": ["No", "Yes"],
+			"hidden": true
+		},
+		{
+			"type": "text",
+			"name": "bar_purchase_item",
+			"label": "Name of Item Purchased",
+			"maxLength": 20,
+			"hidden": true
+		},
+
+		{
+			"type": "hr"
+		},
+
+		{
+			"type": "header",
+			"content": "Play Details"
+		},
+		{
+			"type": "text",
+			"name": "play_machine",
+			"label": "Machine Played",
+			"maxLength": 20,
+			"customerExport": false
+		},
+		{
+			"type": "text",
+			"name": "play_machine_position",
+			"label": "Machine Position",
+			"maxLength": 100,
+			"customerExport": false,
+			"helpText": "Where the machine was located in the venue? (e.g. Opposite the bar.)"
+		},
+		{
+			"type": "inline-radio",
+			"name": "play_machine_line_of_sight",
+			"label": "Machine Line of Sight of Bar",
+			"values": ["0", "1"],
+			"displayStrings": ["No", "Yes"],
+			"helpText": "Was the machine in line of sight of the bar?"
+		},
+		{
+			"type": "radio",
+			"name": "play_jackpot",
+			"label": "Jackpot Value",
+			"values": ["", 5, 10, 15, 20, 25, 35, 50, 100, 500],
+			"displayStrings": ["Did not play", "£5", "£10", "£15", "£20", "£25", "£35", "£50", "£100", "£500"],
+			"customerExport": false
+		},
+		{
+			"type": "radio",
+			"name": "play_machine_stake",
+			"label": "Stake Played",
+			"values": ["", 0.1, 0.2, 0.25, 0.3, 0.5, 1, 2],
+			"displayStrings": ["Did not play", "10p", "20p", "25p", "30p", "50p", "£1", "£2"],
+			"helpText": "This is how much the machine charges you per spin."
+		},
+		{
+			"type": "radio",
+			"name": "play_minutes",
+			"label": "Time Played (Minutes)",
+			"values": ["", "1", "2", "3", "4", "5"],
+			"displayStrings": ["Did not play", "1 minute", "2 minutes", "3 minutes", "4 minutes", "5 minutes or more"]
+		},
+		{
+			"type": "number",
+			"name": "play_spent",
+			"label": "Total Spent",
+			"maxLength": 10,
+			"min": 0,
+			"max": 2,
+			"step": 0.01,
+			"prependText": "£",
+			"helpText": "For example: Enter 1.50 if you have spent £1.50."
+		},
+
+		{
+			"type": "hr"
+		},
+
+		{
+			"type": "header",
+			"content": "Signage Details"
+		},
+		{
+			"type": "inline-radio",
+			"name": "citizen_card_brochure_displayed",
+			"label": "Citizen Card Brochure Displayed",
+			"values": ["0", "1"],
+			"displayStrings": ["No", "Yes"],
+			"defaultValue": "1"
+		},
+		{
+			"type": "inline-radio",
+			"name": "think_21_25",
+			"label": "Think 21 or Think 25",
+			"values": ["Think 21", "Think 25"],
+			"displayStrings": ["Think 21", "Think 25"]
+		},
+		{
+			"type": "inline-radio",
+			"name": "think_21_badge",
+			"label": "Think 21/25 Badge Worn by Staff",
+			"values": ["0", "1"],
+			"displayStrings": ["No", "Yes"],
+			"defaultValue": "1"
+		},
+		{
+			"type": "inline-radio",
+			"name": "think_21_poster",
+			"label": "Think 21/25 Poster Displayed",
+			"values": ["0", "1"],
+			"displayStrings": ["No", "Yes"],
+			"defaultValue": "1"
+		},
+		{
+			"type": "textarea",
+			"name": "think_21_poster_notes",
+			"label": "Think 21/25 Poster Details",
+			"maxLength": 200,
+			"helpText": "Describe the location of the poster that was displayed."
+		},
+
+		{
+			"type": "hr"
+		},
+
+		{
+			"type": "header",
+			"content": "Notes"
+		},
+		{
+			"type": "textarea",
+			"name": "additional_notes",
+			"label": "Additional Notes",
+			"maxLength": 600
+		}
+	]
+}

+ 1 - 98
template_processing/age_verification_mitchells_butlers/project_csv.php

@@ -1,100 +1,3 @@
 <?php
 
-
-$field_names = [
-	"Project ID", "Project Name",
-	"Template Name",
-	"Test ID", "Test Status", "Test Result",
-	"Location Name", "Legal Entity", "Address", "Email", "Phone", "Region", "Internal ID", "Area Manager",
-	"Tester Age", "Tester Gender", "Travel Costs",
-
-	"Date", "Start Time", "End Time", "Duration",
-];
-
-foreach($fields as $field) {
-	$field_names[] = $field->label;
-}
-
-fputcsv($handle, $field_names);
-
-foreach($tests as $test) {
-
-	$project = $test->getProject();
-	$location = $test->getLocation();
-	$tester = $test->getTester();
-	$values = $test->getValues(true);
-
-	$test_date = "";
-	$test_start = "";
-	$test_end = "";
-	$test_duration = "";
-
-	$result = "Pending";
-
-	$age = "";
-	$gender = "";
-	$travel_costs = "";
-
-	$output = [];
-	$output[] = $project->id;
-	$output[] = $project->name;
-	$output[] = $template->name;
-	$output[] = $test->id;
-	$output[] = $test->getStatusText();
-
-	if(!is_null($test->pass)) {
-
-		$result = $test->pass ? "Pass" : "Fail";
-
-		$test_start_dt = new DateTime($test->dts_start);
-		$test_end_dt = new DateTime($test->dts_end);
-		$test_duration_diff = $test_start_dt->diff($test_end_dt, true);
-
-		$test_date = $test_start_dt->format("d/m/Y");
-		$test_start = $test_start_dt->format("H:i:s");
-		$test_end = $test_end_dt->format("H:i:s");
-		$test_duration = $test_duration_diff->h . ":" . $test_duration_diff->i . ":" . $test_duration_diff->s;
-
-		if($tester) {
-			$tester_dob_dt = new DateTime($tester->date_of_birth);
-			$dob_diff = $test_start_dt->diff($tester_dob_dt, true);
-			$age = $dob_diff->y;
-			$gender = $tester->gender;
-			$travel_costs = $test->test_travel_costs;
-		}
-	}
-
-
-	$output[] = $result;
-	$output[] = $location->name;
-	$output[] = $location->legal_entity_name;
-	$output[] = $location->getDisplayAddress();
-	$output[] = $location->email;
-	$output[] = $location->phone;
-	$output[] = $location->region;
-	$output[] = $location->internal_id;
-	$output[] = $location->area_manager;
-	$output[] = $age;
-	$output[] = $gender;
-	$output[] = $travel_costs;
-	$output[] = $test_date;
-	$output[] = $test_start;
-	$output[] = $test_end;
-	$output[] = $test_duration;
-
-	foreach($fields as $field) {
-		$field_name = $field->name;
-		$value = isset($test->$field_name) ? $test->$field_name : ($values[$field->name] ?? "");
-
-		if(!empty($field->displayStrings)) {
-			$index = array_search($value, $field->values);
-			$value = $field->displayStrings[$index];
-		}
-
-		$output[] = $value;
-	}
-
-	fputcsv($handle, $output);
-}
-
-?>
+require ROOT_DIR . "/template_processing/age_verification/project_csv.php";

+ 1 - 86
template_processing/age_verification_mitchells_butlers/project_customer_csv.php

@@ -1,88 +1,3 @@
 <?php
 
-$field_names = [
-	"Test Result",
-	"Location Name", "Address", "Region", "Internal ID", "Area Manager",
-
-	"Date",
-];
-
-foreach($fields as $field) {
-	$customer_export = $field->customerExport ?? true;
-	if(!$customer_export) continue;
-
-	$field_names[] = $field->label;
-}
-
-fputcsv($handle, $field_names);
-
-foreach($tests as $test) {
-
-	$project = $test->getProject();
-	$location = $test->getLocation();
-	$tester = $test->getTester();
-	$values = $test->getValues(true);
-
-	$test_date = "";
-	$test_start = "";
-	$test_end = "";
-	$test_duration = "";
-
-	$result = "Pending";
-
-	$age = "";
-	$gender = "";
-	$travel_costs = "";
-
-	$output = [];
-
-	if(!is_null($test->pass)) {
-
-		$result = $test->pass ? "Pass" : "Fail";
-
-		$test_start_dt = new DateTime($test->dts_start);
-		$test_end_dt = new DateTime($test->dts_end);
-		$test_duration_diff = $test_start_dt->diff($test_end_dt, true);
-
-		$test_date = $test_start_dt->format("d/m/Y");
-		$test_start = $test_start_dt->format("H:i:s");
-		$test_end = $test_end_dt->format("H:i:s");
-		$test_duration = $test_duration_diff->h . ":" . $test_duration_diff->i . ":" . $test_duration_diff->s;
-
-		if($tester) {
-			$tester_dob_dt = new DateTime($tester->date_of_birth);
-			$dob_diff = $test_start_dt->diff($tester_dob_dt, true);
-			$age = $dob_diff->y;
-			$gender = $tester->gender;
-			$travel_costs = $test->test_travel_costs;
-		}
-	}
-
-	$output[] = $result;
-	$output[] = $location->name;
-	$output[] = $location->getDisplayAddress();
-	$output[] = $location->region;
-	$output[] = $location->internal_id;
-	$output[] = $location->area_manager;
-	$output[] = $test_date;
-
-	foreach($fields as $field) {
-
-		$customer_export = $field->customerExport ?? true;
-		if(!$customer_export) continue;
-
-		$field_name = $field->name;
-		$value = isset($test->$field_name) ? $test->$field_name : ($values[$field->name] ?? "");
-
-		if(!empty($field->displayStrings)) {
-			$index = array_search($value, $field->values);
-			$value = $field->displayStrings[$index];
-		}
-
-		$output[] = $value;
-	}
-
-	fputcsv($handle, $output);
-}
-
-?>
+require ROOT_DIR . "/template_processing/age_verification/project_customer_csv.php";

+ 3 - 0
template_processing/age_verification_stonegate/project_csv.php

@@ -0,0 +1,3 @@
+<?php
+
+require ROOT_DIR . "/template_processing/age_verification/project_csv.php";

+ 3 - 0
template_processing/age_verification_stonegate/project_customer_csv.php

@@ -0,0 +1,3 @@
+<?php
+
+require ROOT_DIR . "/template_processing/age_verification/project_customer_csv.php";

+ 34 - 0
template_processing/age_verification_stonegate/reports_build_charts.php

@@ -0,0 +1,34 @@
+<?php
+
+/** @var ChartGenerator $generator */
+
+$charts[] = $generator->getTestsByStageChart();
+$charts[] = $generator->getChallengerGenderChart();
+$charts[] = $generator->getTesterGenderChart();
+$charts[] = $generator->getPassFailCountChart();
+$charts[] = $generator->getPeriodicPassFailRateChart();
+$charts[] = $generator->getPeriodicEyeContactChart();
+
+$charts[] = $generator->getPeriodicMachinePowerChart();
+$charts[] = $generator->getPeriodicMachineSeatChart();
+$charts[] = $generator->getPeriodicMachineTableChart();
+$charts[] = $generator->getPeriodicMachineAccessibleChart();
+
+$charts[] = $generator->getPeriodicEyeContactPassRateChart();
+$charts[] = $generator->getPeriodicLineOfSightPassRateChart();
+$charts[] = $generator->getPeriodicBarPurchasePassRateChart();
+$charts[] = $generator->getPeriodicTotalsChart();
+$charts = array_merge($charts, $generator->getPointOfChallengeCharts());
+$charts[] = $generator->getPeriodicTesterGenderChart();
+$charts[] = $generator->getPeriodicTestCountChart();
+$charts = array_merge($charts, $generator->getGenderComparisonCharts());
+
+if($generator->hasRegionData()) {
+	$charts[] = $generator->getRegionPassRateChart();
+	$charts[] = $generator->getPeriodicRegionPassRateChart();
+}
+
+if($generator->hasAreaManagerData()) {
+	$charts[] = $generator->getAreaManagerPassRateChart();
+	$charts[] = $generator->getPeriodicAreaManagerPassRateChart();
+}

+ 80 - 0
template_processing/age_verification_stonegate/reports_create_empty_objects.php

@@ -0,0 +1,80 @@
+<?php
+
+$empty_data = (object) [
+	"label" => "",
+	"testCount" => 0,
+	"passCount" => 0,
+	"failCount" => 0,
+	"voidCount" => 0,
+
+	"eyeContactCounts" => [0, 0, 0],
+
+	"eyeContactPassCounts" => [0, 0, 0],
+	"eyeContactFailCounts" => [0, 0, 0],
+
+	"lineOfSightPassCounts" => [0, 0, 0],
+	"lineOfSightFailCounts" => [0, 0, 0],
+
+	"machinePowerCounts" => [0, 0, 0],
+	"machineSeatCounts" => [0, 0, 0],
+	"machineTableCounts" => [0, 0, 0],
+	"machineAccessibleCounts" => [0, 0, 0],
+
+	"barPurchasePassCounts" => [0, 0, 0],
+	"barPurchaseFailCounts" => [0, 0, 0],
+
+	"maleTesterCount" => 0,
+	"femaleTesterCount" => 0,
+
+	"maleChallengerCount" => 0,
+	"femaleChallengerCount" => 0,
+	"unspecifiedChallengerCount" => 0,
+
+	"maleChallengeMaleCount" => 0,
+	"maleChallengeMalePassCount" => 0,
+	"maleChallengeMaleStages" => [0, 0, 0, 0, 0],
+
+	"maleChallengeFemaleCount" => 0,
+	"maleChallengeFemalePassCount" => 0,
+	"maleChallengeFemaleStages" => [0, 0, 0, 0, 0],
+
+	"femaleChallengeMaleCount" => 0,
+	"femaleChallengeMalePassCount" => 0,
+	"femaleChallengeMaleStages" => [0, 0, 0, 0, 0],
+
+	"femaleChallengeFemaleCount" => 0,
+	"femaleChallengeFemalePassCount" => 0,
+	"femaleChallengeFemaleStages" => [0, 0, 0, 0, 0],
+
+	"unknownChallengeCount" => 0,
+	"unknownChallengePassCount" => 0,
+	"unknownChallengeStages" => [0, 0, 0, 0, 0],
+
+	"stage1Count" => 0,
+	"stage2Count" => 0,
+	"stage3Count" => 0,
+	"stage4Count" => 0,
+	"stage5Count" => 0,
+];
+
+$total_data = (object) [
+	"maleTesterCount" => 0,
+	"femaleTesterCount" => 0,
+
+	"maleChallengerCount" => 0,
+	"femaleChallengerCount" => 0,
+	"unspecifiedChallengerCount" => 0,
+
+	"eyeContactCounts" => [0, 0, 0],
+
+	"testCount" => 0,
+	"passCount" => 0,
+	"failCount" => 0,
+	"voidCount" => 0,
+
+	"stage1Count" => 0,
+	"stage2Count" => 0,
+	"stage3Count" => 0,
+	"stage4Count" => 0,
+	"stage5Count" => 0,
+];

+ 110 - 0
template_processing/age_verification_stonegate/reports_process_test.php

@@ -0,0 +1,110 @@
+<?php
+
+/**
+ * @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
+ */
+
+$count_incrementor = static function($value, $prefix) use (&$data, $key) {
+	$field = $prefix . "Counts";
+
+	$index = $value ? 1 : 0;
+
+	if($value === null) {
+		$index = 2;
+	}
+
+	$data[$key]->$field[$index]++;
+};
+
+$pass_fail_count_incrementor = static function($value, $pass, $prefix) use (&$data, $key) {
+	$suffix = $pass ? "PassCounts" : "FailCounts";
+	$field = $prefix . $suffix;
+
+	$index = $value ? 1 : 0;
+
+	if($value === null) {
+		$index = 2;
+	}
+
+	$data[$key]->$field[$index]++;
+};
+
+$stage_key = "stage" . $test->challenge_stage . "Count";
+$data[$key]->$stage_key++;
+$total_data->{$stage_key}++;
+
+$line_of_sight = $test_values->play_machine_line_of_sight ?? null;
+$bar_purchase = $test_values->bar_purchase ?? null;
+$machine_power = $test_values->machine_power ?? null;
+$machine_seat = $test_values->machine_seat ?? null;
+$machine_table = $test_values->machine_table ?? null;
+$machine_accessible = $test_values->machine_accessible ?? null;
+$eye_contact = $test->challenger_eye_contact ?? null;
+
+if($test->pass) {
+	$data[$key]->passCount++;
+	$total_data->passCount++;
+	if($region) $region_data[$region][$key]->passCount++;
+	if($area_manager) $area_manager_data[$area_manager][$key]->passCount++;
+}
+else {
+	$data[$key]->failCount++;
+	$total_data->failCount++;
+	if($region) $region_data[$region][$key]->failCount++;
+	if($area_manager) $area_manager_data[$area_manager][$key]->failCount++;
+}
+
+$pass_fail_count_incrementor($eye_contact, $test->isPass(), "eyeContact");
+$pass_fail_count_incrementor($line_of_sight, $test->isPass(), "lineOfSight");
+$pass_fail_count_incrementor($bar_purchase, $test->isPass(), "barPurchase");
+$count_incrementor($machine_power, "machinePower");
+$count_incrementor($machine_seat, "machineSeat");
+$count_incrementor($machine_table, "machineTable");
+$count_incrementor($machine_accessible, "machineAccessible");
+
+if($test->challenger_gender === "M") {
+	$data[$key]->maleChallengerCount++;
+	$total_data->maleChallengerCount++;
+}
+else if($test->challenger_gender === "F") {
+	$data[$key]->femaleChallengerCount++;
+	$total_data->femaleChallengerCount++;
+}
+else {
+	$data[$key]->unspecifiedChallengerCount++;
+	$total_data->unspecifiedChallengerCount++;
+}
+
+// Eye Contact
+$count_incrementor($test->challenger_eye_contact, "eyeContact");
+
+// Genders Comparison
+$gender_prefix = "";
+switch($test->challenger_gender) {
+	case "M": $gender_prefix = "male"; break;
+	case "F": $gender_prefix = "female"; break;
+	default:  $gender_prefix = "unknown"; break;
+}
+
+$gender_prefix .= "Challenge";
+
+if($gender_prefix !== "unknownChallenge") {
+	switch($tester->gender) {
+		case "M": $gender_prefix .= "Male"; break;
+		case "F": $gender_prefix .= "Female"; break;
+		default: $gender_prefix = "unknownChallenge"; break;
+	}
+}
+
+$data[$key]->{$gender_prefix . "Count"}++;
+$data[$key]->{$gender_prefix . "Stages"}[$test->challenge_stage - 1]++;
+if($test->pass) $data[$key]->{$gender_prefix . "PassCount"}++;

+ 1 - 0
template_processing/age_verification_stonegate/result_email_subject_format.txt

@@ -0,0 +1 @@
+{pass} - {stage} - Check Policy visit to: {location} {date-time}

+ 404 - 0
template_processing/age_verification_stonegate/test_pdf.php

@@ -0,0 +1,404 @@
+<?php
+
+/**
+ * @var Template $template
+ * @var Test $test
+ * @var array $values
+ * @var string $location_text
+ * @var Customer $customer
+ * @var Location $location
+ * @var User $tester
+ * @var string $date_start
+ * @var string $time_start
+ * @var string $time_end
+ * @var string $duration_text
+ */
+
+$pass_image = $test->pass ? "pass.png" : "fail.png";
+
+// COVID-19
+$covid_19 = in_array("COVID-19", $template->getKeys());
+
+?>
+
+<h3 class="section">Test Result</h3>
+
+<div align="center" style="margin: auto; width: 75%;">
+	<img src="/img/<?=htmlspecialchars($pass_image)?>" alt="" />
+</div>
+
+<div style="float: left; width: 70%; position: relative;">
+	<h3 class="section"><?=htmlspecialchars($location_text)?></h3>
+
+	<div class="bl">
+		<div class="field"><?=htmlspecialchars($customer->region_field_name)?> / <?=htmlspecialchars($customer->area_manager_field_name)?>:</div>
+		<div class="value">
+			<div style="float: left; width: 25%;">
+				<?=TestPDF::getValueHtml($location->region)?> / <?=TestPDF::getValueHtml($location->area_manager)?>
+			</div>
+			<div style="float: right; width: 74%; text-align: right;">
+				<?=TestPDF::getValueHtml($location->region_name)?> / <?=TestPDF::getValueHtml($location->area_manager_name)?>
+			</div>
+		</div>
+	</div>
+
+	<div class="bl">
+		<div class="field">Address:</div>
+		<div class="value">
+			<div style="float: left; width: 50%;">
+				<?=htmlspecialchars($location->address_1)?><br />
+				<?php
+				if($location->address_2) {
+					?>
+					<?=htmlspecialchars($location->address_2)?><br />
+					<?php
+				}
+				?>
+				<?=htmlspecialchars($location->city)?>
+			</div>
+			<div style="float: right; width: 49%; text-align: right;">
+				<?=htmlspecialchars($location->legal_entity_name)?><br />
+				<strong>OPM:</strong> <?=htmlspecialchars($location->operations_manager_name)?>
+			</div>
+		</div>
+	</div>
+
+	<div class="bl">
+		<div class="field">Postcode:</div>
+		<div class="value"><?=htmlspecialchars($location->postal_code)?></div>
+	</div>
+
+	<div class="bl">
+		<div class="field">Shop Name - Left:</div>
+		<div class="value"><?=htmlspecialchars($test->shop_left)?></div>
+	</div>
+
+	<div class="bl">
+		<div class="field">Shop Name - Right:</div>
+		<div class="value"><?=htmlspecialchars($test->shop_right)?></div>
+	</div>
+
+	<div>
+		<div class="field">Machines Powered:</div>
+		<div class="value"><?=TestPDF::getBooleanHtml($values["machine_power"] ?? false)?></div>
+	</div>
+
+	<div>
+		<div class="field">Seat:</div>
+		<div class="value"><?=TestPDF::getBooleanHtml($values["machine_seat"] ?? false)?></div>
+	</div>
+
+	<div>
+		<div class="field">Table/Shelf:</div>
+		<div class="value"><?=TestPDF::getBooleanHtml($values["machine_table"] ?? false)?></div>
+	</div>
+
+	<div>
+		<div class="field">Machines Accessible:</div>
+		<div class="value"><?=TestPDF::getBooleanHtml($values["machine_accessible"] ?? false)?></div>
+	</div>
+
+
+</div>
+
+<div style="float: right; width: 29%">
+	<h3 class="section">Tester</h3>
+
+	<div class="bl">
+		<div class="field">Gender:</div>
+		<div class="value"><?=htmlspecialchars($tester->getGenderText())?></div>
+	</div>
+
+	<div>
+		<strong>Attire:</strong><br />
+		<?=htmlspecialchars($test->attire)?>
+	</div>
+
+	<h3 class="section">Brand</h3>
+	<strong><?=htmlspecialchars($location->brand)?></strong>
+
+
+</div>
+
+<div style="clear: both;"></div>
+
+<h3 class="section">Test Details</h3>
+
+<div style="float: left; width: 49.5%">
+	<div class="subheader">
+		<strong>Date &amp; Time</strong>
+	</div>
+
+	<div style="float: left; width: 24%">
+		<strong>Date:</strong><br />
+		<?=htmlspecialchars($date_start)?>
+	</div>
+	<div style="float: left; width: 24%">
+		<strong>Entry:</strong><br />
+		<?=htmlspecialchars($time_start)?>
+	</div>
+	<div style="float: left; width: 24%">
+		<strong>Exit:</strong><br />
+		<?=htmlspecialchars($time_end)?>
+	</div>
+	<div style="float: left; width: 24%">
+		<strong>Duration:</strong><br />
+		<?=htmlspecialchars($duration_text)?>
+	</div>
+
+	<div style="clear: both;"></div><br />
+
+	<?php
+	if($covid_19) {
+		?>
+		<div class="subheader">
+			<strong>Venue</strong>
+		</div>
+		<div class="bl">
+			<div class="field">Social Distancing Signage:</div>
+			<div class="value"><?=TestPDF::getBooleanHtml($values["social_distancing_signage"] ?? false)?></div>
+		</div>
+
+		<div class="bl">
+			<div class="field">Entrance Hand Sanitiser:</div>
+			<div class="value"><?=TestPDF::getBooleanHtml($values["entrance_hand_sanitiser"] ?? false)?></div>
+		</div>
+
+		<div>
+			<div class="field">Social Distancing Measures:</div>
+			<div class="value"><?=TestPDF::getBooleanHtml($values["social_distancing_measures"] ?? false)?></div>
+		</div>
+		<?php
+	}
+	?>
+
+	<div style="clear: both;"></div><br />
+
+	<div class="subheader">
+		<strong>Staff</strong>
+	</div>
+
+	<div class="bl">
+		<div class="field">Name:</div>
+		<div class="value"><?=TestPDF::getValueHtml($test->challenger_name)?></div>
+	</div>
+
+	<div class="bl">
+		<div class="field">Gender:</div>
+		<div class="value"><?=TestPDF::getValueHtml(Util::getGenderText($test->challenger_gender))?></div>
+	</div>
+
+	<strong>Description:</strong><br />
+	<?=TestPDF::getValueHtml($test->challenger_description)?><br />
+
+	<br />
+
+	<div class="subheader">
+		<strong>Signage</strong>
+	</div>
+
+	<div class="wide-field-names">
+		<div class="bl">
+			<div class="field">Think 21/25:</div>
+			<div class="value"><?=TestPDF::getValueHtml($values["think_21_25"] ?? "")?></div>
+		</div>
+
+		<?php
+		$value = $values["citizen_card_brochure_displayed"] ?? "";
+		if(strlen($value)) $value = $value ? "Yes" : "No";
+		?>
+
+		<div class="bl">
+			<div class="field">Citizen Card Brochure Displayed:</div>
+			<div class="value"><?=TestPDF::getValueHtml($value)?></div>
+		</div>
+
+		<?php
+		$value = $values["think_21_poster"] ?? "";
+		if(strlen($value)) $value = $value ? "Yes" : "No";
+		?>
+
+		<div class="bl">
+			<div class="field">Think 21/25 Posters Displayed:</div>
+			<div class="value"><?=TestPDF::getValueHtml($value)?></div>
+		</div>
+
+		<strong>Think 21/25 Poster Notes:</strong><br />
+		<?=TestPDF::getValueHtml($values["think_21_poster_notes"] ?? "")?>
+	</div>
+
+	<br />
+
+	<?php
+	$bar_purchase = ($values["bar_purchase"] ?? "") ? "Yes" : "No";
+	$bar_expenditure = ($values["bar_expenditure"] ?? "") ?: 0;
+	$alcohol_purchased = ($values["alcohol_purchased"] ?? "") ? "Yes" : "No";
+	$bar_purchase_item = ($values["bar_purchase_item"] ?? "");
+	?>
+
+	<div class="subheader">
+		<strong>Bar Details</strong>
+	</div>
+
+	<div class="wide-field-names">
+		<div class="bl">
+			<div class="field">Bar Purchase:</div>
+			<div class="value"><?=TestPDF::getValueHtml($bar_purchase)?></div>
+		</div>
+		<div class="bl">
+			<div class="field">Bar Expenditure:</div>
+			<div class="value">£<?=number_format($bar_expenditure, 2)?></div>
+		</div>
+		<div class="bl">
+			<div class="field">Alcohol Purchased:</div>
+			<div class="value"><?=$alcohol_purchased?></div>
+		</div>
+		<div>
+			<div class="field">Name of Item Purchased:</div>
+			<div class="value"><?=TestPDF::getValueHtml($bar_purchase_item)?></div>
+		</div>
+	</div>
+
+
+</div>
+
+<div style="float: right; width: 49.5%">
+	<div class="subheader">
+		<strong>ID Request</strong>
+	</div>
+
+	<?php
+
+	$pass_colour = $test->pass ? "green" : "red";
+
+	switch($test->challenge_stage) {
+		case 1:
+		case 2:
+			$challenge_colour = "green";
+			break;
+		case 3:
+			$challenge_colour = "orange";
+			break;
+		case 4:
+		case 5:
+		default:
+			$challenge_colour = "red";
+			break;
+	}
+	?>
+
+	<div class="bl">
+		<div class="field">Result:</div>
+		<div class="value" style="color: <?=$pass_colour?>">
+			<strong><?=htmlspecialchars($test->getPassText())?></strong>
+		</div>
+	</div>
+
+	<div>
+		<div class="field">ID Stage:</div>
+		<div class="value" style="color: <?=$challenge_colour?>">
+			<strong><?=htmlspecialchars($test->challenge_stage . " - " . $test->getChallengeStageText())?></strong>
+		</div>
+	</div>
+
+	<br />
+
+	<div>
+		<div style="color: green;">1: Challenge on entry</div>
+		<div style="color: green;">2: Challenge while browsing</div>
+		<div style="color: orange;">3: Challenge during play</div>
+		<div style="color: red;">4: Challenge on exit</div>
+		<div style="color: red;">5: No challenge</div>
+	</div>
+
+	<br />
+
+	<div class="bl">
+		<div class="field">Eye Contact:</div>
+		<div class="value"><?=($test->challenger_eye_contact ? "Yes" : "No")?></div>
+	</div>
+
+	<div>
+		<strong>Description:</strong><br />
+		<?=TestPDF::getValueHtml($test->challenge_description)?>
+	</div>
+
+	<br />
+
+	<div class="subheader">
+		<strong>Play Details</strong>
+	</div>
+	<div class="wide-field-names">
+		<div class="bl">
+			<div class="field">Machine Played:</div>
+			<div class="value"><?=TestPDF::getValueHtml($values["play_machine"] ?? "")?></div>
+		</div>
+
+		<div class="bl">
+			<div class="field">Machine Position:</div>
+			<div class="value"><?=TestPDF::getValueHtml($values["play_machine_position"] ?? "")?></div>
+		</div>
+
+		<?php
+		$value = $values["play_machine_line_of_sight"] ?? "";
+		if(strlen($value)) $value = $value ? "Yes" : "No";
+		?>
+
+		<div class="bl">
+			<div class="field">Line of Sight of Bar:</div>
+			<div class="value"><?=TestPDF::getValueHtml($value)?></div>
+		</div>
+
+		<?php
+		$play_jackpot = $values["play_jackpot"] ?? "";
+		if(!empty($play_jackpot)) {
+			$play_jackpot = "£" . number_format($play_jackpot, 2);
+		}
+		?>
+
+		<div class="bl">
+			<div class="field">Jackpot Value:</div>
+			<div class="value"><?=TestPDF::getValueHtml($play_jackpot)?></div>
+		</div>
+
+		<?php
+		$play_machine_stake = $values["play_machine_stake"] ?? "";
+		if(!empty($play_machine_stake)) {
+			$play_machine_stake = "£" . number_format($play_machine_stake, 2);
+		}
+		?>
+
+		<div class="bl">
+			<div class="field">Stake Played:</div>
+			<div class="value"><?=TestPDF::getValueHtml($play_machine_stake)?></div>
+		</div>
+
+		<div class="bl">
+			<div class="field">Minutes Played:</div>
+			<div class="value"><?=TestPDF::getValueHtml($values["play_minutes"] ?? "")?></div>
+		</div>
+
+		<?php
+		$play_spent = $values["play_spent"] ?? "";
+		if(!empty($play_spent)) $play_spent = "£" . number_format($play_spent, 2);
+		?>
+
+		<div>
+			<div class="field">Amount Spent:</div>
+			<div class="value"><?=TestPDF::getValueHtml($play_spent)?></div>
+		</div>
+	</div>
+
+</div>
+
+<div class="clear"></div>
+
+<br />
+
+<div>
+	<div class="subheader">
+		<strong>Additional Notes</strong>
+	</div>
+
+	<?=TestPDF::getValueHtml($test->additional_notes)?>
+</div>