project_list.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. ?>
  47. </td>
  48. <td class="align-middle">
  49. <small><strong>Completed</strong></small><br />
  50. <?=$completed_test_count?> / <?=$project->test_count?>
  51. </td>
  52. <td class="align-middle">
  53. <small><strong><?=$year?></strong></small><br />
  54. <?=$date_start?> -
  55. <?=$date_deadline?>
  56. </td>
  57. <td class="align-middle">
  58. <?=$report_month?>
  59. </td>
  60. <td class="text-right align-middle">
  61. <a class="btn btn-sm btn-outline-primary" href="/account/projects/<?=$project->id?>/edit">Edit</a>
  62. </td>
  63. </tr>
  64. <?php
  65. }
  66. ?>
  67. </tbody>
  68. </table>
  69. <?php
  70. if(empty($projects)) {
  71. ?>
  72. <div class="alert alert-info">
  73. No projects to display.
  74. </div>
  75. <?php
  76. }
  77. ?>