test_verify_form.php 17 KB

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