overview.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var string $page_title
  4. * @var array $ranges
  5. */
  6. use Carbon\CarbonImmutable;
  7. $exclude_customers = Customer::query(["show_in_map_overview" => 0]);
  8. $exclude_customer_ids = array_column($exclude_customers, "id");
  9. $exclude_projects = Project::query(["customer_id" => $exclude_customer_ids]);
  10. $exclude_project_ids = array_column($exclude_projects, "id");
  11. ?>
  12. <div class="container mt-3 py-4">
  13. <h2><?=htmlspecialchars($page_title)?></h2>
  14. <div class="row">
  15. <?php
  16. foreach($ranges as $range) {
  17. $name = $range["name"];
  18. /** @var CarbonImmutable $dt_start */
  19. $dt_start = $range["start"];
  20. /** @var CarbonImmutable $dt_end */
  21. $dt_end = $range["end"];
  22. $dts_start = $dt_start->utc()->format("Y-m-d H:i:s");
  23. $dts_end = $dt_end->utc()->format("Y-m-d H:i:s");
  24. $test_count = Test::count([
  25. "project_id" => Constraint::notIn($exclude_project_ids),
  26. "dts_start" => Constraint::between($dts_start, $dts_end),
  27. "status" => Test::STATUS_COMPLETED
  28. ]);
  29. $projects = Project::query([
  30. "customer_id" => Constraint::notIn($exclude_customer_ids),
  31. "dts_start" => Constraint::between($dts_start, $dts_end),
  32. ], [
  33. "sort" => "dts_start"
  34. ]);
  35. ?>
  36. <div class="col-lg-4">
  37. <h3><?=htmlspecialchars($name)?></h3>
  38. <?php
  39. Html::renderStat("Test Count", $test_count);
  40. ?>
  41. <div class="list-group">
  42. <?php
  43. foreach($projects as $project) {
  44. $completed_count = $project->getCompletedTestCount();
  45. $percentage = round(($completed_count / $project->test_count) * 100);
  46. if($percentage > 100) $percentage = 100;
  47. ?>
  48. <a class="list-group-item list-group-item-action text-nowrap" style="font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis;" href="/account/projects/<?=$project->id?>">
  49. <?=htmlspecialchars($project->name)?>
  50. <div class="progress">
  51. <div class="progress-bar" role="progressbar" aria-valuenow="<?=$percentage?>" aria-valuemin="0" aria-valuemax="100" style="width: <?=$percentage?>%">
  52. </div>
  53. </div>
  54. <strong><?=htmlspecialchars(__("Completed:"))?></strong>
  55. <?=$percentage?>%
  56. (<?=$completed_count?> of <?=$project->test_count?>)
  57. </a>
  58. <?php
  59. }
  60. ?>
  61. </div>
  62. </div>
  63. <?php
  64. }
  65. ?>
  66. </div>
  67. </div>