project_list.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 = "N/A";
  21. if($project->dts_report) {
  22. $dt_report = new DateTime($project->dts_report . " UTC");
  23. $report_month = $dt_report->format("M Y");
  24. }
  25. $time_of_day_icon = $project->time_of_day != "A" ? $project->getTimeOfDayIcon() : null;
  26. $time_of_day_text = $project->getTimeOfDayText();
  27. $template = $project->getTemplate();
  28. $completed_tests = array_filter($tests, function($test) use ($project) {
  29. return ($project->id == $test->project_id) && ($test->status == Test::STATUS_COMPLETED);
  30. });
  31. $completed_test_count = count($completed_tests);
  32. ?>
  33. <tr>
  34. <td class="text-right pr-3 align-middle">
  35. <?=$project->id?>
  36. </td>
  37. <td class="align-middle">
  38. <small><strong><a href="<?=htmlspecialchars($template->getURL())?>"><?=htmlspecialchars($template->name)?></a></strong></small><br />
  39. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  40. <?php
  41. if($time_of_day_icon) {
  42. ?>
  43. <i class="fal fa-<?=$time_of_day_icon?>" data-toggle="tooltip" data-title="<?=$time_of_day_text?> Tests"></i>
  44. <?php
  45. }
  46. if($project->dts_finished) {
  47. ?>
  48. <i class="fa fa-fw fa-check text-success" title="Finished" data-toggle="tooltip"></i>
  49. <?php
  50. }
  51. ?>
  52. </td>
  53. <td class="align-middle">
  54. <small><strong>Completed</strong></small><br />
  55. <?=$completed_test_count?> / <?=$project->test_count?>
  56. </td>
  57. <td class="align-middle">
  58. <small><strong><?=$year?></strong></small><br />
  59. <?=$date_start?> -
  60. <?=$date_deadline?>
  61. </td>
  62. <td class="align-middle">
  63. <?=$report_month?>
  64. </td>
  65. <td class="text-right align-middle">
  66. <a class="btn btn-sm btn-outline-primary" href="/account/projects/<?=$project->id?>/edit">Edit</a>
  67. </td>
  68. </tr>
  69. <?php
  70. }
  71. ?>
  72. </tbody>
  73. </table>
  74. <?php
  75. if(empty($projects)) {
  76. ?>
  77. <div class="alert alert-info">
  78. No projects to display.
  79. </div>
  80. <?php
  81. }
  82. ?>