1
0

test_list_completed.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var object $pagination_object
  4. * @var bool $can_invoice
  5. */
  6. ?>
  7. <div class="container mt-3 py-4">
  8. <h2><?=htmlspecialchars(__("Completed Tests"))?></h2>
  9. <?php
  10. if(empty($tests)) {
  11. ?>
  12. <div class="alert alert-info">
  13. <?=htmlspecialchars(__("You have not completed any tests yet."))?>
  14. </div>
  15. <?php
  16. }
  17. else {
  18. ?>
  19. <div class="mb-3">
  20. <?php
  21. View::include("pagination", compact("pagination_object"));
  22. ?>
  23. </div>
  24. <?php
  25. if(!Core::$user->getInvoiceAddress()) {
  26. ?>
  27. <div class="alert alert-warning">
  28. <i class="fal fa-fw fa-exclamation-triangle"></i>
  29. <?=sprintf(htmlspecialchars(__("You have multiple addresses. %sClick here%s to manage your addresses and set one as the invoice address to enable the invoice link.")), '<a href="/account/addresses">', '</a>')?>
  30. </div>
  31. <?php
  32. }
  33. if(!Core::$user->hasValidPaymentMethod()) {
  34. ?>
  35. <div class="alert alert-warning">
  36. <i class="fal fa-fw fa-exclamation-triangle"></i>
  37. <?=sprintf(htmlspecialchars(__("You have no valid payment method. %sClick here%s and verify your payment method settings are correct to enable the invoice link.")), '<a href="/account/settings">', '</a>')?>
  38. </div>
  39. <?php
  40. }
  41. ?>
  42. <div class="list-group">
  43. <?php
  44. $original_timezone = date_default_timezone_get();
  45. foreach($tests as $test) {
  46. $location = $test->getLocation();
  47. $project = $test->getProject();
  48. $attire = $date_start = $time_start = $duration = __("N/A");
  49. $attire_class = $date_start_class = $time_start_class = $duration_class = $fee_class = "text-muted";
  50. date_default_timezone_set("UTC");
  51. if($test->dts_start) {
  52. $start_dt = new DateTime($test->dts_start);
  53. $date_start = $start_dt->format("jS M Y");
  54. $time_start = $start_dt->format("H:i:s");
  55. $attire = $test->attire;
  56. $attire_class = $date_start_class = $time_start_class = "";
  57. if($test->dts_end) {
  58. $end_dt = new DateTime($test->dts_end);
  59. $diff = $start_dt->diff($end_dt, true);
  60. $duration = $diff->format(__("%i min. %S sec."));
  61. $duration_class = "";
  62. }
  63. }
  64. date_default_timezone_set($original_timezone);
  65. $status_class = $test->getStatusClass();
  66. $status_text = $test->getStatusText();
  67. $status_class = "secondary";
  68. $status_text = __("Pending");
  69. $fee = "N/A";
  70. if($test->status == Test::STATUS_CANCELLED) {
  71. $status_class = "danger";
  72. $status_text = __("Rejected");
  73. }
  74. if($test->status == Test::STATUS_COMPLETED) {
  75. $status_class = "success";
  76. $status_text = __("Accepted");
  77. $fee = $test->getTestFee();
  78. $fee = "£" . $fee;
  79. $fee_class = "";
  80. }
  81. ?>
  82. <div class="list-group-item list-group-item-action">
  83. <div class="row">
  84. <div class="col-xl">
  85. <div class="row">
  86. <div class="col order-1 order-sm-1">
  87. <strong><?=htmlspecialchars(__("ID:"))?> <?=$test->id?></strong><br />
  88. <?php
  89. if($test->status == Test::STATUS_COMPLETED && $can_invoice) {
  90. ?>
  91. <a href="/account/tests/<?=$test->id?>/invoice">
  92. <i class="fal fa-fw fa-external-link"></i>
  93. <?=htmlspecialchars(__("Invoice"))?>
  94. </a>
  95. <?php
  96. }
  97. ?>
  98. </div>
  99. <div class="col-sm order-3 order-sm-2">
  100. <hr class="d-block d-sm-none" />
  101. <?=htmlspecialchars($location->name)?><br />
  102. <small><?=htmlspecialchars($location->getDisplayAddress(["city", "postal_code"]))?></small>
  103. </div>
  104. <div class="col order-2 order-sm-3 text-right text-xl-center align-self-xl-center">
  105. <span class="badge badge-lg badge-<?=$status_class?>"><?=htmlspecialchars($status_text)?></span>
  106. </div>
  107. </div>
  108. <hr class="d-none d-sm-block d-xl-none" />
  109. </div>
  110. <div class="col-xl align-self-xl-center">
  111. <div class="row">
  112. <div class="col-sm <?=$date_start_class?> align-self-xl-center">
  113. <hr class="d-block d-sm-none" />
  114. <strong><?=htmlspecialchars($date_start)?></strong><br />
  115. <small><?=htmlspecialchars($time_start)?> / <?=htmlspecialchars($duration)?></small>
  116. </div>
  117. <div class="col-sm <?=$fee_class?> align-self-xl-center">
  118. <hr class="d-block d-sm-none" />
  119. <?=htmlspecialchars(__("Fee:"))?> <?=$fee?>
  120. </div>
  121. <div class="col-sm <?=$attire_class?> align-self-xl-center">
  122. <hr class="d-block d-sm-none" />
  123. <?=htmlspecialchars($attire)?><br />
  124. <a href="/account/tests/<?=$test->id?>/selfie"><?=htmlspecialchars(__("View selfie."))?></a>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. <?php
  131. }
  132. ?>
  133. </div>
  134. <div class="mt-3">
  135. <?php
  136. View::include("pagination", compact("pagination_object"));
  137. ?>
  138. </div>
  139. <?php
  140. }
  141. ?>
  142. </div>