overview.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. ?>
  34. <div class="col-lg-4">
  35. <h3><?=htmlspecialchars($name)?></h3>
  36. <?php
  37. Html::renderStat("Test Count", $test_count);
  38. foreach($projects as $project) {
  39. $percentage = $project->getCompletedPercentage();
  40. ?>
  41. <div class="card card-body py-2">
  42. <strong><?=htmlspecialchars($project->name)?></strong>
  43. <div class="progress">
  44. <div class="progress-bar" role="progressbar" aria-valuenow="<?=$percentage?>" aria-valuemin="0" aria-valuemax="100" style="width: <?=$percentage?>%">
  45. </div>
  46. </div>
  47. </div>
  48. <?php
  49. }
  50. ?>
  51. </div>
  52. <?php
  53. }
  54. ?>
  55. </div>
  56. </div>