test_verify_form.php 15 KB

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