test_verify_form.php 16 KB

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