test_verify_form.php 17 KB

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