test_verify_form.php 17 KB

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