test_pdf.php 10 KB

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