src/JuridicusBundle/Entity/ProtokollHtml.php line 12

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use JF\JuridicusBundle\Entity\Pruefung;
  6. /**
  7. * ProtokollHtml
  8. */
  9. class ProtokollHtml extends InitModeEntity
  10. {
  11. const CLASSNAME = __CLASS__;
  12. /**
  13. * @var integer
  14. */
  15. private $id;
  16. /**
  17. * @var \DateTime
  18. * @Assert\Type(\DateTimeInterface::class)
  19. */
  20. private $datum;
  21. /**
  22. * @var integer
  23. * @Assert\Type(type="integer")
  24. * @Assert\NotNull
  25. * @Assert\Range(min="1", max="2")
  26. */
  27. private $examen;
  28. /**
  29. * @var string
  30. * @Assert\Length(max="10")
  31. * @Assert\NotNull
  32. */
  33. private $datum_format = '';
  34. /**
  35. * @var string
  36. * @Assert\NotBlank
  37. */
  38. private $html_code;
  39. /**
  40. * @var \DateTime
  41. * @Assert\Type(\DateTimeInterface::class)
  42. */
  43. private $updated_at;
  44. /**
  45. * @var \JF\JuridicusBundle\Entity\Pruefer
  46. * @Assert\NotBlank
  47. * @Assert\Valid
  48. */
  49. private $pruefer;
  50. /**
  51. * Get id
  52. *
  53. * @return integer
  54. */
  55. public function getId()
  56. {
  57. return $this->id;
  58. }
  59. /**
  60. * Set datum
  61. *
  62. * @param \DateTime $datum
  63. * @return ProtokollHtml
  64. */
  65. public function setDatum($datum)
  66. {
  67. $this->datum = $datum;
  68. return $this;
  69. }
  70. /**
  71. * Get datum
  72. *
  73. * @return \DateTime
  74. */
  75. public function getDatum()
  76. {
  77. return $this->datum;
  78. }
  79. /**
  80. * Set datum_format
  81. *
  82. * @param string $datumFormat
  83. * @return ProtokollHtml
  84. */
  85. public function setDatumFormat($datumFormat)
  86. {
  87. $this->datum_format = (string) $datumFormat;
  88. return $this;
  89. }
  90. /**
  91. *
  92. * @return string
  93. */
  94. public function getFormattedDatum()
  95. {
  96. if ($this->datum) {
  97. return $this->datum->format($this->datum_format);
  98. }
  99. return '';
  100. }
  101. /**
  102. * Get datum_format
  103. *
  104. * @return string
  105. */
  106. public function getDatumFormat()
  107. {
  108. return $this->datum_format;
  109. }
  110. /**
  111. * Set examen
  112. *
  113. * @param integer $examen
  114. * @return ProtokollHtml
  115. */
  116. public function setExamen($examen)
  117. {
  118. $this->examen = $examen;
  119. return $this;
  120. }
  121. /**
  122. * Get examen
  123. *
  124. * @return integer
  125. */
  126. public function getExamen()
  127. {
  128. return $this->examen;
  129. }
  130. /**
  131. * Set html_code
  132. *
  133. * @param string $htmlCode
  134. * @return ProtokollHtml
  135. */
  136. public function setHtmlCode($htmlCode)
  137. {
  138. $this->html_code = $htmlCode;
  139. return $this;
  140. }
  141. /**
  142. * Get html_code
  143. *
  144. * @return string
  145. */
  146. public function getHtmlCode()
  147. {
  148. return $this->html_code;
  149. }
  150. /**
  151. * Set updated_at
  152. *
  153. * @param \DateTime $updatedAt
  154. * @return ProtokollHtml
  155. */
  156. public function setUpdatedAt($updatedAt)
  157. {
  158. $this->updated_at = $updatedAt;
  159. return $this;
  160. }
  161. /**
  162. * Get updated_at
  163. *
  164. * @return \DateTime
  165. */
  166. public function getUpdatedAt()
  167. {
  168. return $this->updated_at;
  169. }
  170. /**
  171. * Set pruefer [OWNING SIDE]
  172. *
  173. * @param \JF\JuridicusBundle\Entity\Pruefer $pruefer
  174. * @return ProtokollHtml
  175. */
  176. public function setPruefer(\JF\JuridicusBundle\Entity\Pruefer $pruefer = null)
  177. {
  178. $this->pruefer = $pruefer;
  179. return $this;
  180. }
  181. /**
  182. * Get pruefer
  183. *
  184. * @return \JF\JuridicusBundle\Entity\Pruefer
  185. */
  186. public function getPruefer()
  187. {
  188. return $this->pruefer;
  189. }
  190. /**
  191. *
  192. */
  193. public function getPruefungsamt()
  194. {
  195. if (empty($this->id))
  196. {
  197. return null;
  198. }
  199. foreach($this->getPruefer()->getPruefungsaemter() as $pa)
  200. {
  201. if ($pa->getExamen() == $this->examen)
  202. {
  203. return $pa;
  204. }
  205. }
  206. return null;
  207. }
  208. /**
  209. * string representation of the entity
  210. *
  211. * @return string
  212. */
  213. public function __toString()
  214. {
  215. if ($this->id)
  216. {
  217. return sprintf('%s - %s.Examen', $this->getPruefer()->getFullText(), $this->examen);
  218. }
  219. return 'Neues HTML-Protokoll';
  220. }
  221. /**
  222. * addToPdf
  223. *
  224. * @param \TCPDF $pdf
  225. */
  226. public function addToPdf( \TCPDF & $pdf )
  227. {
  228. $pdf->writeHTML($this->html_code, true, 0, true, 0);
  229. $pdf->lastPage();
  230. }
  231. }