1
0

project_list.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 class="text-center align-middle">
  6. <input id="projects-table-select-all" type="checkbox" />
  7. </th>
  8. <th class="text-right pr-3">ID</th>
  9. <th>Name</th>
  10. <th>Tests</th>
  11. <th>Period</th>
  12. <th>Report Month</th>
  13. <th>Actions</th>
  14. </tr>
  15. </thead>
  16. <tbody class="table-pointer">
  17. <?php
  18. $project_ids = array_column($projects, "id");
  19. $tests = Test::query(["project_id" => $project_ids]);
  20. foreach($projects as $project) {
  21. $year = date("Y", strtotime($project->dts_start));
  22. $date_start = date("M jS", strtotime(explode(" ", $project->dts_start)[0]));
  23. $date_deadline = date("M jS", strtotime(explode(" ", $project->dts_deadline)[0]));
  24. $report_month = $project->getDisplayReportMonth();
  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-center align-middle">
  35. <input type="checkbox" name="ids[]" value="<?=$project->id?>" />
  36. </td>
  37. <td class="text-right pr-3 align-middle">
  38. <?=$project->id?>
  39. </td>
  40. <td class="align-middle">
  41. <small><strong><?=htmlspecialchars($template->name)?></strong></small><br />
  42. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  43. <?php
  44. if($time_of_day_icon) {
  45. ?>
  46. <i class="fal fa-<?=$time_of_day_icon?>" data-toggle="tooltip" data-title="<?=$time_of_day_text?> Tests"></i>
  47. <?php
  48. }
  49. if($project->dts_finished) {
  50. ?>
  51. <i class="fa fa-fw fa-check text-success" title="Finished" data-toggle="tooltip"></i>
  52. <?php
  53. }
  54. ?>
  55. </td>
  56. <td class="align-middle">
  57. <small><strong>Completed</strong></small><br />
  58. <?=$completed_test_count?> / <?=$project->test_count?>
  59. </td>
  60. <td class="align-middle">
  61. <small><strong><?=$year?></strong></small><br />
  62. <?=$date_start?> -
  63. <?=$date_deadline?>
  64. </td>
  65. <td class="align-middle">
  66. <?=$report_month?>
  67. </td>
  68. <td class="text-right align-middle">
  69. <a class="btn btn-sm btn-outline-primary" href="/account/projects/<?=$project->id?>/edit">Edit</a>
  70. </td>
  71. </tr>
  72. <?php
  73. }
  74. ?>
  75. </tbody>
  76. </table>
  77. <?php
  78. if(empty($projects)) {
  79. ?>
  80. <div class="alert alert-info">
  81. No projects to display.
  82. </div>
  83. <?php
  84. }
  85. ?>