test_list.php 8.5 KB

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