test_list.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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-xl-6 col-lg-8 offset-xl-3 offset-lg-2">
  48. <div class="row mb-1">
  49. <label class="col-form-label col-sm-4" for="status">Status</label>
  50. <div class="col-sm">
  51. <select class="form-control" name="status" id="status">
  52. <option value="">Any</option>
  53. <?php
  54. foreach(Test::STATUSES as $value => $display) {
  55. $selected = ($value === $status) ? "selected" : "";
  56. ?>
  57. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  58. <?php
  59. }
  60. ?>
  61. </select>
  62. </div>
  63. </div>
  64. <div class="row mb-1">
  65. <label class="col-form-label col-sm-4" for="project-id">Project</label>
  66. <div class="col-sm">
  67. <select class="form-control" name="project_id" id="project-id">
  68. <option value="">Select project</option>
  69. <?php
  70. foreach($projects as $project) {
  71. $selected = ($project->id == $project_id) ? "selected" : "";
  72. ?>
  73. <option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
  74. <?php
  75. }
  76. ?>
  77. </select>
  78. </div>
  79. </div>
  80. <div class="row mb-1">
  81. <label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
  82. <div class="col-sm">
  83. <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
  84. </div>
  85. </div>
  86. <div class="row mb-1">
  87. <label class="col-sm-4 col-form-label" for="location-internal-id">Location Internal ID</label>
  88. <div class="col-sm">
  89. <input class="form-control" type="text" name="location_internal_id" id="location-internal-id" placeholder="Enter location internal ID" value="<?=$location_internal_id?>" />
  90. </div>
  91. </div>
  92. <div class="row mb-1">
  93. <label class="col-sm-4 col-form-label" for="test-id">Test ID</label>
  94. <div class="col-sm">
  95. <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
  96. </div>
  97. </div>
  98. <br />
  99. <button class="btn btn-primary" type="submit">Filter</button>
  100. <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <input type="hidden" name="sort" value="<?=$sort?>" />
  106. </form>
  107. </div>
  108. <?php
  109. if(empty($tests)) {
  110. ?>
  111. <div class="alert alert-info">
  112. There are no tests to display.
  113. </div>
  114. <?php
  115. }
  116. else {
  117. ?>
  118. <div class="row">
  119. <div class="col-md text-center text-md-left align-self-md-center mb-3">
  120. <?=htmlspecialchars($pagination_string)?>
  121. </div>
  122. <div class="col-md-auto d-flex justify-content-center">
  123. <?php
  124. View::include("pagination");
  125. ?>
  126. </div>
  127. </div>
  128. <div class="table-responsive mb-3">
  129. <table class="table table-sm table-hover" style="min-width: 1024px;">
  130. <thead>
  131. <th>ID</th>
  132. <th>Location</th>
  133. <th>Project</th>
  134. <th>Tester</th>
  135. <th>Due Date</th>
  136. <th>Status</th>
  137. <th>Result</th>
  138. <th></th>
  139. </thead>
  140. <tbody>
  141. <?php
  142. foreach($tests as $test) {
  143. $location = $test->getLocation();
  144. $project = $test->getProject();
  145. $tester = $test->getTester();
  146. $unix_start = strtotime($test->dts_start . " UTC");
  147. $unix_end = strtotime($test->dts_end . " UTC");
  148. ?>
  149. <tr>
  150. <td>
  151. <?=$test->id?>
  152. </td>
  153. <td class="align-middle">
  154. <a href="/account/locations/<?=$location->id?>">
  155. <?=htmlspecialchars($location->name)?>
  156. <?php
  157. if($location->internal_id) {
  158. ?>
  159. <small>(Internal ID: <?=htmlspecialchars($location->internal_id)?>)</small>
  160. <?php
  161. }
  162. ?>
  163. </a><br />
  164. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
  165. </td>
  166. <td class="align-middle">
  167. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  168. </td>
  169. <td class="align-middle">
  170. <?php
  171. if($tester) {
  172. ?>
  173. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  174. <?php
  175. }
  176. else {
  177. ?>
  178. <small class="text-muted">N/A</small>
  179. <?php
  180. }
  181. ?>
  182. </td>
  183. <td class="text-center align-middle">
  184. <?php
  185. if(is_null($test->dts_due)) {
  186. ?>
  187. <small class="text-muted">N/A</small>
  188. <?php
  189. }
  190. else {
  191. ?>
  192. <?=explode(" ", $test->dts_due)[0]?>
  193. <?php
  194. }
  195. ?>
  196. </td>
  197. <td class="text-center align-middle">
  198. <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  199. </td>
  200. <td class="text-center align-middle text-<?=$test->getPassClass()?>">
  201. <div data-toggle="tooltip" title="<?=$test->getPassText()?>">
  202. <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
  203. </div>
  204. </td>
  205. <td class="text-right align-middle">
  206. <a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>
  207. </td>
  208. </tr>
  209. <?php
  210. }
  211. ?>
  212. </tbody>
  213. </table>
  214. </div>
  215. <div class="row">
  216. <div class="col-md text-center text-md-left align-self-md-center mb-3">
  217. <?=htmlspecialchars($pagination_string)?>
  218. </div>
  219. <div class="col-md-auto d-flex justify-content-center">
  220. <?php
  221. View::include("pagination");
  222. ?>
  223. </div>
  224. </div>
  225. <?php
  226. }
  227. ?>
  228. </div>