test_verify_form.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <?php
  2. $test_details = [
  3. "Status" => "<span class=\"badge badge-lg badge-" . $test->getStatusClass() . "\">" . $test->getStatusText() . "</span>",
  4. "Result" => "<span class=\"badge badge-lg badge-" . $test->getPassClass() . "\">" . $test->getPassText() . "</span>",
  5. "Location" => "<a href=\"/account/locations/$location->id\" target=\"_blank\">" . htmlspecialchars($location->name) . "</a>",
  6. "Address" => htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"])),
  7. ];
  8. if(!is_null($test->dts_end)) {
  9. $test_details = array_merge($test_details, [
  10. "Duration" => $test->getDisplayDuration(),
  11. "Start" => Util::getDisplayDateTime(strtotime($test->dts_start . " UTC")),
  12. "End" => Util::getDisplayDateTime(strtotime($test->dts_end . " UTC")),
  13. ]);
  14. }
  15. if(in_array($test->status, [Test::STATUS_CANCELLED, Test::STATUS_COMPLETED])) {
  16. $test_details["Verified"] = Util::getDisplayDateTime(strtotime($test->dts_verified . " UTC"));
  17. }
  18. $tester_details = [
  19. "Name" => "Unassigned"
  20. ];
  21. if($tester) {
  22. $tester_details = [
  23. "Name" => "<a href=\"/account/users/$tester->id\" target=\"_blank\">" . $tester->getDisplayName() . "</a>",
  24. "Date of Birth" => $tester->date_of_birth,
  25. "Gender" => $tester->getGenderText(),
  26. "Phone" => $tester->phone,
  27. "Score" => $tester->score
  28. ];
  29. }
  30. function render_card_list_group($details) {
  31. ?>
  32. <div class="list-group list-group-flush">
  33. <?php
  34. foreach($details as $title => $html) {
  35. ?>
  36. <div class="list-group-item">
  37. <div class="row" style="overflow: hidden; text-overflow: ellipsis;">
  38. <div class="col-md-auto">
  39. <?=htmlspecialchars($title)?>
  40. </div>
  41. <div class="col-md text-right" style="width: auto; overflow: hidden; text-overflow: ellipsis;">
  42. <?=$html?>
  43. </div>
  44. </div>
  45. </div>
  46. <?php
  47. }
  48. ?>
  49. </div>
  50. <?php
  51. }
  52. ?>
  53. <div class="container mt-3 py-4">
  54. <div class="row">
  55. <div class="col">
  56. <h2>Edit/Verify Test</h2>
  57. </div>
  58. <div class="col-auto justify-self-center">
  59. <div class="dropdown">
  60. <button class="btn btn-secondary dropdown-toggle" type="button" id="actions-button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  61. Actions
  62. </button>
  63. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="actions-button">
  64. <a class="dropdown-item" href="/account/projects/<?=$test->project_id?>">View Project</a>
  65. <div class="dropdown-divider"></div>
  66. <a class="dropdown-item" href="/account/tests/<?=$test->id?>/pdf" target="_blank">Generate New PDF</a>
  67. <?php
  68. if($has_pdf) {
  69. ?>
  70. <a class="dropdown-item" href="/account/tests/<?=$test->id?>/files/pdf" target="_blank">View Sent PDF</a>
  71. <?php
  72. }
  73. ?>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <form method="post">
  79. <input type="hidden" name="submit" value="<?=$_SESSION["csrf_token"]?>" />
  80. <div class="row">
  81. <div class="col-xl">
  82. <div class="card mb-3">
  83. <div class="card-header">
  84. Submitted Data
  85. </div>
  86. <div class="card-body">
  87. <?php
  88. $header_count = 0;
  89. foreach($fields as $field) {
  90. $field = $template->applyOverridesToField($field);
  91. if($header_count > 0 && $field->type == "header") {
  92. ?>
  93. <hr />
  94. <?php
  95. }
  96. if($field->type == "file") {
  97. $path = $test->getDirectory() . "/" . $field->name . ".jpg";
  98. ?>
  99. <div class="row mb-1">
  100. <label class="col-sm-8 col-form-label"><?=htmlspecialchars($field->label)?></label>
  101. <div class="col-sm-4">
  102. <a href="/account/tests/<?=$test->id?>/files/<?=$field->name?>" target="_blank">
  103. <img class="img-fluid rounded" src="/account/tests/<?=$test->id?>/files/<?=$field->name?>" alt="<?=htmlspecialchars($field->label)?>" />
  104. </a>
  105. </div>
  106. </div>
  107. <?php
  108. continue;
  109. }
  110. if(!empty($field->name)) {
  111. $name = $field->name;
  112. if(isset($test->$name)) $field->value = $test->$name;
  113. else if(isset($values[$name])) $field->value = $values[$name];
  114. }
  115. Form::renderField($field);
  116. if($field->type == "header") {
  117. $header_count++;
  118. }
  119. }
  120. ?>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="col-xl">
  125. <div class="row">
  126. <div class="col-md col-xl-12">
  127. <div class="card mb-3">
  128. <div class="card-header">
  129. Info
  130. </div>
  131. <div class="card-body p-0">
  132. <div id="map" data-maps data-lat="<?=$location->latitude?>" data-lng="<?=$location->longitude?>" data-zoom="17" data-marker="true" style="height: 320px;">
  133. </div>
  134. </div>
  135. <?php
  136. render_card_list_group($test_details);
  137. ?>
  138. </div>
  139. </div>
  140. <div class="col-md col-xl-12">
  141. <div class="card mb-3">
  142. <div class="card-header">
  143. Tester
  144. </div>
  145. <?php
  146. render_card_list_group($tester_details);
  147. ?>
  148. </div>
  149. </div>
  150. </div>
  151. <div class="card mb-3">
  152. <div class="card-header">
  153. Verification
  154. </div>
  155. <div class="card-body">
  156. <div class="row mb-1">
  157. <label class="col-sm-4 col-form-label">Verifier</label>
  158. <div class="col-sm">
  159. <?=htmlspecialchars(Core::$user->getDisplayName())?>
  160. </div>
  161. </div>
  162. <hr />
  163. <div class="row mb-1">
  164. <label class="col-sm-4 col-form-label" for="pass-override">Pass Override</label>
  165. <div class="col-sm">
  166. <select class="form-control" name="pass_override" id="pass-override">
  167. <option value="">None</option>
  168. <option value="1">Pass</option>
  169. <option value="0">Fail</option>
  170. </select>
  171. </div>
  172. </div>
  173. <div class="row mb-1">
  174. <label class="col-sm-4 col-form-label" for="start-override-day">Start Override</label>
  175. <div class="col-sm">
  176. <select class="form-control w-auto d-inline-block" name="start_override_day" id="start-override-day">
  177. <option value="">Day</option>
  178. <?php
  179. Form::renderDayOptions();
  180. ?>
  181. </select>
  182. <select class="form-control w-auto d-inline-block" name="start_override_month" id="start-override-month">
  183. <option value="">Month</option>
  184. <?php
  185. Form::renderMonthOptions();
  186. ?>
  187. </select>
  188. <select class="form-control w-auto d-inline-block" name="start_override_year" id="start-override-year">
  189. <option value="">Year</option>
  190. <?php
  191. Form::renderYearOptionsDescending(2017, date("Y"), date("Y"));
  192. ?>
  193. </select>
  194. <select class="form-control w-auto d-inline-block" name="start_override_hour" id="start-override-hour">
  195. <option value="">HH</option>
  196. <?php
  197. Form::renderHourOptions();
  198. ?>
  199. </select>
  200. <select class="form-control w-auto d-inline-block" name="start_override_minute" id="start-override-minute">
  201. <option value="">MM</option>
  202. <?php
  203. Form::renderMinuteOptions();
  204. ?>
  205. </select>
  206. <select class="form-control w-auto d-inline-block" name="start_override_second" id="start-override-second">
  207. <option value="">SS</option>
  208. <?php
  209. Form::renderSecondOptions();
  210. ?>
  211. </select>
  212. </div>
  213. </div>
  214. <div class="row mb-1">
  215. <label class="col-sm-4 col-form-label" for="end-override-day">End Override</label>
  216. <div class="col-sm">
  217. <select class="form-control w-auto d-inline-block" name="end_override_day" id="end-override-day">
  218. <option value="">Day</option>
  219. <?php
  220. Form::renderDayOptions();
  221. ?>
  222. </select>
  223. <select class="form-control w-auto d-inline-block" name="end_override_month" id="end-override-month">
  224. <option value="">Month</option>
  225. <?php
  226. Form::renderMonthOptions();
  227. ?>
  228. </select>
  229. <select class="form-control w-auto d-inline-block" name="end_override_year" id="end-override-year">
  230. <option value="">Year</option>
  231. <?php
  232. Form::renderYearOptionsDescending(2017, date("Y"), date("Y"));
  233. ?>
  234. </select>
  235. <select class="form-control w-auto d-inline-block" name="end_override_hour" id="end-override-hour">
  236. <option value="">HH</option>
  237. <?php
  238. Form::renderHourOptions();
  239. ?>
  240. </select>
  241. <select class="form-control w-auto d-inline-block" name="end_override_minute" id="end-override-minute">
  242. <option value="">MM</option>
  243. <?php
  244. Form::renderMinuteOptions();
  245. ?>
  246. </select>
  247. <select class="form-control w-auto d-inline-block" name="end_override_second" id="end-override-second">
  248. <option value="">SS</option>
  249. <?php
  250. Form::renderSecondOptions();
  251. ?>
  252. </select>
  253. </div>
  254. </div>
  255. <div class="row mb-1">
  256. <label class="col-sm-4 col-form-label" for="tester-fee">Tester Fee Override</label>
  257. <div class="col-sm">
  258. <div class="input-group">
  259. <div class="input-group-prepend">
  260. <span class="input-group-text">£</span>
  261. </div>
  262. <input class="form-control" type="number" step="0.01" min="0" name="tester_fee" id="tester-fee" placeholder="Enter tester fee override" value="<?=htmlspecialchars($test->test_fee)?>" />
  263. </div>
  264. </div>
  265. </div>
  266. <div class="row mb-1">
  267. <label class="col-sm-4 col-form-label" for="verifier-notes">Verifier Notes</label>
  268. <div class="col-sm">
  269. <textarea class="form-control" name="verifier_notes" id="verifier-notes" placeholder="Enter verifier notes" value="<?=htmlspecialchars($test->verifier_notes)?>" rows="4"></textarea>
  270. </div>
  271. </div>
  272. <?php
  273. if($test->status == Test::STATUS_PENDING_VERIFICATION) {
  274. ?>
  275. <?php
  276. if($customer->email) {
  277. ?>
  278. <div class="row mb-1">
  279. <div class="col-sm-4">
  280. <label class="form-check-label" for="email-customer">Email Headquarters</label>
  281. </div>
  282. <div class="col-sm">
  283. <div class="form-check">
  284. <input class="form-check-input" type="checkbox" name="email_customer" id="email-customer" value="1" <?=Form::checked($customer->email_after_test)?> />
  285. <label class="form-check-label" for="email-customer"><?=htmlspecialchars($customer->email)?></label>
  286. </div>
  287. </div>
  288. </div>
  289. <?php
  290. }
  291. if($location->email) {
  292. ?>
  293. <div class="row mb-1">
  294. <div class="col-sm-4">
  295. <label class="form-check-label" for="email-location">Email Venue</label>
  296. </div>
  297. <div class="col-sm">
  298. <div class="form-check">
  299. <input class="form-check-input" type="checkbox" name="email_location" id="email-location" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
  300. <label class="form-check-label" for="email-location"><?=htmlspecialchars($location->email)?></label>
  301. </div>
  302. </div>
  303. </div>
  304. <?php
  305. }
  306. if($location->area_manager_email) {
  307. ?>
  308. <div class="row mb-1">
  309. <div class="col-sm-4">
  310. <label class="form-check-label" for="email-location-area-manager">Email Area Manager</label>
  311. </div>
  312. <div class="col-sm">
  313. <div class="form-check">
  314. <input class="form-check-input" type="checkbox" name="email_location_area_manager" id="email-location-area-manager" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
  315. <label class="form-check-label" for="email-location-area-manager"><?=htmlspecialchars($location->area_manager_email)?></label>
  316. </div>
  317. </div>
  318. </div>
  319. <?php
  320. }
  321. ?>
  322. <div class="row mb-1">
  323. <div class="col-sm-4">Retest</div>
  324. <div class="col-sm">
  325. <div class="form-check">
  326. <input class="form-check-input" type="checkbox" name="retest" id="retest" value="1" <?=Form::checked($test->retest)?> />
  327. <label class="form-check-label" for="retest">Retest</label>
  328. </div>
  329. <small class="form-text text-muted">
  330. If this test was a retest, please check the box above. Once the test is accepted or rejected, this flag cannot be changed.
  331. </small>
  332. </div>
  333. </div>
  334. <div class="row mb-1">
  335. <label class="col-sm-4 col-form-label" for="tester-message">Message to Tester (if rejecting)</label>
  336. <div class="col-sm">
  337. <textarea class="form-control" name="tester_message" id="tester-message" placeholder="Enter message to tester" value="<?=htmlspecialchars($tester_message)?>" rows="4"></textarea>
  338. </div>
  339. </div>
  340. <div class="row mb-1">
  341. <div class="col-sm offset-sm-4">
  342. <button class="btn btn-success" type="submit" name="accept" value="1">Accept</button>
  343. <button class="btn btn-danger" type="submit" name="reject" value="1">Reject</button>
  344. </div>
  345. </div>
  346. <?php
  347. }
  348. else {
  349. ?>
  350. <div class="row mb-1">
  351. <div class="col-sm offset-sm-4">
  352. <button class="btn btn-primary" type="submit">Submit</button>
  353. </div>
  354. </div>
  355. <?php
  356. }
  357. ?>
  358. </div>
  359. </div>
  360. </div>
  361. </div>
  362. </form>
  363. </div>