test_list.php 13 KB

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