1
0

test_verify_form.php 16 KB

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