test_list.php 5.3 KB

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