فهرست منبع

Add "Total" row for total tables

Alan Lam 2 سال پیش
والد
کامیت
01b9f709ab
1فایلهای تغییر یافته به همراه28 افزوده شده و 0 حذف شده
  1. 28 0
      views/reports.php

+ 28 - 0
views/reports.php

@@ -478,6 +478,10 @@ let projectData = <?=json_encode($project_table_data)?>;
 						return strnatcasecmp($a["name"], $b["name"]);
 						return strnatcasecmp($a["name"], $b["name"]);
 					});
 					});
 
 
+					$total_test_count = 0;
+					$total_pass_count = 0;
+					$total_fail_count = 0;
+
 					?>
 					?>
 
 
 					<table class="table table-sm table-bordered">
 					<table class="table table-sm table-bordered">
@@ -500,6 +504,10 @@ let projectData = <?=json_encode($project_table_data)?>;
 						<tbody>
 						<tbody>
 						<?php
 						<?php
 						foreach($totals as $data) {
 						foreach($totals as $data) {
+							$total_test_count += $data["testCount"];
+							$total_pass_count += $data["passCount"];
+							$total_fail_count += $data["failCount"];
+
 							$rate = ($data["testCount"] === 0) ? "0.00" : number_format(($data["passCount"] * 100) / $data["testCount"], 2);
 							$rate = ($data["testCount"] === 0) ? "0.00" : number_format(($data["passCount"] * 100) / $data["testCount"], 2);
 							?>
 							?>
 							<tr>
 							<tr>
@@ -511,8 +519,28 @@ let projectData = <?=json_encode($project_table_data)?>;
 							</tr>
 							</tr>
 							<?php
 							<?php
 						}
 						}
+
+						$total_rate = ($total_test_count === 0) ? "0.00" : number_format(($total_pass_count * 100) / $total_test_count, 2);
+
 						?>
 						?>
 						</tbody>
 						</tbody>
+						<tfoot>
+						<tr class="table-active">
+							<th>
+								Total
+							</th>
+							<th class="text-right">
+								<?=number_format($total_test_count)?>
+							</th>
+							<th class="text-right">
+								<?=number_format($total_pass_count)?>
+							</th>
+							<th class="text-right">
+								<?=number_format($total_fail_count)?>
+							</th>
+							<th class="text-right"><?=$total_rate?>%</th>
+						</tr>
+						</tfoot>
 					</table>
 					</table>
 
 
 					<?php
 					<?php