test_verify_form.php 13 KB

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