overview.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. ?>
  39. <div class="list-group">
  40. <?php
  41. foreach($projects as $project) {
  42. $percentage = $project->getCompletedPercentage();
  43. ?>
  44. <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?>">
  45. <?=htmlspecialchars($project->name)?>
  46. <div class="progress">
  47. <div class="progress-bar" role="progressbar" aria-valuenow="<?=$percentage?>" aria-valuemin="0" aria-valuemax="100" style="width: <?=$percentage?>%">
  48. </div>
  49. </div>
  50. </a>
  51. <?php
  52. }
  53. ?>
  54. </div>
  55. <?php
  56. ?>
  57. </div>
  58. <?php
  59. }
  60. ?>
  61. </div>
  62. </div>