test_pdf.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @var Template $template
  4. * @var Test $test
  5. * @var Mpdf $mpdf
  6. * @var array $values
  7. * @var string $location_text
  8. * @var Customer $customer
  9. * @var Location $location
  10. * @var User $tester
  11. * @var string $date_start
  12. * @var string $time_start
  13. * @var string $time_end
  14. * @var string $duration_text
  15. */
  16. use Helpers\PdfHelper;
  17. use Mpdf\Mpdf;
  18. $year_cycle_constraint = $customer->getYearCycleConstraint(TIMEZONE);
  19. $display_year_cycle = $customer->getDisplayYearCycle();
  20. $alcohol_purchased = $values["alcohol_purchased"] ?? "";
  21. $pass_image = $test->pass ? "pass.png" : "fail.png";
  22. $alcohol_pass_image = empty($alcohol_purchased) ? "pass.png" : "fail.png";
  23. // Bar Receipt
  24. $receipt_path_pattern = $test->getDirectory() . "/bar_receipt.*";
  25. $receipt_config = null;
  26. foreach(glob($receipt_path_pattern) as $receipt_path) {
  27. $receipt_config = PdfHelper::getImageConfig($receipt_path);
  28. $mpdf->imageVars["bar_receipt"] = $receipt_config["contents"];
  29. }
  30. // Test counts
  31. $test_count = count($location->getCompletedTests());
  32. $current_test_count = count($location->getCompletedTests(["dts_start" => $year_cycle_constraint]));
  33. $render_field_value = static function($field, $value): void {
  34. ?>
  35. <div class="bl">
  36. <div class="field"><?=htmlspecialchars($field)?>:</div>
  37. <div class="value"><?=htmlspecialchars($value)?></div>
  38. </div>
  39. <?php
  40. };
  41. if($test->pass) {
  42. ?>
  43. <h3 class="section">Test Result</h3>
  44. <div align="center" style="margin: auto; width: 75%;">
  45. <img src="/img/<?=htmlspecialchars($pass_image)?>" alt="" />
  46. </div>
  47. <?php
  48. }
  49. else {
  50. ?>
  51. <div style="float: left; width: 49.25%; position: relative;">
  52. <h3 class="section">Machine Test Result</h3>
  53. <div align="center" style="margin: auto; width: 90%;">
  54. <img src="/img/<?=htmlspecialchars($pass_image)?>" alt="" />
  55. </div>
  56. </div>
  57. <div style="float: right; width: 49.25%; position: relative;">
  58. <h3 class="section">Alcohol Test Result</h3>
  59. <div align="center" style="margin: auto; width: 90%;">
  60. <img src="/img/<?=htmlspecialchars($alcohol_pass_image)?>" alt="" />
  61. </div>
  62. </div>
  63. <br />
  64. <?php
  65. }
  66. ?>
  67. <div style="float: left; width: 49.25%; position: relative;">
  68. <h3 class="section"><?=htmlspecialchars($location_text)?></h3>
  69. <?php
  70. $render_field_value("Address", $location->getDisplayAddress());
  71. ?>
  72. <div class="bl">
  73. <div class="field">Tests (All-Time)</div>
  74. <div class="value"><?=$test_count?></div>
  75. </div>
  76. <div class="bl">
  77. <div class="field">Tests (Cur. Year Period)</div>
  78. <div class="value">
  79. <?=$current_test_count?>
  80. <small style="color: #808080">
  81. (<?=$display_year_cycle?>)
  82. </small>
  83. </div>
  84. </div>
  85. <section>
  86. <h3 class="section">Tester</h3>
  87. <div class="bl">
  88. <div class="field">Gender:</div>
  89. <div class="value"><?=htmlspecialchars($tester->getGenderText())?></div>
  90. </div>
  91. <div>
  92. <strong>Attire:</strong><br />
  93. <?=htmlspecialchars($test->attire)?>
  94. </div>
  95. </section>
  96. </div>
  97. <div style="float: right; width: 49.25%">
  98. <section>
  99. <h3 class="section">House Information</h3>
  100. <?php
  101. $render_field_value("Division", $location->brand);
  102. $render_field_value("OM", $location->operations_manager_name);
  103. $render_field_value("BDM", $location->region_name);
  104. $render_field_value("SGEM", $location->senior_gaming_manager_name);
  105. $render_field_value("GEM", $location->gaming_manager_name);
  106. $render_field_value("Density", $location->machine_count);
  107. ?>
  108. </section>
  109. </div>
  110. <div style="clear: both;"></div>
  111. <div style="float: left; width: 49.25%">
  112. <h3 class="section">Machine Test Details</h3>
  113. <div class="subheader">
  114. <strong>Date &amp; Time</strong>
  115. </div>
  116. <div style="float: left; width: 24%">
  117. <strong>Date:</strong><br />
  118. <?=htmlspecialchars($date_start)?>
  119. </div>
  120. <div style="float: left; width: 24%">
  121. <strong>Entry:</strong><br />
  122. <?=htmlspecialchars($time_start)?>
  123. </div>
  124. <div style="float: left; width: 24%">
  125. <strong>Exit:</strong><br />
  126. <?=htmlspecialchars($time_end)?>
  127. </div>
  128. <div style="float: left; width: 24%">
  129. <strong>Duration:</strong><br />
  130. <?=htmlspecialchars($duration_text)?>
  131. </div>
  132. <div style="clear: both;"></div><br />
  133. <div class="subheader">
  134. <strong>ID Request</strong>
  135. </div>
  136. <?php
  137. $pass_colour = $test->pass ? "green" : "red";
  138. switch($test->challenge_stage) {
  139. case 1:
  140. case 2:
  141. $challenge_colour = "green";
  142. break;
  143. case 3:
  144. $challenge_colour = "orange";
  145. break;
  146. case 4:
  147. case 5:
  148. default:
  149. $challenge_colour = "red";
  150. break;
  151. }
  152. ?>
  153. <div class="bl">
  154. <div class="field">Result:</div>
  155. <div class="value" style="color: <?=$pass_colour?>">
  156. <strong><?=htmlspecialchars($test->getPassText())?></strong>
  157. </div>
  158. </div>
  159. <div>
  160. <div class="field">ID Stage:</div>
  161. <div class="value" style="color: <?=$challenge_colour?>">
  162. <strong><?=htmlspecialchars($test->challenge_stage . " - " . $test->getChallengeStageText())?></strong>
  163. </div>
  164. </div>
  165. <div class="bl">
  166. <div class="field">Eye Contact:</div>
  167. <div class="value"><?=($test->challenger_eye_contact ? "Yes" : "No")?></div>
  168. </div>
  169. <div>
  170. <strong>Description:</strong><br />
  171. <?=TestPDF::getValueHtml($test->challenge_description)?>
  172. </div>
  173. <br />
  174. <div class="subheader">
  175. <strong>Play Details</strong>
  176. </div>
  177. <div class="wide-field-names">
  178. <div class="bl">
  179. <div class="field">Machine Played:</div>
  180. <div class="value"><?=TestPDF::getValueHtml($values["play_machine"] ?? "")?></div>
  181. </div>
  182. <div class="bl">
  183. <div class="field">Machine Position:</div>
  184. <div class="value"><?=TestPDF::getValueHtml($values["play_machine_position"] ?? "")?></div>
  185. </div>
  186. <?php
  187. $play_jackpot = $values["play_jackpot"] ?? "";
  188. if(!empty($play_jackpot)) {
  189. $play_jackpot = "£" . number_format($play_jackpot, 2);
  190. }
  191. ?>
  192. <div class="bl">
  193. <div class="field">Jackpot Value:</div>
  194. <div class="value"><?=TestPDF::getValueHtml($play_jackpot)?></div>
  195. </div>
  196. <?php
  197. $play_machine_stake = $values["play_machine_stake"] ?? "";
  198. if(!empty($play_machine_stake)) {
  199. $play_machine_stake = "£" . number_format($play_machine_stake, 2);
  200. }
  201. ?>
  202. <div class="bl">
  203. <div class="field">Stake Played:</div>
  204. <div class="value"><?=TestPDF::getValueHtml($play_machine_stake)?></div>
  205. </div>
  206. <div class="bl">
  207. <div class="field">Minutes Played:</div>
  208. <div class="value"><?=TestPDF::getValueHtml($values["play_minutes"] ?? "")?></div>
  209. </div>
  210. <?php
  211. $play_spent = $values["play_spent"] ?? "";
  212. if(!empty($play_spent)) $play_spent = "£" . number_format($play_spent, 2);
  213. ?>
  214. <div>
  215. <div class="field">Amount Spent:</div>
  216. <div class="value"><?=TestPDF::getValueHtml($play_spent)?></div>
  217. </div>
  218. </div>
  219. <br />
  220. <section>
  221. <div class="subheader">
  222. <strong>Staff</strong>
  223. </div>
  224. <div class="bl">
  225. <div class="field">Name:</div>
  226. <div class="value"><?=TestPDF::getValueHtml($test->challenger_name)?></div>
  227. </div>
  228. <div class="bl">
  229. <div class="field">Gender:</div>
  230. <div class="value"><?=TestPDF::getValueHtml(Util::getGenderText($test->challenger_gender))?></div>
  231. </div>
  232. <strong>Description:</strong><br />
  233. <?=TestPDF::getValueHtml($test->challenger_description)?><br />
  234. <br />
  235. </section>
  236. </div>
  237. <div style="float: right; width: 49.25%">
  238. <h3 class="section">Alcohol Test Details</h3>
  239. <section>
  240. <?php
  241. $bar_time = $values["bar_time"] ?? "";
  242. $bar_staff_name = $values["bar_staff_name"] ?? "";
  243. $bar_staff_gender = $values["bar_staff_gender"] ?? "";
  244. $bar_staff_description = $values["bar_staff_description"] ?? "";
  245. $bar_age_verification = $values["bar_age_verification"];
  246. $alcohol_purchased = $values["alcohol_purchased"] ?? "";
  247. $bar_expenditure = ($values["bar_expenditure"] ?? "") ?: 0;
  248. $bar_purchase_item = ($values["bar_purchase_item"] ?? "");
  249. ?>
  250. <div class="subheader">
  251. <strong>Bar Details</strong>
  252. </div>
  253. <div class="wide-field-names">
  254. <div class="bl">
  255. <div class="field">Arrival:</div>
  256. <div class="value"><?=TestPDF::getValueHtml($bar_time)?></div>
  257. </div>
  258. <div class="bl">
  259. <div class="field">Asked For ID:</div>
  260. <div class="value"><?=TestPDF::getBooleanHtml($bar_age_verification)?></div>
  261. </div>
  262. <div class="bl">
  263. <div class="field">Alcohol Purchased:</div>
  264. <div class="value"><?=TestPDF::getBooleanHtml($alcohol_purchased)?></div>
  265. </div>
  266. <div class="bl">
  267. <div class="field">Drink Purchased:</div>
  268. <div class="value"><?=TestPDF::getValueHtml($bar_purchase_item)?></div>
  269. </div>
  270. <div class="bl">
  271. <div class="field">Bar Spend:</div>
  272. <div class="value">£<?=number_format($bar_expenditure, 2)?></div>
  273. </div>
  274. </div>
  275. <br />
  276. <div class="subheader">
  277. <strong>Staff</strong>
  278. </div>
  279. <div class="bl">
  280. <div class="field">Name:</div>
  281. <div class="value"><?=TestPDF::getValueHtml($bar_staff_name)?></div>
  282. </div>
  283. <div class="bl">
  284. <div class="field">Gender:</div>
  285. <div class="value"><?=TestPDF::getValueHtml($bar_staff_gender)?></div>
  286. </div>
  287. <strong>Description:</strong><br />
  288. <?=TestPDF::getValueHtml($bar_staff_description)?><br />
  289. <br />
  290. <?php
  291. if($receipt_config) {
  292. ?>
  293. <div class="subheader">
  294. <strong>Receipt</strong>
  295. </div>
  296. <img src="var:bar_receipt" width="<?=$receipt_config["width"]?>" height="<?=$receipt_config["height"]?>" alt="" />
  297. <?php
  298. }
  299. ?>
  300. </section>
  301. <section>
  302. <h3 class="section">ID Stage Reference</h3>
  303. <div>
  304. <div style="color: green;">1: Challenge on entry</div>
  305. <div style="color: green;">2: Challenge while browsing</div>
  306. <div style="color: orange;">3: Challenge during play</div>
  307. <div style="color: red;">4: Challenge after play</div>
  308. <div style="color: red;">5: No challenge</div>
  309. </div>
  310. <br />
  311. </section>
  312. </div>
  313. <div class="clear" style="page-break-before: always"></div>
  314. <h3 class="section">Other Test Details</h3>
  315. <section>
  316. <div class="subheader">
  317. <strong>Door Security Staff</strong>
  318. </div>
  319. <div class="bl">
  320. <div class="field">Present:</div>
  321. <div class="value"><?=TestPDF::getBooleanHtml($values["security_staff_present"] ?? false)?></div>
  322. </div>
  323. <div class="bl">
  324. <div class="field">Asked For ID:</div>
  325. <div class="value"><?=TestPDF::getBooleanHtml($values["security_staff_challenge"] ?? false)?></div>
  326. </div>
  327. <div class="bl">
  328. <div class="field">Line of Sight of Bar:</div>
  329. <div class="value"><?=TestPDF::getBooleanHtml($values["play_machine_line_of_sight"] ?? false)?></div>
  330. </div>
  331. </section>
  332. <div style="clear: both;"></div><br />
  333. <div>
  334. <div class="subheader">
  335. <strong>Additional Notes</strong>
  336. </div>
  337. <?=TestPDF::getValueHtml($test->additional_notes)?>
  338. </div>