src/JuridicusBundle/Entity/Export.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 Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. /**
  7. * Export
  8. */
  9. class Export extends InitModeEntity
  10. {
  11. const CLASSNAME = __CLASS__;
  12. /**
  13. * @var integer
  14. */
  15. private $id;
  16. /**
  17. * @var integer
  18. * @Assert\Type(type="integer")
  19. * @Assert\NotNull
  20. * @Assert\Range(min="1")
  21. */
  22. private $anzahl;
  23. /**
  24. * @var \DateTime
  25. * @Assert\Type(\DateTimeInterface::class)
  26. */
  27. private $created_at;
  28. /**
  29. * @var \JF\JuridicusBundle\Entity\Partner
  30. * @Assert\Valid
  31. */
  32. private $partner;
  33. /**
  34. * @var \Doctrine\Common\Collections\Collection
  35. */
  36. private $kunden;
  37. /**
  38. * @var integer
  39. */
  40. private $examen;
  41. /**
  42. * Constructor
  43. */
  44. public function __construct()
  45. {
  46. $this->kunden = new \Doctrine\Common\Collections\ArrayCollection();
  47. }
  48. /**
  49. * Get id
  50. *
  51. * @return integer
  52. */
  53. public function getId()
  54. {
  55. return $this->id;
  56. }
  57. /**
  58. * Set created_at
  59. *
  60. * @param \DateTime $createdAt
  61. * @return Export
  62. */
  63. public function setCreatedAt($createdAt)
  64. {
  65. $this->created_at = $createdAt;
  66. return $this;
  67. }
  68. /**
  69. * Get created_at
  70. *
  71. * @return \DateTime
  72. */
  73. public function getCreatedAt()
  74. {
  75. return $this->created_at;
  76. }
  77. /**
  78. * Get created_at
  79. *
  80. * @return \DateTime
  81. */
  82. public function getListString()
  83. {
  84. return sprintf( '%d Kunden am %s', $this->anzahl,
  85. $this->created_at ? $this->created_at->format('d.m.Y H:i:s') : '(Datum unbekannt)'
  86. );
  87. }
  88. /**
  89. * Set partner [OWNING SIDE]
  90. *
  91. * @param \JF\JuridicusBundle\Entity\Partner $partner
  92. * @return Export
  93. */
  94. public function setPartner(\JF\JuridicusBundle\Entity\Partner $partner = null)
  95. {
  96. $this->partner = $partner;
  97. return $this;
  98. }
  99. /**
  100. * Get partner
  101. *
  102. * @return \JF\JuridicusBundle\Entity\Partner
  103. */
  104. public function getPartner()
  105. {
  106. return $this->partner;
  107. }
  108. /**
  109. * Add kunden [OWNINGS SIDE]
  110. *
  111. * @param \JF\JuridicusBundle\Entity\Kunde $kunden
  112. * @return Export
  113. */
  114. public function addKunden(\JF\JuridicusBundle\Entity\Kunde $kunden = NULL)
  115. {
  116. $this->kunden[] = $kunden;
  117. $kunden->addExporte($this);
  118. return $this;
  119. }
  120. /**
  121. * Remove kunden
  122. *
  123. * @param \JF\JuridicusBundle\Entity\Kunde $kunden
  124. */
  125. public function removeKunden(\JF\JuridicusBundle\Entity\Kunde $kunden)
  126. {
  127. $this->kunden->removeElement($kunden);
  128. $kunden->removeExporte($this);
  129. }
  130. /**
  131. * Get kunden
  132. *
  133. * @return \Doctrine\Common\Collections\Collection
  134. */
  135. public function getKunden()
  136. {
  137. return $this->kunden;
  138. }
  139. /**
  140. * Set anzahl
  141. *
  142. * @param integer $anzahl
  143. * @return Export
  144. */
  145. public function setAnzahl($anzahl)
  146. {
  147. $this->anzahl = $anzahl;
  148. return $this;
  149. }
  150. /**
  151. * Get anzahl
  152. *
  153. * @return integer
  154. */
  155. public function getAnzahl()
  156. {
  157. return $this->anzahl;
  158. }
  159. /**
  160. * @ORM\PrePersist
  161. */
  162. public function setCreatedAtValue()
  163. {
  164. if (!$this->init_mode AND !isset($this->created_at))
  165. {
  166. $this->setCreatedAt(new \DateTime());
  167. }
  168. }
  169. /**
  170. * Set examen
  171. *
  172. * @param integer $examen
  173. * @return Export
  174. */
  175. public function setExamen($examen)
  176. {
  177. $this->examen = $examen;
  178. return $this;
  179. }
  180. /**
  181. * Get examen
  182. *
  183. * @return integer
  184. */
  185. public function getExamen()
  186. {
  187. return $this->examen;
  188. }
  189. public function __toString()
  190. {
  191. if (isset($this->id))
  192. {
  193. if (isset($this->created_at))
  194. {
  195. return sprintf('%s - %s', $this->created_at->format('d.m.Y H:i:s'), $this->getPartner()->getName());
  196. }
  197. else
  198. {
  199. return $this->getPartner()->getName();
  200. }
  201. }
  202. return 'Neuer Export';
  203. }
  204. }