test_verify_form.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  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 string $tester_message
  14. */
  15. $values = $test->getValues(true);
  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->getStatus(), [Test::STATUS_CANCELLED, Test::STATUS_COMPLETED], true)) {
  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. if($test->void) {
  171. ?>
  172. <label for="void-notes">Venue Closed Notes</label>
  173. <textarea class="form-control" name="void_notes" id="void-notes" rows="4" placeholder="Enter venue closed notes"><?=htmlspecialchars($test->void_notes)?></textarea>
  174. <?php
  175. }
  176. ?>
  177. </div>
  178. </div>
  179. </div>
  180. <div class="col-xl">
  181. <div class="row">
  182. <div class="col-md col-xl-12">
  183. <div class="card mb-3">
  184. <div class="card-header">
  185. Info
  186. </div>
  187. <div class="card-body p-0">
  188. <div id="map" data-maps data-lat="<?=$location->latitude?>" data-lng="<?=$location->longitude?>" data-zoom="17" data-marker="true" style="height: 320px;">
  189. </div>
  190. </div>
  191. <?php
  192. render_card_list_group($test_details);
  193. ?>
  194. </div>
  195. </div>
  196. <div class="col-md col-xl-12">
  197. <div class="card mb-3">
  198. <div class="card-header">
  199. Tester
  200. </div>
  201. <?php
  202. render_card_list_group($tester_details);
  203. ?>
  204. </div>
  205. <?php
  206. if(isset($tester_invoice_details)) {
  207. ?>
  208. <div class="card mb-3">
  209. <div class="card-header">
  210. Tester Invoice
  211. </div>
  212. <?php
  213. render_card_list_group($tester_invoice_details);
  214. if($test->getTesterInvoiceStatus() === Test::STATUS_TESTER_INVOICE_PENDING) {
  215. ?>
  216. <div class="card-body text-center">
  217. <button class="btn btn-success" type="submit" name="accept_tester_invoice" value="1">
  218. Paid Invoice
  219. </button>
  220. <button class="btn btn-danger" type="submit" name="reject_tester_invoice" value="1">
  221. Reject Invoice
  222. </button>
  223. </div>
  224. <?php
  225. }
  226. ?>
  227. </div>
  228. <?php
  229. }
  230. ?>
  231. </div>
  232. </div>
  233. <div class="card mb-3">
  234. <div class="card-header">
  235. Verification
  236. </div>
  237. <div class="card-body">
  238. <div class="row mb-1">
  239. <label class="col-sm-4 col-form-label">Verifier</label>
  240. <div class="col-sm">
  241. <?=htmlspecialchars(Core::$user->getDisplayName())?>
  242. </div>
  243. </div>
  244. <hr />
  245. <?php
  246. if($template->hasPassFail()) {
  247. ?>
  248. <div class="row mb-1">
  249. <label class="col-sm-4 col-form-label" for="pass-override">Pass Override</label>
  250. <div class="col-sm">
  251. <select class="form-control" name="pass_override" id="pass-override">
  252. <option value="">None</option>
  253. <option value="1">Pass</option>
  254. <option value="0">Fail</option>
  255. </select>
  256. </div>
  257. </div>
  258. <?php
  259. }
  260. ?>
  261. <div class="row mb-1">
  262. <label class="col-sm-4 col-form-label" for="start-override">Start Override</label>
  263. <div class="col-sm">
  264. <input class="form-control" type="datetime-local" name="start_override" id="start-override" />
  265. </div>
  266. </div>
  267. <div class="row mb-1">
  268. <label class="col-sm-4 col-form-label" for="end-override">End Override</label>
  269. <div class="col-sm">
  270. <input class="form-control" type="datetime-local" name="end_override" id="end-override" />
  271. </div>
  272. </div>
  273. <div class="row mb-1">
  274. <label class="col-sm-4 col-form-label" for="customer-fee">Customer Fee Override</label>
  275. <div class="col-sm">
  276. <div class="input-group">
  277. <div class="input-group-prepend">
  278. <span class="input-group-text">£</span>
  279. </div>
  280. <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)?>" />
  281. </div>
  282. </div>
  283. </div>
  284. <div class="row mb-1">
  285. <label class="col-sm-4 col-form-label" for="tester-fee">Tester Fee Override</label>
  286. <div class="col-sm">
  287. <div class="input-group">
  288. <div class="input-group-prepend">
  289. <span class="input-group-text">£</span>
  290. </div>
  291. <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)?>" />
  292. </div>
  293. </div>
  294. </div>
  295. <row class="row mb-1">
  296. <label class="col-sm-4 col-form-label" for="travel-cost">Travel Costs</label>
  297. <div class="col-sm">
  298. <div class="input-group">
  299. <div class="input-group-prepend">
  300. <span class="input-group-text">£</span>
  301. </div>
  302. <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)?>" />
  303. </div>
  304. </div>
  305. </row>
  306. <div class="row mb-1">
  307. <label class="col-sm-4 col-form-label" for="verifier-notes">Verifier Notes</label>
  308. <div class="col-sm">
  309. <textarea class="form-control" name="verifier_notes" id="verifier-notes" placeholder="Enter verifier notes" rows="4"><?=htmlspecialchars($test->verifier_notes)?></textarea>
  310. </div>
  311. </div>
  312. <div class="row mb-1">
  313. <div class="col-sm-4">Set As Retest</div>
  314. <div class="col-sm">
  315. <div class="custom-control custom-checkbox">
  316. <input class="custom-control-input" type="checkbox" name="retest" id="retest" value="1" <?=Form::checked($test->retest)?> />
  317. <label class="custom-control-label" for="retest">This test was a retest</label>
  318. </div>
  319. </div>
  320. </div>
  321. <div class="row mb-1">
  322. <label class="col-sm-4 col-form-label" for="new-test-project-id">Create New Test</label>
  323. <div class="col-sm">
  324. <div class="input-group">
  325. <select class="form-control" name="new_test_project_id" id="new-test-project-id">
  326. <option value="0">Do not create</option>
  327. <?php
  328. foreach($future_projects as $future_project) {
  329. ?>
  330. <option value="<?=$future_project->id?>"><?=htmlspecialchars($future_project->name)?></option>
  331. <?php
  332. }
  333. ?>
  334. </select>
  335. <div class="input-group-append">
  336. <div class="input-group-text">
  337. <div class="custom-control custom-checkbox">
  338. <input class="custom-control-input" type="checkbox" name="new_test_is_retest" id="new-test-is-retest" value="1" />
  339. <label class="custom-control-label" for="new-test-is-retest"><?=htmlspecialchars(__("Retest"))?></label>
  340. </div>
  341. </div>
  342. </div>
  343. </div>
  344. </div>
  345. </div>
  346. <?php
  347. if($test->getStatus() === Test::STATUS_PENDING_VERIFICATION) {
  348. ?>
  349. <?php
  350. if($customer->email) {
  351. ?>
  352. <div class="row mb-1">
  353. <div class="col-sm-4">
  354. <label class="form-check-label" for="email-customer">Email Headquarters</label>
  355. </div>
  356. <div class="col-sm">
  357. <div class="custom-control custom-checkbox">
  358. <input class="custom-control-input" type="checkbox" name="email_customer" id="email-customer" value="1" <?=Form::checked($customer->email_after_test)?> />
  359. <label class="custom-control-label" for="email-customer"><?=htmlspecialchars($customer->email)?></label>
  360. </div>
  361. </div>
  362. </div>
  363. <?php
  364. }
  365. if($location->email) {
  366. ?>
  367. <div class="row mb-1">
  368. <div class="col-sm-4">
  369. <label class="form-check-label" for="email-location">Email Venue</label>
  370. </div>
  371. <div class="col-sm">
  372. <div class="custom-control custom-checkbox">
  373. <input class="custom-control-input" type="checkbox" name="email_location" id="email-location" value="1" <?=Form::checked($customer->email_locations_after_test)?> />
  374. <label class="custom-control-label" for="email-location"><?=htmlspecialchars($location->email)?></label>
  375. </div>
  376. </div>
  377. </div>
  378. <?php
  379. }
  380. if($location->area_manager_email) {
  381. ?>
  382. <div class="row mb-1">
  383. <div class="col-sm-4">
  384. <label class="form-check-label" for="email-location-area-manager">Email Area Manager</label>
  385. </div>
  386. <div class="col-sm">
  387. <div class="custom-control custom-checkbox">
  388. <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)?> />
  389. <label class="custom-control-label" for="email-location-area-manager"><?=htmlspecialchars($location->area_manager_email)?></label>
  390. </div>
  391. </div>
  392. </div>
  393. <?php
  394. }
  395. ?>
  396. <div class="row mb-1">
  397. <label class="col-sm-4 col-form-label" for="tester-message">Message to Tester (if rejecting)</label>
  398. <div class="col-sm">
  399. <textarea class="form-control" name="tester_message" id="tester-message" placeholder="Enter message to tester" rows="4"><?=htmlspecialchars($tester_message)?></textarea>
  400. </div>
  401. </div>
  402. <div class="row mb-1">
  403. <div class="col-sm offset-sm-4">
  404. <button class="btn btn-success" type="submit" name="accept" value="1">Accept</button>
  405. <button class="btn btn-danger" type="submit" name="reject" value="1">Reject</button>
  406. </div>
  407. </div>
  408. <?php
  409. }
  410. else {
  411. ?>
  412. <div class="row mb-1">
  413. <div class="col-sm offset-sm-4">
  414. <button class="btn btn-primary" type="submit">Submit</button>
  415. </div>
  416. </div>
  417. <?php
  418. }
  419. ?>
  420. </div>
  421. </div>
  422. </div>
  423. </div>
  424. </form>
  425. </div>