project_list.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <table class="table table-sm table-sm-text table-hover">
  2. <thead>
  3. <tr>
  4. <th class="text-right pr-3">ID</th>
  5. <th>Name</th>
  6. <th>Tests</th>
  7. <th>Period</th>
  8. <th>Report Month</th>
  9. <th></th>
  10. </tr>
  11. </thead>
  12. <tbody>
  13. <?php
  14. $project_ids = array_column($projects, "id");
  15. $tests = Test::query(["project_id" => $project_ids]);
  16. foreach($projects as $project) {
  17. $year = date("Y", strtotime($project->dts_start));
  18. $date_start = date("M jS", strtotime(explode(" ", $project->dts_start)[0]));
  19. $date_deadline = date("M jS", strtotime(explode(" ", $project->dts_deadline)[0]));
  20. $report_month = $project->getDisplayReportMonth();
  21. $time_of_day_icon = $project->time_of_day != "A" ? $project->getTimeOfDayIcon() : null;
  22. $time_of_day_text = $project->getTimeOfDayText();
  23. $template = $project->getTemplate();
  24. $completed_tests = array_filter($tests, function($test) use ($project) {
  25. return ($project->id == $test->project_id) && ($test->status == Test::STATUS_COMPLETED);
  26. });
  27. $completed_test_count = count($completed_tests);
  28. ?>
  29. <tr>
  30. <td class="text-right pr-3 align-middle">
  31. <?=$project->id?>
  32. </td>
  33. <td class="align-middle">
  34. <small><strong><?=htmlspecialchars($template->name)?></strong></small><br />
  35. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  36. <?php
  37. if($time_of_day_icon) {
  38. ?>
  39. <i class="fal fa-<?=$time_of_day_icon?>" data-toggle="tooltip" data-title="<?=$time_of_day_text?> Tests"></i>
  40. <?php
  41. }
  42. if($project->dts_finished) {
  43. ?>
  44. <i class="fa fa-fw fa-check text-success" title="Finished" data-toggle="tooltip"></i>
  45. <?php
  46. }
  47. ?>
  48. </td>
  49. <td class="align-middle">
  50. <small><strong>Completed</strong></small><br />
  51. <?=$completed_test_count?> / <?=$project->test_count?>
  52. </td>
  53. <td class="align-middle">
  54. <small><strong><?=$year?></strong></small><br />
  55. <?=$date_start?> -
  56. <?=$date_deadline?>
  57. </td>
  58. <td class="align-middle">
  59. <?=$report_month?>
  60. </td>
  61. <td class="text-right align-middle">
  62. <a class="btn btn-sm btn-outline-primary" href="/account/projects/<?=$project->id?>/edit">Edit</a>
  63. </td>
  64. </tr>
  65. <?php
  66. }
  67. ?>
  68. </tbody>
  69. </table>
  70. <?php
  71. if(empty($projects)) {
  72. ?>
  73. <div class="alert alert-info">
  74. No projects to display.
  75. </div>
  76. <?php
  77. }
  78. ?>