<?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\Pruefung;
/**
* ProtokollInfothekPruefung
*/
class ProtokollInfothekPruefung extends InitModeEntity
{
const CLASSNAME = __CLASS__;
/**
* @var integer
*/
private $id;
/**
* @var integer
*/
private $mask;
/**
* @var \DateTime
* @Assert\Type(\DateTimeInterface::class)
*/
private $datum;
/**
* @var string
* @Assert\NotBlank(groups={"finish"})
* @Assert\Length(max="64")
*/
private $ort;
/**
* @var string
* @Assert\Length(max="48")
*/
private $wahlfach;
/**
* @var string
* @Assert\Length(max="48")
*/
private $aktenvortrag;
/**
* @var integer
* @Assert\Type(type="integer")
* @Assert\Range(min="1",max="2")
* @Assert\NotNull(message="Bitte Examen angeben")
*/
private $examen;
/**
* @var boolean
* @Assert\NotNull()
*/
private $wahlfachpruefung = false;
/**
* @var boolean
* @Assert\NotNull(message="Bitte Aktiv-Status angeben")
*/
private $aktiv = false;
/**
* @var boolean
* @Assert\NotNull(message="Bitte Fertig-Status angeben")
*/
private $fertig = false;
/**
* @var \DateTime
*/
private $fertig_at = null;
/**
* @var boolean
*/
private $pdf_need_update = true;
/**
* @var boolean
*/
private $send_last_minute;
/**
* @var \DateTime
* @Assert\Type(\DateTimeInterface::class)
*/
private $created_at;
/**
* @var \DateTime
* @Assert\Type(\DateTimeInterface::class)
*/
private $updated_at;
/**
* @var \JF\JuridicusBundle\Entity\Pruefung
*/
private $pruefung;
/**
* @var \JF\JuridicusBundle\Entity\KundePruefung
*/
private $kunde_pruefung;
/**
* @var \JF\JuridicusBundle\Entity\PdfProtokollInfothekPruefung
*/
private $pdf_protokoll_infothek_pruefung;
/**
* @var \Doctrine\Common\Collections\Collection
* @Assert\Valid(traverse=true)
*/
private $protokoll_infothek_pruefer;
/**
* @var \Doctrine\Common\Collections\Collection
* @Assert\Valid(traverse=true)
*/
private $protokoll_infothek_noten;
/**
*
* @var \JF\JuridicusBundle\Entity\ProtokollKlausur
* @Assert\Valid()
*/
private $protokoll_klausur;
/**
*
* @var \JF\JuridicusBundle\Entity\ProtokollAktenvortrag
* @Assert\Valid()
*/
private $protokoll_aktenvortrag;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $similarities;
/**
* Constructor
*/
public function __construct()
{
$this->protokoll_infothek_pruefer = new ArrayCollection();
$this->protokoll_infothek_noten = new ArrayCollection();
$this->similarities = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set datum
*
* @param \DateTime $datum
* @return ProtokollInfothekPruefung
*/
public function setDatum(\DateTime $datum = null)
{
$this->datum = $datum;
return $this;
}
/**
* Get datum
*
* @return \DateTime
*/
public function getDatum()
{
return $this->datum;
}
/**
* Set ort
*
* @param string $ort
* @return ProtokollInfothekPruefung
*/
public function setOrt($ort)
{
$this->ort = $ort;
return $this;
}
/**
* Get ort
*
* @return string
*/
public function getOrt()
{
return $this->ort;
}
/**
* Set wahlfach
*
* @param string $wahlfach
* @return ProtokollInfothekPruefung
*/
public function setWahlfach($wahlfach)
{
$this->wahlfach = $wahlfach;
return $this;
}
/**
* Get wahlfach
*
* @return string
*/
public function getWahlfach()
{
return $this->wahlfach;
}
/**
* Set aktenvortrag
*
* @param string $aktenvortrag
* @return ProtokollInfothekPruefung
*/
public function setAktenvortrag($aktenvortrag)
{
$this->aktenvortrag = $aktenvortrag;
if ($this->getProtokollAktenvortrag()) {
$this->getProtokollAktenvortrag()->setFach($aktenvortrag);
}
return $this;
}
/**
* Get aktenvortrag
*
* @return string
*/
public function getAktenvortrag()
{
return $this->aktenvortrag;
}
/**
* Set aktiv
*
* @param boolean $aktiv
* @return ProtokollInfothekPruefung
*/
public function setAktiv($aktiv = true)
{
$this->aktiv = (bool) $aktiv;
return $this;
}
/**
* Get aktiv
*
* @return boolean
*/
public function getAktiv()
{
return $this->aktiv;
}
/**
* Set fertig
*
* @param boolean $fertig
* @return ProtokollInfothekPruefung
*/
public function setFertig($fertig = true)
{
$this->fertig = (bool) $fertig;
if ($this->getProtokollAktenvortrag()) {
$this->getProtokollAktenvortrag()->setFertig($fertig);
}
if ($this->getProtokollKlausur()) {
$this->getProtokollKlausur()->setFertig($fertig);
}
return $this;
}
/**
* Get fertig
*
* @return boolean
*/
public function getFertig()
{
return $this->fertig;
}
/**
* Set created_at
*
* @param \DateTime $createdAt
* @return ProtokollInfothekPruefung
*/
public function setCreatedAt(\DateTime $createdAt = null)
{
$this->created_at = $createdAt;
return $this;
}
/**
* Get created_at
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->created_at;
}
/**
* Set updated_at
*
* @param \DateTime $updatedAt
* @return ProtokollInfothekPruefung
*/
public function setUpdatedAt(\DateTime $updatedAt = null)
{
$this->updated_at = $updatedAt;
return $this;
}
/**
* Get updated_at
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updated_at;
}
/**
* Set kunde_pruefung [INVERSE SIDE]
*
* @param \JF\JuridicusBundle\Entity\KundePruefung $kundePruefung
* @return ProtokollInfothekPruefung
*/
public function setKundePruefung(KundePruefung $kundePruefung = null)
{
$this->kunde_pruefung = $kundePruefung;
if ($this->getProtokollAktenvortrag()) {
$this->getProtokollAktenvortrag()->setKundePruefung($kundePruefung);
if ($kundePruefung) {
$this->getProtokollAktenvortrag()->setPruefungsamt($kundePruefung->getPruefungsamt());
}
}
if ($this->getProtokollKlausur()) {
$this->getProtokollKlausur()->setKundePruefung($kundePruefung);
}
return $this;
}
/**
* Get kunde_pruefung
*
* @return \JF\JuridicusBundle\Entity\KundePruefung
*/
public function getKundePruefung()
{
return $this->kunde_pruefung;
}
/**
* Add protokoll_infothek_pruefer [INVERSE SIDE]
*
* @param \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer $protokollInfothekPruefer
* @return ProtokollInfothekPruefung
*/
public function addProtokollInfothekPruefer(ProtokollInfothekPruefer $protokollInfothekPruefer)
{
$this->protokoll_infothek_pruefer[] = $protokollInfothekPruefer;
$protokollInfothekPruefer->setProtokollInfothekPruefung($this);
return $this;
}
/**
* Remove protokoll_infothek_pruefer [INVERSE SIDE]
*
* @param \JF\JuridicusBundle\Entity\ProtokollInfothekPruefer $protokollInfothekPruefer
*/
public function removeProtokollInfothekPruefer(ProtokollInfothekPruefer $protokollInfothekPruefer)
{
$this->protokoll_infothek_pruefer->removeElement($protokollInfothekPruefer);
$protokollInfothekPruefer->setProtokollInfothekPruefung(null);
}
/**
* Get protokoll_infothek_pruefer
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProtokollInfothekPruefer()
{
return $this->protokoll_infothek_pruefer;
}
/**
* Set pdf_protokoll_infothek_pruefung [INVERSE SIDE]
*
* @param \JF\JuridicusBundle\Entity\PdfProtokollInfothekPruefung $pdfProtokollInfothekPruefung
* @return ProtokollInfothekPruefung
*/
public function setPdfProtokollInfothekPruefung(PdfProtokollInfothekPruefung $pdfProtokollInfothekPruefung = null)
{
$this->pdf_protokoll_infothek_pruefung = $pdfProtokollInfothekPruefung;
return $this;
}
/**
* Get pdf_protokoll_infothek_pruefung
*
* @return \JF\JuridicusBundle\Entity\PdfProtokollInfothekPruefung
*/
public function getPdfProtokollInfothekPruefung()
{
return $this->pdf_protokoll_infothek_pruefung;
}
/**
* Add protokoll_infothek_noten [INVERSE SIDE]
*
* @param \JF\JuridicusBundle\Entity\ProtokollInfothekNoten $protokollInfothekNoten
* @return ProtokollInfothekPruefung
*/
public function addProtokollInfothekNoten(ProtokollInfothekNoten $protokollInfothekNoten)
{
$this->protokoll_infothek_noten[] = $protokollInfothekNoten;
$protokollInfothekNoten->setProtokollInfothekPruefung($this);
return $this;
}
/**
* Remove protokoll_infothek_noten [INVERSE SIDE]
*
* @param \JF\JuridicusBundle\Entity\ProtokollInfothekNoten $protokollInfothekNoten
*/
public function removeProtokollInfothekNoten(ProtokollInfothekNoten $protokollInfothekNoten)
{
$this->protokoll_infothek_noten->removeElement($protokollInfothekNoten);
$protokollInfothekNoten->setProtokollInfothekPruefung(null);
}
/**
* Get protokoll_infothek_noten
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProtokollInfothekNoten()
{
return $this->protokoll_infothek_noten;
}
/**
* Set pruefung [OWNING SIDE]
*
* @param \JF\JuridicusBundle\Entity\Pruefung $pruefung
* @return ProtokollInfothekPruefung
*/
public function setPruefung(Pruefung $pruefung = null)
{
$this->pruefung = $pruefung;
return $this;
}
/**
* Get pruefung
*
* @return \JF\JuridicusBundle\Entity\Pruefung
*/
public function getPruefung()
{
return $this->pruefung;
}
/**
* String Representation
*
* @return string
*/
public function __toString()
{
if (isset($this->id)) {
return sprintf('Kundenprotokoll #%s', $this->id);
}
return 'Neues Kundenprotokoll';
}
/**
* get Kommission
*
* @param int $sortierung gibt an welches Kommissionsmitglied als Prüfer gekennzeichnet wird
* @return string[]
*/
private function getKommission($sortierung)
{
$kommission = array();
foreach ($this->getProtokollInfothekPruefer() as $protokoll_infothek_pruefer) {
$pruefer = $protokoll_infothek_pruefer->getPruefer();
if ($protokoll_infothek_pruefer->getSortierung() == 1) {
if ($protokoll_infothek_pruefer->getSortierung() == $sortierung) {
$kommission[] = sprintf('%s (Vorsitzender + Prüfer)',
$pruefer->getFullTextWithOrt());
} else {
$kommission[] = sprintf('%s (Vorsitzender)',
$pruefer->getFullTextWithOrt());
}
} else if ($protokoll_infothek_pruefer->getSortierung() == $sortierung) {
$kommission[] = sprintf('%s (Prüfer)',
$pruefer->getFullTextWithOrt());
} else {
$kommission[] = $pruefer->getFullTextWithOrt();
}
}
return $kommission;
}
/**
* addBaseToPdf - fügt Basisdaten in die Pdf-Datei ein
*
* @param \TCPDF $pdf
* @param $sortierung gibt an welches Kommissionsmitglied als Prüfer markiert werden soll
*/
public function addBaseToPdf(\TCPDF & $pdf, $sortierung)
{
$width = 50;
$nwidth = 10;
if ($this->examen == 1 && ! $this->wahlfachpruefung) {
$pdf->writeHTML('<h3>Protokoll der mündlichen Prüfung zum 1. Staatsexamen</h3>');
} elseif ($this->examen == 1 && $this->wahlfachpruefung) {
$pdf->writeHTML('<h3>Protokoll der mündlichen Wahlfachprüfung zum 1. Staatsexamen</h3>');
} elseif ($this->examen == 2 && ! $this->wahlfachpruefung) {
$pdf->writeHTML('<h3>Protokoll der mündlichen Prüfung zum 2. Staatsexamen</h3>');
} elseif ($this->examen == 2 && $this->wahlfachpruefung) {
$pdf->writeHTML('<h3>Protokoll der mündlichen Wahlfachprüfung zum 2. Staatsexamen</h3>');
}
$pdf->Ln(5);
$pdf->Cell($width, 0, "vom");
$pdf->Cell(0, 0, $this->datum->format('d.m.Y'));
$pdf->Ln();
$pdf->Cell($width, 0, "in");
$pdf->Cell(0, 0, $this->ort);
$pdf->Ln();
if ($this->mask & ProtokollInfothekNoten::OPTION_WAHLFACH && $this->wahlfach) {
$pdf->Cell($width, 0, "Wahlfach");
$pdf->Cell(0, 0, $this->wahlfach, 0, 1);
} else if ($this->mask & ProtokollInfothekNoten::OPTION_VORTRAG && $this->aktenvortrag) {
$pdf->Cell($width, 0, "Rechtsgebiet Aktenvortrag");
$pdf->Cell(0, 0, $this->aktenvortrag, 0, 1);
}
$pdf->Cell($width, 0, 'Kommissionsmitglieder');
foreach ($this->getKommission($sortierung) as $kommission) {
$pdf->Cell(0, 0, $kommission, 0, 2);
}
$pdf->Ln(0);
}
/**
* addNotenToPdf - fügt Notentabelle in Pdf-Datei ein
*
* @param \TCPDF $pdf
*/
public function addNotenToPdf(\TCPDF & $pdf)
{
$noten = $this->getProtokollInfothekNoten();
if (!$noten) {
return;
}
// Notentabelle einfügen
$fill = 0;
$pdf->SetFillColor(196);
// Header
$pdf->Cell(50, 6, "Kandidat", 1, 0, 'C', 1);
foreach ($noten as $note) {
$note->createHeaderCell($pdf);
}
$pdf->Ln();
// Body
foreach (ProtokollInfothekNoten::getOptionKeys() as $key) {
if ($this->mask & $key) {
$this->createTableRow($pdf, $key, $fill);
$fill = !$fill;
}
}
}
/**
* createTableRow
*
* Fügt eine Zeile zu einer Notentabelle hinzu
*
* @param \TCPDF $pdf
* @param integer $key Auswahl der Note
* @param boolean $fill
*/
private function createTableRow(\TCPDF & $pdf, $key, $fill)
{
// Zeilen-Bezeichnung eintragen
$pdf->SetFillColor(196);
$pdf->Cell(50, 6, ProtokollInfothekNoten::getOptionString($key), 1, 0,
ProtokollInfothekNoten::getAlignment($key), 1);
// Noten eintragen
$pdf->SetFillColor(224, 235, 255);
foreach ($this->getProtokollInfothekNoten() as $note) {
$note->createBodyCell($pdf, $key, $fill);
}
$pdf->Ln();
}
/**
* Set mask
*
* @param integer $mask
* @return ProtokollInfothekPruefung
*/
public function setMask($mask)
{
$this->mask = $mask;
return $this;
}
/**
* Get mask
*
* @return integer
*/
public function getMask()
{
return $this->mask;
}
/**
*
* @param integer $option
* @return boolean
*/
public function hasNotenOption($option)
{
return (bool) ($this->mask & $option);
}
/**
* Set examen
*
* @param integer $examen
* @return ProtokollInfothekPruefung
*/
public function setExamen($examen)
{
$this->examen = $examen;
return $this;
}
/**
* Get examen
*
* @return integer
*/
public function getExamen()
{
return $this->examen;
}
/**
* Set wahlfachpruefung
*
* @param boolean $wahlfachpruefung
* @return ProtokollInfothekPruefung
*/
public function setWahlfachpruefung($wahlfachpruefung)
{
$this->wahlfachpruefung = $wahlfachpruefung;
return $this;
}
/**
* Get wahlfachpruefung
*
* @return boolean
*/
public function getWahlfachpruefung()
{
return $this->wahlfachpruefung;
}
/**
* Add similarities
*
* @param \JF\JuridicusBundle\Entity\Similarity $similarities
* @return ProtokollInfothekPruefung
*/
public function addSimilaritie(Similarity $similarities)
{
$this->similarities[] = $similarities;
return $this;
}
/**
* Remove similarities
*
* @param \JF\JuridicusBundle\Entity\Similarity $similarities
*/
public function removeSimilaritie(Similarity $similarities)
{
$this->similarities->removeElement($similarities);
}
/**
* Get similarities
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getSimilarities()
{
return $this->similarities;
}
/**
* Set pdf_need_update
*
* @param boolean $pdfNeedUpdate
* @return ProtokollInfothekPruefung
*/
public function setPdfNeedUpdate($pdfNeedUpdate)
{
$this->pdf_need_update = (bool) $pdfNeedUpdate;
return $this;
}
/**
* Get pdf_need_update
*
* @return boolean
*/
public function getPdfNeedUpdate()
{
return $this->pdf_need_update;
}
/**
* Set send_last_minute
*
* @param boolean $sendLastMinute
* @return ProtokollInfothekPruefung
*/
public function setSendLastMinute($sendLastMinute)
{
$this->send_last_minute = (bool) $sendLastMinute;
return $this;
}
/**
* Get send_last_minute
*
* @return boolean
*/
public function getSendLastMinute()
{
return $this->send_last_minute;
}
/**
* Set fertig_at
*
* @param \DateTime $fertigAt
* @return ProtokollInfothekPruefung
*/
public function setFertigAt(\DateTime $fertigAt = null)
{
$this->fertig_at = $fertigAt;
return $this;
}
/**
* Get fertig_at
*
* @return \DateTime
*/
public function getFertigAt()
{
return $this->fertig_at;
}
/**
*
* @param integer $limit
*/
public function expandNoten($limit)
{
$count = $this->getProtokollInfothekNoten()->count();
for ($i = $count + 1; $i <= $limit; $i++) {
$protokoll_infothek_noten = new ProtokollInfothekNoten();
$protokoll_infothek_noten->setKandidatNummer($i);
$this->addProtokollInfothekNoten($protokoll_infothek_noten);
}
}
/**
*
* @param integer $limit
*/
public function expandPruefer($limit)
{
$count = $this->getProtokollInfothekPruefer()->count();
for ($i = $count + 1; $i <= $limit; $i++) {
$protokoll_infothek_pruefer = new ProtokollInfothekPruefer();
$protokoll_infothek_pruefer->setSortierung($i);
$this->addProtokollInfothekPruefer($protokoll_infothek_pruefer);
}
}
/**
*
* @param \JF\JuridicusBundle\Entity\PrueferPruefung $prueferPruefung
*/
public function addPrueferFromPrueferPruefung(PrueferPruefung $prueferPruefung)
{
$protokoll_infothek_pruefer = new ProtokollInfothekPruefer();
$protokoll_infothek_pruefer->setPruefer($prueferPruefung->getPruefer());
$protokoll_infothek_pruefer->setSortierung($prueferPruefung->getSortierung());
$protokoll_infothek_pruefer->setFach($prueferPruefung->getFach());
$this->addProtokollInfothekPruefer($protokoll_infothek_pruefer);
}
/**
*
* @param \JF\JuridicusBundle\Entity\Pruefung $pruefung
*/
public function addPrueferFromPruefung(Pruefung $pruefung)
{
foreach ($pruefung->getPrueferPruefungen() as $prueferPruefung) {
$this->addPrueferFromPrueferPruefung($prueferPruefung);
}
}
/**
* removes empty ProtokollGesetz entities from each item of the protokoll_infothek_pruefer collection.
*/
public function removeEmptyProtokollGesetze()
{
foreach ($this->getProtokollInfothekPruefer() as $p) {
$p->removeEmptyProtokollGesetze();
}
}
/**
* Set protokoll_klausur
*
* @param \JF\JuridicusBundle\Entity\ProtokollKlausur $protokollKlausur
* @return ProtokollInfothekPruefung
*/
public function setProtokollKlausur(ProtokollKlausur $protokollKlausur = null)
{
$this->protokoll_klausur = $protokollKlausur;
if ($protokollKlausur) {
$protokollKlausur->setProtokollInfothekPruefung($this);
}
return $this;
}
/**
* Get protokoll_klausur
*
* @return \JF\JuridicusBundle\Entity\ProtokollKlausur
*/
public function getProtokollKlausur()
{
return $this->protokoll_klausur;
}
/**
* Set protokoll_aktenvortrag
*
* @param \JF\JuridicusBundle\Entity\ProtokollAktenvortrag $protokollAktenvortrag
* @return ProtokollInfothekPruefung
*/
public function setProtokollAktenvortrag(ProtokollAktenvortrag $protokollAktenvortrag = null)
{
$this->protokoll_aktenvortrag = $protokollAktenvortrag;
if ($protokollAktenvortrag) {
$protokollAktenvortrag->setProtokollInfothekPruefung($this);
}
return $this;
}
/**
* Get protokoll_aktenvortrag
*
* @return \JF\JuridicusBundle\Entity\ProtokollAktenvortrag
*/
public function getProtokollAktenvortrag()
{
return $this->protokoll_aktenvortrag;
}
/**
*
*/
public function updateChildData()
{
$buchung = $this->getKundePruefung();
$protokoll_klausur = $this->getProtokollKlausur();
if ($protokoll_klausur) {
$protokoll_klausur->setKundePruefung($buchung);
if ($buchung) {
$protokoll_klausur->setPruefungsamt($buchung->getPruefungsamt());
}
$protokoll_klausur->setFertig($this->getFertig());
}
$protokoll_aktenvortrag = $this->getProtokollAktenvortrag();
if ($protokoll_aktenvortrag) {
$protokoll_aktenvortrag->setKundePruefung($buchung);
if ($buchung) {
$protokoll_aktenvortrag->setPruefungsamt($buchung->getPruefungsamt());
}
$protokoll_aktenvortrag->setFach($this->getAktenvortrag());
$protokoll_aktenvortrag->setFertig($this->getFertig());
}
}
}