test_list.php 3.7 KB

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