瀏覽代碼

Add stage reference to reports

Alan Lam 2 年之前
父節點
當前提交
468d7ae6e5
共有 2 個文件被更改,包括 52 次插入 和 3 次删除
  1. 18 1
      controllers/reports.php
  2. 34 2
      views/reports.php

+ 18 - 1
controllers/reports.php

@@ -99,6 +99,8 @@ $has_pass_fail = false;
 
 $template_config = new stdClass();
 
+$challenge_stages = null;
+
 $submit = http::value("submit");
 if($submit) {
 	try {
@@ -144,6 +146,21 @@ if($submit) {
 
 		$template_config = $template->getConfiguration();
 
+		$fields = $template->getFields();
+
+		$challenge_stages = [];
+
+		if(isset($fields["challenge_stage"])) {
+			$field = $fields["challenge_stage"];
+			$values = $field->values;
+			$displays = $field->displayStrings;
+			foreach($values as $index => $value) {
+				if($value) {
+					$challenge_stages[$value] = $displays[$index];
+				}
+			}
+		}
+
 		// Exclude categories
 		if(!$exclude_categories || !is_array($exclude_categories)) {
 			$exclude_categories = $template_config->reports->excludeCategories ?? [];
@@ -548,7 +565,7 @@ if($submit) {
 }
 
 View::includeOnce("header", compact("page_title"));
-View::include("reports", compact("customer", "project_id", "date_range", "date_start", "date_end", "date_resolution", "all_projects", "project_table_data", "exclude_project_ids", "location_ids", "retests", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "locations_missing_operations_manager", "locations_missing_brand", "region_data", "area_manager_data", "brand_data", "operations_manager_data", "key_labels", "has_pass_fail", "template_config", "exclude_categories"));
+View::include("reports", compact("customer", "project_id", "date_range", "date_start", "date_end", "date_resolution", "all_projects", "project_table_data", "exclude_project_ids", "location_ids", "retests", "charts", "data", "total_data", "locations_missing_region", "locations_missing_area_manager", "locations_missing_operations_manager", "locations_missing_brand", "region_data", "area_manager_data", "brand_data", "operations_manager_data", "key_labels", "has_pass_fail", "template_config", "exclude_categories", "challenge_stages"));
 View::includeOnce("footer");
 
 file_put_contents("periodic_data.bin", serialize($data));

+ 34 - 2
views/reports.php

@@ -31,6 +31,8 @@
  * @var array $area_manager_data
  * @var array $brand_data
  * @var array $operations_manager_data
+ *
+ * @var string[] $challenge_stages
  */
 
 $user = Core::$user;
@@ -406,7 +408,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 		<section class="mb-4">
 			<h4><?=htmlspecialchars(__("Numbers"))?></h4>
 
-			<table class="table table-sm table-bordered mb-0">
+			<table class="table table-bordered mb-0">
 				<colgroup>
 					<col style="width: 30%"/>
 					<col style="width: 14%"/>
@@ -478,7 +480,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 
 			<h4><?=htmlspecialchars(__("Numbers Explained"))?></h4>
 
-			<table class="table table-sm table-bordered mb-0">
+			<table class="table table-bordered mb-0">
 				<colgroup>
 					<col style="width: 30%"/>
 					<col style="width: 70%"/>
@@ -563,6 +565,36 @@ let projectData = <?=json_encode($project_table_data)?>;
 			</table>
 		</section>
 
+		<?php
+		if($challenge_stages) {
+			?>
+			<section class="mb-4">
+				<h4><?=htmlspecialchars(__("Challenge Stage Reference"))?></h4>
+
+				<table class="table table-bordered mb-0">
+					<thead>
+					<tr>
+						<th><?=htmlspecialchars(__("Stage"))?></th>
+						<th><?=htmlspecialchars(__("Description"))?></th>
+					</tr>
+					</thead>
+					<tbody>
+					<?php
+					foreach($challenge_stages as $stage => $description) {
+						?>
+						<tr>
+							<th><?=htmlspecialchars(__("Stage %d", $stage))?></th>
+							<td><?=htmlspecialchars($description)?></td>
+						</tr>
+						<?php
+					}
+					?>
+					</tbody>
+				</table>
+			</section>
+			<?php
+		}
+		?>
 
 		<div class="row mb-4">
 			<div class="col-md-4 d-print-none" style="position: relative;">