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

Add "Void" column to aggregate report table

Alan Lam 2 лет назад
Родитель
Сommit
b8e421a717

+ 2 - 0
controllers/reports.php

@@ -418,6 +418,8 @@ if($submit) {
 		}
 
 		// Process test results
+
+		/** @var Test $test */
 		foreach($tests as $test) {
 
 			$tester = $test->getTester();

+ 8 - 6
template_processing/age_verification_greene_king/reports_create_empty_objects.php

@@ -42,10 +42,11 @@ $empty_data = (object) [
 	"unknownChallengePassCount" => 0,
 	"unknownChallengeStages" => [0, 0, 0, 0, 0],
 
-	"barCounts" => ["pass" => 0, "fail" => 0],
-	"barAgeVerificationCounts" => ["pass" => 0, "fail" => 0],
+	"gamingCounts" => ["void" => 0],
+	"barCounts" => ["pass" => 0, "fail" => 0, "void" => 0],
+	"barAgeVerificationCounts" => ["pass" => 0, "fail" => 0, "void" => 0],
 
-	"combinedCounts" => ["pass" => 0, "fail" => 0],
+	"combinedCounts" => ["pass" => 0, "fail" => 0, "void" => 0],
 
 	"stage1Count" => 0,
 	"stage2Count" => 0,
@@ -75,8 +76,9 @@ $total_data = (object) [
 	"stage4Count" => 0,
 	"stage5Count" => 0,
 
-	"barCounts" => ["pass" => 0, "fail" => 0],
-	"barAgeVerificationCounts" => ["pass" => 0, "fail" => 0],
+	"gamingCounts" => ["void" => 0],
+	"barCounts" => ["pass" => 0, "fail" => 0, "void" => 0],
+	"barAgeVerificationCounts" => ["pass" => 0, "fail" => 0, "void" => 0],
 
-	"combinedCounts" => ["pass" => 0, "fail" => 0],
+	"combinedCounts" => ["pass" => 0, "fail" => 0, "void" => 0],
 ];

+ 9 - 1
template_processing/age_verification_greene_king/reports_process_test.php

@@ -123,10 +123,18 @@ if(!$test->void_primary) {
 	$data[$key]->{$gender_prefix . "Stages"}[$test->challenge_stage - 1]++;
 	if($test->pass) $data[$key]->{$gender_prefix . "PassCount"}++;
 }
+else {
+	$total_data->gamingCounts["void"]++;
+	$total_data->combinedCounts["void"]++;
+}
 
 // Alcohol Pass/Fail
 
-if($test->challenge_stage === 5 || $test->void_primary) {
+if($test->void_secondary) {
+	$total_data->barCounts["void"]++;
+	$total_data->combinedCounts["void"]++;
+}
+else if($test->challenge_stage === 5 || $test->void_primary) {
 	$av = (bool) ($test_values->bar_age_verification ?? false);
 	$av_key = $av ? "pass" : "fail";
 	$data[$key]->barAgeVerificationCounts[$av_key]++;

+ 14 - 10
views/reports.php

@@ -383,7 +383,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 
 		<?php
 
-		$render_pass_fail_row = static function(string $title, $pass, $fail) {
+		$render_pass_fail_row = static function(string $title, $pass, $fail, $void) {
 			$total = $pass + $fail;
 
 			$pass_percentage = 0;
@@ -397,6 +397,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 				<td class="text-right"><?=$pass_percentage?></td>
 				<td class="text-right"><?=$fail?></td>
 				<td class="text-right"><?=$total?></td>
+				<td class="text-right"><?=$void?></td>
 			</tr>
 			<?php
 		};
@@ -404,18 +405,20 @@ let projectData = <?=json_encode($project_table_data)?>;
 
 		<table class="table table-sm table-bordered">
 			<colgroup>
-				<col style="width: 20%"/>
-				<col style="width: 20%"/>
-				<col style="width: 20%"/>
-				<col style="width: 20%"/>
+				<col style="width: 16%"/>
+				<col style="width: 16%"/>
+				<col style="width: 16%"/>
+				<col style="width: 16%"/>
+				<col style="width: 16%"/>
 			</colgroup>
 			<thead>
 			<tr>
 				<th></th>
-				<th><?=htmlspecialchars(__("Pass"))?></th>
+				<th><?=htmlspecialchars(__("Passes"))?></th>
 				<th><?=htmlspecialchars(__("Pass Rate (%)"))?></th>
-				<th><?=htmlspecialchars(__("Fail"))?></th>
+				<th><?=htmlspecialchars(__("Fails"))?></th>
 				<th><?=htmlspecialchars(__("Total"))?></th>
+				<th><?=htmlspecialchars(__("Voids"))?></th>
 			</tr>
 			</thead>
 			<tbody>
@@ -423,18 +426,19 @@ let projectData = <?=json_encode($project_table_data)?>;
 				<th><?=htmlspecialchars(__("Venue Tests"))?></th>
 				<td colspan="3"></td>
 				<td class="text-right"><?=htmlspecialchars($total_data->testCount)?></td>
+				<td class="text-right"><?=htmlspecialchars($total_data->voidCount)?></td>
 			</tr>
 			<?php
 			if(isset($total_data->passCount)) {
-				$render_pass_fail_row("Gaming Tests", $total_data->passCount, $total_data->failCount);
+				$render_pass_fail_row("Gaming Tests", $total_data->passCount, $total_data->failCount, $total_data->gamingCounts["void"] ?? 0);
 			}
 
 			if(isset($total_data->barCounts)) {
-				$render_pass_fail_row("Alcohol Tests", $total_data->barCounts["pass"],  $total_data->barCounts["fail"]);
+				$render_pass_fail_row("Alcohol Tests", $total_data->barCounts["pass"],  $total_data->barCounts["fail"], $total_data->barCounts["void"] ?? 0);
 			}
 
 			if(isset($total_data->combinedCounts)) {
-				$render_pass_fail_row("Combined Tests", $total_data->combinedCounts["pass"],  $total_data->combinedCounts["fail"]);
+				$render_pass_fail_row("Combined Tests", $total_data->combinedCounts["pass"],  $total_data->combinedCounts["fail"], $total_data->combinedCounts["void"] ?? 0);
 			}
 			?>
 			</tbody>