test_list_completed.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <div class="container mt-3 py-4">
  2. <h2>Completed Tests</h2>
  3. <?php
  4. if(empty($tests)) {
  5. ?>
  6. <div class="alert alert-info">
  7. You have not completed any tests yet.
  8. </div>
  9. <?php
  10. }
  11. else {
  12. ?>
  13. <div class="row">
  14. <div class="col-sm text-center text-sm-left align-self-center mb-3">
  15. <?=htmlspecialchars($pagination_object->rangeText)?>
  16. </div>
  17. <div class="col-sm-auto mb-3">
  18. <?php
  19. View::include("pagination");
  20. ?>
  21. </div>
  22. </div>
  23. <table class="table table-sm table-hover">
  24. <thead>
  25. <tr>
  26. <th class="text-right">ID</th>
  27. <th>Location</th>
  28. <th>Attire</th>
  29. <th>Selfie</th>
  30. <th>Date</th>
  31. <th>Time</th>
  32. <th>Duration</th>
  33. <th>Status</th>
  34. <th>Fee</th>
  35. </tr>
  36. </thead>
  37. <tbody>
  38. <?php
  39. $original_timezone = date_default_timezone_get();
  40. foreach($tests as $test) {
  41. $location = $test->getLocation();
  42. $project = $test->getProject();
  43. $attire = $date_start = $time_start = $duration = "N/A";
  44. $attire_class = $date_start_class = $time_start_class = $duration_class = $fee_class = "text-muted";
  45. date_default_timezone_set("UTC");
  46. if($test->dts_start) {
  47. $start_dt = new DateTime($test->dts_start);
  48. $date_start = $start_dt->format("d/m/Y");
  49. $time_start = $start_dt->format("H:i:s");
  50. $attire = $test->attire;
  51. $attire_class = $date_start_class = $time_start_class = "";
  52. }
  53. if($test->dts_start && $test->dts_end) {
  54. $end_dt = new DateTime($test->dts_end);
  55. $diff = $start_dt->diff($end_dt, true);
  56. $duration = $diff->format("%H:%I:%S");
  57. $duration_class = "";
  58. }
  59. date_default_timezone_set($original_timezone);
  60. $status_class = $test->getStatusClass();
  61. $status_text = $test->getStatusText();
  62. $status_class = "secondary";
  63. $status_text = "Pending";
  64. if($test->status == Test::STATUS_CANCELLED) {
  65. $status_class = "danger";
  66. $status_text = "Rejected";
  67. $fee = "N/A";
  68. }
  69. if($test->status == Test::STATUS_COMPLETED) {
  70. $status_class = "success";
  71. $status_text = "Accepted";
  72. $fee = $test->fee ? $test->fee : $project->default_tester_fee;
  73. $fee = "£" . $fee;
  74. $fee_class = "";
  75. }
  76. ?>
  77. <tr>
  78. <td class="text-right">
  79. <?=$test->id?>
  80. </td>
  81. <td>
  82. <?=htmlspecialchars($location->name)?><br />
  83. <small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]))?></small>
  84. </td>
  85. <td class="<?=$attire_class?>">
  86. <?=htmlspecialchars($attire)?>
  87. </td>
  88. <td class="align-middle">
  89. <a class="btn btn-outline-primary" href="/account/tests/<?=$test->id?>/selfie">View</a>
  90. </td>
  91. <td class="text-center align-middle <?=$date_start_class?>">
  92. <?=htmlspecialchars($date_start)?>
  93. </td>
  94. <td class="text-center align-middle <?=$time_start_class?>">
  95. <?=htmlspecialchars($time_start)?>
  96. </td>
  97. <td class="text-center align-middle <?=$duration_class?>">
  98. <?=htmlspecialchars($duration)?>
  99. </td>
  100. <td class="text-center align-middle">
  101. <span class="badge badge-lg badge-<?=$status_class?>"><?=htmlspecialchars($status_text)?></span>
  102. </td>
  103. <td class="text-center align-middle <?=$fee_class?>">
  104. <?=$fee?>
  105. </td>
  106. </tr>
  107. <?php
  108. }
  109. ?>
  110. </tbody>
  111. </table>
  112. <?php
  113. }
  114. ?>
  115. </div>