<?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 JF\JuridicusBundle\Validator\Constraints as JfAssert;
use JF\JuridicusBundle\Utils\Juridicus;
use Doctrine\Common\Collections\ArrayCollection;
use JF\JuridicusBundle\Repository\ProtokollInfothekPrueferRepository;
/**
* ProtokollInfothekPruefer
*
* @UniqueEntity(fields={"protokoll_infothek_pruefung","pruefer"}, message="Ein Prüfer kann nur einmal an der Prüfung teilnehmen.")
*/
#[ORM\Entity(repositoryClass: ProtokollInfothekPrueferRepository::class)]
class ProtokollInfothekPruefer extends InitModeEntity
{
const CLASSNAME = __CLASS__;
/**
* @var integer
*/
private $id;
/**
* @var integer
*/
private $sortierung = 0;
/**
* @var string
* @Assert\Length(max="18")
*/
private $fach;
/**
* @var integer
* @Assert\Type(type="integer")
* @Assert\Range(min="1", max="2047", minMessage="Es muss mindestens ein Wert ausgewählt werden.",groups={"finish"})
*/
private $person_verhalten;
/**
* @var array
*/
private static $person_verhalten_options = array(
1 => 'freundlich',
2 => 'humorvoll',
4 => 'neutral',
8 => 'distanziert',
16 => 'wohlwollend',
32 => 'beruhigend',
64 => 'nervös',
128 => 'unsicher',
256 => 'ungeduldig',
512 => 'ernst',
1024 => 'sachlich'
);
/**
* @return array
*/
public static function getPersonVerhaltenOptions()
{
return self::$person_verhalten_options;
}
/**
* @var integer
* @Assert\NotNull(groups={"finish"}, message="Es muss ein Wert ausgewählt werden.")
* @Assert\Choice(callback = "getPersonFuehrtKeys", groups={"finish"})
*/
private $person_fuehrt;
/**
* @var array
*/
private static $person_fuehrt_options = array(
0 => 'gut',
1 => 'schlecht'
);
/**
* @return string
* @throws \OutOfBoundsException
*/
public function getPersonFuehrtString()
{
if (!isset($this->person_fuehrt)) {
return '';
} else if (isset(self::$person_fuehrt_options[$this->person_fuehrt])) {
return self::$person_fuehrt_options[$this->person_fuehrt];
} else {
throw new \OutOfBoundsException(sprintf('%s, Ungültiger Index %d', __METHOD__, $this->person_fuehrt));
}
}
/**
* @return array
*/
public static function getPersonFuehrtKeys()
{
return array_keys(self::$person_fuehrt_options);
}
/**
* @return array
*/
public static function getPersonFuehrtOptions()
{
return self::$person_fuehrt_options;
}
/**
* @var integer
* @Assert\NotNull(groups={"finish"}, message="Es muss ein Wert ausgewählt werden.")
* @Assert\Choice(callback="getPersonNotengebungKeys",groups={"finish"})
*/
private $person_notengebung;
/**
* @return string
* @throws \OutOfBoundsException
*/
public function getPersonNotengebungString()
{
if (!isset($this->person_notengebung)) {
return '';
} else if (isset(self::$person_notengebung_options[$this->person_notengebung])) {
return self::$person_notengebung_options[$this->person_notengebung];
} else {
throw new \OutOfBoundsException(sprintf('%s, Ungültiger Index %d', __METHOD__, $this->person_notengebung));
}
}
/**
* @var array
*/
private static $person_notengebung_options = array(
1 => 'wohlwollend',
2 => 'korrekt',
3 => 'streng'
);
/**
* @return array
*/
public static function getPersonNotengebungKeys()
{
return array_keys(self::$person_notengebung_options);
}
/**
* @return array
*/
public static function getPersonNotengebungOptions()
{
return self::$person_notengebung_options;
}
/**
* @var integer
* @Assert\NotNull(groups={"finish"}, message="Es muss ein Wert ausgewählt werden.")
* @Assert\Range(min="1", max="5", groups={"finish"})
*/
private $person_eindruck;
/**
* @var string
* @Assert\NotBlank(groups={"finish"})
* @JfAssert\StripMinLength(min="500", groups={"finish"})
*/
private $person_lang;
/**
* @var integer
* @Assert\Range(min="0", max="3", groups={"finish"})
*/
private $sache_stoff;
/**
* @var array
*/
private static $sache_stoff_options = array(
1 => "protokollfest",
2 => "aktuelle Fälle"
);
/**
* @return array
*/
public static function getSacheStoffOptions()
{
return self::$sache_stoff_options;
}
/**
* @var string
* @Assert\NotBlank(groups={"finish"})
*/
private $sache_themen;
/**
* @var integer
* @Assert\NotNull(groups={"finish"})
* @Assert\Range(min="1", minMessage="Es muss mindestens ein Wert ausgewählt werden.", groups={"finish"})
*/
private $sache_gespraech;
/**
* @var array
*/
private static $sache_gespraech_options = array(
1 => 'Frage-Antwort',
2 => 'Diskussion',
4 => 'hält Reihenfolge ein',
8 => 'lässt Meldungen zu',
16 => 'Intensivbefragung Einzelner',
32 => 'verfolgt Zwischenthemen',
64 => 'hart am Fall',
128 => 'lässt sich ablenken',
256 => 'Fragestellung klar'
);
/**
* @return array
*/
public static function getSacheGespraechOptions()
{
return self::$sache_gespraech_options;
}
/**
* @var string
* @Assert\NotBlank(groups={"finish"})
* @JfAssert\StripMinLength(min="1500", groups={"finish"})
*/
private $sache_lang;
/**
* @var \JF\JuridicusBundle\Entity\Pruefer
* @Assert\NotNull(message="Bitte Prüfer angeben",groups={"finish"})
*/
private $pruefer;
/**
* @var \JF\JuridicusBundle\Entity\PdfProtokollInfothekPruefer
*/
private $pdf_protokoll_infothek_pruefer;
/**
* @var \JF\JuridicusBundle\Entity\ProtokollInfothekPruefung
*/
private $protokoll_infothek_pruefung;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $similarities;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $emails;
/**
*
* @var \Doctrine\Common\Collections\Collection
* @Assert\Count(
* max = "5",
* maxMessage = "Es dürfen höchstens {{ limit }} Gesetze angegeben werden.",
* groups = {"admin"}
* )
* @Assert\Valid()
*/
private $protokoll_gesetze;
/**
* @Assert\IsFalse(
* message = "Es muss mindestens ein Paragraph angegeben werden.",
* groups = {"finish"}
* )
* changedFrom Assert\False
*/
public function isProtokollGesetzeEmpty()
{
foreach ($this->getProtokollGesetze() as $pg) {
if (!$pg->isEmpty()) {
return false;
}
}
return true;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set sortierung
*
* @param integer $sortierung
* @return ProtokollInfothekPruefer
*/
public function setSortierung($sortierung)
{
$this->sortierung = $sortierung;
return $this;
}
/**
* Get sortierung
*
* @return integer
*/
public function getSortierung()
{
return $this->sortierung;
}
/**
* Set fach
*
* @param string $fach
* @return ProtokollInfothekPruefer
*/
public function setFach($fach)
{
$this->fach = PrueferPruefung::unifyFach($fach);
return $this;
}
/**
* Get fach
*
* @return string
*/
public function getFach()
{
return $this->fach;
}
/**
* Set person_verhalten
*
* @param integer $personVerhalten
* @return ProtokollInfothekPruefer
*/
public function setPersonVerhalten($personVerhalten)
{
$this->person_verhalten = $personVerhalten;
return $this;
}
/**
* Get person_verhalten
*
* @return integer
*/
public function getPersonVerhalten()
{
return $this->person_verhalten;
}
/**
* Set person_fuehrt
*
* @param integer $personFuehrt
* @return ProtokollInfothekPruefer
*/
public function setPersonFuehrt($personFuehrt)
{
$this->person_fuehrt = $personFuehrt;
return $this;
}
/**
* Get person_fuehrt
*
* @return integer
*/
public function getPersonFuehrt()
{
return $this->person_fuehrt;
}
/**
* Set person_notengebung
*
* @param integer $personNotengebung
* @return ProtokollInfothekPruefer
*/
public function setPersonNotengebung($personNotengebung)
{
$this->person_notengebung = $personNotengebung;
return $this;
}
/**
* Get person_notengebung
*
* @return integer
*/
public function getPersonNotengebung()
{
return $this->person_notengebung;
}
/**
* Set person_eindruck
*
* @param integer $personEindruck
* @return ProtokollInfothekPruefer
*/
public function setPersonEindruck($personEindruck)
{
$this->person_eindruck = $personEindruck;
return $this;
}
/**
* Get person_eindruck
*
* @return integer
*/
public function getPersonEindruck()
{
return $this->person_eindruck;
}
/**
* Set person_lang
*
* @param string $personLang
* @return ProtokollInfothekPruefer
*/
public function setPersonLang($personLang)
{
$this->person_lang = $personLang;
return $this;
}
/**
* Get person_lang
*
* @return string
*/
public function getPersonLang()
{
return $this->person_lang;
}
/**
* Set sache_stoff
*
* @param integer $sacheStoff
* @return ProtokollInfothekPruefer
*/
public function setSacheStoff($sacheStoff)
{
$this->sache_stoff = $sacheStoff;
return $this;
}
/**
* Get sache_stoff
*
* @return integer
*/
public function getSacheStoff()
{
return $this->sache_stoff;
}
/**
* Set sache_themen
*
* @param string $sacheThemen
* @return ProtokollInfothekPruefer
*/
public function setSacheThemen($sacheThemen)
{
$this->sache_themen = $sacheThemen;
return $this;
}
/**
* Get sache_themen
*
* @return string
*/
public function getSacheThemen()
{
return $this->sache_themen;
}
/**
* Set sache_gespraech
*
* @param integer $sacheGespraech
* @return ProtokollInfothekPruefer
*/
public function setSacheGespraech($sacheGespraech)
{
$this->sache_gespraech = $sacheGespraech;
return $this;
}
/**
* Get sache_gespraech
*
* @return integer
*/
public function getSacheGespraech()
{
return $this->sache_gespraech;
}
/**
* Set sache_lang
*
* @param string $sacheLang
* @return ProtokollInfothekPruefer
*/
public function setSacheLang($sacheLang)
{
$this->sache_lang = $sacheLang;
return $this;
}
/**
* Get sache_lang
*
* @return string
*/
public function getSacheLang()
{
return $this->sache_lang;
}
/**
* Set pruefer [OWNING SIDE]
*
* @param \JF\JuridicusBundle\Entity\Pruefer $pruefer
* @return ProtokollInfothekPruefer
*/
public function setPruefer(Pruefer $pruefer = null)
{
$this->pruefer = $pruefer;
return $this;
}
/**
* Get pruefer
*
* @return \JF\JuridicusBundle\Entity\Pruefer
*/
public function getPruefer()
{
return $this->pruefer;
}
/**
* Set protokoll_infothek_pruefung [OWNING SIDE]
*
* @param \JF\JuridicusBundle\Entity\ProtokollInfothekPruefung $protokollInfothekPruefung
* @return ProtokollInfothekPruefer
*/
public function setProtokollInfothekPruefung(ProtokollInfothekPruefung $protokollInfothekPruefung = null)
{
$this->protokoll_infothek_pruefung = $protokollInfothekPruefung;
return $this;
}
/**
* Get protokoll_infothek_pruefung
*
* @return \JF\JuridicusBundle\Entity\ProtokollInfothekPruefung
*/
public function getProtokollInfothekPruefung()
{
return $this->protokoll_infothek_pruefung;
}
/**
* Set pdf_protokoll_infothek_pruefer [INVERSE SIDE]
*
* @param \JF\JuridicusBundle\Entity\PdfProtokollInfothekPruefer $pdfProtokollInfothekPruefer
* @return ProtokollInfothekPruefer
*/
public function setPdfProtokollInfothekPruefer(PdfProtokollInfothekPruefer $pdfProtokollInfothekPruefer = null)
{
$this->pdf_protokoll_infothek_pruefer = $pdfProtokollInfothekPruefer;
return $this;
}
/**
* Get pdf_protokoll_infothek_pruefer
*
* @return \JF\JuridicusBundle\Entity\PdfProtokollInfothekPruefer
*/
public function getPdfProtokollInfothekPruefer()
{
return $this->pdf_protokoll_infothek_pruefer;
}
/**
* String Representation
*
* @return string
*/
public function __toString()
{
return sprintf('Protokoll Infothek Prüfer #%s', $this->id);
}
/**
* addToPdf
*
* @param \TCPDF $pdf
*/
public function addToPdf(\TCPDF & $pdf)
{
$width = 50;
$nwidth = 10;
$protokoll_infothek_pruefung = $this->getProtokollInfothekPruefung();
// Basisdaten einfügen
$protokoll_infothek_pruefung->addBaseToPdf($pdf, $this->sortierung);
$pdf->Cell($width, 0, "Prüfungsfach (-fächer)");
$pdf->Cell(0, 0, $this->fach, 0, 1);
$pdf->Ln(5);
$pdf->writeHTML("<h3>Die Prüfung im Einzelnen</h3>");
$pdf->Ln(5);
// Notentabelle einfügen
$protokoll_infothek_pruefung->addNotenToPdf($pdf);
$pdf->Ln(5);
$pdf->writeHTML("<h3>Zur Person:</h3>");
$pdf->Ln(5);
$pdf->Cell($nwidth, 0, '1.');
$pdf->Cell($width, 0, 'Prüfungsverhalten');
foreach (Juridicus::pick($this->person_verhalten, self::$person_verhalten_options) AS $option) {
$pdf->Cell(0, 0, $option, 0, 2);
}
$pdf->Ln(0);
if (isset($this->person_fuehrt)) {
$pdf->Cell($nwidth, 0, '');
$pdf->Cell($width, 0, 'führt');
$pdf->Cell(0, 0, $this->getPersonFuehrtString(), 0, 1);
}
if (isset($this->person_notengebung)) {
$pdf->Cell($nwidth, 0, '2.');
$pdf->Cell($width, 0, 'Notengebung');
$pdf->Cell(0, 0, $this->getPersonNotengebungString(), 0, 1);
}
if (isset($this->person_eindruck)) {
$pdf->Cell($nwidth, 0, '3.');
$pdf->Cell($width, 0, 'Gesamteindruck');
$pdf->Cell(0, 0, sprintf('%s (1 = ideal ... 5 = äußerst unangenehm)', $this->person_eindruck), 0, 1);
}
$pdf->Ln(5);
$pdf->writeHTML("<h3>Zur Sache:</h3>");
$pdf->Ln(5);
$pdf->Cell($nwidth, 0, '1.');
if (!empty($this->sache_stoff)) {
$selected = Juridicus::pick($this->sache_stoff, self::$sache_stoff_options);
$pdf->Cell($width, 0, 'Prüfungsstoff');
$pdf->Cell(0, 0, implode(", ", $selected), 0, 1);
$pdf->Cell($nwidth, 0, '');
}
$pdf->Cell($width, 0, 'Prüfungsthemen');
$pdf->writeHTMLCell(0, 0, '', '', $this->sache_themen, 0, 1);
$paragraphen = array();
foreach($this->getProtokollGesetze() as $protokoll_gesetz) {
/* @var $protokoll_gesetz \JF\JuridicusBundle\Entity\ProtokollGesetz */
$paragraphen[] = sprintf('<a href="%s">%s</a>',
$protokoll_gesetz->getAbsoluteLink(),
$protokoll_gesetz->getKurzbezeichnung()
);
}
if (!empty($paragraphen)) {
$pdf->Cell($nwidth, 0, '');
$pdf->Cell($width, 0, 'Paragraphen');
$pdf->writeHTMLCell(0, 0, '', '', \implode(', ', $paragraphen), 0, 1);
}
$pdf->Cell($nwidth, 0, '2.');
$pdf->Cell($width, 0, 'Prüfungsgespräch');
foreach (Juridicus::pick($this->sache_gespraech, self::$sache_gespraech_options) AS $option) {
$pdf->Cell(0, 0, $option, 0, 2);
}
$pdf->Ln(5);
$pdf->writeHTML("<h3>Zur Person des Prüfers (ausführlich)</h3>");
$pdf->Ln(5);
$pdf->writeHTML($this->person_lang);
$pdf->Ln(5);
$pdf->writeHTML("<h3>Zur Sache (ausführlich)</h3>");
$pdf->Ln(5);
$pdf->writeHTML($this->sache_lang);
$pdf->Ln(5);
$pdf->lastPage();
}
/**
* Konstructor.
*/
public function __construct()
{
$this->similarities = new ArrayCollection();
$this->emails = new ArrayCollection();
$this->protokoll_gesetze = new ArrayCollection();
}
/**
* Add similarities
*
* @param \JF\JuridicusBundle\Entity\Similarity $similarities
* @return ProtokollInfothekPruefer
*/
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;
}
/**
* Add emails
*
* @param \JF\JuridicusBundle\Entity\Email $emails
* @return ProtokollInfothekPruefer
*/
public function addEmail(Email $emails)
{
$this->emails[] = $emails;
return $this;
}
/**
* Remove emails
*
* @param \JF\JuridicusBundle\Entity\Email $emails
*/
public function removeEmail(Email $emails)
{
$this->emails->removeElement($emails);
}
/**
* Get emails
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getEmails()
{
return $this->emails;
}
/**
* Add protokoll_gesetze
*
* @param \JF\JuridicusBundle\Entity\ProtokollGesetz $protokollGesetz
* @return ProtokollInfothekPruefer
*/
public function addProtokollGesetze(ProtokollGesetz $protokollGesetz)
{
$this->protokoll_gesetze[] = $protokollGesetz;
$protokollGesetz->setProtokollInfothekPruefer($this);
return $this;
}
/**
* Remove protokoll_gesetze
*
* @param \JF\JuridicusBundle\Entity\ProtokollGesetz $protokollGesetz
*/
public function removeProtokollGesetze(ProtokollGesetz $protokollGesetz)
{
$this->protokoll_gesetze->removeElement($protokollGesetz);
}
/**
* Get protokoll_gesetze
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getProtokollGesetze()
{
return $this->protokoll_gesetze;
}
/**
*
* @param integer $limit
*/
public function expandProtokollGesetze($limit = 5)
{
$pg_count = $this->getProtokollGesetze()->count();
for ($i = $pg_count + 1; $i <= $limit; $i++) {
$pg = new ProtokollGesetz();
// $pg->setSortierung($i);
$this->addProtokollGesetze($pg);
}
}
/**
*
*/
public function removeEmptyProtokollGesetze()
{
foreach($this->getProtokollGesetze() as $pg) {
if ($pg->isEmpty()) {
$this->removeProtokollGesetze($pg);
}
}
}
}