reports.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var Customer $customer
  4. * @var Chart[] $charts
  5. * @var string[] $key_labels
  6. * @var bool $has_pass_fail
  7. *
  8. * @var array $exclude_categories
  9. * @var object $template_config
  10. *
  11. * @var int $project_id
  12. *
  13. * @var string $date_range
  14. * @var string $date_resolution
  15. * @var string $date_start
  16. * @var string $date_end
  17. *
  18. * @var int[] $location_ids
  19. * @var int $retests
  20. * @var int[] $exclude_project_ids
  21. *
  22. * @var array $project_table_data
  23. * @var Location[] $locations_missing_region
  24. * @var Location[] $locations_missing_area_manager
  25. * @var Location[] $locations_missing_brand
  26. * @var Location[] $locations_missing_operations_manager
  27. *
  28. * @var array $total_data
  29. * @var array $region_data
  30. * @var array $area_manager_data
  31. * @var array $brand_data
  32. * @var array $operations_manager_data
  33. */
  34. $user = Core::$user;
  35. $date_resolutions = [
  36. "quarterly" => "Quarterly",
  37. "monthly" => "Monthly",
  38. ];
  39. $date_ranges = [
  40. "ytd" => "Year to Date",
  41. //"unbound" => "Unbound",
  42. "custom" => "Custom",
  43. ];
  44. $retests_options = [
  45. 0 => "Exclude",
  46. 1 => "Retests Only"
  47. ];
  48. $years = range(2018, date("Y"));
  49. $date_range_custom_style = ($date_range === "custom") ? "" : "display: none";
  50. $date_range_value = "";
  51. if($date_start && $date_end) {
  52. [$min_year, $min_month, $min_day] = explode("-", $date_start);
  53. [$max_year, $max_month, $max_day] = explode("-", $date_end);
  54. $date_range_value = "$min_day/$min_month/$min_year - $max_day/$max_month/$max_year";
  55. }
  56. $collator = new Collator("en_GB");
  57. if($charts) {
  58. $brands = array_keys($brand_data);
  59. $regions = array_keys($region_data);
  60. $area_managers = array_keys($area_manager_data);
  61. $operations_managers = array_keys($operations_manager_data);
  62. }
  63. else {
  64. $brands = $customer->getBrands();
  65. $regions = $customer->getRegions();
  66. $area_managers = $customer->getAreaManagerNames();
  67. $operations_managers = $customer->getOperationsManagerNames();
  68. }
  69. $gaming_managers = $customer->getGamingManagerNames();
  70. $senior_gaming_managers = $customer->getSeniorGamingManagerNames();
  71. $collator->sort($brands);
  72. $collator->sort($regions);
  73. $collator->sort($area_managers);
  74. $collator->sort($operations_managers);
  75. $project_options = [];
  76. foreach($project_table_data as $project_data) {
  77. $project_options[$project_data["id"]] = $project_data["name"];
  78. }
  79. ?>
  80. <script>
  81. let selectedProjectIds = <?=json_encode($exclude_project_ids)?>;
  82. let projectData = <?=json_encode($project_table_data)?>;
  83. </script>
  84. <div class="container mt-3 py-4">
  85. <div class="row d-print-none">
  86. <div class="col">
  87. <h2><?=htmlspecialchars($customer->name)?> Reports</h2>
  88. </div>
  89. <div class="col-auto">
  90. <?php
  91. if($charts) {
  92. ?>
  93. <div class="dropdown">
  94. <button type="button" class="btn btn-secondary dropdown-toggle" id="actions-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  95. Actions
  96. </button>
  97. <div class="dropdown-menu" aria-labelledby="actions-button">
  98. <a class="dropdown-item" href="#" id="export-pptx-action">Export PPTX</a>
  99. </div>
  100. </div>
  101. <?php
  102. }
  103. ?>
  104. </div>
  105. </div>
  106. <form class="mb-4 d-print-none" method="post">
  107. <input type="hidden" name="customer_id" value="<?=htmlspecialchars($customer->id)?>" />
  108. <div class="row">
  109. <div class="col-md">
  110. <div class="form-group">
  111. <label for="project"><?=htmlspecialchars(__("Project"))?></label>
  112. <select class="form-control" name="project_id" id="project">
  113. <option value=""><?=htmlspecialchars(__("Select Project"))?></option>
  114. <?php
  115. HtmlHelper::renderOptions($project_options, $project_id);
  116. ?>
  117. </select>
  118. </div>
  119. <div class="form-group">
  120. <label class="form-label" for="date-range">
  121. Date Range
  122. </label><br />
  123. <?php
  124. foreach($date_ranges as $value => $display) {
  125. $checked = ($value === $date_range) ? "checked" : "";
  126. ?>
  127. <div class="form-check form-check-inline">
  128. <input class="form-check-input" type="radio" name="date_range" id="date-range-<?=htmlspecialchars($value)?>" value="<?=htmlspecialchars($value)?>" <?=$checked?> data-date-range-radio-input />
  129. <label class="form-check-label" for="date-range-<?=htmlspecialchars($value)?>"><?=htmlspecialchars($display)?></label>
  130. </div>
  131. <?php
  132. }
  133. ?>
  134. <div class="row mt-1" id="date-range-custom-fields" style="<?=$date_range_custom_style?>">
  135. <div class="col-lg">
  136. <input class="form-control" type="text" id="date-range" value="<?=htmlspecialchars($date_range_value)?>" />
  137. <input type="hidden" name="date_start" id="date-start" value="<?=htmlspecialchars($date_start)?>" />
  138. <input type="hidden" name="date_end" id="date-end" value="<?=htmlspecialchars($date_end)?>" />
  139. </div>
  140. </div>
  141. </div>
  142. <div class="form-group">
  143. <label for="date-resolution">
  144. Date Resolution
  145. </label>
  146. <select class="form-control" name="date_resolution" id="date-resolution">
  147. <?php
  148. foreach($date_resolutions as $value => $display) {
  149. $selected = ($value === $date_resolution) ? "selected" : "";
  150. ?>
  151. <option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  152. <?php
  153. }
  154. ?>
  155. </select>
  156. </div>
  157. <div class="form-group">
  158. <label for="location-ids">
  159. Location IDs
  160. </label>
  161. <input class="form-control" name="location_ids" type="text" id="location-ids" value="<?=htmlspecialchars(implode(" ", $location_ids))?>" placeholder="Enter location IDs" />
  162. <small class="form-text text-muted">Separate each location ID with a space.<br />Leave blank to generate a report for all locations.</small>
  163. </div>
  164. <div class="form-group">
  165. <label for="retests">Retests</label>
  166. <select name="retests" id="retests" class="form-control">
  167. <option value="">Include</option>
  168. <?php
  169. foreach($retests_options as $value => $display) {
  170. $selected = $value === $retests ? "selected" : "";
  171. ?>
  172. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  173. <?php
  174. }
  175. ?>
  176. </select>
  177. </div>
  178. <?php
  179. $categories = $template_config->reports->categories ?? [];
  180. if($total_data && $categories) {
  181. ?>
  182. <div class="form-group">
  183. <label><?=htmlspecialchars(__("Exclude Categories"))?></label><br />
  184. <?php
  185. foreach($categories as $category) {
  186. $id = sprintf("exclude-category-%s", strtolower($category));
  187. $checked = in_array($category, $exclude_categories) ? "checked" : "";
  188. ?>
  189. <div class="custom-control custom-switch">
  190. <input class="custom-control-input" id="<?=$id?>" name="exclude_categories[]" type="checkbox" value="<?=htmlspecialchars($category)?>" <?=$checked?> />
  191. <label class="custom-control-label" for="<?=$id?>"><?=htmlspecialchars($category)?></label>
  192. </div>
  193. <?php
  194. }
  195. ?>
  196. <input type="hidden" name="exclude_categories[]" value="none" />
  197. </div>
  198. <?php
  199. }
  200. /**
  201. * @param string $name
  202. * @param string $id
  203. * @param string $label
  204. * @param array $values
  205. * @return void
  206. * @throws Exception
  207. */
  208. $render_location_entity_filter = static function(string $name, string $id, string $label, array $values): void {
  209. if(!$values) {
  210. return;
  211. }
  212. $request_name = preg_replace("/\[]/", "", $name);
  213. $selected_values = http::value($request_name, "trim") ?? [];
  214. ?>
  215. <div class="form-group">
  216. <label for="<?=$id?>"><?=htmlspecialchars($label)?></label>
  217. <select class="form-control" name="<?=$name?>" id="<?=$id?>" data-toggle="select2" data-placeholder="<?=htmlspecialchars(__("All"))?>" multiple>
  218. <?php
  219. foreach($values as $value) {
  220. $selected = in_array($value, $selected_values) ? "selected" : ""
  221. ?>
  222. <option value="<?=htmlspecialchars($value)?>" <?=$selected?>><?=htmlspecialchars($value)?></option>
  223. <?php
  224. }
  225. ?>
  226. </select>
  227. </div>
  228. <?php
  229. };
  230. ?>
  231. </div>
  232. <div class="col-md">
  233. <?php
  234. $render_location_entity_filter("brands[]", "brands", $customer->getBrandLabel(2), $brands);
  235. $render_location_entity_filter("operations_managers[]", "operation_managers", $customer->getOperationsManagerLabel(2), $operations_managers);
  236. $render_location_entity_filter("regions[]", "regions", $customer->getRegionLabel(2), $regions);
  237. $render_location_entity_filter("area_managers[]", "area_managers", $customer->getAreaManagerLabel(2), $area_managers);
  238. $render_location_entity_filter("senior_gaming_managers[]", "senior_gaming_managers", $customer->getSeniorGamingManagerLabel(2), $senior_gaming_managers);
  239. $render_location_entity_filter("gaming_managers[]", "gaming_managers", $customer->getGamingManagerLabel(2), $gaming_managers);
  240. ?>
  241. <div class="form-group">
  242. <label class="d-block">
  243. Exclude Projects
  244. </label>
  245. <button id="show-projects-list-button" type="button" class="btn btn-secondary">
  246. <?=htmlspecialchars(__("Show project list"))?>
  247. </button>
  248. <div id="projects-table-wrapper" style="display: none;">
  249. <table class="table table-sm table-sm-text table-hover table-pointer" id="projects-table">
  250. <thead>
  251. <tr>
  252. <th>
  253. <label for="exclude-projects-header-checkbox" class="sr-only">
  254. <?=htmlspecialchars(__("Exclude All"))?>
  255. </label>
  256. <input id="exclude-projects-header-checkbox" type="checkbox" />
  257. </th>
  258. <th>ID</th>
  259. <th>Name</th>
  260. <th><span title="Time of Day" data-toggle="tooltip">TOD</span></th>
  261. <th>Tests</th>
  262. <th>Report Month</th>
  263. </tr>
  264. </thead>
  265. </table>
  266. </div>
  267. </div>
  268. </div>
  269. </div>
  270. <button class="btn btn-primary" type="submit" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
  271. Submit
  272. </button>
  273. </form>
  274. <?php
  275. if($user->canSeeMissingData()) {
  276. /**
  277. * @param string $field
  278. * @param Location[] $locations
  279. * @return void
  280. */
  281. $render_locations_missing_data = static function(string $field, array $locations): void {
  282. ?>
  283. <div class="alert alert-warning limit-height-1 d-print-none">
  284. There are some locations that are missing "<?=htmlspecialchars($field)?>" information:
  285. <ul class="mb-0">
  286. <?php
  287. foreach($locations as $location) {
  288. $url = (Core::$user->canAdmin()) ? "/account/locations/$location->id/edit" : "#";
  289. ?>
  290. <li>
  291. <a href="<?=htmlspecialchars($url)?>"><?=htmlspecialchars($location->name)?></a>
  292. <?php
  293. if($location->internal_id) {
  294. ?>
  295. <small class="text-info">(Internal ID: <?=htmlspecialchars($location->internal_id)?>)</small>
  296. <?php
  297. }
  298. ?>
  299. </li>
  300. <?php
  301. }
  302. ?>
  303. </ul>
  304. </div>
  305. <?php
  306. };
  307. if($locations_missing_region) {
  308. $render_locations_missing_data("region", $locations_missing_region);
  309. }
  310. if($locations_missing_area_manager) {
  311. $render_locations_missing_data("area manager", $locations_missing_area_manager);
  312. }
  313. if($locations_missing_operations_manager) {
  314. $render_locations_missing_data("operations manager", $locations_missing_operations_manager);
  315. }
  316. if($locations_missing_brand) {
  317. $render_locations_missing_data("brand", $locations_missing_brand);
  318. }
  319. }
  320. if($charts) {
  321. ?>
  322. <h2>
  323. Report
  324. </h2>
  325. <p>
  326. <?php
  327. if($retests === 0) {
  328. ?>
  329. <span class="badge badge-warning">Retests Excluded</span>
  330. <?php
  331. }
  332. else if($retests === 1) {
  333. ?>
  334. <span class="badge badge-warning">Retests Only</span>
  335. <?php
  336. }
  337. else {
  338. ?>
  339. <span class="badge badge-success">Retests Included</span>
  340. <?php
  341. }
  342. ?>
  343. </p>
  344. <?php
  345. $render_pass_fail_row = static function(string $title, $pass, $fail, $void) {
  346. $total = $pass + $fail;
  347. $pass_percentage = 0;
  348. if($total > 0) {
  349. $pass_percentage = number_format(($pass * 100) / $total, 2);
  350. }
  351. ?>
  352. <tr>
  353. <th><?=htmlspecialchars($title)?></th>
  354. <td class="text-right"><?=$pass?></td>
  355. <td class="text-right"><?=$pass_percentage?></td>
  356. <td class="text-right"><?=$fail?></td>
  357. <td class="text-right"><?=$total?></td>
  358. <td class="text-right"><?=$void?></td>
  359. </tr>
  360. <?php
  361. };
  362. ?>
  363. <table class="table table-sm table-bordered">
  364. <colgroup>
  365. <col style="width: 16%"/>
  366. <col style="width: 16%"/>
  367. <col style="width: 16%"/>
  368. <col style="width: 16%"/>
  369. <col style="width: 16%"/>
  370. </colgroup>
  371. <thead>
  372. <tr>
  373. <th></th>
  374. <th><?=htmlspecialchars(__("Passes"))?></th>
  375. <th><?=htmlspecialchars(__("Pass Rate (%)"))?></th>
  376. <th><?=htmlspecialchars(__("Fails"))?></th>
  377. <th><?=htmlspecialchars(__("Total"))?></th>
  378. <th><?=htmlspecialchars(__("Voids"))?></th>
  379. </tr>
  380. </thead>
  381. <tbody>
  382. <tr>
  383. <th><?=htmlspecialchars(__("Venue Tests"))?></th>
  384. <td colspan="3"></td>
  385. <td class="text-right"><?=htmlspecialchars($total_data->testCount)?></td>
  386. <td class="text-right"><?=htmlspecialchars($total_data->voidCount)?></td>
  387. </tr>
  388. <?php
  389. if(isset($total_data->passCount)) {
  390. $render_pass_fail_row("Gaming Tests", $total_data->passCount, $total_data->failCount, $total_data->gamingCounts["void"] ?? 0);
  391. }
  392. if(isset($total_data->barCounts)) {
  393. $render_pass_fail_row("Alcohol Tests", $total_data->barCounts["pass"], $total_data->barCounts["fail"], $total_data->barCounts["void"] ?? 0);
  394. }
  395. if(isset($total_data->combinedCounts)) {
  396. $render_pass_fail_row("Combined Tests", $total_data->combinedCounts["pass"], $total_data->combinedCounts["fail"], $total_data->combinedCounts["void"] ?? 0);
  397. }
  398. ?>
  399. </tbody>
  400. </table>
  401. <div class="row mb-4">
  402. <div class="col-md-4 d-print-none" style="position: relative;">
  403. <h3>Chart List</h3>
  404. <div class="list-group limit-height-2" style="position: sticky; top: 7rem;">
  405. <?php
  406. foreach($charts as $index => $chart) {
  407. if($project_id && $chart->isPeriodic()) {
  408. continue;
  409. }
  410. ?>
  411. <a class="list-group-item list-group-item-action" href="#chart-<?=$index?>">
  412. <?=htmlspecialchars($chart->getTitle())?>
  413. </a>
  414. <?php
  415. }
  416. ?>
  417. </div>
  418. </div>
  419. <div class="col-md-8">
  420. <?php
  421. foreach($charts as $index => $chart) {
  422. if($project_id && $chart->isPeriodic()) {
  423. continue;
  424. }
  425. if($index > 0) {
  426. ?>
  427. <br />
  428. <?php
  429. }
  430. if($chart->beforeHtml) {
  431. echo $chart->beforeHtml;
  432. }
  433. ?>
  434. <a id="chart-<?=$index?>" style="display: block; position: relative; top: -7rem; visibility: hidden;"></a>
  435. <canvas id="<?=$chart->getID()?>" data-chart="<?=htmlspecialchars($chart->getJSON())?>" width="400" height="300">
  436. </canvas>
  437. <?php
  438. if($chart->print) {
  439. $chart->printDataTable();
  440. }
  441. if($chart->afterHtml) {
  442. echo $chart->afterHtml;
  443. }
  444. }
  445. ?>
  446. </div>
  447. </div>
  448. <?php
  449. foreach(["pptx", "odp"] as $format) {
  450. ?>
  451. <form id="form-<?=$format?>" method="post" action="/account/reports/export-<?=$format?>" data-rendered="0">
  452. <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
  453. <input type="hidden" name="customer_id" value="<?=$customer->id?>" />
  454. <input type="hidden" name="project_id" value="<?=$project_id?>" />
  455. <input type="hidden" name="date_range" value="<?=htmlspecialchars($date_range)?>" />
  456. <input type="hidden" name="date_start" id="date-start" value="<?=htmlspecialchars($date_start)?>" />
  457. <input type="hidden" name="date_end" id="date-end" value="<?=htmlspecialchars($date_end)?>" />
  458. <input type="hidden" name="date_resolution" value="<?=htmlspecialchars($date_resolution)?>" />
  459. <input type="hidden" name="retests" value="<?=htmlspecialchars($retests)?>" />
  460. <?php
  461. foreach($exclude_project_ids as $exclude_project_id) {
  462. ?>
  463. <input type="hidden" name="exclude_project_ids[]" value="<?=$exclude_project_id?>" />
  464. <?php
  465. }
  466. foreach($exclude_categories as $exclude_category) {
  467. ?>
  468. <input type="hidden" name="exclude_categories[]" value="<?=$exclude_category?>" />
  469. <?php
  470. }
  471. ?>
  472. <input type="submit" value="Submit" class="d-none" />
  473. </form>
  474. <?php
  475. }
  476. if($has_pass_fail) {
  477. $tables = [
  478. (object) [
  479. "name" => $customer->getRegionLabel(1),
  480. "data" => $region_data
  481. ],
  482. (object) [
  483. "name" => $customer->getAreaManagerLabel(1),
  484. "data" => $area_manager_data
  485. ],
  486. (object) [
  487. "name" => $customer->getOperationsManagerLabel(1),
  488. "data" => $operations_manager_data
  489. ],
  490. (object) [
  491. "name" => $customer->getBrandLabel(1),
  492. "data" => $brand_data
  493. ],
  494. ]
  495. ?>
  496. <div class="d-print-none">
  497. <h2>Extra Information</h2>
  498. <?php
  499. foreach($tables as $table) {
  500. $title = $table->name . " Data";
  501. $entity_type = $table->name;
  502. // Calculate totals
  503. $totals = [];
  504. foreach($table->data as $entity_name => $rows) {
  505. $totals[] = [
  506. "name" => $entity_name,
  507. "testCount" => array_sum(array_column($rows, "testCount")),
  508. "passCount" => array_sum(array_column($rows, "passCount")),
  509. "failCount" => array_sum(array_column($rows, "failCount")),
  510. ];
  511. }
  512. if(!$totals) {
  513. continue;
  514. }
  515. ?>
  516. <h3><?=htmlspecialchars($title)?></h3>
  517. <h4><?=htmlspecialchars($entity_type)?>: Totals</h4>
  518. <?php
  519. usort($totals, static function($a, $b) {
  520. return strnatcasecmp($a["name"], $b["name"]);
  521. });
  522. $total_test_count = 0;
  523. $total_pass_count = 0;
  524. $total_fail_count = 0;
  525. ?>
  526. <table class="table table-sm table-bordered">
  527. <colgroup>
  528. <col style="width: 20%" />
  529. <col style="width: 20%" />
  530. <col style="width: 20%" />
  531. <col style="width: 20%" />
  532. <col style="width: 20%" />
  533. </colgroup>
  534. <thead>
  535. <tr>
  536. <th><?=htmlspecialchars($title)?></th>
  537. <th>Tests</th>
  538. <th>Passes</th>
  539. <th>Fails</th>
  540. <th>Rate</th>
  541. </tr>
  542. </thead>
  543. <tbody>
  544. <?php
  545. foreach($totals as $data) {
  546. $total_test_count += $data["testCount"];
  547. $total_pass_count += $data["passCount"];
  548. $total_fail_count += $data["failCount"];
  549. $rate = ($data["testCount"] === 0) ? "0.00" : number_format(($data["passCount"] * 100) / $data["testCount"], 2);
  550. ?>
  551. <tr>
  552. <td><?=htmlspecialchars($data["name"])?></td>
  553. <td class="text-right"><?=number_format($data["testCount"])?></td>
  554. <td class="text-right"><?=number_format($data["passCount"])?></td>
  555. <td class="text-right"><?=number_format($data["failCount"])?></td>
  556. <td class="text-right"><?=$rate?>%</td>
  557. </tr>
  558. <?php
  559. }
  560. $total_rate = ($total_test_count === 0) ? "0.00" : number_format(($total_pass_count * 100) / $total_test_count, 2);
  561. ?>
  562. </tbody>
  563. <tfoot>
  564. <tr class="table-active">
  565. <th>
  566. Total
  567. </th>
  568. <th class="text-right">
  569. <?=number_format($total_test_count)?>
  570. </th>
  571. <th class="text-right">
  572. <?=number_format($total_pass_count)?>
  573. </th>
  574. <th class="text-right">
  575. <?=number_format($total_fail_count)?>
  576. </th>
  577. <th class="text-right"><?=$total_rate?>%</th>
  578. </tr>
  579. </tfoot>
  580. </table>
  581. <?php
  582. foreach($table->data as $entity_name => $rows) {
  583. ?>
  584. <h4><?=htmlspecialchars($entity_type)?>: <?=htmlspecialchars($entity_name)?></h4>
  585. <table class="table table-sm table-bordered">
  586. <colgroup>
  587. <col style="width: 20%" />
  588. <col style="width: 20%" />
  589. <col style="width: 20%" />
  590. <col style="width: 20%" />
  591. <col style="width: 20%" />
  592. </colgroup>
  593. <thead>
  594. <tr>
  595. <th>Period</th>
  596. <th>Tests</th>
  597. <th>Passes</th>
  598. <th>Fails</th>
  599. <th>Rate</th>
  600. </tr>
  601. </thead>
  602. <tbody>
  603. <?php
  604. $index = 0;
  605. foreach($rows as $key => $data) {
  606. $rate = ($data->testCount == 0) ? "0.00" : number_format(($data->passCount * 100) / $data->testCount, 2);
  607. $label = $key_labels[$index];
  608. ?>
  609. <tr>
  610. <td><?=htmlspecialchars($label)?></td>
  611. <td class="text-right"><?=number_format($data->testCount)?></td>
  612. <td class="text-right"><?=number_format($data->passCount)?></td>
  613. <td class="text-right"><?=number_format($data->failCount)?></td>
  614. <td class="text-right"><?=$rate?>%</td>
  615. </tr>
  616. <?php
  617. $index++;
  618. }
  619. ?>
  620. </tbody>
  621. </table>
  622. <?php
  623. }
  624. }
  625. ?>
  626. </div>
  627. <?php
  628. }
  629. }
  630. ?>
  631. </div>