test_list.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. $filters_collapse = $filter_count ? "collapse show" : "collapse";
  3. ?>
  4. <div class="container mt-3 py-4">
  5. <div class="row">
  6. <div class="col">
  7. <h2>Tests</h2>
  8. </div>
  9. <div class="col-auto">
  10. <a class="btn btn-outline-primary" href="#filters" data-toggle="collapse">
  11. Toggle Filters <span class="badge badge-pill badge-danger"><?=$filter_count?></span>
  12. </a>
  13. </div>
  14. </div>
  15. <div class="<?=$filters_collapse?>" id="filters">
  16. <form method="get">
  17. <div class="card mb-3">
  18. <div class="card-header">
  19. Filters
  20. </div>
  21. <div class="card-body">
  22. <div class="row">
  23. <div class="col-3">
  24. <div class="form-group">
  25. <label for="status">Status</label>
  26. <select class="form-control" name="status" id="status">
  27. <option value="">Any</option>
  28. <?php
  29. foreach(Test::STATUSES as $value => $display) {
  30. $selected = ($value === $status) ? "selected" : "";
  31. ?>
  32. <option value="<?=$value?>" <?=$selected?>><?=htmlspecialchars($display)?></option>
  33. <?php
  34. }
  35. ?>
  36. </select>
  37. </div>
  38. </div>
  39. <div class="col-3">
  40. <div class="form-group">
  41. <label for="project-id">Project</label>
  42. <select class="form-control" name="project_id" id="project-id">
  43. <option value="">Select project</option>
  44. <?php
  45. foreach($projects as $project) {
  46. $selected = ($project->id == $project_id) ? "selected" : "";
  47. ?>
  48. <option value="<?=$project->id?>" <?=$selected?>><?=htmlspecialchars($project->name)?></option>
  49. <?php
  50. }
  51. ?>
  52. </select>
  53. </div>
  54. </div>
  55. <div class="col-3">
  56. <div class="form-group">
  57. <label for="location-id">Location ID</label>
  58. <input class="form-control" type="text" name="location_id" id="location-id" placeholder="Enter location ID" value="<?=$location_id?>" />
  59. </div>
  60. </div>
  61. <div class="col-3">
  62. <div class="form-group">
  63. <label for="test-id">Test ID</label>
  64. <input class="form-control" type="text" name="test_id" id="test-id" placeholder="Enter test ID" value="<?=$test_id?>" />
  65. </div>
  66. </div>
  67. </div>
  68. <button class="btn btn-primary" type="submit">Filter</button>
  69. <a class="btn btn-secondary" href="/account/tests">Clear Filters</a>
  70. </div>
  71. </div>
  72. </form>
  73. </div>
  74. <?php
  75. if(empty($tests)) {
  76. ?>
  77. <div class="alert alert-info">
  78. There are no tests to display.
  79. </div>
  80. <?php
  81. }
  82. else {
  83. ?>
  84. <div class="alert alert-info">
  85. Showing <?=number_format(count($tests))?> test(s).
  86. </div>
  87. <div class="table-responsive">
  88. <table class="table table-sm table-hover" style="min-width: 1024px;">
  89. <thead>
  90. <th>ID</th>
  91. <th>Location</th>
  92. <th>Project</th>
  93. <th>Tester</th>
  94. <th>Due Date</th>
  95. <th>Status</th>
  96. <th>Result</th>
  97. <th></th>
  98. </thead>
  99. <tbody>
  100. <?php
  101. foreach($tests as $test) {
  102. $location = $test->getLocation();
  103. $project = $test->getProject();
  104. $tester = $test->getTester();
  105. $unix_start = strtotime($test->dts_start . " UTC");
  106. $unix_end = strtotime($test->dts_end . " UTC");
  107. ?>
  108. <tr>
  109. <td class="text-right align-middle">
  110. <?=$test->id?>
  111. </td>
  112. <td class="align-middle">
  113. <a href="/account/locations/<?=$location->id?>"><?=htmlspecialchars($location->name)?></a><br />
  114. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city"]))?></small>
  115. </td>
  116. <td class="align-middle">
  117. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  118. </td>
  119. <td class="align-middle">
  120. <?php
  121. if($tester) {
  122. ?>
  123. <a href="/account/users/<?=$tester->id?>"><?=htmlspecialchars($tester->getDisplayName())?></a>
  124. <?php
  125. }
  126. else {
  127. ?>
  128. <small class="text-muted">N/A</small>
  129. <?php
  130. }
  131. ?>
  132. </td>
  133. <td class="text-center align-middle">
  134. <?php
  135. if(is_null($test->dts_due)) {
  136. ?>
  137. <small class="text-muted">N/A</small>
  138. <?php
  139. }
  140. else {
  141. ?>
  142. <?=explode(" ", $test->dts_due)[0]?>
  143. <?php
  144. }
  145. ?>
  146. </td>
  147. <td class="text-center align-middle">
  148. <span class="badge badge-<?=$test->getStatusClass()?>"><?=$test->getStatusText()?></span>
  149. </td>
  150. <td class="text-center align-middle text-<?=$test->getPassClass()?>">
  151. <div data-toggle="tooltip" title="<?=$test->getPassText()?>">
  152. <i class="fas fa-2x fa-fw fa-<?=$test->getPassIcon()?>"></i>
  153. </div>
  154. </td>
  155. <td class="text-right align-middle">
  156. <a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>">View</a>
  157. </td>
  158. </tr>
  159. <?php
  160. }
  161. ?>
  162. </tbody>
  163. </table>
  164. </div>
  165. <?php
  166. }
  167. ?>
  168. </div>