test_verify_form.php 12 KB

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