project_list.php 2.5 KB

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