test_list.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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="status-tester-invoice">Tester Invoice Status</label>
  93. <div class="col-sm">
  94. <select class="form-control" name="status_tester_invoice" id="status-tester-invoice">
  95. <option value="">Any</option>
  96. <?php
  97. foreach(Test::STATUSES_TESTER_INVOICE as $value) {
  98. $display = Test::getStatusTesterInvoiceText($value);
  99. $selected = ($value === $status_tester_invoice) ? "selected" : "";
  100. ?>
  101. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  102. <?php
  103. }
  104. ?>
  105. </select>
  106. </div>
  107. </div>
  108. <div class="row mb-1">
  109. <label class="col-form-label col-sm-4" for="customer-id">Customer</label>
  110. <div class="col-sm">
  111. <select class="form-control" name="customer_id" id="customer-id">
  112. <option value="">Select customer</option>
  113. <?php
  114. foreach($customers as $customer) {
  115. $selected = ($customer->id == $customer_id) ? "selected" : "";
  116. ?>
  117. <option value="<?=$customer->id?>" <?=$selected?>><?=htmlspecialchars($customer->name)?></option>
  118. <?php
  119. }
  120. ?>
  121. </select>
  122. </div>
  123. </div>
  124. <div class="row mb-1">
  125. <label class="col-form-label col-sm-4" for="project-id">Project</label>
  126. <div class="col-sm">
  127. <select class="form-control" name="project_id" id="project-id">
  128. <option value="">Select project</option>
  129. <?php
  130. foreach($projects as $project) {
  131. $selected = ($project->id == $project_id) ? "selected" : "";
  132. ?>
  133. <option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
  134. <?php
  135. }
  136. ?>
  137. </select>
  138. </div>
  139. </div>
  140. <div class="row mb-1">
  141. <label class="col-sm-4 col-form-label" for="pass">Result</label>
  142. <div class="col-sm">
  143. <select class="form-control" name="pass" id="pass">
  144. <?php
  145. foreach($results as $value => $display) {
  146. $selected = (strval($value) === strval($pass)) ? "selected" : "";
  147. ?>
  148. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  149. <?php
  150. }
  151. ?>
  152. </select>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="col-lg">
  157. <div class="row mb-1">
  158. <label class="col-sm-4 col-form-label" for="test-id">Test ID</label>
  159. <div class="col-sm">
  160. <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
  161. </div>
  162. </div>
  163. <div class="row mb-1">
  164. <label class="col-sm-4 col-form-label" for="tester-id">Tester ID</label>
  165. <div class="col-sm">
  166. <input class="form-control" type="text" name="tester_id" id="tester-id" placeholder="Enter tester ID" value="<?=$tester_id?>" />
  167. </div>
  168. </div>
  169. <div class="row mb-1">
  170. <label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
  171. <div class="col-sm">
  172. <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
  173. </div>
  174. </div>
  175. <div class="row mb-1">
  176. <label class="col-sm-4 col-form-label" for="location-internal-id">Internal ID</label>
  177. <div class="col-sm">
  178. <input class="form-control" type="text" name="location_internal_id" id="location-internal-id" placeholder="Enter location internal ID" value="<?=$location_internal_id?>" />
  179. </div>
  180. </div>
  181. <div class="row mb-1">
  182. <label class="col-sm-4 col-form-label" for="custom">Custom Filter</label>
  183. <div class="col-sm">
  184. <select class="form-control" name="custom" id="custom">
  185. <option value="">Select custom filter</option>
  186. <?php
  187. foreach($custom_filters as $value => $display) {
  188. $selected = (strval($value) === strval($custom)) ? "selected" : "";
  189. ?>
  190. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  191. <?php
  192. }
  193. ?>
  194. </select>
  195. </div>
  196. </div>
  197. </div>
  198. </div>
  199. <div class="row">
  200. <div class="col-lg">
  201. <div class="row">
  202. <div class="col-sm offset-sm-4">
  203. <button class="btn btn-primary" type="submit">Filter</button>
  204. <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
  205. </div>
  206. </div>
  207. </div>
  208. <div class="col-lg">
  209. </div>
  210. </div>
  211. </div>
  212. <input type="hidden" name="sort" value="<?=$sort?>" />
  213. </form>
  214. </div>
  215. <?php
  216. if(empty($tests)) {
  217. ?>
  218. <div class="alert alert-info">
  219. There are no tests to display.
  220. </div>
  221. <?php
  222. }
  223. else {
  224. ?>
  225. <div class="mb-3">
  226. <?php
  227. View::include("pagination", compact("pagination_object"));
  228. ?>
  229. </div>
  230. <form method="post">
  231. <div class="table-responsive mb-3">
  232. <table class="table table-sm table-hover" style="min-width: 1024px;">
  233. <thead>
  234. <th></th>
  235. <th>ID</th>
  236. <th>Location</th>
  237. <th>Project</th>
  238. <th>Tester</th>
  239. <th>Due Date</th>
  240. <th>Status</th>
  241. <th>Result</th>
  242. <th></th>
  243. </thead>
  244. <tbody>
  245. <?php
  246. foreach($tests as $test) {
  247. $location = $test->getLocation();
  248. $project = $test->getProject();
  249. $tester = $test->getTester();
  250. $unix_start = strtotime($test->dts_start . " UTC");
  251. $unix_end = strtotime($test->dts_end . " UTC");
  252. ?>
  253. <tr>
  254. <td>
  255. <input type="checkbox" name="test_ids[]" value="<?=$test->id?>" />
  256. </td>
  257. <td>
  258. <?=$test->id?>
  259. </td>
  260. <td class="align-middle">
  261. <a href="/account/locations/<?=$location->id?>">
  262. <?=htmlspecialchars($location->name)?>
  263. <?php
  264. if($location->internal_id) {
  265. ?>
  266. <small>(Internal ID: <?=htmlspecialchars($location->internal_id)?>)</small>
  267. <?php
  268. }
  269. ?>
  270. </a><br />
  271. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
  272. </td>
  273. <td class="align-middle">
  274. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a><br />
  275. <small><strong>Deadline:</strong> <?=date("d/m/Y", strtotime($project->dts_deadline . " UTC"))?><small>
  276. </td>
  277. <td class="align-middle">
  278. <?php
  279. if($tester) {
  280. ?>
  281. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  282. <?php
  283. if($test->status_tester_invoice > 0) {
  284. $time = Util::getUnixTimeFromUTC($test->dts_tester_invoice_generated);
  285. $dts = Util::getDisplayDateTime($time);
  286. ?>
  287. <br />
  288. <span class="badge badge-<?=Test::getStatusTesterInvoiceClass($test->status_tester_invoice)?>" title="Generated on <?=$dts?>"><?=$test->getStatusTesterInvoiceText($test->status_tester_invoice)?></span>
  289. <?php
  290. }
  291. }
  292. else {
  293. ?>
  294. <small class="text-muted">N/A</small>
  295. <?php
  296. }
  297. ?>
  298. </td>
  299. <td class="text-center align-middle">
  300. <?php
  301. if(is_null($test->dts_due)) {
  302. ?>
  303. <small class="text-muted">N/A</small>
  304. <?php
  305. }
  306. else {
  307. ?>
  308. <?=explode(" ", $test->dts_due)[0]?>
  309. <?php
  310. }
  311. ?>
  312. </td>
  313. <td class="text-center align-middle">
  314. <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  315. </td>
  316. <td class="text-center align-middle text-<?=$test->getPassClass()?>">
  317. <div title="<?=$test->getPassText()?>">
  318. <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
  319. </div>
  320. </td>
  321. <td class="text-right align-middle">
  322. <div class="dropdown">
  323. <button class="btn btn-secondary dropdown-toggle" type="button" id="test-dropdown-<?=$test->id?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  324. Actions
  325. </button>
  326. <div class="dropdown-menu" aria-labelledby="test-dropdown-<?=$test->id?>">
  327. <a class="dropdown-item" href="/account/tests/<?=$test->id?>">View</a>
  328. <?php
  329. if($test->hasTesterInvoicePDF()) {
  330. ?>
  331. <a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice">Download Tester Invoice</a>
  332. <?php
  333. }
  334. ?>
  335. </div>
  336. </div>
  337. </td>
  338. </tr>
  339. <?php
  340. }
  341. ?>
  342. </tbody>
  343. </table>
  344. </div>
  345. <div class="row">
  346. <div class="col-md-6 offset-md-6">
  347. <div class="input-group">
  348. <div class="input-group-prepend">
  349. <span class="input-group-text">
  350. Batch Action
  351. </span>
  352. </div>
  353. <select class="form-control" name="batch_action" required>
  354. <option value="">Select Action</option>
  355. <option value="unassign">Unassign</option>
  356. <option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
  357. </select>
  358. <div class="input-group-append">
  359. <button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
  360. Submit
  361. </button>
  362. </div>
  363. </div>
  364. </div>
  365. </div>
  366. </form>
  367. <div class="mt-3">
  368. <?php
  369. View::include("pagination", compact("pagination_object"));
  370. ?>
  371. </div>
  372. <?php
  373. }
  374. ?>
  375. </div>