test_pdf.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. // Location / Tester Headers
  3. $pdf->SetTextColor(56, 87, 35);
  4. $pdf->SetFont("Arial", "B", $header_font_size);
  5. $tester_x = 150;
  6. $tester_y = $pdf->GetY();
  7. $pdf->Cell(135, 10, $location_text, 0, 1, "L", true);
  8. $pdf->SetY($pdf->GetY() + 2);
  9. $pdf->SetFont("Arial", "", $normal_font_size);
  10. $pdf->SetTextColor(0, 0, 0);
  11. $pdf->Cell(30, $cell_height, "Region / Manager:", 0, 0);
  12. $pdf->SetX($pdf->GetX() + 5);
  13. $pdf->Write($cell_height, $location->region);
  14. $pdf->Write($cell_height, "/ ");
  15. $pdf->Write($cell_height, $location->area_manager);
  16. $pdf->SetY($pdf->GetY() + $cell_height);
  17. $pdf->Cell(30, $cell_height, "Address:", 0, 0);
  18. $pdf->SetX($pdf->GetX() + 5);
  19. $pdf->MultiCell(100, $cell_height, $location->getDisplayAddress(["address_1", "address_2", "city"], "\n"), 0, 1);
  20. $pdf->Cell(30, $cell_height, "Postcode:", 0, 0);
  21. $pdf->SetX($pdf->GetX() + 5);
  22. $pdf->Cell(100, $cell_height, $location->postal_code, 0, 1);
  23. $pdf->Cell(30, $cell_height, "Shop Name - Left:", 0, 0);
  24. $pdf->SetX($pdf->GetX() + 5);
  25. $pdf->Cell(100, $cell_height, $test->shop_left, 0, 1);
  26. $pdf->Cell(30, $cell_height, "Shop Name - Right:", 0, 0);
  27. $pdf->SetX($pdf->GetX() + 5);
  28. $pdf->Cell(100, $cell_height, $test->shop_right, 0, 1);
  29. $test_details_y = $pdf->GetY();
  30. // Tester Info
  31. $pdf->SetXY($tester_x, $tester_y);
  32. $pdf->SetLeftMargin(150);
  33. $pdf->SetTextColor(56, 87, 35);
  34. $pdf->SetFont("Arial", "B", $header_font_size);
  35. $pdf->Cell(50, 10, " Tester", 0, 1, "L", true);
  36. $pdf->SetY($pdf->GetY() + 2);
  37. $pdf->SetFont("Arial", "", $normal_font_size);
  38. $pdf->SetTextColor(0, 0, 0);
  39. $pdf->Cell(20, $cell_height, "Gender:", 0, 0);
  40. $pdf->SetX($pdf->GetX() + 5);
  41. $pdf->Cell(20, $cell_height, $tester->getGenderText(), 0, 1);
  42. $pdf->Cell(20, $cell_height, "Attire:", 0, 1);
  43. $pdf->SetX(150);
  44. $pdf->SetFont("Arial", "", $small_font_size);
  45. $pdf->MultiCell(50, 4, $test->attire, 0, 1);
  46. // Test Details
  47. $pdf->SetLeftMargin(10);
  48. $pdf->setXY(10, $test_details_y + 5 + 2);
  49. $pdf->SetTextColor(56, 87, 35);
  50. $pdf->SetFont("Arial", "B", $header_font_size);
  51. $pdf->Cell(190, 10, " Test Details", 0, 1, "L", true);
  52. $pdf->SetY($pdf->GetY() + 2);
  53. // Date / Time
  54. $id_requests_y = $pdf->GetY();
  55. $pdf->SetFont("Arial", "B", $normal_font_size);
  56. $pdf->SetTextColor(0, 0, 0);
  57. $pdf->Cell(95, $cell_height, "Date & Time", 0, 1);
  58. $pdf->SetFont("Arial");
  59. $pdf->Cell(23, $cell_height, "Date");
  60. $pdf->Cell(23, $cell_height, "Entry");
  61. $pdf->Cell(23, $cell_height, "Exit");
  62. $pdf->Cell(23, $cell_height, "Duration", 0, 1);
  63. $pdf->SetFont("Arial", "", $small_font_size);
  64. $pdf->Cell(23, $cell_height, $date_start);
  65. $pdf->Cell(23, $cell_height, $time_start);
  66. $pdf->Cell(23, $cell_height, $time_end);
  67. $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);
  68. $pdf->SetY($pdf->GetY() + $cell_height);
  69. // Venue Details
  70. $pdf->SetFont("Arial", "B", $normal_font_size);
  71. $pdf->Cell(95, $cell_height, "Venue", 0, 1);
  72. $pdf->SetFont("Arial");
  73. $cleanliness = $values["cleanliness"];
  74. switch($cleanliness) {
  75. case 1: $cleanliness = "Very dirty"; break;
  76. case 2: $cleanliness = "Dirty"; break;
  77. case 3: $cleanliness = "Adequate"; break;
  78. case 4: $cleanliness = "Clean"; break;
  79. case 5: $cleanliness = "Very clean"; break;
  80. }
  81. $pdf->Cell(30, $cell_height, "Cleanliness:", 0, 0);
  82. $pdf->SetX($pdf->GetX() + 5);
  83. $pdf->Cell(57.5, $cell_height, $cleanliness, 0, 1);
  84. $pdf->SetY($pdf->GetY() + $cell_height);
  85. $pdf->SetFont("Arial", "B", $normal_font_size);
  86. $pdf->Cell(95, $cell_height, "Tester's Notes", 0, 1);
  87. $pdf->SetFont("Arial");
  88. $pdf->SetFont("Arial", "", $small_font_size);
  89. $pdf->MultiCell(90, 4, Util::convertUTF8($test->additional_notes), 0, 1);
  90. $pdf->SetY($pdf->GetY() + $cell_height);
  91. // Location photo
  92. $pdf->SetFont("Arial", "B", $normal_font_size);
  93. $pdf->Cell(95, $cell_height, "Location Photo", 0, 1);
  94. $pdf->SetFont("Arial");
  95. $location_photo_path = $test->getDirectory() . "/location_photo.jpg";
  96. $size = getimagesize($location_photo_path);
  97. list($image_width, $image_height) = $size;
  98. $width = 0;
  99. $height = 0;
  100. if($image_height > $image_width) {
  101. $height = 70;
  102. }
  103. else {
  104. $width = 70;
  105. }
  106. $pdf->Image($location_photo_path, $pdf->GetX(), $pdf->GetY(), $width, $height);
  107. // Staff Details
  108. $pdf->SetLeftMargin(107.5);
  109. $pdf->SetY($id_requests_y);
  110. $pdf->SetFont("Arial", "B", $normal_font_size);
  111. $pdf->Cell(95, $cell_height, "Staff Details", 0, 1);
  112. $pdf->SetFont("Arial");
  113. $value = $values["staff_badge_worn"] ?? "";
  114. if(strlen($value) == 0) $value = "Don't know/Not approached";
  115. else $value = ($value == 0) ? "No" : "Yes";
  116. $pdf->Cell(30, $cell_height, "Staff Badge Worn:", 0, 0);
  117. $pdf->SetX($pdf->GetX() + 5);
  118. $pdf->Cell(60, $cell_height, $value, 0, 1);
  119. $value = $values["staff_name"] ?? "";
  120. $pdf->Cell(30, $cell_height, "Staff Name:", 0, 0);
  121. $pdf->SetX($pdf->GetX() + 5);
  122. $pdf->Cell(60, $cell_height, $value, 0, 1);
  123. $pdf->SetY($pdf->GetY() + $cell_height);
  124. $value = $values["drink_offered"] ?? "";
  125. $value = $value ? "Yes" : "No";
  126. $pdf->Cell(30, $cell_height, "Drink Offered:", 0, 0);
  127. $pdf->SetX($pdf->GetX() + 5);
  128. $pdf->Cell(60, $cell_height, $value, 0, 1);
  129. $value = $values["staff_offered_drink_name"] ?? "";
  130. $value = $value ?: "No drink offered";
  131. $pdf->Cell(30, $cell_height, "Drink Name:", 0, 0);
  132. $pdf->SetX($pdf->GetX() + 5);
  133. $pdf->Cell(60, $cell_height, $value, 0, 1);
  134. $pdf->SetY($pdf->GetY() + $cell_height);
  135. $value = $values["staff_offered_promotion"] ?? "";
  136. $value = $value ? "Yes" : "No";
  137. $pdf->Cell(30, $cell_height, "Promotion Offered:", 0, 0);
  138. $pdf->SetX($pdf->GetX() + 5);
  139. $pdf->Cell(60, $cell_height, $value, 0, 1);
  140. $value = $values["staff_offered_promotion_name"] ?? "";
  141. $value = $value ?: "No promotion offered";
  142. $pdf->Cell(95, $cell_height, "Promotion Name:", 0, 1);
  143. $pdf->SetFont("Arial", "", $small_font_size);
  144. $pdf->MultiCell(90, 4, $value, 0, 1);
  145. $pdf->SetY($pdf->GetY() + $cell_height);
  146. $value = $values["staff_help"] ?? "";
  147. $value = $value ? "Yes" : "No";
  148. $pdf->Cell(30, $cell_height, "Machine Explanation:", 0, 0);
  149. $pdf->SetX($pdf->GetX() + 5);
  150. $pdf->Cell(60, $cell_height, $value, 0, 1);
  151. $pdf->SetY($pdf->GetY() + $cell_height);
  152. $value = $values["staff_behaviour"];
  153. switch($value) {
  154. case 1: $value = "Rude"; break;
  155. case 2: $value = "Slightly rude"; break;
  156. case 3: $value = "Neither rude or polite"; break;
  157. case 4: $value = "Polite and friendly"; break;
  158. case 5: $value = "Very polite and friendly"; break;
  159. default: $value = "N/A"; break;
  160. }
  161. $pdf->Cell(30, $cell_height, "Staff Behaviour:", 0, 0);
  162. $pdf->SetX($pdf->GetX() + 5);
  163. $pdf->Cell(60, $cell_height, $value, 0, 1);
  164. $pdf->SetY($pdf->GetY() + $cell_height);
  165. $value = $values["staff_uniform"] ?? "";
  166. $value = $value ? "Yes" : "No";
  167. $pdf->Cell(30, $cell_height, "Staff Uniform:", 0, 0);
  168. $pdf->SetX($pdf->GetX() + 5);
  169. $pdf->Cell(60, $cell_height, $value, 0, 1);
  170. $value = $values["staff_uniform_description"] ?? "";
  171. $value = $value ?: "N/A";
  172. $pdf->Cell(95, $cell_height, "Staff Uniform Description:", 0, 1);
  173. $pdf->SetFont("Arial", "", $small_font_size);
  174. $pdf->MultiCell(90, 4, $value, 0, 1);
  175. // Footer
  176. $pdf->SetLeftMargin(10);
  177. $pdf->SetY(265);
  178. $pdf->SetFillColor(0, 146, 69);
  179. $pdf->Rect($pdf->GetX(), $pdf->GetY(), 190, 1, "DF");
  180. $pdf->SetY($pdf->GetY() + 6);
  181. $pdf->SetFont("Arial", "B", $normal_font_size);
  182. $pdf->Cell(0, $cell_height, "Check Policy Limited");
  183. $pdf->SetY($pdf->GetY() + $cell_height);
  184. $pdf->SetFont("Arial", "", $normal_font_size);
  185. $pdf->Cell(0, $cell_height, "8 Market Street, Liskeard, Cornwall, PL14 3JJ");
  186. $pdf->SetY($pdf->GetY() + $cell_height);
  187. $pdf->Cell(0, $cell_height, "Company Number: 09506865");
  188. ?>