test_verify_form.php 18 KB

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