test_verify_form.php 16 KB

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