test_list.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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 mb-3">
  73. <div class="col-lg-6">
  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="pass">Result</label>
  108. <div class="col-sm">
  109. <select class="form-control" name="pass" id="pass">
  110. <?php
  111. foreach($results as $value => $display) {
  112. $selected = (strval($value) === strval($pass)) ? "selected" : "";
  113. ?>
  114. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  115. <?php
  116. }
  117. ?>
  118. </select>
  119. </div>
  120. </div>
  121. </div>
  122. <div class="col-lg">
  123. <div class="row mb-1">
  124. <label class="col-sm-4 col-form-label" for="test-id">Test ID</label>
  125. <div class="col-sm">
  126. <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
  127. </div>
  128. </div>
  129. <div class="row mb-1">
  130. <label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
  131. <div class="col-sm">
  132. <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
  133. </div>
  134. </div>
  135. <div class="row mb-1">
  136. <label class="col-sm-4 col-form-label" for="location-internal-id">Internal ID</label>
  137. <div class="col-sm">
  138. <input class="form-control" type="text" name="location_internal_id" id="location-internal-id" placeholder="Enter location internal ID" value="<?=$location_internal_id?>" />
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. <button class="btn btn-primary" type="submit">Filter</button>
  144. <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
  145. </div>
  146. </div>
  147. <input type="hidden" name="sort" value="<?=$sort?>" />
  148. </form>
  149. </div>
  150. <?php
  151. if(empty($tests)) {
  152. ?>
  153. <div class="alert alert-info">
  154. There are no tests to display.
  155. </div>
  156. <?php
  157. }
  158. else {
  159. ?>
  160. <div class="row">
  161. <div class="col-md text-center text-md-left align-self-center mb-3">
  162. <?=htmlspecialchars($pagination_string)?>
  163. </div>
  164. <div class="col-md-auto mb-3">
  165. <?php
  166. View::include("pagination");
  167. ?>
  168. </div>
  169. </div>
  170. <div class="table-responsive mb-3">
  171. <table class="table table-sm table-hover" style="min-width: 1024px;">
  172. <thead>
  173. <th>ID</th>
  174. <th>Location</th>
  175. <th>Project</th>
  176. <th>Tester</th>
  177. <th>Due Date</th>
  178. <th>Status</th>
  179. <th>Result</th>
  180. <th></th>
  181. </thead>
  182. <tbody>
  183. <?php
  184. foreach($tests as $test) {
  185. $location = $test->getLocation();
  186. $project = $test->getProject();
  187. $tester = $test->getTester();
  188. $unix_start = strtotime($test->dts_start . " UTC");
  189. $unix_end = strtotime($test->dts_end . " UTC");
  190. ?>
  191. <tr>
  192. <td>
  193. <?=$test->id?>
  194. </td>
  195. <td class="align-middle">
  196. <a href="/account/locations/<?=$location->id?>">
  197. <?=htmlspecialchars($location->name)?>
  198. <?php
  199. if($location->internal_id) {
  200. ?>
  201. <small>(Internal ID: <?=htmlspecialchars($location->internal_id)?>)</small>
  202. <?php
  203. }
  204. ?>
  205. </a><br />
  206. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
  207. </td>
  208. <td class="align-middle">
  209. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  210. </td>
  211. <td class="align-middle">
  212. <?php
  213. if($tester) {
  214. ?>
  215. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  216. <?php
  217. }
  218. else {
  219. ?>
  220. <small class="text-muted">N/A</small>
  221. <?php
  222. }
  223. ?>
  224. </td>
  225. <td class="text-center align-middle">
  226. <?php
  227. if(is_null($test->dts_due)) {
  228. ?>
  229. <small class="text-muted">N/A</small>
  230. <?php
  231. }
  232. else {
  233. ?>
  234. <?=explode(" ", $test->dts_due)[0]?>
  235. <?php
  236. }
  237. ?>
  238. </td>
  239. <td class="text-center align-middle">
  240. <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  241. </td>
  242. <td class="text-center align-middle text-<?=$test->getPassClass()?>">
  243. <div data-toggle="tooltip" title="<?=$test->getPassText()?>">
  244. <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
  245. </div>
  246. </td>
  247. <td class="text-right align-middle">
  248. <a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>
  249. </td>
  250. </tr>
  251. <?php
  252. }
  253. ?>
  254. </tbody>
  255. </table>
  256. </div>
  257. <div class="row">
  258. <div class="col-md text-center mb-3 text-md-left align-self-center">
  259. <?=htmlspecialchars($pagination_string)?>
  260. </div>
  261. <div class="col-md-auto mb-3">
  262. <?php
  263. View::include("pagination");
  264. ?>
  265. </div>
  266. </div>
  267. <?php
  268. }
  269. ?>
  270. </div>