src/JuridicusBundle/Entity/Pruefungsamt.php line 14

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. use Doctrine\Common\Collections\ArrayCollection;
  7. use \JF\JuridicusBundle\Entity\Gebuehr;
  8. /**
  9.  * Pruefungsamt
  10.  */
  11. class Pruefungsamt
  12. {
  13.     const CLASSNAME __CLASS__;
  14.     const BESTAND_KEIN 1;
  15.     const BESTAND_KLEIN 2;
  16.     const BESTAND_ANFANG 3;
  17.     const BESTAND_VOLL 4;
  18.     private static $bestand_options = array(
  19.         self::BESTAND_KEIN => 'Kein Bestand',
  20.         self::BESTAND_KLEIN => 'Kleiner Anfangsbestand',
  21.         self::BESTAND_ANFANG => 'Anfangsbestand',
  22.         self::BESTAND_VOLL => 'Bestand'
  23.     );
  24.     public static function getBestandOptions()
  25.     {
  26.         return self::$bestand_options;
  27.     }
  28.     public static function getBestandKeys()
  29.     {
  30.         return array_keys(self::$bestand_options);
  31.     }
  32.     /**
  33.      * @var integer
  34.      */
  35.     private $id;
  36.     /**
  37.      * @var string
  38.      * @Assert\NotNull
  39.      * @Assert\Length(max="64")
  40.      */
  41.     private $bezeichnung;
  42.     /**
  43.      * @var integer
  44.      * @Assert\NotNull
  45.      * @Assert\Choice(choices = {"1", "2"})
  46.      */
  47.     private $examen;
  48.     /**
  49.      * @var integer
  50.      * @Assert\NotNull()
  51.      * @Assert\Choice(callback="getBestandKeys")
  52.      */
  53.     private $bestand;
  54.     /**
  55.      * @var integer maximale Anzahl der Prüfer bei einer Prüfung
  56.      * @Assert\NotNull()
  57.      * @Assert\Type(type="integer")
  58.      * @Assert\Range(min = "1")
  59.      */
  60.     private $anzahl_pruefer;
  61.     /**
  62.      * @var integer maximale Anzahl der Kandidaten bei einer Prüfung
  63.      * @Assert\NotNull()
  64.      * @Assert\Type(type="integer")
  65.      * @Assert\Range(min = "1")
  66.      */
  67.     private $anzahl_kandidaten;
  68.     /**
  69.      * @var string
  70.      * @Assert\Length(max="32")
  71.      */
  72.     private $termine;
  73.     /**
  74.      * @var integer
  75.      * @Assert\NotNull
  76.      */
  77.     private $noten_options;
  78.     /**
  79.      * @var integer
  80.      */
  81.     private $wahlfach_noten_options;
  82.     /**
  83.      * @var string
  84.      * @Assert\Length(max="255")
  85.      */
  86.     private $import_url;
  87.     /**
  88.      * @var integer
  89.      * @Assert\Type(type="integer")
  90.      * @Assert\Range(min="0")
  91.      * @Assert\NotNull
  92.      */
  93.     private $kennziffer_parts;
  94.     /**
  95.      * @var boolean
  96.      * @Assert\NotNull
  97.      */
  98.     private $wahlfach;
  99.     /**
  100.      * @var \Doctrine\Common\Collections\Collection
  101.      */
  102.     private $bundeslaender;
  103.     /**
  104.      * @var \Doctrine\Common\Collections\Collection
  105.      */
  106.     private $pruefer;
  107.     /**
  108.      * @var \Doctrine\Common\Collections\Collection
  109.      */
  110.     private $gebuehren;
  111.     /**
  112.      * @var \Doctrine\Common\Collections\Collection
  113.      */
  114.     private $pruefungen;
  115.     /**
  116.      * Constructor
  117.      */
  118.     public function __construct()
  119.     {
  120.         $this->bundeslaender = new ArrayCollection();
  121.         $this->gebuehren = new ArrayCollection();
  122.         $this->pruefer = new ArrayCollection();
  123.         $this->pruefungen = new ArrayCollection();
  124.     }
  125.     /**
  126.      * Get id
  127.      *
  128.      * @return integer
  129.      */
  130.     public function getId()
  131.     {
  132.         return $this->id;
  133.     }
  134.     /**
  135.      * Set examen
  136.      *
  137.      * @param integer $examen
  138.      * @return Pruefungsamt
  139.      */
  140.     public function setExamen($examen)
  141.     {
  142.         $this->examen $examen;
  143.         return $this;
  144.     }
  145.     /**
  146.      * Get examen
  147.      *
  148.      * @return integer
  149.      */
  150.     public function getExamen()
  151.     {
  152.         return $this->examen;
  153.     }
  154.     /**
  155.      * Add bundeslaender [OWNING SIDE]
  156.      *
  157.      * @param Bundesland $bundeslaender
  158.      * @return Pruefungsamt
  159.      */
  160.     public function addBundeslaender(Bundesland $bundeslaender)
  161.     {
  162.         $this->bundeslaender[] = $bundeslaender;
  163.         $bundeslaender->addPruefungsaemter($this); // synchronously updating inverse side
  164.         return $this;
  165.     }
  166.     /**
  167.      * Remove bundeslaender [OWNING SIDE]
  168.      *
  169.      * @param Bundesland $bundeslaender
  170.      */
  171.     public function removeBundeslaender(Bundesland $bundeslaender)
  172.     {
  173.         $this->bundeslaender->removeElement($bundeslaender);
  174.         $bundeslaender->removePruefungsaemter($this); // synchronously updating inverse side
  175.     }
  176.     /**
  177.      * Get bundeslaender
  178.      *
  179.      * @return \Doctrine\Common\Collections\Collection
  180.      */
  181.     public function getBundeslaender()
  182.     {
  183.         return $this->bundeslaender;
  184.     }
  185.     /**
  186.      * Set anzahl_pruefer
  187.      *
  188.      * @param integer $anzahlPruefer
  189.      * @return Pruefungsamt
  190.      */
  191.     public function setAnzahlPruefer($anzahlPruefer)
  192.     {
  193.         $this->anzahl_pruefer $anzahlPruefer;
  194.         return $this;
  195.     }
  196.     /**
  197.      * Get anzahl_pruefer
  198.      *
  199.      * @return integer
  200.      */
  201.     public function getAnzahlPruefer()
  202.     {
  203.         return $this->anzahl_pruefer;
  204.     }
  205.     /**
  206.      * Set bestand
  207.      *
  208.      * @param integer $bestand
  209.      * @return Pruefungsamt
  210.      */
  211.     public function setBestand($bestand)
  212.     {
  213.         $this->bestand $bestand;
  214.         return $this;
  215.     }
  216.     /**
  217.      * Get bestand
  218.      *
  219.      * @return integer
  220.      */
  221.     public function getBestand()
  222.     {
  223.         return $this->bestand;
  224.     }
  225.     /**
  226.      *
  227.      * @return string
  228.      */
  229.     public function getBestandString()
  230.     {
  231.         if ($this->bestand)    {
  232.             return self::$bestand_options[$this->bestand];
  233.         } else {
  234.             return 'nicht verfügbar';
  235.         }
  236.     }
  237.     /**
  238.      * hat/hatte das Prüfungsamt zum gegebenen Zeitpunkt Vollbastand und eine Grundgebühr?
  239.      * 
  240.      * @param \DateTime $datum     
  241.      * @return boolean
  242.      */
  243.     public function hasVollbestand(\DateTime $datum null)
  244.     {
  245.         $grundGebuehr $this->getCurrentGebuehrByTyp(Gebuehr::TYP_GRUNDGEBUEHR$datum);
  246.                 
  247.         return $grundGebuehr && $this->bestand == self::BESTAND_VOLL;
  248.     }
  249.     /**
  250.      * Set anzahl_kandidaten
  251.      *
  252.      * @param integer $anzahlKandidaten
  253.      * @return Pruefungsamt
  254.      */
  255.     public function setAnzahlKandidaten($anzahlKandidaten)
  256.     {
  257.         $this->anzahl_kandidaten $anzahlKandidaten;
  258.         return $this;
  259.     }
  260.     /**
  261.      * Get anzahl_kandidaten
  262.      *
  263.      * @return integer
  264.      */
  265.     public function getAnzahlKandidaten()
  266.     {
  267.         return $this->anzahl_kandidaten;
  268.     }
  269.     /**
  270.      * Set termine
  271.      *
  272.      * @param string $termine
  273.      * @return Pruefungsamt
  274.      */
  275.     public function setTermine($termine)
  276.     {
  277.         $this->termine $termine;
  278.         return $this;
  279.     }
  280.     /**
  281.      * Get termine
  282.      *
  283.      * @return string
  284.      */
  285.     public function getTermine()
  286.     {
  287.         return $this->termine;
  288.     }
  289.     /**
  290.      * Add pruefer [INVERSE SIDE]
  291.      *
  292.      * @param Pruefer $pruefer
  293.      * @return Pruefungsamt
  294.      */
  295.     public function addPruefer(Pruefer $pruefer)
  296.     {
  297.         $this->pruefer[] = $pruefer;
  298.         return $this;
  299.     }
  300.     /**
  301.      * Remove pruefer [INVERSE SIDE]
  302.      *
  303.      * @param Pruefer $pruefer
  304.      */
  305.     public function removePruefer(Pruefer $pruefer)
  306.     {
  307.         $this->pruefer->removeElement($pruefer);
  308.     }
  309.     /**
  310.      * Get pruefer
  311.      *
  312.      * @return \Doctrine\Common\Collections\Collection
  313.      */
  314.     public function getPruefer()
  315.     {
  316.         return $this->pruefer;
  317.     }
  318.     /**
  319.      * Add pruefungen [INVERSE SIDE]
  320.      *
  321.      * @param Pruefung $pruefungen
  322.      * @return Pruefungsamt
  323.      */
  324.     public function addPruefungen(Pruefung $pruefungen)
  325.     {
  326.         $this->pruefungen[] = $pruefungen;
  327.         $pruefungen->setPruefungsamt($this);
  328.         return $this;
  329.     }
  330.     /**
  331.      * Remove pruefungen [INVERSE SIDE]
  332.      *
  333.      * @param Pruefung $pruefungen
  334.      */
  335.     public function removePruefungen(Pruefung $pruefungen)
  336.     {
  337.         $this->pruefungen->removeElement($pruefungen);
  338.         $pruefungen->setPruefungsamt(null);
  339.     }
  340.     /**
  341.      * Add gebuehren  [OWNING SIDE]
  342.      *
  343.      * @param Gebuehr $gebuehren
  344.      * @return Pruefungsamt
  345.      */
  346.     public function addGebuehren(Gebuehr $gebuehren)
  347.     {
  348.         $this->gebuehren[] = $gebuehren;
  349.         $gebuehren->addPruefungsaemter($this);  // keep inverse side synced
  350.         return $this;
  351.     }
  352.     /**
  353.      * Remove gebuehren [OWNING SIDE]
  354.      *
  355.      * @param Gebuehr $gebuehren
  356.      */
  357.     public function removeGebuehren(Gebuehr $gebuehren)
  358.     {
  359.         $this->gebuehren->removeElement($gebuehren);
  360.         $gebuehren->removePruefungsaemter($this);  // keep inverse side synced
  361.     }
  362.     /**
  363.      * Get gebuehren
  364.      *
  365.      * @return \Doctrine\Common\Collections\Collection
  366.      */
  367.     public function getGebuehren()
  368.     {
  369.         return $this->gebuehren;
  370.     }
  371.     /**
  372.      *
  373.      * @param integer $typ
  374.      * @param \DateTime $datum 
  375.      * @return \JF\JuridicusBundle\Entity\Gebuehr
  376.      */
  377.     public function getCurrentGebuehrByTyp($typ\DateTime $datum null)
  378.     {
  379.         if (!$datum) {
  380.             $datum = new \DateTime("today 00:00:00");
  381.         }
  382.         
  383.         $current_gebuehr null;
  384.         foreach ($this->getGebuehren() as $gebuehr) {
  385.             if ($gebuehr->getTyp() !== $typ || $gebuehr->getDatum() >= $datum) {
  386.                 continue;
  387.             }
  388.             if (!$current_gebuehr || $gebuehr->getDatum() > $current_gebuehr->getDatum()) {
  389.                 $current_gebuehr $gebuehr;
  390.             }
  391.         }
  392.         return $current_gebuehr;
  393.     }
  394.     /**
  395.      *
  396.      * @param integer $typ
  397.      * @param \DateTime $datum
  398.      * @return Gebuehr
  399.      */
  400.     public function getComingGebuehrByTyp($typ\DateTime $datum null)
  401.     {
  402.         if (!$datum) {
  403.             $datum = new \DateTime("today 00:00:00");
  404.         }
  405.         
  406.         $coming_gebuehr null;
  407.         foreach ($this->getGebuehren() as $gebuehr)    {
  408.             if ($gebuehr->getTyp() !== $typ or $gebuehr->getDatum() < $datum) {
  409.                 continue;
  410.             }
  411.             if (!$coming_gebuehr || $gebuehr->getDatum() < $comming_gebuehr->getDatum()) {
  412.                 $coming_gebuehr $gebuehr;
  413.             }
  414.         }
  415.         
  416.         return $coming_gebuehr;
  417.     }
  418.     /**
  419.      * Get pruefungen
  420.      *
  421.      * @return \Doctrine\Common\Collections\Collection
  422.      */
  423.     public function getPruefungen()
  424.     {
  425.         return $this->pruefungen;
  426.     }
  427.     /**
  428.      * Set kennziffer_format
  429.      *
  430.      * @param string $kennzifferFormat
  431.      * @return Pruefungsamt
  432.      */
  433.     public function setKennzifferFormat($kennzifferFormat)
  434.     {
  435.         $this->kennziffer_format $kennzifferFormat;
  436.         return $this;
  437.     }
  438.     /**
  439.      * Get kennziffer_format
  440.      *
  441.      * @return string
  442.      */
  443.     public function getKennzifferFormat()
  444.     {
  445.         return $this->kennziffer_format;
  446.     }
  447.     /**
  448.      * Set noten_options
  449.      *
  450.      * @param integer $notenOptions
  451.      * @return Pruefungsamt
  452.      */
  453.     public function setNotenOptions($notenOptions)
  454.     {
  455.         $this->noten_options $notenOptions;
  456.         return $this;
  457.     }
  458.     /**
  459.      * Get noten_options
  460.      *
  461.      * @return integer
  462.      */
  463.     public function getNotenOptions()
  464.     {
  465.         return $this->noten_options;
  466.     }
  467.     /**
  468.      *
  469.      * @param integer $option
  470.      * @return boolean
  471.      */
  472.     public function hasNotenOption($option)
  473.     {
  474.         return (bool) ($this->noten_options $option);
  475.     }
  476.     /**
  477.      * Set wahlfach_noten_options
  478.      *
  479.      * @param integer $wahlfachNotenOptions
  480.      * @return Pruefungsamt
  481.      */
  482.     public function setWahlfachNotenOptions($wahlfachNotenOptions)
  483.     {
  484.         $this->wahlfach_noten_options $wahlfachNotenOptions;
  485.         return $this;
  486.     }
  487.     /**
  488.      * Get wahlfach_noten_options
  489.      *
  490.      * @return integer
  491.      */
  492.     public function getWahlfachNotenOptions()
  493.     {
  494.         return $this->wahlfach_noten_options;
  495.     }
  496.     /**
  497.      * Set wahlfach
  498.      *
  499.      * @param boolean $wahlfach
  500.      * @return Pruefungsamt
  501.      */
  502.     public function setWahlfach($wahlfach)
  503.     {
  504.         $this->wahlfach $wahlfach;
  505.         return $this;
  506.     }
  507.     /**
  508.      * Get wahlfach
  509.      *
  510.      * @return boolean
  511.      */
  512.     public function getWahlfach()
  513.     {
  514.         return $this->wahlfach;
  515.     }
  516.     /**
  517.      * Set import_url
  518.      *
  519.      * @param string $importUrl
  520.      * @return Pruefungsamt
  521.      */
  522.     public function setImportUrl($importUrl)
  523.     {
  524.         $this->import_url $importUrl;
  525.         return $this;
  526.     }
  527.     /**
  528.      * Get import_url
  529.      *
  530.      * @return string
  531.      */
  532.     public function getImportUrl()
  533.     {
  534.         return $this->import_url;
  535.     }
  536.     /**
  537.      * Set bezeichnung
  538.      *
  539.      * @param string $bezeichnung
  540.      * @return Pruefungsamt
  541.      */
  542.     public function setBezeichnung($bezeichnung)
  543.     {
  544.         $this->bezeichnung $bezeichnung;
  545.         return $this;
  546.     }
  547.     /**
  548.      * Get bezeichnung
  549.      *
  550.      * @return string
  551.      */
  552.     public function getBezeichnung()
  553.     {
  554.         return $this->bezeichnung;
  555.     }
  556.     /**
  557.      * Set kennziffer_parts
  558.      *
  559.      * @param integer $kennzifferParts
  560.      * @return Pruefungsamt
  561.      */
  562.     public function setKennzifferParts($kennzifferParts)
  563.     {
  564.         $this->kennziffer_parts $kennzifferParts;
  565.         return $this;
  566.     }
  567.     /**
  568.      * Get kennziffer_parts
  569.      *
  570.      * @return integer
  571.      */
  572.     public function getKennzifferParts()
  573.     {
  574.         return $this->kennziffer_parts;
  575.     }
  576.     /**
  577.      * String Representation
  578.      *
  579.      * @return string
  580.      */
  581.     public function __toString()
  582.     {
  583.         $kuerzel $this->bundeslaender->map(function($bundesland) {
  584.                     return $bundesland->getKuerzel();
  585.         });
  586.                 
  587.         return sprintf('Prüfungsamt %s (%d. Examen) 'join('/'$kuerzel->toArray()), $this->examen);
  588.     }
  589.     /**
  590.      * Prüfungsämter sind connected, wenn sie in einem Bundesland übereinstimmen
  591.      *
  592.      * @param \JF\JuridicusBundle\Entity\Pruefungsamt $p
  593.      * @return bool
  594.      */
  595.     public function isConnected(Pruefungsamt $p)
  596.     {
  597.         foreach ($this->getBundeslaender() as $b) {
  598.             if ($p->getBundeslaender()->contains($b)) {
  599.                 return true;
  600.             }
  601.         }
  602.         
  603.         return false;
  604.     }
  605. }