test_list.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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="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. <span class="input-group-text">
  35. Sort
  36. </span>
  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">
  233. <table class="table table-sm table-sm-text table-hover" style="min-width: 1024px;">
  234. <thead>
  235. <th></th>
  236. <th>ID</th>
  237. <th>Location</th>
  238. <th>Project</th>
  239. <th>Tester</th>
  240. <th>Due Date</th>
  241. <th>Status</th>
  242. <th>Result</th>
  243. <th></th>
  244. </thead>
  245. <tbody>
  246. <?php
  247. foreach($tests as $test) {
  248. $location = $test->getLocation();
  249. $project = $test->getProject();
  250. $tester = $test->getTester();
  251. $unix_start = strtotime($test->dts_start . " UTC");
  252. $unix_end = strtotime($test->dts_end . " UTC");
  253. ?>
  254. <tr>
  255. <td>
  256. <input type="checkbox" name="test_ids[]" value="<?=$test->id?>" />
  257. </td>
  258. <td>
  259. <?=$test->id?>
  260. </td>
  261. <td class="align-middle">
  262. <a href="/account/locations/<?=$location->id?>">
  263. <?=htmlspecialchars($location->name)?>
  264. <?php
  265. if($location->internal_id) {
  266. ?>
  267. (Internal ID: <?=htmlspecialchars($location->internal_id)?>)
  268. <?php
  269. }
  270. ?>
  271. </a><br />
  272. <?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?>
  273. </td>
  274. <td class="align-middle">
  275. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a><br />
  276. <strong>Deadline:</strong> <?=date("d/m/Y", strtotime($project->dts_deadline . " UTC"))?>
  277. </td>
  278. <td class="align-middle">
  279. <?php
  280. if($tester) {
  281. ?>
  282. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  283. <?php
  284. if($test->status_tester_invoice > 0) {
  285. $time = Util::getUnixTimeFromUTC($test->dts_tester_invoice_generated);
  286. $dts = Util::getDisplayDateTime($time);
  287. ?>
  288. <br />
  289. <span class="badge badge-<?=Test::getStatusTesterInvoiceClass($test->status_tester_invoice)?>" title="Generated on <?=$dts?>"><?=$test->getStatusTesterInvoiceText($test->status_tester_invoice)?></span>
  290. <?php
  291. }
  292. }
  293. else {
  294. ?>
  295. <small class="text-muted">N/A</small>
  296. <?php
  297. }
  298. ?>
  299. </td>
  300. <td class="text-center align-middle">
  301. <?php
  302. if(is_null($test->dts_due)) {
  303. ?>
  304. <small class="text-muted">N/A</small>
  305. <?php
  306. }
  307. else {
  308. ?>
  309. <?=explode(" ", $test->dts_due)[0]?>
  310. <?php
  311. }
  312. ?>
  313. </td>
  314. <td class="text-center align-middle">
  315. <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  316. </td>
  317. <td class="text-center align-middle text-<?=$test->getPassClass()?>">
  318. <div title="<?=$test->getPassText()?>">
  319. <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
  320. </div>
  321. </td>
  322. <td class="text-right align-middle">
  323. <div class="dropdown">
  324. <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">
  325. Actions
  326. </button>
  327. <div class="dropdown-menu" aria-labelledby="test-dropdown-<?=$test->id?>">
  328. <a class="dropdown-item" href="/account/tests/<?=$test->id?>">View</a>
  329. <?php
  330. if($test->hasTesterInvoicePDF()) {
  331. ?>
  332. <a class="dropdown-item" href="/account/tests/<?=$test->id?>/invoice">Download Tester Invoice</a>
  333. <?php
  334. }
  335. ?>
  336. </div>
  337. </div>
  338. </td>
  339. </tr>
  340. <?php
  341. }
  342. ?>
  343. </tbody>
  344. </table>
  345. </div>
  346. <div class="row">
  347. <div class="col-md-6 offset-md-6">
  348. <div class="input-group">
  349. <div class="input-group-prepend">
  350. <span class="input-group-text">
  351. Batch Action
  352. </span>
  353. </div>
  354. <select class="form-control" name="batch_action" required>
  355. <option value="">Select Action</option>
  356. <option value="unassign">Unassign</option>
  357. <option value="mark_tester_invoice_paid">Mark Tester Invoice as Paid</option>
  358. </select>
  359. <div class="input-group-append">
  360. <button type="submit" class="btn btn-primary" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>">
  361. Submit
  362. </button>
  363. </div>
  364. </div>
  365. </div>
  366. </div>
  367. </form>
  368. <div class="mt-3">
  369. <?php
  370. View::include("pagination", compact("pagination_object"));
  371. ?>
  372. </div>
  373. <?php
  374. }
  375. ?>
  376. </div>
  377. </div>