test_pdf.php 11 KB

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