test_pdf.php 7.9 KB

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