test_list.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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. $custom_filters = [
  12. "overdue_project" => "Overdue (Project Deadline)",
  13. "overdue_test" => "Overdue (Test Due Date)",
  14. ];
  15. ?>
  16. <div class="container mt-3 py-4">
  17. <div class="row">
  18. <div class="col-sm">
  19. <h2>
  20. Tests
  21. </h2>
  22. </div>
  23. <div class="col-sm-auto">
  24. <div class="row">
  25. <div class="col-auto">
  26. <a class="btn btn-outline-primary" href="#filters" data-toggle="collapse">
  27. Toggle Filters <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
  28. </a>
  29. </div>
  30. <div class="col">
  31. <div class="input-group">
  32. <div class="input-group-prepend">
  33. <span class="input-group-text">
  34. Sort
  35. </span>
  36. </div>
  37. <select class="form-control" id="sort-dropdown" data-url-template="/account/tests?<?=htmlspecialchars(http_build_query($query))?>">
  38. <?php
  39. foreach($sorts as $value => $display) {
  40. $selected = ($value == $sort) ? "selected" : "";
  41. ?>
  42. <option value="<?=$value?>" <?=$selected?>><?=$display?></option>
  43. <?php
  44. }
  45. ?>
  46. </select>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="row my-3">
  53. <div class="col mb-1">
  54. <a class="btn btn-block btn-primary" href="/account/tests">Show All</a>
  55. </div>
  56. <div class="col mb-1">
  57. <a class="btn btn-block btn-secondary" href="/account/tests?status=<?=Test::STATUS_UNASSIGNED?>">Unassigned</a>
  58. </div>
  59. <div class="col mb-1">
  60. <a class="btn btn-block btn-warning" href="/account/tests?status=<?=Test::STATUS_CONFIRMED?>">Confirmed</a>
  61. </div>
  62. <div class="col mb-1">
  63. <a class="btn btn-block btn-success" href="/account/tests?status=<?=Test::STATUS_PENDING_VERIFICATION?>">Pending Verification</a>
  64. </div>
  65. <div class="col mb-1">
  66. <a class="btn btn-block btn-danger" href="/account/tests?pass=0">Fails</a>
  67. </div>
  68. </div>
  69. <div class="<?=$filters_collapse?>" id="filters">
  70. <form method="get">
  71. <div class="card card-body bg-light text-dark mb-3">
  72. <h3>Filters</h3>
  73. <div class="row mb-1">
  74. <div class="col-lg-6">
  75. <div class="row mb-1">
  76. <label class="col-form-label col-sm-4" for="status">Status</label>
  77. <div class="col-sm">
  78. <select class="form-control" name="status" id="status">
  79. <option value="">Any not cancelled</option>
  80. <?php
  81. foreach(Test::STATUSES as $value => $display) {
  82. $selected = ($value === $status) ? "selected" : "";
  83. ?>
  84. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  85. <?php
  86. }
  87. ?>
  88. </select>
  89. </div>
  90. </div>
  91. <div class="row mb-1">
  92. <label class="col-form-label col-sm-4" for="customer-id">Customer</label>
  93. <div class="col-sm">
  94. <select class="form-control" name="customer_id" id="customer-id">
  95. <option value="">Select customer</option>
  96. <?php
  97. foreach($customers as $customer) {
  98. $selected = ($customer->id == $customer_id) ? "selected" : "";
  99. ?>
  100. <option value="<?=$customer->id?>" <?=$selected?>><?=htmlspecialchars($customer->name)?></option>
  101. <?php
  102. }
  103. ?>
  104. </select>
  105. </div>
  106. </div>
  107. <div class="row mb-1">
  108. <label class="col-form-label col-sm-4" for="project-id">Project</label>
  109. <div class="col-sm">
  110. <select class="form-control" name="project_id" id="project-id">
  111. <option value="">Select project</option>
  112. <?php
  113. foreach($projects as $project) {
  114. $selected = ($project->id == $project_id) ? "selected" : "";
  115. ?>
  116. <option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
  117. <?php
  118. }
  119. ?>
  120. </select>
  121. </div>
  122. </div>
  123. <div class="row mb-1">
  124. <label class="col-sm-4 col-form-label" for="pass">Result</label>
  125. <div class="col-sm">
  126. <select class="form-control" name="pass" id="pass">
  127. <?php
  128. foreach($results as $value => $display) {
  129. $selected = (strval($value) === strval($pass)) ? "selected" : "";
  130. ?>
  131. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  132. <?php
  133. }
  134. ?>
  135. </select>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="col-lg">
  140. <div class="row mb-1">
  141. <label class="col-sm-4 col-form-label" for="test-id">Test ID</label>
  142. <div class="col-sm">
  143. <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
  144. </div>
  145. </div>
  146. <div class="row mb-1">
  147. <label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
  148. <div class="col-sm">
  149. <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
  150. </div>
  151. </div>
  152. <div class="row mb-1">
  153. <label class="col-sm-4 col-form-label" for="location-internal-id">Internal ID</label>
  154. <div class="col-sm">
  155. <input class="form-control" type="text" name="location_internal_id" id="location-internal-id" placeholder="Enter location internal ID" value="<?=$location_internal_id?>" />
  156. </div>
  157. </div>
  158. <div class="row mb-1">
  159. <label class="col-sm-4 col-form-label" for="custom">Custom Filter</label>
  160. <div class="col-sm">
  161. <select class="form-control" name="custom" id="custom">
  162. <option value="">Select custom filter</option>
  163. <?php
  164. foreach($custom_filters as $value => $display) {
  165. $selected = (strval($value) === strval($custom)) ? "selected" : "";
  166. ?>
  167. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  168. <?php
  169. }
  170. ?>
  171. </select>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. <div class="row">
  177. <div class="col-lg">
  178. <div class="row">
  179. <div class="col-sm offset-sm-4">
  180. <button class="btn btn-primary" type="submit">Filter</button>
  181. <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
  182. </div>
  183. </div>
  184. </div>
  185. <div class="col-lg">
  186. </div>
  187. </div>
  188. </div>
  189. <input type="hidden" name="sort" value="<?=$sort?>" />
  190. </form>
  191. </div>
  192. <?php
  193. if(empty($tests)) {
  194. ?>
  195. <div class="alert alert-info">
  196. There are no tests to display.
  197. </div>
  198. <?php
  199. }
  200. else {
  201. ?>
  202. <div class="mb-3">
  203. <?php
  204. View::include("pagination", compact("pagination_object"));
  205. ?>
  206. </div>
  207. <form method="post">
  208. <div class="table-responsive mb-3">
  209. <table class="table table-sm table-hover" style="min-width: 1024px;">
  210. <thead>
  211. <th></th>
  212. <th>ID</th>
  213. <th>Location</th>
  214. <th>Project</th>
  215. <th>Tester</th>
  216. <th>Due Date</th>
  217. <th>Status</th>
  218. <th>Result</th>
  219. <th></th>
  220. </thead>
  221. <tbody>
  222. <?php
  223. foreach($tests as $test) {
  224. $location = $test->getLocation();
  225. $project = $test->getProject();
  226. $tester = $test->getTester();
  227. $unix_start = strtotime($test->dts_start . " UTC");
  228. $unix_end = strtotime($test->dts_end . " UTC");
  229. ?>
  230. <tr>
  231. <td>
  232. <input type="checkbox" name="test_ids[]" value="<?=$test->id?>" />
  233. </td>
  234. <td>
  235. <?=$test->id?>
  236. </td>
  237. <td class="align-middle">
  238. <a href="/account/locations/<?=$location->id?>">
  239. <?=htmlspecialchars($location->name)?>
  240. <?php
  241. if($location->internal_id) {
  242. ?>
  243. <small>(Internal ID: <?=htmlspecialchars($location->internal_id)?>)</small>
  244. <?php
  245. }
  246. ?>
  247. </a><br />
  248. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
  249. </td>
  250. <td class="align-middle">
  251. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a><br />
  252. <small><strong>Deadline:</strong> <?=date("d/m/Y", strtotime($project->dts_deadline . " UTC"))?><small>
  253. </td>
  254. <td class="align-middle">
  255. <?php
  256. if($tester) {
  257. ?>
  258. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  259. <?php
  260. }
  261. else {
  262. ?>
  263. <small class="text-muted">N/A</small>
  264. <?php
  265. }
  266. ?>
  267. </td>
  268. <td class="text-center align-middle">
  269. <?php
  270. if(is_null($test->dts_due)) {
  271. ?>
  272. <small class="text-muted">N/A</small>
  273. <?php
  274. }
  275. else {
  276. ?>
  277. <?=explode(" ", $test->dts_due)[0]?>
  278. <?php
  279. }
  280. ?>
  281. </td>
  282. <td class="text-center align-middle">
  283. <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  284. </td>
  285. <td class="text-center align-middle text-<?=$test->getPassClass()?>">
  286. <div data-toggle="tooltip" title="<?=$test->getPassText()?>">
  287. <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
  288. </div>
  289. </td>
  290. <td class="text-right align-middle">
  291. <a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>
  292. </td>
  293. </tr>
  294. <?php
  295. }
  296. ?>
  297. </tbody>
  298. </table>
  299. </div>
  300. <div class="row">
  301. <div class="col-md-6 offset-md-6">
  302. <div class="input-group">
  303. <div class="input-group-prepend">
  304. <span class="input-group-text">
  305. Batch Action
  306. </span>
  307. </div>
  308. <select class="form-control" name="batch_action" required>
  309. <option value="">Select Action</option>
  310. <option value="unassign">Unassign</option>
  311. </select>
  312. <div class="input-group-append">
  313. <button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
  314. Submit
  315. </button>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. </form>
  321. <div class="mt-3">
  322. <?php
  323. View::include("pagination", compact("pagination_object"));
  324. ?>
  325. </div>
  326. <?php
  327. }
  328. ?>
  329. </div>