test_pdf.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <?php
  2. $main_y = $pdf->GetY();
  3. // Retest info
  4. if($test->retest) {
  5. $pdf->SetLeftMargin(83);
  6. $pdf->SetY(10);
  7. $pdf->SetFont("Arial", "B", $header_font_size);
  8. $pdf->SetTextColor(0, 0, 255);
  9. $pdf->Cell(43, 4, "RETEST", 0, 1);
  10. $pdf->SetY($pdf->GetY() + 2);
  11. // Find previous test
  12. $previous_test = $test->getPreviousTest();
  13. if($previous_test) {
  14. $previous_test_pass_text = $previous_test->pass ? "PASS" : "FAIL";
  15. $previous_test_unix_start = Util::getUnixTimeFromUTC($previous_test->dts_start);
  16. $previous_test_date = date("d/m/Y", $previous_test_unix_start);
  17. $pdf->SetFont("Arial", "", $normal_font_size);
  18. $pdf->SetTextColor(0, 0, 0);
  19. $pdf->Cell(43, 4, "Prev. Test Date: $previous_test_date", 0, 1);
  20. $pdf->Cell(43, 4, "Prev. Test Result: $previous_test_pass_text", 0, 1);
  21. }
  22. }
  23. $pdf->SetLeftMargin(10);
  24. $pdf->SetY($main_y);
  25. // Header
  26. $pdf->SetTextColor(56, 87, 35);
  27. $pdf->SetFont("Arial", "B", $header_font_size);
  28. $pdf->Cell(190, 10, " Test Result", 0, 1, "L", true);
  29. // Pass/Fail
  30. $image_width = 130;
  31. if($test->pass) {
  32. $pdf->Image("public/img/pass.png", (210 - $image_width) / 2, $pdf->GetY() + 2, $image_width);
  33. }
  34. else {
  35. $pdf->Image("public/img/fail.png", (210 - $image_width) / 2, $pdf->GetY() + 2, $image_width);
  36. }
  37. $pdf->SetY($pdf->GetY() + 30);
  38. $pdf->SetTextColor(56, 87, 35);
  39. // Location / Tester Headers
  40. $pdf->SetFont("Arial", "B", $header_font_size);
  41. $tester_x = 150;
  42. $tester_y = $pdf->GetY();
  43. $pdf->Cell(135, 10, $location_text, 0, 1, "L", true);
  44. $pdf->SetY($pdf->GetY() + 2);
  45. $pdf->SetFont("Arial", "", $normal_font_size);
  46. $pdf->SetTextColor(0, 0, 0);
  47. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
  48. $pdf->Cell(30, $cell_height, "Region / Manager:", 0, 0);
  49. $pdf->SetX($pdf->GetX() + 5);
  50. $pdf->Write($cell_height, $location->region);
  51. $pdf->Write($cell_height, "/ ");
  52. $pdf->Write($cell_height, $location->area_manager);
  53. $pdf->SetY($pdf->GetY() + $cell_height);
  54. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
  55. $pdf->Cell(30, $cell_height, "Address:", 0, 0);
  56. $pdf->SetX($pdf->GetX() + 5);
  57. $pdf->MultiCell(100, $cell_height, $location->getDisplayAddress(["address_1", "address_2", "city"], "\n"), 0, 1);
  58. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
  59. $pdf->Cell(30, $cell_height, "Postcode:", 0, 0);
  60. $pdf->SetX($pdf->GetX() + 5);
  61. $pdf->Cell(100, $cell_height, $location->postal_code, 0, 1);
  62. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
  63. $pdf->Cell(30, $cell_height, "Shop Name - Left:", 0, 0);
  64. $pdf->SetX($pdf->GetX() + 5);
  65. $pdf->Cell(100, $cell_height, $test->shop_left, 0, 1);
  66. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
  67. $pdf->Cell(30, $cell_height, "Shop Name - Right:", 0, 0);
  68. $pdf->SetX($pdf->GetX() + 5);
  69. $pdf->Cell(100, $cell_height, $test->shop_right, 0, 1);
  70. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 135, $pdf->GetY());
  71. $test_details_y = $pdf->GetY();
  72. // Tester Info
  73. $pdf->SetXY($tester_x, $tester_y);
  74. $pdf->SetLeftMargin(150);
  75. $pdf->SetTextColor(56, 87, 35);
  76. $pdf->SetFont("Arial", "B", $header_font_size);
  77. $pdf->Cell(50, 10, " Tester", 0, 1, "L", true);
  78. $pdf->SetY($pdf->GetY() + 2);
  79. $pdf->SetFont("Arial", "", $normal_font_size);
  80. $pdf->SetTextColor(0, 0, 0);
  81. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 50, $pdf->GetY());
  82. $pdf->Cell(20, $cell_height, "Gender:", 0, 0);
  83. $pdf->SetX($pdf->GetX() + 5);
  84. $pdf->Cell(20, $cell_height, $tester->getGenderText(), 0, 1);
  85. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 50, $pdf->GetY());
  86. $pdf->Cell(20, $cell_height, "Attire:", 0, 1);
  87. $pdf->SetX(150);
  88. $pdf->SetFont("Arial", "", $small_font_size);
  89. $pdf->MultiCell(50, 4, $test->attire, 0, 1);
  90. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 50, $pdf->GetY());
  91. // Test Details
  92. $pdf->SetLeftMargin(10);
  93. $pdf->setXY(10, $test_details_y + 5 + 2);
  94. $pdf->SetTextColor(56, 87, 35);
  95. $pdf->SetFont("Arial", "B", $header_font_size);
  96. $pdf->Cell(190, 10, " Test Details", 0, 1, "L", true);
  97. $pdf->SetY($pdf->GetY() + 2);
  98. // Date / Time
  99. $id_requests_y = $pdf->GetY();
  100. $pdf->SetFont("Arial", "B", $normal_font_size);
  101. $pdf->SetTextColor(0, 0, 0);
  102. $pdf->Cell(95, $cell_height, "Date & Time", 0, 1);
  103. $pdf->SetY($pdf->GetY() + 2);
  104. $pdf->SetFont("Arial");
  105. $pdf->Cell(23, $cell_height, "Date");
  106. $pdf->Cell(23, $cell_height, "Entry");
  107. $pdf->Cell(23, $cell_height, "Exit");
  108. $pdf->Cell(23, $cell_height, "Duration", 0, 1);
  109. $pdf->SetFont("Arial", "", $small_font_size);
  110. $pdf->Cell(23, $cell_height, $date_start);
  111. $pdf->Cell(23, $cell_height, $time_start);
  112. $pdf->Cell(23, $cell_height, $time_end);
  113. $pdf->Cell(23, $cell_height, str_pad($diff->h, 2, "0", STR_PAD_LEFT) . ":" . str_pad($diff->i, 2, "0", STR_PAD_LEFT) . ":" . str_pad($diff->s, 2, "0", STR_PAD_LEFT), 0, 1);
  114. $pdf->SetY($pdf->GetY() + 2);
  115. // Staff
  116. $pdf->SetFont("Arial", "B", $normal_font_size);
  117. $pdf->Cell(95, $cell_height, "Staff", 0, 1);
  118. $pdf->SetY($pdf->GetY() + 2);
  119. $pdf->SetFont("Arial");
  120. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  121. $pdf->Cell(30, $cell_height, "Name:", 0, 0);
  122. $pdf->SetX($pdf->GetX() + 5);
  123. $pdf->Cell(57.5, $cell_height, $test->challenger_name, 0, 1);
  124. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  125. $pdf->Cell(30, $cell_height, "Gender:", 0, 0);
  126. $pdf->SetX($pdf->GetX() + 5);
  127. $pdf->Cell(57.5, $cell_height, $test->challenger_gender, 0, 1);
  128. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  129. $pdf->Cell(30, $cell_height, "Description:", 0, 1);
  130. $pdf->SetFont("Arial", "", $small_font_size);
  131. $pdf->MultiCell(90, 4, $test->challenger_description, 0, 1);
  132. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  133. $pdf->SetY($pdf->GetY() + 2);
  134. $pdf->SetFont("Arial", "B", $normal_font_size);
  135. $pdf->Cell(95, $cell_height, "Tester's Notes", 0, 1);
  136. $pdf->SetY($pdf->GetY() + 2);
  137. $pdf->SetFont("Arial");
  138. $pdf->SetFont("Arial", "", $small_font_size);
  139. $pdf->MultiCell(90, 4, Util::convertUTF8($test->additional_notes), 0, 1);
  140. $pdf->SetY($pdf->GetY() + 2);
  141. // Challenge
  142. $pdf->SetLeftMargin(107.5);
  143. $pdf->SetY($id_requests_y);
  144. $pdf->SetFont("Arial", "B", $normal_font_size);
  145. $pdf->Cell(95, $cell_height, "ID Request", 0, 1);
  146. $pdf->SetY($pdf->GetY() + 2);
  147. $pdf->SetFont("Arial");
  148. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  149. $pdf->Cell(30, $cell_height, "Result:", 0, 0);
  150. $pdf->SetX($pdf->GetX() + 5);
  151. $pdf->Cell(60, $cell_height, $test->getPassText(), 0, 1);
  152. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  153. $pdf->Cell(30, $cell_height, "ID Stage:", 0, 0);
  154. $pdf->SetX($pdf->GetX() + 5);
  155. $pdf->Cell(60, $cell_height, $test->challenge_stage . " - " . $test->getChallengeStageText(), 0, 1);
  156. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  157. $pdf->SetY($pdf->GetY() + 2);
  158. $pdf->SetFont("Arial", "", $small_font_size);
  159. $pdf->SetTextColor(0, 128, 0);
  160. $pdf->MultiCell(95, 4, "1: Challenge on entry", 0, 1);
  161. $pdf->SetTextColor(255, 128, 0);
  162. $pdf->MultiCell(95, 4, "2: Challenge while browsing
  163. 3: Challenge during play", 0, 1);
  164. $pdf->SetTextColor(255, 0, 0);
  165. $pdf->MultiCell(95, 4, "4: Challenge on exit
  166. 5: No challenge", 0, 1);
  167. $pdf->SetFont("Arial", "", $normal_font_size);
  168. $pdf->SetTextColor(0, 0, 0);
  169. $pdf->SetY($pdf->GetY() + 2);
  170. $pdf->SetFont("Arial", "", $normal_font_size);
  171. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  172. $pdf->Cell(30, $cell_height, "Eye Contact:", 0, 0);
  173. $pdf->SetX($pdf->GetX() + 5);
  174. $pdf->Cell(60, $cell_height, $test->challenger_eye_contact ? "Y" : "N", 0, 1);
  175. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  176. $pdf->Cell(95, $cell_height, "Description:", 0, 1);
  177. $pdf->SetFont("Arial", "", $small_font_size);
  178. $pdf->MultiCell(90, 4, $test->challenge_description, 0, 1);
  179. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  180. $pdf->SetY($pdf->GetY() + 2);
  181. // Details / Signage
  182. $pdf->SetFont("Arial", "B", $normal_font_size);
  183. $pdf->Cell(95, $cell_height, "Play Details & Signage", 0, 1);
  184. $pdf->SetY($pdf->GetY() + 2);
  185. $pdf->SetFont("Arial");
  186. $field_width = 50;
  187. $value_width = 40;
  188. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  189. $pdf->Cell($field_width, $cell_height, "Machine Played:", 0, 0);
  190. $pdf->SetX($pdf->GetX() + 5);
  191. $pdf->Cell($value_width, $cell_height, $values["play_machine"] ?? "N/A", 0, 1);
  192. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  193. $value = $values["play_jackpot"] ?? "N/A";
  194. if($value != "N/A") $value = "\xa3" . number_format($value);
  195. $pdf->Cell($field_width, $cell_height, "Jackpot Value:", 0, 0);
  196. $pdf->SetX($pdf->GetX() + 5);
  197. $pdf->Cell($value_width, $cell_height, $value, 0, 1);
  198. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  199. $value = $values["play_machine_stake"] ?? "N/A";
  200. if($value != "N/A") $value = "\xa3" . number_format($value, 2);
  201. $pdf->Cell($field_width, $cell_height, "Stake Played:", 0, 0);
  202. $pdf->SetX($pdf->GetX() + 5);
  203. $pdf->Cell($value_width, $cell_height, $value, 0, 1);
  204. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  205. $pdf->Cell($field_width, $cell_height, "Minutes Played:", 0, 0);
  206. $pdf->SetX($pdf->GetX() + 5);
  207. $pdf->Cell($value_width, $cell_height, $values["play_minutes"] ?? "N/A", 0, 1);
  208. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  209. $value = $values["play_spent"] ?? "N/A";
  210. if($value != "N/A") $value = "\xa3" . number_format($value, 2);
  211. $pdf->Cell($field_width, $cell_height, "Amount Spent:", 0, 0);
  212. $pdf->SetX($pdf->GetX() + 5);
  213. $pdf->Cell($value_width, $cell_height, $value, 0, 1);
  214. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  215. $pdf->Cell($field_width, $cell_height, "Think 21/25:", 0, 0);
  216. $pdf->SetX($pdf->GetX() + 5);
  217. $pdf->Cell($value_width, $cell_height, $values["think_21_25"] ?? "N/A", 0, 1);
  218. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  219. $value = $values["citizen_card_brochure_displayed"] ?? "";
  220. if(strlen($value) > 0) $value = $value ? "Yes" : "No";
  221. $pdf->Cell($field_width, $cell_height, "Citizen Card Brochure Displayed:", 0, 0);
  222. $pdf->SetX($pdf->GetX() + 5);
  223. $pdf->Cell($value_width, $cell_height, $value ?? "N/A", 0, 1);
  224. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  225. $value = $values["think_21_badge"] ?? "";
  226. if(strlen($value) > 0) $value = $value ? "Yes" : "No";
  227. $pdf->Cell($field_width, $cell_height, "Think 21/25 Badge Worn by Staff:", 0, 0);
  228. $pdf->SetX($pdf->GetX() + 5);
  229. $pdf->Cell($value_width, $cell_height, $value ?? "N/A", 0, 1);
  230. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  231. $value = $values["think_21_poster"] ?? "";
  232. if(strlen($value) > 0) $value = $value ? "Yes" : "No";
  233. $pdf->Cell($field_width, $cell_height, "Think 21/25 Posters Displayed:", 0, 0);
  234. $pdf->SetX($pdf->GetX() + 5);
  235. $pdf->Cell($value_width, $cell_height, $value ?? "N/A", 0, 1);
  236. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  237. $pdf->Cell($field_width, $cell_height, "Think 21/25 Poster Notes:", 0, 1);
  238. $pdf->SetFont("Arial", "", $small_font_size);
  239. $pdf->MultiCell(95, 4, $values["think_21_poster_notes"] ?? "N/A", 0, 1);
  240. $pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetX() + 92.5, $pdf->GetY());
  241. // Footer
  242. $pdf->SetLeftMargin(10);
  243. $pdf->SetY(265);
  244. $pdf->SetFillColor(0, 146, 69);
  245. $pdf->Rect($pdf->GetX(), $pdf->GetY(), 190, 1, "DF");
  246. $pdf->SetY($pdf->GetY() + 6);
  247. $pdf->SetFont("Arial", "B", $normal_font_size);
  248. $pdf->Cell(0, $cell_height, "Check Policy Limited");
  249. $pdf->SetY($pdf->GetY() + $cell_height);
  250. $pdf->SetFont("Arial", "", $normal_font_size);
  251. $pdf->Cell(0, $cell_height, "8 Market Street, Liskeard, Cornwall, PL14 3JJ");
  252. $pdf->SetY($pdf->GetY() + $cell_height);
  253. $pdf->Cell(0, $cell_height, "Company Number: 09506865");
  254. ?>