<?php
namespace JF\JuridicusBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Doctrine\Common\Collections\ArrayCollection;
use \JF\JuridicusBundle\Entity\Gebuehr;
/**
* Pruefungsamt
*/
class Pruefungsamt
{
const CLASSNAME = __CLASS__;
const BESTAND_KEIN = 1;
const BESTAND_KLEIN = 2;
const BESTAND_ANFANG = 3;
const BESTAND_VOLL = 4;
private static $bestand_options = array(
self::BESTAND_KEIN => 'Kein Bestand',
self::BESTAND_KLEIN => 'Kleiner Anfangsbestand',
self::BESTAND_ANFANG => 'Anfangsbestand',
self::BESTAND_VOLL => 'Bestand'
);
public static function getBestandOptions()
{
return self::$bestand_options;
}
public static function getBestandKeys()
{
return array_keys(self::$bestand_options);
}
/**
* @var integer
*/
private $id;
/**
* @var string
* @Assert\NotNull
* @Assert\Length(max="64")
*/
private $bezeichnung;
/**
* @var integer
* @Assert\NotNull
* @Assert\Choice(choices = {"1", "2"})
*/
private $examen;
/**
* @var integer
* @Assert\NotNull()
* @Assert\Choice(callback="getBestandKeys")
*/
private $bestand;
/**
* @var integer maximale Anzahl der Prüfer bei einer Prüfung
* @Assert\NotNull()
* @Assert\Type(type="integer")
* @Assert\Range(min = "1")
*/
private $anzahl_pruefer;
/**
* @var integer maximale Anzahl der Kandidaten bei einer Prüfung
* @Assert\NotNull()
* @Assert\Type(type="integer")
* @Assert\Range(min = "1")
*/
private $anzahl_kandidaten;
/**
* @var string
* @Assert\Length(max="32")
*/
private $termine;
/**
* @var integer
* @Assert\NotNull
*/
private $noten_options;
/**
* @var integer
*/
private $wahlfach_noten_options;
/**
* @var string
* @Assert\Length(max="255")
*/
private $import_url;
/**
* @var integer
* @Assert\Type(type="integer")
* @Assert\Range(min="0")
* @Assert\NotNull
*/
private $kennziffer_parts;
/**
* @var boolean
* @Assert\NotNull
*/
private $wahlfach;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $bundeslaender;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $pruefer;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $gebuehren;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $pruefungen;
/**
* Constructor
*/
public function __construct()
{
$this->bundeslaender = new ArrayCollection();
$this->gebuehren = new ArrayCollection();
$this->pruefer = new ArrayCollection();
$this->pruefungen = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set examen
*
* @param integer $examen
* @return Pruefungsamt
*/
public function setExamen($examen)
{
$this->examen = $examen;
return $this;
}
/**
* Get examen
*
* @return integer
*/
public function getExamen()
{
return $this->examen;
}
/**
* Add bundeslaender [OWNING SIDE]
*
* @param Bundesland $bundeslaender
* @return Pruefungsamt
*/
public function addBundeslaender(Bundesland $bundeslaender)
{
$this->bundeslaender[] = $bundeslaender;
$bundeslaender->addPruefungsaemter($this); // synchronously updating inverse side
return $this;
}
/**
* Remove bundeslaender [OWNING SIDE]
*
* @param Bundesland $bundeslaender
*/
public function removeBundeslaender(Bundesland $bundeslaender)
{
$this->bundeslaender->removeElement($bundeslaender);
$bundeslaender->removePruefungsaemter($this); // synchronously updating inverse side
}
/**
* Get bundeslaender
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBundeslaender()
{
return $this->bundeslaender;
}
/**
* Set anzahl_pruefer
*
* @param integer $anzahlPruefer
* @return Pruefungsamt
*/
public function setAnzahlPruefer($anzahlPruefer)
{
$this->anzahl_pruefer = $anzahlPruefer;
return $this;
}
/**
* Get anzahl_pruefer
*
* @return integer
*/
public function getAnzahlPruefer()
{
return $this->anzahl_pruefer;
}
/**
* Set bestand
*
* @param integer $bestand
* @return Pruefungsamt
*/
public function setBestand($bestand)
{
$this->bestand = $bestand;
return $this;
}
/**
* Get bestand
*
* @return integer
*/
public function getBestand()
{
return $this->bestand;
}
/**
*
* @return string
*/
public function getBestandString()
{
if ($this->bestand) {
return self::$bestand_options[$this->bestand];
} else {
return 'nicht verfügbar';
}
}
/**
* hat/hatte das Prüfungsamt zum gegebenen Zeitpunkt Vollbastand und eine Grundgebühr?
*
* @param \DateTime $datum
* @return boolean
*/
public function hasVollbestand(\DateTime $datum = null)
{
$grundGebuehr = $this->getCurrentGebuehrByTyp(Gebuehr::TYP_GRUNDGEBUEHR, $datum);
return $grundGebuehr && $this->bestand == self::BESTAND_VOLL;
}
/**
* Set anzahl_kandidaten
*
* @param integer $anzahlKandidaten
* @return Pruefungsamt
*/
public function setAnzahlKandidaten($anzahlKandidaten)
{
$this->anzahl_kandidaten = $anzahlKandidaten;
return $this;
}
/**
* Get anzahl_kandidaten
*
* @return integer
*/
public function getAnzahlKandidaten()
{
return $this->anzahl_kandidaten;
}
/**
* Set termine
*
* @param string $termine
* @return Pruefungsamt
*/
public function setTermine($termine)
{
$this->termine = $termine;
return $this;
}
/**
* Get termine
*
* @return string
*/
public function getTermine()
{
return $this->termine;
}
/**
* Add pruefer [INVERSE SIDE]
*
* @param Pruefer $pruefer
* @return Pruefungsamt
*/
public function addPruefer(Pruefer $pruefer)
{
$this->pruefer[] = $pruefer;
return $this;
}
/**
* Remove pruefer [INVERSE SIDE]
*
* @param Pruefer $pruefer
*/
public function removePruefer(Pruefer $pruefer)
{
$this->pruefer->removeElement($pruefer);
}
/**
* Get pruefer
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPruefer()
{
return $this->pruefer;
}
/**
* Add pruefungen [INVERSE SIDE]
*
* @param Pruefung $pruefungen
* @return Pruefungsamt
*/
public function addPruefungen(Pruefung $pruefungen)
{
$this->pruefungen[] = $pruefungen;
$pruefungen->setPruefungsamt($this);
return $this;
}
/**
* Remove pruefungen [INVERSE SIDE]
*
* @param Pruefung $pruefungen
*/
public function removePruefungen(Pruefung $pruefungen)
{
$this->pruefungen->removeElement($pruefungen);
$pruefungen->setPruefungsamt(null);
}
/**
* Add gebuehren [OWNING SIDE]
*
* @param Gebuehr $gebuehren
* @return Pruefungsamt
*/
public function addGebuehren(Gebuehr $gebuehren)
{
$this->gebuehren[] = $gebuehren;
$gebuehren->addPruefungsaemter($this); // keep inverse side synced
return $this;
}
/**
* Remove gebuehren [OWNING SIDE]
*
* @param Gebuehr $gebuehren
*/
public function removeGebuehren(Gebuehr $gebuehren)
{
$this->gebuehren->removeElement($gebuehren);
$gebuehren->removePruefungsaemter($this); // keep inverse side synced
}
/**
* Get gebuehren
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getGebuehren()
{
return $this->gebuehren;
}
/**
*
* @param integer $typ
* @param \DateTime $datum
* @return \JF\JuridicusBundle\Entity\Gebuehr
*/
public function getCurrentGebuehrByTyp($typ, \DateTime $datum = null)
{
if (!$datum) {
$datum = new \DateTime("today 00:00:00");
}
$current_gebuehr = null;
foreach ($this->getGebuehren() as $gebuehr) {
if ($gebuehr->getTyp() !== $typ || $gebuehr->getDatum() >= $datum) {
continue;
}
if (!$current_gebuehr || $gebuehr->getDatum() > $current_gebuehr->getDatum()) {
$current_gebuehr = $gebuehr;
}
}
return $current_gebuehr;
}
/**
*
* @param integer $typ
* @param \DateTime $datum
* @return Gebuehr
*/
public function getComingGebuehrByTyp($typ, \DateTime $datum = null)
{
if (!$datum) {
$datum = new \DateTime("today 00:00:00");
}
$coming_gebuehr = null;
foreach ($this->getGebuehren() as $gebuehr) {
if ($gebuehr->getTyp() !== $typ or $gebuehr->getDatum() < $datum) {
continue;
}
if (!$coming_gebuehr || $gebuehr->getDatum() < $comming_gebuehr->getDatum()) {
$coming_gebuehr = $gebuehr;
}
}
return $coming_gebuehr;
}
/**
* Get pruefungen
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPruefungen()
{
return $this->pruefungen;
}
/**
* Set kennziffer_format
*
* @param string $kennzifferFormat
* @return Pruefungsamt
*/
public function setKennzifferFormat($kennzifferFormat)
{
$this->kennziffer_format = $kennzifferFormat;
return $this;
}
/**
* Get kennziffer_format
*
* @return string
*/
public function getKennzifferFormat()
{
return $this->kennziffer_format;
}
/**
* Set noten_options
*
* @param integer $notenOptions
* @return Pruefungsamt
*/
public function setNotenOptions($notenOptions)
{
$this->noten_options = $notenOptions;
return $this;
}
/**
* Get noten_options
*
* @return integer
*/
public function getNotenOptions()
{
return $this->noten_options;
}
/**
*
* @param integer $option
* @return boolean
*/
public function hasNotenOption($option)
{
return (bool) ($this->noten_options & $option);
}
/**
* Set wahlfach_noten_options
*
* @param integer $wahlfachNotenOptions
* @return Pruefungsamt
*/
public function setWahlfachNotenOptions($wahlfachNotenOptions)
{
$this->wahlfach_noten_options = $wahlfachNotenOptions;
return $this;
}
/**
* Get wahlfach_noten_options
*
* @return integer
*/
public function getWahlfachNotenOptions()
{
return $this->wahlfach_noten_options;
}
/**
* Set wahlfach
*
* @param boolean $wahlfach
* @return Pruefungsamt
*/
public function setWahlfach($wahlfach)
{
$this->wahlfach = $wahlfach;
return $this;
}
/**
* Get wahlfach
*
* @return boolean
*/
public function getWahlfach()
{
return $this->wahlfach;
}
/**
* Set import_url
*
* @param string $importUrl
* @return Pruefungsamt
*/
public function setImportUrl($importUrl)
{
$this->import_url = $importUrl;
return $this;
}
/**
* Get import_url
*
* @return string
*/
public function getImportUrl()
{
return $this->import_url;
}
/**
* Set bezeichnung
*
* @param string $bezeichnung
* @return Pruefungsamt
*/
public function setBezeichnung($bezeichnung)
{
$this->bezeichnung = $bezeichnung;
return $this;
}
/**
* Get bezeichnung
*
* @return string
*/
public function getBezeichnung()
{
return $this->bezeichnung;
}
/**
* Set kennziffer_parts
*
* @param integer $kennzifferParts
* @return Pruefungsamt
*/
public function setKennzifferParts($kennzifferParts)
{
$this->kennziffer_parts = $kennzifferParts;
return $this;
}
/**
* Get kennziffer_parts
*
* @return integer
*/
public function getKennzifferParts()
{
return $this->kennziffer_parts;
}
/**
* String Representation
*
* @return string
*/
public function __toString()
{
$kuerzel = $this->bundeslaender->map(function($bundesland) {
return $bundesland->getKuerzel();
});
return sprintf('Prüfungsamt %s (%d. Examen) ', join('/', $kuerzel->toArray()), $this->examen);
}
/**
* Prüfungsämter sind connected, wenn sie in einem Bundesland übereinstimmen
*
* @param \JF\JuridicusBundle\Entity\Pruefungsamt $p
* @return bool
*/
public function isConnected(Pruefungsamt $p)
{
foreach ($this->getBundeslaender() as $b) {
if ($p->getBundeslaender()->contains($b)) {
return true;
}
}
return false;
}
}