test_pdf.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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">Gaming 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. <!-- Page 1 / Machine Test -->
  112. <div style="float: left; width: 49.25%">
  113. <h3 class="section">Gaming Machine Test Details</h3>
  114. <div class="subheader">
  115. <strong>Date &amp; Time</strong>
  116. </div>
  117. <div style="float: left; width: 24%">
  118. <strong>Date:</strong><br />
  119. <?=htmlspecialchars($date_start)?>
  120. </div>
  121. <div style="float: left; width: 24%">
  122. <strong>Entry:</strong><br />
  123. <?=htmlspecialchars($time_start)?>
  124. </div>
  125. <div style="float: left; width: 24%">
  126. <strong>Exit:</strong><br />
  127. <?=htmlspecialchars($time_end)?>
  128. </div>
  129. <div style="float: left; width: 24%">
  130. <strong>Duration:</strong><br />
  131. <?=htmlspecialchars($duration_text)?>
  132. </div>
  133. <div style="clear: both;"></div><br />
  134. <div class="subheader">
  135. <strong>ID Request</strong>
  136. </div>
  137. <?php
  138. $pass_colour = $test->pass ? "green" : "red";
  139. switch($test->challenge_stage) {
  140. case 1:
  141. case 2:
  142. $challenge_colour = "green";
  143. break;
  144. case 3:
  145. $challenge_colour = "orange";
  146. break;
  147. case 4:
  148. case 5:
  149. default:
  150. $challenge_colour = "red";
  151. break;
  152. }
  153. ?>
  154. <div class="bl">
  155. <div class="field">Result:</div>
  156. <div class="value" style="color: <?=$pass_colour?>">
  157. <strong><?=htmlspecialchars($test->getPassText())?></strong>
  158. </div>
  159. </div>
  160. <div>
  161. <div class="field">ID Stage:</div>
  162. <div class="value" style="color: <?=$challenge_colour?>">
  163. <strong><?=htmlspecialchars($test->challenge_stage . " - " . $test->getChallengeStageText())?></strong>
  164. </div>
  165. </div>
  166. <div class="bl">
  167. <div class="field">Eye Contact:</div>
  168. <div class="value"><?=($test->challenger_eye_contact ? "Yes" : "No")?></div>
  169. </div>
  170. <div>
  171. <strong>Description:</strong><br />
  172. <?=TestPDF::getValueHtml($test->challenge_description)?>
  173. </div>
  174. <br />
  175. <section>
  176. <div class="subheader">
  177. <strong>Staff</strong>
  178. </div>
  179. <div class="bl">
  180. <div class="field">Name:</div>
  181. <div class="value"><?=TestPDF::getValueHtml($test->challenger_name)?></div>
  182. </div>
  183. <strong>Description:</strong><br />
  184. <?=TestPDF::getValueHtml($test->challenger_description)?><br />
  185. <br />
  186. </section>
  187. </div>
  188. <!-- Page 1 / Alcohol Test -->
  189. <div style="float: right; width: 49.25%">
  190. <h3 class="section">Alcohol Test Details</h3>
  191. <section>
  192. <?php
  193. $bar_time = $values["bar_time"] ?? "";
  194. $bar_staff_name = $values["bar_staff_name"] ?? "";
  195. $bar_staff_description = $values["bar_staff_description"] ?? "";
  196. $bar_age_verification = $values["bar_age_verification"];
  197. $alcohol_purchased = $values["alcohol_purchased"] ?? "";
  198. $bar_expenditure = ($values["bar_expenditure"] ?? "") ?: 0;
  199. $bar_purchase_item = ($values["bar_purchase_item"] ?? "");
  200. ?>
  201. <div class="subheader">
  202. <strong>Bar Details</strong>
  203. </div>
  204. <div class="wide-field-names">
  205. <div class="bl">
  206. <div class="field">Arrival:</div>
  207. <div class="value"><?=TestPDF::getValueHtml($bar_time)?></div>
  208. </div>
  209. <div class="bl">
  210. <div class="field">Asked For ID:</div>
  211. <div class="value"><?=TestPDF::getBooleanHtml($bar_age_verification)?></div>
  212. </div>
  213. <div class="bl">
  214. <div class="field">Alcohol Purchased:</div>
  215. <div class="value"><?=TestPDF::getBooleanHtml($alcohol_purchased)?></div>
  216. </div>
  217. <div class="bl">
  218. <div class="field">Drink Purchased:</div>
  219. <div class="value"><?=TestPDF::getValueHtml($bar_purchase_item)?></div>
  220. </div>
  221. <div class="bl">
  222. <div class="field">Bar Spend:</div>
  223. <div class="value">£<?=number_format($bar_expenditure, 2)?></div>
  224. </div>
  225. </div>
  226. <br />
  227. <div class="subheader">
  228. <strong>Staff</strong>
  229. </div>
  230. <div class="bl">
  231. <div class="field">Name:</div>
  232. <div class="value"><?=TestPDF::getValueHtml($bar_staff_name)?></div>
  233. </div>
  234. <strong>Description:</strong><br />
  235. <?=TestPDF::getValueHtml($bar_staff_description)?><br />
  236. <br />
  237. </section>
  238. </div>
  239. <div class="clear" style="page-break-before: always"></div>
  240. <!-- Page 2 / Machine Test -->
  241. <div style="float: left; width: 49.25%">
  242. <div class="subheader">
  243. <strong>Play Details</strong>
  244. </div>
  245. <div class="wide-field-names">
  246. <div class="bl">
  247. <div class="field">Machine Played:</div>
  248. <div class="value"><?=TestPDF::getValueHtml($values["play_machine"] ?? "")?></div>
  249. </div>
  250. <div class="bl">
  251. <div class="field">Machine Position:</div>
  252. <div class="value"><?=TestPDF::getValueHtml($values["play_machine_position"] ?? "")?></div>
  253. </div>
  254. <?php
  255. $play_jackpot = $values["play_jackpot"] ?? "";
  256. if(!empty($play_jackpot)) {
  257. $play_jackpot = "£" . number_format($play_jackpot, 2);
  258. }
  259. ?>
  260. <div class="bl">
  261. <div class="field">Jackpot Value:</div>
  262. <div class="value"><?=TestPDF::getValueHtml($play_jackpot)?></div>
  263. </div>
  264. <?php
  265. $play_machine_stake = $values["play_machine_stake"] ?? "";
  266. if(!empty($play_machine_stake)) {
  267. $play_machine_stake = "£" . number_format($play_machine_stake, 2);
  268. }
  269. ?>
  270. <div class="bl">
  271. <div class="field">Stake Played:</div>
  272. <div class="value"><?=TestPDF::getValueHtml($play_machine_stake)?></div>
  273. </div>
  274. <div class="bl">
  275. <div class="field">Minutes Played:</div>
  276. <div class="value"><?=TestPDF::getValueHtml($values["play_minutes"] ?? "")?></div>
  277. </div>
  278. <?php
  279. $play_spent = $values["play_spent"] ?? "";
  280. if(!empty($play_spent)) $play_spent = "£" . number_format($play_spent, 2);
  281. ?>
  282. <div>
  283. <div class="field">Amount Spent:</div>
  284. <div class="value"><?=TestPDF::getValueHtml($play_spent)?></div>
  285. </div>
  286. </div>
  287. <section>
  288. <h3 class="subheader">ID Stage Reference</h3>
  289. <div>
  290. <div style="color: green;">1: Challenge on entry</div>
  291. <div style="color: green;">2: Challenge while browsing</div>
  292. <div style="color: orange;">3: Challenge during play</div>
  293. <div style="color: red;">4: Challenge after play</div>
  294. <div style="color: red;">5: No challenge</div>
  295. </div>
  296. </section>
  297. </div>
  298. <!-- Page 2 / Alcohol Test -->
  299. <div style="float: right; width: 49.25%">
  300. <?php
  301. if($receipt_config) {
  302. ?>
  303. <div class="subheader">
  304. <strong>Receipt</strong>
  305. </div>
  306. <img src="var:bar_receipt" width="<?=$receipt_config["width"]?>" height="<?=$receipt_config["height"]?>" alt="" />
  307. <?php
  308. }
  309. ?>
  310. </div>
  311. <div class="clear"></div>
  312. <h3 class="section">Other Test Details</h3>
  313. <section>
  314. <div class="subheader">
  315. <strong>Door Security Staff</strong>
  316. </div>
  317. <div class="bl">
  318. <div class="field">Present:</div>
  319. <div class="value"><?=TestPDF::getBooleanHtml($values["security_staff_present"] ?? false)?></div>
  320. </div>
  321. <div class="bl">
  322. <div class="field">Asked For ID:</div>
  323. <div class="value"><?=TestPDF::getBooleanHtml($values["security_staff_challenge"] ?? false)?></div>
  324. </div>
  325. <div class="bl">
  326. <div class="field">Line of Sight of Bar:</div>
  327. <div class="value"><?=TestPDF::getBooleanHtml($values["play_machine_line_of_sight"] ?? false)?></div>
  328. </div>
  329. </section>
  330. <div style="clear: both;"></div><br />
  331. <div>
  332. <div class="subheader">
  333. <strong>Additional Notes</strong>
  334. </div>
  335. <?=TestPDF::getValueHtml($test->additional_notes)?>
  336. </div>