test_list.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. $filters_collapse = $filter_count ? "collapse show" : "collapse";
  3. $query = $_GET;
  4. unset($query["path"]);
  5. $query["sort"] = "SORT";
  6. ?>
  7. <div class="container mt-3 py-4">
  8. <div class="row">
  9. <div class="col">
  10. <h2>
  11. Tests
  12. </h2>
  13. </div>
  14. <div class="col-auto">
  15. <a class="btn btn-outline-primary" href="#filters" data-toggle="collapse">
  16. Toggle Filters <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
  17. </a>
  18. </div>
  19. <div class="col-auto pl-0">
  20. <div class="input-group">
  21. <div class="input-group-prepend">
  22. <span class="input-group-text">
  23. Sort
  24. </span>
  25. </div>
  26. <select class="form-control" id="sort-dropdown" data-url-template="/account/tests?<?=htmlspecialchars(http_build_query($query))?>">
  27. <?php
  28. foreach($sorts as $value => $display) {
  29. $selected = ($value == $sort) ? "selected" : "";
  30. ?>
  31. <option value="<?=$value?>" <?=$selected?>><?=$display?></option>
  32. <?php
  33. }
  34. ?>
  35. </select>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="<?=$filters_collapse?>" id="filters">
  40. <form method="get">
  41. <div class="card mb-3">
  42. <div class="card-header">
  43. Filters
  44. </div>
  45. <div class="card-body">
  46. <div class="row">
  47. <div class="col-3">
  48. <div class="form-group">
  49. <label for="status">Status</label>
  50. <select class="form-control" name="status" id="status">
  51. <option value="">Any</option>
  52. <?php
  53. foreach(Test::STATUSES as $value => $display) {
  54. $selected = ($value === $status) ? "selected" : "";
  55. ?>
  56. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  57. <?php
  58. }
  59. ?>
  60. </select>
  61. </div>
  62. </div>
  63. <div class="col-3">
  64. <div class="form-group">
  65. <label for="project-id">Project</label>
  66. <select class="form-control" name="project_id" id="project-id">
  67. <option value="">Select project</option>
  68. <?php
  69. foreach($projects as $project) {
  70. $selected = ($project->id == $project_id) ? "selected" : "";
  71. ?>
  72. <option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
  73. <?php
  74. }
  75. ?>
  76. </select>
  77. </div>
  78. </div>
  79. <div class="col-3">
  80. <div class="form-group">
  81. <label for="location-id">Location ID</label>
  82. <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
  83. </div>
  84. </div>
  85. <div class="col-3">
  86. <div class="form-group">
  87. <label for="test-id">Test ID</label>
  88. <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
  89. </div>
  90. </div>
  91. </div>
  92. <button class="btn btn-primary" type="submit">Filter</button>
  93. <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
  94. </div>
  95. </div>
  96. <input type="hidden" name="sort" value="<?=$sort?>" />
  97. </form>
  98. </div>
  99. <?php
  100. if(empty($tests)) {
  101. ?>
  102. <div class="alert alert-info">
  103. There are no tests to display.
  104. </div>
  105. <?php
  106. }
  107. else {
  108. ?>
  109. <div class="row">
  110. <div class="col-md text-center text-md-left align-self-md-center mb-3">
  111. <?=htmlspecialchars($pagination_string)?>
  112. </div>
  113. <div class="col-md-auto d-flex justify-content-center">
  114. <?php
  115. View::include("pagination");
  116. ?>
  117. </div>
  118. </div>
  119. <div class="table-responsive mb-3">
  120. <table class="table table-sm table-hover" style="min-width: 1024px;">
  121. <thead>
  122. <th class="pr-3">ID</th>
  123. <th>Location</th>
  124. <th>Project</th>
  125. <th>Tester</th>
  126. <th>Due Date</th>
  127. <th>Status</th>
  128. <th>Result</th>
  129. <th></th>
  130. </thead>
  131. <tbody>
  132. <?php
  133. foreach($tests as $test) {
  134. $location = $test->getLocation();
  135. $project = $test->getProject();
  136. $tester = $test->getTester();
  137. $unix_start = strtotime($test->dts_start . " UTC");
  138. $unix_end = strtotime($test->dts_end . " UTC");
  139. ?>
  140. <tr>
  141. <td class="text-right pr-3">
  142. <?=$test->id?>
  143. </td>
  144. <td class="align-middle">
  145. <a href="/account/locations/<?=$location->id?>"><?=htmlspecialchars($location->name)?></a><br />
  146. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
  147. </td>
  148. <td class="align-middle">
  149. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  150. </td>
  151. <td class="align-middle">
  152. <?php
  153. if($tester) {
  154. ?>
  155. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  156. <?php
  157. }
  158. else {
  159. ?>
  160. <small class="text-muted">N/A</small>
  161. <?php
  162. }
  163. ?>
  164. </td>
  165. <td class="text-center align-middle">
  166. <?php
  167. if(is_null($test->dts_due)) {
  168. ?>
  169. <small class="text-muted">N/A</small>
  170. <?php
  171. }
  172. else {
  173. ?>
  174. <?=explode(" ", $test->dts_due)[0]?>
  175. <?php
  176. }
  177. ?>
  178. </td>
  179. <td class="text-center align-middle">
  180. <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  181. </td>
  182. <td class="text-center align-middle text-<?=$test->getPassClass()?>">
  183. <div data-toggle="tooltip" title="<?=$test->getPassText()?>">
  184. <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
  185. </div>
  186. </td>
  187. <td class="text-right align-middle">
  188. <a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>
  189. </td>
  190. </tr>
  191. <?php
  192. }
  193. ?>
  194. </tbody>
  195. </table>
  196. </div>
  197. <div class="row">
  198. <div class="col-md text-center text-md-left align-self-md-center mb-3">
  199. <?=htmlspecialchars($pagination_string)?>
  200. </div>
  201. <div class="col-md-auto d-flex justify-content-center">
  202. <?php
  203. View::include("pagination");
  204. ?>
  205. </div>
  206. </div>
  207. <?php
  208. }
  209. ?>
  210. </div>