test_verify_form.php 16 KB

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