test_list.php 8.6 KB

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