test_verify_form.php 16 KB

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