test_list.php 8.1 KB

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