test_pdf.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <?php
  2. /**
  3. * @var Template $template
  4. * @var array $values
  5. */
  6. // Values
  7. $cleanliness = $values["cleanliness"];
  8. switch($cleanliness) {
  9. case 1: $cleanliness = "Very dirty"; break;
  10. case 2: $cleanliness = "Dirty"; break;
  11. case 3: $cleanliness = "Adequate"; break;
  12. case 4: $cleanliness = "Clean"; break;
  13. case 5: $cleanliness = "Very clean"; break;
  14. }
  15. $staff_badge_worn = $values["staff_badge_worn"] ?? "";
  16. if(strlen($staff_badge_worn) == 0) $staff_badge_worn = "Don't know/Not approached";
  17. else $staff_badge_worn = ($staff_badge_worn == 0) ? "No" : "Yes";
  18. $staff_offered_drink = $values["staff_offered_drink"] ?? "";
  19. $staff_offered_drink = $staff_offered_drink ? "Yes" : "No";
  20. $staff_offered_promotion = $values["staff_offered_promotion"] ?? "";
  21. $staff_offered_promotion = $staff_offered_promotion ? "Yes" : "No";
  22. $staff_help = $values["staff_help"] ?? "";
  23. $staff_help = $staff_help ? "Yes" : "No";
  24. $staff_behaviour = $values["staff_behaviour"] ?? 0;
  25. switch($staff_behaviour) {
  26. case 1: $staff_behaviour = "Rude"; break;
  27. case 2: $staff_behaviour = "Slightly rude"; break;
  28. case 3: $staff_behaviour = "Neither rude or polite"; break;
  29. case 4: $staff_behaviour = "Polite and friendly"; break;
  30. case 5: $staff_behaviour = "Very polite and friendly"; break;
  31. default: $staff_behaviour = ""; break;
  32. }
  33. $staff_uniform = $values["staff_uniform"] ?? "";
  34. $staff_uniform = $staff_uniform ? "Yes" : "No";
  35. // COVID-19
  36. $covid_19 = in_array("COVID-19", $template->getKeys());
  37. // Location Photo
  38. $location_photo_path = $test->getDirectory() . "/location_photo.jpg";
  39. if(!file_exists($location_photo_path)) {
  40. $location_photo_path = "public/img/no_image_4_3.png";
  41. }
  42. $size = getimagesize($location_photo_path);
  43. list($image_width, $image_height) = $size;
  44. $width = "";
  45. $height = "";
  46. if($image_height > $image_width) {
  47. $height = "8cm";
  48. }
  49. else {
  50. $width = "100%";
  51. }
  52. $mpdf->imageVars["location_photo"] = file_get_contents($location_photo_path);
  53. ?>
  54. <div style="float: left; width: 70%; position: relative;">
  55. <h3 class="section"><?=htmlspecialchars($location_text)?></h3>
  56. <div class="bl">
  57. <div class="field"><?=htmlspecialchars($customer->region_field_name)?> / <?=htmlspecialchars($customer->area_manager_field_name)?>:</div>
  58. <div class="value">
  59. <?=TestPDF::getValueHtml($location->region)?> / <?=TestPDF::getValueHtml($location->area_manager)?>
  60. </div>
  61. </div>
  62. <div class="bl">
  63. <div class="field">Address:</div>
  64. <div class="value">
  65. <?=htmlspecialchars($location->address_1)?><br />
  66. <?php
  67. if($location->address_2) {
  68. ?>
  69. <?=htmlspecialchars($location->address_2)?><br />
  70. <?php
  71. }
  72. ?>
  73. <?=htmlspecialchars($location->city)?>
  74. </div>
  75. </div>
  76. <div class="bl">
  77. <div class="field">Postcode:</div>
  78. <div class="value"><?=htmlspecialchars($location->postal_code)?></div>
  79. </div>
  80. <div class="bl">
  81. <div class="field">Shop Name - Left:</div>
  82. <div class="value"><?=htmlspecialchars($test->shop_left)?></div>
  83. </div>
  84. <div>
  85. <div class="field">Shop Name - Right:</div>
  86. <div class="value"><?=htmlspecialchars($test->shop_right)?></div>
  87. </div>
  88. </div>
  89. <div style="float: right; width: 29%">
  90. <h3 class="section">Tester</h3>
  91. <div class="bl">
  92. <div class="field">Gender:</div>
  93. <div class="value"><?=htmlspecialchars($tester->getGenderText())?></div>
  94. </div>
  95. <div>
  96. <strong>Attire:</strong><br />
  97. <?=htmlspecialchars($test->attire)?>
  98. </div>
  99. </div>
  100. <div style="clear: both;"></div>
  101. <h3 class="section">Test Details</h3>
  102. <div style="float: left; width: 49.5%">
  103. <div class="subheader">
  104. <strong>Date &amp; Time</strong>
  105. </div>
  106. <div style="float: left; width: 24%">
  107. <strong>Date:</strong><br />
  108. <?=htmlspecialchars($date_start)?>
  109. </div>
  110. <div style="float: left; width: 24%">
  111. <strong>Entry:</strong><br />
  112. <?=htmlspecialchars($time_start)?>
  113. </div>
  114. <div style="float: left; width: 24%">
  115. <strong>Exit:</strong><br />
  116. <?=htmlspecialchars($time_end)?>
  117. </div>
  118. <div style="float: left; width: 24%">
  119. <strong>Duration:</strong><br />
  120. <?=htmlspecialchars($duration_text)?>
  121. </div>
  122. <div style="clear: both;"></div><br />
  123. <div class="subheader">
  124. <strong>Venue</strong>
  125. </div>
  126. <div class="wide-field-names">
  127. <div class="field">Cleanliness:</div>
  128. <div class="value"><?=TestPDF::getValueHtml($cleanliness)?></div>
  129. </div>
  130. <?php
  131. if($covid_19) {
  132. ?>
  133. <div style="clear: both;"></div><br />
  134. <div class="subheader">
  135. <strong>COVID-19</strong>
  136. </div>
  137. <div class="wide-field-names">
  138. <div class="field"><?=htmlspecialchars($field_name_label_map["entrance_hand_sanitiser"])?>:</div>
  139. <div class="value"><?=TestPDF::getBooleanHtml($values["entrance_hand_sanitiser"] ?? false)?></div>
  140. </div>
  141. <div class="wide-field-names">
  142. <div class="field"><?=htmlspecialchars($field_name_label_map["face_mask_offered"])?>:</div>
  143. <div class="value"><?=TestPDF::getBooleanHtml($values["face_mask_offered"] ?? 0)?></div>
  144. </div>
  145. <div class="wide-field-names">
  146. <div class="field"><?=htmlspecialchars($field_name_label_map["gloves_offered"])?>:</div>
  147. <div class="value"><?=TestPDF::getBooleanHtml($values["gloves_offered"] ?? 0)?></div>
  148. </div>
  149. <div class="wide-field-names">
  150. <div class="field"><?=htmlspecialchars($field_name_label_map["social_distancing_signage"])?>:</div>
  151. <div class="value"><?=TestPDF::getBooleanHtml($values["social_distancing_signage"] ?? 0)?></div>
  152. </div>
  153. <?php
  154. }
  155. ?>
  156. <br />
  157. <div class="subheader">
  158. <strong>Tester's Notes</strong>
  159. </div>
  160. <?=TestPDF::getValueHtml($test->additional_notes)?><br />
  161. <br />
  162. <div class="subheader">
  163. <strong>Location Photo</strong>
  164. </div>
  165. <img src="var:location_photo" width="<?=$width?>" height="<?=$height?>" />
  166. </div>
  167. <div style="float: right; width: 49.5%">
  168. <div class="wide-field-names">
  169. <div class="subheader">
  170. <strong>Staff Details</strong>
  171. </div>
  172. <div>
  173. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_badge_worn"])?>:</div>
  174. <div class="value"><?=TestPDF::getValueHtml($staff_badge_worn)?></div>
  175. </div>
  176. <div>
  177. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_name"])?>:</div>
  178. <div class="value"><?=TestPDF::getValueHtml($values["staff_name"] ?? "")?></div>
  179. </div>
  180. <hr />
  181. <div>
  182. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_offered_drink"])?>:</div>
  183. <div class="value"><?=TestPDF::getValueHtml($staff_offered_drink)?></div>
  184. </div>
  185. <div>
  186. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_offered_drink_name"])?>:</div>
  187. <div class="value"><?=TestPDF::getValueHtml($values["staff_offered_drink_name"] ?? "")?></div>
  188. </div>
  189. <hr />
  190. <div>
  191. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_offered_promotion"])?>:</div>
  192. <div class="value"><?=TestPDF::getValueHtml($staff_offered_promotion)?></div>
  193. </div>
  194. <div>
  195. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_offered_promotion_name"])?>:</div>
  196. <div class="value"><?=TestPDF::getValueHtml($values["staff_offered_promotion_name"] ?? "")?></div>
  197. </div>
  198. <hr />
  199. <div>
  200. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_help"])?>:</div>
  201. <div class="value"><?=TestPDF::getValueHtml($staff_help)?></div>
  202. </div>
  203. <div>
  204. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_behaviour"])?>:</div>
  205. <div class="value"><?=TestPDF::getValueHtml($staff_behaviour)?></div>
  206. </div>
  207. <hr />
  208. <div>
  209. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_uniform"])?>:</div>
  210. <div class="value"><?=TestPDF::getValueHtml($staff_uniform)?></div>
  211. </div>
  212. </div>
  213. <div>
  214. <strong><?=htmlspecialchars($field_name_label_map["staff_uniform_description"])?>:</strong><br />
  215. <?=TestPDF::getValueHtml($values["staff_uniform_description"] ?? "")?>
  216. </div>
  217. <?php
  218. if($covid_19) {
  219. ?>
  220. <hr />
  221. <div class="wide-field-names">
  222. <div>
  223. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_wearing_gloves"])?>:</div>
  224. <div class="value"><?=TestPDF::getBooleanHtml($values["staff_wearing_gloves"] ?? 0)?></div>
  225. </div>
  226. <div>
  227. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_wearing_face_mask"])?>:</div>
  228. <div class="value"><?=TestPDF::getBooleanHtml($values["staff_wearing_face_mask"] ?? 0)?></div>
  229. </div>
  230. <div>
  231. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_wearing_face_protection"])?>:</div>
  232. <div class="value"><?=TestPDF::getBooleanHtml($values["staff_wearing_face_protection"] ?? 0)?></div>
  233. </div>
  234. <div>
  235. <div class="field"><?=htmlspecialchars($field_name_label_map["staff_offered_cleaning"])?>:</div>
  236. <div class="value"><?=TestPDF::getBooleanHtml($values["staff_offered_cleaning"] ?? 0)?></div>
  237. </div>
  238. <div>
  239. <strong><?=htmlspecialchars($field_name_label_map["social_distancing_notes"])?>:</strong><br />
  240. <?=TestPDF::getValueHtml($values["social_distancing_notes"] ?? "")?>
  241. </div>
  242. </div>
  243. <?php
  244. }
  245. ?>
  246. </div>