test_verify_form.php 15 KB

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