test_list.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var int $filter_count
  4. * @var array $sorts
  5. * @var string $sort
  6. * @var int $status
  7. * @var int $status_tester_invoice
  8. * @var Customer[] $customers
  9. * @var int $customer_id
  10. * @var Project[] $projects
  11. * @var int $project_id
  12. * @var bool $pass
  13. * @var int $test_id
  14. * @var int $tester_id
  15. * @var int $location_id
  16. * @var int $location_internal_id
  17. * @var int $custom
  18. */
  19. $filters_collapse = $filter_count ? "collapse show" : "collapse";
  20. $query = $_GET;
  21. unset($query["path"]);
  22. $query["sort"] = "SORT";
  23. $results = [
  24. "" => "Any",
  25. "1" => "Pass",
  26. "0" => "Fail",
  27. ];
  28. $custom_filters = [
  29. "overdue_project" => "Overdue (Project Deadline)",
  30. "overdue_test" => "Overdue (Test Due Date)",
  31. ];
  32. ?>
  33. <div class="mt-3 py-4">
  34. <div class="container-fluid">
  35. <div class="row">
  36. <div class="col-sm">
  37. <h2>
  38. Tests
  39. </h2>
  40. </div>
  41. <div class="col-sm-auto">
  42. <div class="row">
  43. <div class="col-auto">
  44. <a class="btn btn-outline-primary" href="#filters" data-toggle="collapse">
  45. Toggle Filters <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
  46. </a>
  47. </div>
  48. <div class="col">
  49. <div class="input-group">
  50. <div class="input-group-prepend">
  51. <label for="sort-dropdown" class="input-group-text">
  52. Sort
  53. </label>
  54. </div>
  55. <select class="form-control" id="sort-dropdown" data-url-template="/account/tests?<?=htmlspecialchars(http_build_query($query))?>">
  56. <?php
  57. foreach($sorts as $value => $display) {
  58. $selected = ($value == $sort) ? "selected" : "";
  59. ?>
  60. <option value="<?=$value?>" <?=$selected?>><?=$display?></option>
  61. <?php
  62. }
  63. ?>
  64. </select>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="row my-3">
  71. <div class="col mb-1">
  72. <a class="btn btn-block btn-primary" href="/account/tests">Show All</a>
  73. </div>
  74. <div class="col mb-1">
  75. <a class="btn btn-block btn-secondary" href="/account/tests?status=<?=Test::STATUS_UNASSIGNED?>">Unassigned</a>
  76. </div>
  77. <div class="col mb-1">
  78. <a class="btn btn-block btn-warning" href="/account/tests?status=<?=Test::STATUS_CONFIRMED?>">Confirmed</a>
  79. </div>
  80. <div class="col mb-1">
  81. <a class="btn btn-block btn-success" href="/account/tests?status=<?=Test::STATUS_PENDING_VERIFICATION?>">Pending Verification</a>
  82. </div>
  83. <div class="col mb-1">
  84. <a class="btn btn-block btn-danger" href="/account/tests?pass=0">Fails</a>
  85. </div>
  86. </div>
  87. <div class="<?=$filters_collapse?>" id="filters">
  88. <form method="get">
  89. <div class="card card-body bg-light text-dark mb-3">
  90. <h3>Filters</h3>
  91. <div class="row mb-1">
  92. <div class="col-lg-6">
  93. <div class="row mb-1">
  94. <label class="col-form-label col-sm-4" for="status">Status</label>
  95. <div class="col-sm">
  96. <select class="form-control" name="status" id="status">
  97. <option value="">Any not cancelled</option>
  98. <?php
  99. foreach(Test::STATUSES as $value => $display) {
  100. $selected = ($value === $status) ? "selected" : "";
  101. ?>
  102. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  103. <?php
  104. }
  105. ?>
  106. </select>
  107. </div>
  108. </div>
  109. <div class="row mb-1">
  110. <label class="col-form-label col-sm-4" for="status-tester-invoice">Tester Invoice Status</label>
  111. <div class="col-sm">
  112. <select class="form-control" name="status_tester_invoice" id="status-tester-invoice">
  113. <option value="">Any</option>
  114. <?php
  115. foreach(Test::STATUSES_TESTER_INVOICE as $value) {
  116. $display = Test::getStatusTesterInvoiceText($value);
  117. $selected = ($value === $status_tester_invoice) ? "selected" : "";
  118. ?>
  119. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  120. <?php
  121. }
  122. ?>
  123. </select>
  124. </div>
  125. </div>
  126. <div class="row mb-1">
  127. <label class="col-form-label col-sm-4" for="customer-id">Customer</label>
  128. <div class="col-sm">
  129. <select class="form-control" name="customer_id" id="customer-id">
  130. <option value="">Select customer</option>
  131. <?php
  132. foreach($customers as $customer) {
  133. $selected = ($customer->id == $customer_id) ? "selected" : "";
  134. ?>
  135. <option value="<?=$customer->id?>" <?=$selected?>><?=htmlspecialchars($customer->name)?></option>
  136. <?php
  137. }
  138. ?>
  139. </select>
  140. </div>
  141. </div>
  142. <div class="row mb-1">
  143. <label class="col-form-label col-sm-4" for="project-id">Project</label>
  144. <div class="col-sm">
  145. <select class="form-control" name="project_id" id="project-id">
  146. <option value="">Select project</option>
  147. <?php
  148. foreach($projects as $project) {
  149. $selected = ($project->id == $project_id) ? "selected" : "";
  150. ?>
  151. <option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
  152. <?php
  153. }
  154. ?>
  155. </select>
  156. </div>
  157. </div>
  158. <div class="row mb-1">
  159. <label class="col-sm-4 col-form-label" for="pass">Result</label>
  160. <div class="col-sm">
  161. <select class="form-control" name="pass" id="pass">
  162. <?php
  163. foreach($results as $value => $display) {
  164. $selected = (strval($value) === strval($pass)) ? "selected" : "";
  165. ?>
  166. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  167. <?php
  168. }
  169. ?>
  170. </select>
  171. </div>
  172. </div>
  173. </div>
  174. <div class="col-lg">
  175. <div class="row mb-1">
  176. <label class="col-sm-4 col-form-label" for="test-id">Test ID</label>
  177. <div class="col-sm">
  178. <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
  179. </div>
  180. </div>
  181. <div class="row mb-1">
  182. <label class="col-sm-4 col-form-label" for="tester-id">Tester ID</label>
  183. <div class="col-sm">
  184. <input class="form-control" type="text" name="tester_id" id="tester-id" placeholder="Enter tester ID" value="<?=$tester_id?>" />
  185. </div>
  186. </div>
  187. <div class="row mb-1">
  188. <label class="col-sm-4 col-form-label" for="location-id">Location ID</label>
  189. <div class="col-sm">
  190. <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
  191. </div>
  192. </div>
  193. <div class="row mb-1">
  194. <label class="col-sm-4 col-form-label" for="location-internal-id">Internal ID</label>
  195. <div class="col-sm">
  196. <input class="form-control" type="text" name="location_internal_id" id="location-internal-id" placeholder="Enter location internal ID" value="<?=$location_internal_id?>" />
  197. </div>
  198. </div>
  199. <div class="row mb-1">
  200. <label class="col-sm-4 col-form-label" for="custom">Custom Filter</label>
  201. <div class="col-sm">
  202. <select class="form-control" name="custom" id="custom">
  203. <option value="">Select custom filter</option>
  204. <?php
  205. foreach($custom_filters as $value => $display) {
  206. $selected = (strval($value) === strval($custom)) ? "selected" : "";
  207. ?>
  208. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  209. <?php
  210. }
  211. ?>
  212. </select>
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. <div class="row">
  218. <div class="col-lg">
  219. <div class="row">
  220. <div class="col-sm offset-sm-4">
  221. <button class="btn btn-primary" type="submit">Filter</button>
  222. <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
  223. </div>
  224. </div>
  225. </div>
  226. <div class="col-lg">
  227. </div>
  228. </div>
  229. </div>
  230. <input type="hidden" name="sort" value="<?=$sort?>" />
  231. </form>
  232. </div>
  233. <?php
  234. if(empty($tests)) {
  235. ?>
  236. <div class="alert alert-info">
  237. There are no tests to display.
  238. </div>
  239. <?php
  240. }
  241. else {
  242. ?>
  243. <div class="mb-3">
  244. <?php
  245. View::include("pagination", compact("pagination_object"));
  246. ?>
  247. </div>
  248. <form method="post">
  249. <div class="table-responsive mb-3" style="min-height: 224px;">
  250. <table class="table table-sm table-sm-text table-hover" style="min-width: 1024px;">
  251. <thead>
  252. <tr>
  253. <th>
  254. <label for="tests-table-select-all" class="sr-only">
  255. <?=htmlspecialchars(__("Select All"))?>
  256. </label>
  257. <input type="checkbox" id="tests-table-select-all" />
  258. </th>
  259. <th>ID</th>
  260. <th>Location</th>
  261. <th>Project</th>
  262. <th>Tester</th>
  263. <th>Due Date</th>
  264. <th>Status</th>
  265. <th>Result</th>
  266. <th></th>
  267. </tr>
  268. </thead>
  269. <tbody>
  270. <?php
  271. foreach($tests as $test) {
  272. $location = $test->getLocation();
  273. $project = $test->getProject();
  274. $tester = $test->getTester();
  275. $unix_start = strtotime($test->dts_start . " UTC");
  276. $unix_end = strtotime($test->dts_end . " UTC");
  277. ?>
  278. <tr>
  279. <td>
  280. <label for="test-checkbox-<?=$test->id?>" class="sr-only">
  281. <?=htmlspecialchars(__("Select Test ID %d", $test->id))?>
  282. </label>
  283. <input type="checkbox" name="test_ids[]" id="test-checkbox-<?=$test->id?>" value="<?=$test->id?>" />
  284. </td>
  285. <td>
  286. <?=$test->id?>
  287. </td>
  288. <td class="align-middle">
  289. <a href="/account/locations/<?=$location->id?>">
  290. <?=htmlspecialchars($location->name)?>
  291. <?php
  292. if($location->internal_id) {
  293. ?>
  294. (Internal ID: <?=htmlspecialchars($location->internal_id)?>)
  295. <?php
  296. }
  297. ?>
  298. </a><br />
  299. <?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?>
  300. </td>
  301. <td class="align-middle">
  302. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a><br />
  303. <strong>Deadline:</strong> <?=date("d/m/Y", strtotime($project->dts_deadline . " UTC"))?>
  304. </td>
  305. <td class="align-middle">
  306. <?php
  307. if($tester) {
  308. ?>
  309. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  310. <?php
  311. if($test->status_tester_invoice > 0) {
  312. $time = Util::getUnixTimeFromUTC($test->dts_tester_invoice_generated);
  313. $dts = Util::getDisplayDateTime($time);
  314. ?>
  315. <br />
  316. <span class="badge badge-<?=Test::getStatusTesterInvoiceClass($test->status_tester_invoice)?>" title="Generated on <?=$dts?>"><?=$test->getStatusTesterInvoiceText($test->status_tester_invoice)?></span>
  317. <?php
  318. }
  319. }
  320. else {
  321. ?>
  322. <small class="text-muted">N/A</small>
  323. <?php
  324. }
  325. ?>
  326. </td>
  327. <td class="text-center align-middle">
  328. <?php
  329. if(is_null($test->dts_due)) {
  330. ?>
  331. <small class="text-muted">N/A</small>
  332. <?php
  333. }
  334. else {
  335. ?>
  336. <?=explode(" ", $test->dts_due)[0]?>
  337. <?php
  338. }
  339. ?>
  340. </td>
  341. <td class="text-center align-middle">
  342. <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  343. </td>
  344. <td class="text-center align-middle text-<?=$test->getPassClass()?>">
  345. <div title="<?=$test->getPassText()?>">
  346. <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
  347. </div>
  348. </td>
  349. <td class="text-right align-middle">
  350. <div class="dropdown">
  351. <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="test-dropdown-<?=$test->id?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  352. Actions
  353. </button>
  354. <div class="dropdown-menu" aria-labelledby="test-dropdown-<?=$test->id?>">
  355. <a class="dropdown-item" href="/account/tests/<?=$test->id?>">View</a>
  356. <?php
  357. if($test->hasTesterInvoicePDF()) {
  358. ?>
  359. <a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice">Download Tester Invoice</a>
  360. <?php
  361. }
  362. if($test->hasTravelCostsPhoto()) {
  363. ?>
  364. <a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/travel_costs">View Travel Costs Photo</a>
  365. <?php
  366. }
  367. ?>
  368. </div>
  369. </div>
  370. </td>
  371. </tr>
  372. <?php
  373. }
  374. ?>
  375. </tbody>
  376. </table>
  377. </div>
  378. <div class="row">
  379. <div class="col-md">
  380. </div>
  381. <div class="col-md-auto">
  382. <div class="input-group">
  383. <div class="input-group-prepend">
  384. <label class="input-group-text" for="batch-action">
  385. Batch Action
  386. </label>
  387. </div>
  388. <select class="form-control" name="batch_action" id="batch-action" required>
  389. <option value="">Select Action</option>
  390. <option value="unassign">Unassign</option>
  391. <option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
  392. <option value="reject_tester_invoice">Reject Tester Invoices</option>
  393. </select>
  394. <div class="input-group-append">
  395. <button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
  396. Submit
  397. </button>
  398. </div>
  399. </div>
  400. </div>
  401. </div>
  402. </form>
  403. <div class="mt-3">
  404. <?php
  405. View::include("pagination", compact("pagination_object"));
  406. ?>
  407. </div>
  408. <?php
  409. }
  410. ?>
  411. </div>
  412. </div>