test_list.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. $filters_collapse = $filter_count ? "collapse show" : "collapse";
  3. ?>
  4. <div class="container mt-3 py-4">
  5. <div class="row">
  6. <div class="col">
  7. <h2>Tests</h2>
  8. </div>
  9. <div class="col-auto">
  10. <a class="btn btn-outline-primary" href="#filters" data-toggle="collapse">
  11. Toggle Filters <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
  12. </a>
  13. </div>
  14. </div>
  15. <div class="<?=$filters_collapse?>" id="filters">
  16. <form method="get">
  17. <div class="card mb-3">
  18. <div class="card-header">
  19. Filters
  20. </div>
  21. <div class="card-body">
  22. <div class="row">
  23. <div class="col-3">
  24. <div class="form-group">
  25. <label for="status">Status</label>
  26. <select class="form-control" name="status" id="status">
  27. <option value="">Any</option>
  28. <?php
  29. foreach(Test::STATUSES as $value => $display) {
  30. $selected = ($value === $status) ? "selected" : "";
  31. ?>
  32. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  33. <?php
  34. }
  35. ?>
  36. </select>
  37. </div>
  38. </div>
  39. <div class="col-3">
  40. <div class="form-group">
  41. <label for="project-id">Project</label>
  42. <select class="form-control" name="project_id" id="project-id">
  43. <option value="">Select project</option>
  44. <?php
  45. foreach($projects as $project) {
  46. $selected = ($project->id == $project_id) ? "selected" : "";
  47. ?>
  48. <option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
  49. <?php
  50. }
  51. ?>
  52. </select>
  53. </div>
  54. </div>
  55. <div class="col-3">
  56. <div class="form-group">
  57. <label for="location-id">Location ID</label>
  58. <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
  59. </div>
  60. </div>
  61. <div class="col-3">
  62. <div class="form-group">
  63. <label for="test-id">Test ID</label>
  64. <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
  65. </div>
  66. </div>
  67. </div>
  68. <button class="btn btn-primary" type="submit">Filter</button>
  69. <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
  70. </div>
  71. </div>
  72. </form>
  73. </div>
  74. <?php
  75. if(empty($tests)) {
  76. ?>
  77. <div class="alert alert-info">
  78. There are no tests to display.
  79. </div>
  80. <?php
  81. }
  82. else {
  83. ?>
  84. <div class="alert alert-info">
  85. Showing <?=number_format(count($tests))?> test(s).
  86. </div>
  87. <div class="table-responsive">
  88. <table class="table table-hover">
  89. <thead>
  90. <th>ID</th>
  91. <th>Location</th>
  92. <th>Project</th>
  93. <th>Tester</th>
  94. <th>Due Date</th>
  95. <th>Status</th>
  96. <th></th>
  97. </thead>
  98. <tbody>
  99. <?php
  100. foreach($tests as $test) {
  101. $location = $test->getLocation();
  102. $project = $test->getProject();
  103. $tester = $test->getTester();
  104. $unix_start = strtotime($test->dts_start . " UTC");
  105. $unix_end = strtotime($test->dts_end . " UTC");
  106. ?>
  107. <tr>
  108. <td class="text-right align-middle">
  109. <?=$test->id?>
  110. </td>
  111. <td class="align-middle">
  112. <a href="/account/locations/<?=$location->id?>"><?=htmlspecialchars($location->name)?></a><br />
  113. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
  114. </td>
  115. <td class="align-middle">
  116. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  117. </td>
  118. <td class="align-middle">
  119. <?php
  120. if($tester) {
  121. ?>
  122. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  123. <?php
  124. }
  125. else {
  126. ?>
  127. <small class="text-muted">N/A</small>
  128. <?php
  129. }
  130. ?>
  131. </td>
  132. <td class="text-center align-middle">
  133. <?php
  134. if(is_null($test->dts_due)) {
  135. ?>
  136. <small class="text-muted">N/A</small>
  137. <?php
  138. }
  139. else {
  140. ?>
  141. <?=explode(" ", $test->dts_due)[0]?>
  142. <?php
  143. }
  144. ?>
  145. </td>
  146. <td class="text-center align-middle">
  147. <span class="badge badge-lg badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  148. </td>
  149. <td class="text-right align-middle">
  150. <a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>
  151. </td>
  152. </tr>
  153. <?php
  154. }
  155. ?>
  156. </tbody>
  157. </table>
  158. </div>
  159. <?php
  160. }
  161. ?>
  162. </div>