src/JuridicusBundle/Entity/Gebuehr.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. * Gebuehr
  8. */
  9. class Gebuehr
  10. {
  11. const CLASSNAME = __CLASS__;
  12. const TYP_GRUNDGEBUEHR = 1;
  13. const TYP_WAHLFACHGEBUEHR = 2;
  14. const TYP_STRAFGEBUEHR = 3;
  15. /**
  16. * @var array
  17. */
  18. private static $typen = array(
  19. self::TYP_GRUNDGEBUEHR => 'Grundgebühr',
  20. self::TYP_WAHLFACHGEBUEHR => 'Wahlfachgebühr',
  21. self::TYP_STRAFGEBUEHR => 'Strafgebühr'
  22. );
  23. public static function getTypOptions()
  24. {
  25. return self::$typen;
  26. }
  27. public static function getTypKeys()
  28. {
  29. return array_keys(self::$typen);
  30. }
  31. /**
  32. * @var integer
  33. */
  34. private $id;
  35. /**
  36. * @var integer
  37. * @Assert\Choice(callback = "getTypKeys")
  38. */
  39. private $typ;
  40. /**
  41. * @var float
  42. * @Assert\Range(min="0")
  43. */
  44. private $betrag;
  45. /**
  46. * @var \DateTime
  47. * @Assert\Type(\DateTimeInterface::class)
  48. */
  49. private $datum;
  50. /**
  51. * @var \Doctrine\Common\Collections\Collection
  52. */
  53. private $pruefungsaemter;
  54. /**
  55. * Get id
  56. *
  57. * @return integer
  58. */
  59. public function getId()
  60. {
  61. return $this->id;
  62. }
  63. /**
  64. * Set typ
  65. *
  66. * @param integer $typ
  67. * @return Gebuehr
  68. */
  69. public function setTyp($typ)
  70. {
  71. $this->typ = $typ;
  72. return $this;
  73. }
  74. /**
  75. * Get typ
  76. *
  77. * @return integer
  78. */
  79. public function getTyp()
  80. {
  81. return $this->typ;
  82. }
  83. /**
  84. * Get typ_string
  85. *
  86. * @return string
  87. */
  88. public function getTypString()
  89. {
  90. return self::$typen[$this->typ];
  91. }
  92. /**
  93. * Set datum
  94. *
  95. * @param \DateTime $datum
  96. * @return Gebuehr
  97. */
  98. public function setDatum(\DateTime $datum)
  99. {
  100. $this->datum = $datum;
  101. return $this;
  102. }
  103. /**
  104. * Get datum
  105. *
  106. * @return \DateTime
  107. */
  108. public function getDatum()
  109. {
  110. return $this->datum;
  111. }
  112. /**
  113. * Set betrag
  114. *
  115. * @param float $betrag
  116. * @return Gebuehr
  117. */
  118. public function setBetrag($betrag)
  119. {
  120. $this->betrag = $betrag;
  121. return $this;
  122. }
  123. /**
  124. * Get betrag
  125. *
  126. * @return float
  127. */
  128. public function getBetrag()
  129. {
  130. return $this->betrag;
  131. }
  132. public function __toString()
  133. {
  134. return ($this->betrag && $this->datum && self::$typen[$this->typ]) ? sprintf( '%.2f € %s ab %s', $this->betrag, self::$typen[$this->typ], $this->datum->format('d.m.Y') ) : "";
  135. //return ($this->betrag && $this->datum && in_array($this->typ, self::$typen)) ? sprintf( '%.2f € %s ab %s', $this->betrag, $this->typ, $this->datum->format('d.m.Y') ) : "";
  136. }
  137. /**
  138. * Constructor
  139. */
  140. public function __construct()
  141. {
  142. $this->pruefungsaemter = new \Doctrine\Common\Collections\ArrayCollection();
  143. }
  144. /**
  145. * Add pruefungsaemter [INVERSE SIDE]
  146. *
  147. * @param \JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter
  148. * @return Gebuehr
  149. */
  150. public function addPruefungsaemter(\JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter)
  151. {
  152. $this->pruefungsaemter[] = $pruefungsaemter;
  153. return $this;
  154. }
  155. /**
  156. * Remove pruefungsaemter [INVERSE SIDE]
  157. *
  158. * @param \JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter
  159. */
  160. public function removePruefungsaemter(\JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter)
  161. {
  162. $this->pruefungsaemter->removeElement($pruefungsaemter);
  163. }
  164. /**
  165. * Get pruefungsaemter
  166. *
  167. * @return \Doctrine\Common\Collections\Collection
  168. */
  169. public function getPruefungsaemter()
  170. {
  171. return $this->pruefungsaemter;
  172. }
  173. }