test_verify_form.php 17 KB

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