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

Move explainers to its own table

Alan Lam 2 лет назад
Родитель
Сommit
9beb2ebc52
1 измененных файлов с 103 добавлено и 34 удалено
  1. 103 34
      views/reports.php

+ 103 - 34
views/reports.php

@@ -383,7 +383,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 
 
 		<?php
 		<?php
 
 
-		$render_pass_fail_row = static function(string $title, $pass, $fail, $void, $explainer = "") {
+		$render_pass_fail_row = static function(string $title, $pass, $fail, $void) {
 			$total = $pass + $fail;
 			$total = $pass + $fail;
 
 
 			$pass_percentage = 0;
 			$pass_percentage = 0;
@@ -392,23 +392,20 @@ let projectData = <?=json_encode($project_table_data)?>;
 			}
 			}
 			?>
 			?>
 			<tr>
 			<tr>
-				<th rowspan="2"><?=htmlspecialchars($title)?></th>
+				<th><?=htmlspecialchars($title)?></th>
 				<td class="text-right"><?=$total?></td>
 				<td class="text-right"><?=$total?></td>
 				<td class="text-right"><?=$pass?></td>
 				<td class="text-right"><?=$pass?></td>
 				<td class="text-right"><?=$fail?></td>
 				<td class="text-right"><?=$fail?></td>
 				<td class="text-right"><?=$pass_percentage?>%</td>
 				<td class="text-right"><?=$pass_percentage?>%</td>
 				<td class="text-right"><?=$void?></td>
 				<td class="text-right"><?=$void?></td>
 			</tr>
 			</tr>
-			<tr>
-				<td colspan="5">
-					<?=htmlspecialchars($explainer)?>
-				</td>
-			</tr>
 			<?php
 			<?php
 		};
 		};
 		?>
 		?>
 
 
 		<section class="mb-4">
 		<section class="mb-4">
+			<h4><?=htmlspecialchars(__("Numbers"))?></h4>
+
 			<table class="table table-sm table-bordered mb-0">
 			<table class="table table-sm table-bordered mb-0">
 				<colgroup>
 				<colgroup>
 					<col style="width: 30%"/>
 					<col style="width: 30%"/>
@@ -430,64 +427,135 @@ let projectData = <?=json_encode($project_table_data)?>;
 				</thead>
 				</thead>
 				<tbody>
 				<tbody>
 				<tr>
 				<tr>
-					<th rowspan="2"><?=htmlspecialchars(__("Venue Tests"))?></th>
+					<th><?=htmlspecialchars(__("Venue Tests"))?></th>
 					<td class="text-right"><?=htmlspecialchars($total_data->testCount)?></td>
 					<td class="text-right"><?=htmlspecialchars($total_data->testCount)?></td>
 					<td></td>
 					<td></td>
 					<td></td>
 					<td></td>
 					<td></td>
 					<td></td>
 					<td class="text-right"><?=htmlspecialchars($total_data->voidCount)?></td>
 					<td class="text-right"><?=htmlspecialchars($total_data->voidCount)?></td>
 				</tr>
 				</tr>
-				<tr>
-					<td colspan="5">
-						<?=htmlspecialchars(__("There were %d tests of which %d were voids resulting in %d gaming tests being carried out.", $total_data->testCount + $total_data->voidCount, $total_data->voidCount, $total_data->testCount))?>
-					</td>
-				</tr>
 				<?php
 				<?php
 				if(isset($total_data->passCount)) {
 				if(isset($total_data->passCount)) {
 					$pass_count = $total_data->passCount;
 					$pass_count = $total_data->passCount;
 					$fail_count = $total_data->failCount;
 					$fail_count = $total_data->failCount;
 					$void_count = $total_data->gamingCounts["void"] ?? 0;
 					$void_count = $total_data->gamingCounts["void"] ?? 0;
-					$explainer = __("There were %d gaming tests of which there were %d passes and %d fails and %d voids.", ($pass_count + $fail_count + $void_count), $pass_count, $fail_count, $void_count);
 
 
-					$render_pass_fail_row(__("Gaming Tests"), $pass_count, $fail_count, $void_count, $explainer);
+					$render_pass_fail_row(__("Gaming Tests"), $pass_count, $fail_count, $void_count);
 				}
 				}
 
 
 				if(isset($total_data->barCounts)) {
 				if(isset($total_data->barCounts)) {
-
-					$gaming_stage_5 = $total_data->stage5Count ?? 0;
-					$gaming_void_count = $total_data->gamingCounts["void"] ?? 0;
-
 					$pass_count = $total_data->barCounts["pass"];
 					$pass_count = $total_data->barCounts["pass"];
 					$fail_count = $total_data->barCounts["fail"];
 					$fail_count = $total_data->barCounts["fail"];
 					$void_count = $total_data->barCounts["void"] ?? 0;
 					$void_count = $total_data->barCounts["void"] ?? 0;
-					$explainer = __("There were %d alcohol tests which come from %d gaming tests that ended up in Stage 5 plus %d gaming tests that were void. Of these alcohol tests there were %d passes and %d fails and %d voids.", ($pass_count + $fail_count + $void_count), $gaming_stage_5, $gaming_void_count, $pass_count, $fail_count, $void_count);
 
 
-					$render_pass_fail_row(__("Alcohol Tests"), $pass_count, $fail_count, $void_count, $explainer);
+					$render_pass_fail_row(__("Alcohol Tests"), $pass_count, $fail_count, $void_count);
 				}
 				}
 
 
+				if(isset($total_data->combinedCounts) || isset($total_data->blendedCounts) || isset($total_data->mergedCounts)) {
+					?>
+					<tr>
+						<th class="bg-light" colspan="6"><?=htmlspecialchars(__("Aggregate Counts"))?></th>
+					</tr>
+					<?php
+					if(isset($total_data->combinedCounts)) {
+						$render_pass_fail_row(__("Gaming and Alcohol"), $total_data->combinedCounts["pass"],  $total_data->combinedCounts["fail"], $total_data->combinedCounts["void"] ?? 0);
+					}
+
+					if(isset($total_data->blendedCounts)) {
+						$render_pass_fail_row(__("Gaming and Assumed Alcohol"), $total_data->blendedCounts["pass"],  $total_data->blendedCounts["fail"], $total_data->blendedCounts["void"] ?? 0);
+					}
+
+					if(isset($total_data->mergedCounts)) {
+						$render_pass_fail_row(__("Gaming or Alcohol Pass"), $total_data->mergedCounts["pass"], $total_data->mergedCounts["fail"], $total_data->mergedCounts["void"] ?? 0);
+					}
+				}
 				?>
 				?>
+				</tbody>
+			</table>
+		</section>
+
+		<section class="mb-4">
+
+			<h4><?=htmlspecialchars(__("Numbers Explained"))?></h4>
+
+			<table class="table table-sm table-bordered mb-0">
+				<colgroup>
+					<col style="width: 30%"/>
+					<col style="width: 70%"/>
+				</colgroup>
+				<thead>
+				<tr>
+					<th><?=htmlspecialchars(__("Type"))?></th>
+					<th><?=htmlspecialchars(__("Description"))?></th>
+				</tr>
+				</thead>
+				<tbody>
 				<tr>
 				<tr>
-					<th class="bg-light" colspan="6"><?=htmlspecialchars(__("Aggregate Counts"))?></th>
+					<th><?=htmlspecialchars(__("Venue Tests"))?></th>
+					<td><?=htmlspecialchars(__("There were %d tests of which %d were voids resulting in %d gaming tests being carried out.", $total_data->testCount + $total_data->voidCount, $total_data->voidCount, $total_data->testCount))?></td>
 				</tr>
 				</tr>
 				<?php
 				<?php
-
-				if(isset($total_data->combinedCounts)) {
-					$render_pass_fail_row(__("Gaming and Alcohol"), $total_data->combinedCounts["pass"],  $total_data->combinedCounts["fail"], $total_data->combinedCounts["void"] ?? 0, __("The gaming and alcohol tests added together."));
+				if(isset($total_data->passCount)) {
+					$pass_count = $total_data->passCount;
+					$fail_count = $total_data->failCount;
+					$void_count = $total_data->gamingCounts["void"] ?? 0;
+					?>
+					<tr>
+						<th><?=htmlspecialchars(__("Gaming Tests"))?></th>
+						<td><?=htmlspecialchars(__("There were %d gaming tests of which there were %d passes and %d fails and %d voids.", ($pass_count + $fail_count + $void_count), $pass_count, $fail_count, $void_count))?></td>
+					</tr>
+					<?php
 				}
 				}
+				if(isset($total_data->barCounts)) {
+					$gaming_stage_5 = $total_data->stage5Count ?? 0;
+					$gaming_void_count = $total_data->gamingCounts["void"] ?? 0;
 
 
-				if(isset($total_data->blendedCounts)) {
-					$render_pass_fail_row(__("Gaming and Assumed Alcohol"), $total_data->blendedCounts["pass"],  $total_data->blendedCounts["fail"], $total_data->blendedCounts["void"] ?? 0, __("The gaming and alcohol tests added together but also assuming that any gaming test pass is also an alcohol test pass. %d passes were added.", $total_data->passCount));
+					$pass_count = $total_data->barCounts["pass"];
+					$fail_count = $total_data->barCounts["fail"];
+					$void_count = $total_data->barCounts["void"] ?? 0;
+					$explainer = __("There were %d alcohol tests which come from %d gaming tests that ended up in Stage 5 plus %d gaming tests that were void. Of these alcohol tests there were %d passes and %d fails and %d voids.", ($pass_count + $fail_count + $void_count), $gaming_stage_5, $gaming_void_count, $pass_count, $fail_count, $void_count);
+					?>
+					<tr>
+						<th><?=htmlspecialchars(__("Alcohol Tests"))?></th>
+						<td><?=htmlspecialchars(__("There were %d alcohol tests which come from %d gaming tests that ended up in Stage 5 plus %d gaming tests that were void. Of these alcohol tests there were %d passes and %d fails and %d voids.", ($pass_count + $fail_count + $void_count), $gaming_stage_5, $gaming_void_count, $pass_count, $fail_count, $void_count))?></td>
+					</tr>
+					<?php
 				}
 				}
 
 
-				if(isset($total_data->mergedCounts)) {
-					$pass_count = $total_data->mergedCounts["pass"];
-					$fail_count = $total_data->mergedCounts["fail"];
-					$void_count = $total_data->mergedCounts["void"] ?? 0;
 
 
-					$gaming_stage_3 = $total_data->stage3Count ?? 0;
-					$gaming_stage_4 = $total_data->stage4Count ?? 0;
+				if(isset($total_data->combinedCounts) || isset($total_data->blendedCounts) || isset($total_data->mergedCounts)) {
+					?>
+					<tr>
+						<th class="bg-light" colspan="2"><?=htmlspecialchars(__("Aggregate Counts"))?></th>
+					</tr>
+					<?php
+					if(isset($total_data->combinedCounts)) {
+						?>
+						<tr>
+							<th><?=htmlspecialchars(__("Gaming and Alcohol"))?></th>
+							<td><?=htmlspecialchars(__("The gaming and alcohol tests added together."))?></td>
+						</tr>
+						<?php
+					}
+					if(isset($total_data->blendedCounts)) {
+						?>
+						<tr>
+							<th><?=htmlspecialchars(__("Gaming and Assumed Alcohol"))?></th>
+							<td><?=htmlspecialchars(__("The gaming and alcohol tests added together but also assuming that any gaming test pass is also an alcohol test pass. %d passes were added.", $total_data->passCount))?></td>
+						</tr>
+						<?php
+					}
 
 
-					$render_pass_fail_row(__("Gaming or Alcohol Pass"), $pass_count, $fail_count, $void_count, __("The gaming and alcohol passes added together. %d tests either passed the gaming test or alcohol test. There were %d outright fails: %d were caught at Stage 3, %d were caught at Stage 4 and %d failed the alcohol test.", $pass_count, $total_data->mergedCounts["fail"], $gaming_stage_3, $gaming_stage_4, $total_data->barCounts["fail"]));
+					if(isset($total_data->mergedCounts)) {
+						$gaming_stage_3 = $total_data->stage3Count ?? 0;
+						$gaming_stage_4 = $total_data->stage4Count ?? 0;
+						?>
+						<tr>
+							<th><?=htmlspecialchars(__("Gaming or Alcohol Pass"))?></th>
+							<td><?=htmlspecialchars(__("The gaming and alcohol passes added together. %d tests either passed the gaming test or alcohol test. There were %d outright fails: %d were caught at Stage 3, %d were caught at Stage 4 and %d failed the alcohol test.", $total_data->mergedCounts["pass"], $total_data->mergedCounts["fail"], $gaming_stage_3, $gaming_stage_4, $total_data->barCounts["fail"]))?></td>
+						</tr>
+						<?php
+					}
 				}
 				}
 
 
 				?>
 				?>
@@ -495,6 +563,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 			</table>
 			</table>
 		</section>
 		</section>
 
 
+
 		<div class="row mb-4">
 		<div class="row mb-4">
 			<div class="col-md-4 d-print-none" style="position: relative;">
 			<div class="col-md-4 d-print-none" style="position: relative;">
 				<h3>Chart List</h3>
 				<h3>Chart List</h3>