mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
cleanup according to current vertragsbestandteil db tables
This commit is contained in:
@@ -204,8 +204,11 @@ EOTXT;
|
||||
return $this->validationerrors;
|
||||
}
|
||||
|
||||
public function validate() {
|
||||
public function validate() {
|
||||
//do Validation here
|
||||
$ci = get_instance();
|
||||
$ci->load->library('vertragsbestandteil/VertragsbestandteilLib',
|
||||
null, 'VertragsbestandteilLib');
|
||||
|
||||
if( empty($this->mitarbeiter_uid) ) {
|
||||
$this->validationerrors[] = 'Mitarbeiter_UID fehlt.';
|
||||
@@ -219,6 +222,27 @@ EOTXT;
|
||||
$this->validationerrors[] = 'Vertragsart fehlt.';
|
||||
}
|
||||
|
||||
$von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von);
|
||||
$bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis);
|
||||
|
||||
if( false === $von ) {
|
||||
$this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.';
|
||||
}
|
||||
|
||||
if( $this->bis !== null && $bis === false ) {
|
||||
$this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.';
|
||||
}
|
||||
|
||||
if( $this-> bis !== null && $von && $bis && $von > $bis ) {
|
||||
$this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.';
|
||||
}
|
||||
|
||||
// TODO check for overlapping DVs
|
||||
if( $ci->VertragsbestandteilLib->isOverlappingExistingDV($this) )
|
||||
{
|
||||
$this->validationerrors[] = 'Es existiert bereits ein überlappendes Dienstverhältnis';
|
||||
}
|
||||
|
||||
// return status after Validation
|
||||
if( count($this->validationerrors) > 0 ) {
|
||||
$this->isvalid = false;
|
||||
|
||||
@@ -298,6 +298,22 @@ EOTXT;
|
||||
{
|
||||
$this->validationerrors[] = "Betrag fehlt.";
|
||||
}
|
||||
|
||||
$von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von);
|
||||
$bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis);
|
||||
|
||||
if( false === $von ) {
|
||||
$this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.';
|
||||
}
|
||||
|
||||
if( $this->bis !== null && $bis === false ) {
|
||||
$this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.';
|
||||
}
|
||||
|
||||
if( $this-> bis !== null && $von && $bis && $von > $bis ) {
|
||||
$this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.';
|
||||
}
|
||||
|
||||
// return status after Validation
|
||||
if( count($this->validationerrors) > 0 ) {
|
||||
$this->isvalid = false;
|
||||
|
||||
@@ -219,6 +219,21 @@ EOTXT;
|
||||
}
|
||||
|
||||
public function validate() {
|
||||
$von = \DateTimeImmutable::createFromFormat('Y-m-d', $this->von);
|
||||
$bis = \DateTimeImmutable::createFromFormat('Y-m-d', $this->bis);
|
||||
|
||||
if( false === $von ) {
|
||||
$this->validationerrors[] = 'Beginn muss ein gültiges Datum sein.';
|
||||
}
|
||||
|
||||
if( $this->bis !== null && $bis === false ) {
|
||||
$this->validationerrors[] = 'Ende muss ein gültiges Datum oder leer sein.';
|
||||
}
|
||||
|
||||
if( $this-> bis !== null && $von && $bis && $von > $bis ) {
|
||||
$this->validationerrors[] = 'Das Beginndatum muss vor dem Endedatum liegen.';
|
||||
}
|
||||
|
||||
if( count($this->validationerrors) > 0 ) {
|
||||
$this->isvalid = false;
|
||||
} else {
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
class VertragsbestandteilBefristung extends Vertragsbestandteil
|
||||
{
|
||||
protected $befristet;
|
||||
protected $befristet_bis;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_BEFRISTUNG);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data)
|
||||
{
|
||||
parent::hydrateByStdClass($data);
|
||||
isset($data->befristet) && $this->setBefristet($data->befristet);
|
||||
isset($data->befristet_bis) && $this->setBefristetBis($data->befristet_bis);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of befristet
|
||||
*/
|
||||
public function getBefristet()
|
||||
{
|
||||
return $this->befristet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of befristet
|
||||
*/
|
||||
public function setBefristet($befristet): self
|
||||
{
|
||||
$this->befristet = $befristet;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of befristet_bis
|
||||
*/
|
||||
public function getBefristetBis()
|
||||
{
|
||||
return $this->befristet_bis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of befristet_bis
|
||||
*/
|
||||
public function setBefristetBis($befristet_bis): self
|
||||
{
|
||||
$this->befristet_bis = $befristet_bis;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'befristet' => $this->getBefristet(),
|
||||
'befristet_bis' => $this->getBefristetBis()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($v) {
|
||||
return !is_null($v);
|
||||
});
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
befristet: {$this->getBefristet()}
|
||||
befristet_bis: {$this->getBefristetBis()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
return parent::validate();
|
||||
}
|
||||
}
|
||||
@@ -35,39 +35,13 @@ class VertragsbestandteilFactory
|
||||
$vertragsbestandteil = null;
|
||||
switch ($vertragsbestandteiltyp_kurzbz)
|
||||
{
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_STUNDEN:
|
||||
$vertragsbestandteil = new VertragsbestandteilStunden();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FUNKTION:
|
||||
$vertragsbestandteil = new VertragsbestandteilFunktion();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_GEHALT:
|
||||
$vertragsbestandteil = new VertragsbestandteilGehalt();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST:
|
||||
$vertragsbestandteil = new VertragsbestandteilKuendigungsfrist();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FREITEXT:
|
||||
$vertragsbestandteil = new VertragsbestandteilFreitext();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG:
|
||||
$vertragsbestandteil = new VertragsbestandteilZeitaufzeichnung();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_BEFRISTUNG:
|
||||
$vertragsbestandteil = new VertragsbestandteilBefristung();
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FUNKTION:
|
||||
$vertragsbestandteil = new VertragsbestandteilFunktion();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
@@ -76,11 +50,26 @@ class VertragsbestandteilFactory
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST:
|
||||
$vertragsbestandteil = new VertragsbestandteilKuendigungsfrist();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_STUNDEN:
|
||||
$vertragsbestandteil = new VertragsbestandteilStunden();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH:
|
||||
$vertragsbestandteil = new VertragsbestandteilUrlaubsanspruch();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG:
|
||||
$vertragsbestandteil = new VertragsbestandteilZeitaufzeichnung();
|
||||
$vertragsbestandteil->hydrateByStdClass($data);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown vertragsbestandteiltyp_kurzbz '
|
||||
. $vertragsbestandteiltyp_kurzbz);
|
||||
@@ -96,28 +85,22 @@ class VertragsbestandteilFactory
|
||||
$vertragsbestandteildbmodel = null;
|
||||
switch ($vertragsbestandteil_kurzbz)
|
||||
{
|
||||
case self::VERTRAGSBESTANDTEIL_STUNDEN:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilStunden_model',
|
||||
'VertragsbestandteilStunden_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilStunden_model;
|
||||
case self::VERTRAGSBESTANDTEIL_FREITEXT:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model',
|
||||
'VertragsbestandteilFreitext_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilFreitext_model;
|
||||
break;
|
||||
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FUNKTION:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilFunktion_model',
|
||||
'VertragsbestandteilFunktion_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilFunktion_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_GEHALT:
|
||||
$CI->load->model('vertragsbestandteil/Gehaltsbestandteil_model',
|
||||
'Gehaltsbestandteil_model');
|
||||
$vertragsbestandteildbmodel = $CI->Gehaltsbestandteil_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_FREITEXT:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilFreitext_model',
|
||||
'VertragsbestandteilFreitext_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilFreitext_model;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KARENZ:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilKarenz_model',
|
||||
'VertragsbestandteilKarenz_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilKarenz_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST:
|
||||
@@ -125,24 +108,24 @@ class VertragsbestandteilFactory
|
||||
'VertragsbestandteilKuendigungsfrist_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilKuendigungsfrist_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_KARENZ:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilKarenz_model',
|
||||
'VertragsbestandteilKarenz_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilKarenz_model;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_STUNDEN:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilStunden_model',
|
||||
'VertragsbestandteilStunden_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilStunden_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model',
|
||||
'VertragsbestandteilZeitaufzeichnung_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilZeitaufzeichnung_model;
|
||||
break;
|
||||
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilUrlaubsanspruch_model',
|
||||
'VertragsbestandteilUrlaubsanspruch_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilUrlaubsanspruch_model;
|
||||
break;
|
||||
|
||||
case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG:
|
||||
$CI->load->model('vertragsbestandteil/VertragsbestandteilZeitaufzeichnung_model',
|
||||
'VertragsbestandteilZeitaufzeichnung_model');
|
||||
$vertragsbestandteildbmodel = $CI->VertragsbestandteilZeitaufzeichnung_model;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown vertragsbestandteil_kurzbz '
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
namespace vertragsbestandteil;
|
||||
|
||||
use vertragsbestandteil\Vertragsbestandteil;
|
||||
use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
|
||||
class VertragsbestandteilLehre extends Vertragsbestandteil
|
||||
{
|
||||
protected $inkludierte_lehre;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setVertragsbestandteiltyp_kurzbz(
|
||||
VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_LEHRE);
|
||||
}
|
||||
|
||||
public function hydrateByStdClass($data)
|
||||
{
|
||||
parent::hydrateByStdClass($data);
|
||||
isset($data->inkludierte_lehre) && $this->setInkludierteLehre($data->inkludierte_lehre);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of inkludierte_lehre
|
||||
*/
|
||||
public function getInkludierteLehre()
|
||||
{
|
||||
return $this->inkludierte_lehre;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of inkludierte_lehre
|
||||
*/
|
||||
public function setInkludierteLehre($inkludierte_lehre): self
|
||||
{
|
||||
$this->inkludierte_lehre = $inkludierte_lehre;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toStdClass(): \stdClass
|
||||
{
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'inkludierte_lehre' => $this->getInkludierteLehre(),
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($v) {
|
||||
return !is_null($v);
|
||||
});
|
||||
|
||||
return (object) $tmp;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
inkludierte_lehre: {$this->getInkludierteLehre()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
return parent::validate();
|
||||
}
|
||||
}
|
||||
@@ -222,4 +222,14 @@ class VertragsbestandteilLib
|
||||
. 'failed to store Gehaltsbestandteile. ' . $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function isOverlappingExistingDV(Dienstverhaeltnis $dv)
|
||||
{
|
||||
return $this->DienstverhaeltnisModel->isOverlappingExistingDV(
|
||||
$dv->getMitarbeiter_uid(),
|
||||
$dv->getOe_kurzbz(),
|
||||
$dv->getVon(),
|
||||
$dv->getBis()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use vertragsbestandteil\VertragsbestandteilFactory;
|
||||
class VertragsbestandteilStunden extends Vertragsbestandteil
|
||||
{
|
||||
protected $wochenstunden;
|
||||
protected $karenz;
|
||||
protected $teilzeittyp_kurzbz;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -28,7 +28,7 @@ class VertragsbestandteilStunden extends Vertragsbestandteil
|
||||
{
|
||||
parent::hydrateByStdClass($data);
|
||||
isset($data->wochenstunden) && $this->setWochenstunden($data->wochenstunden);
|
||||
isset($data->karenz) && $this->setKarenz($data->karenz);
|
||||
isset($data->teilzeittyp_kurzbz) && $this->setTeilzeittyp_kurzbz($data->teilzeittyp_kurzbz);
|
||||
}
|
||||
|
||||
public function getWochenstunden()
|
||||
@@ -36,9 +36,9 @@ class VertragsbestandteilStunden extends Vertragsbestandteil
|
||||
return $this->wochenstunden;
|
||||
}
|
||||
|
||||
public function getKarenz()
|
||||
public function getTeilzeittyp_kurzbz()
|
||||
{
|
||||
return $this->karenz;
|
||||
return $this->teilzeittyp_kurzbz;
|
||||
}
|
||||
|
||||
public function setWochenstunden($wochenstunden)
|
||||
@@ -47,9 +47,9 @@ class VertragsbestandteilStunden extends Vertragsbestandteil
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setKarenz($karenz)
|
||||
public function setTeilzeittyp_kurzbz($teilzeittyp_kurzbz)
|
||||
{
|
||||
$this->karenz = $karenz;
|
||||
$this->teilzeittyp_kurzbz = $teilzeittyp_kurzbz;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class VertragsbestandteilStunden extends Vertragsbestandteil
|
||||
$tmp = array(
|
||||
'vertragsbestandteil_id' => $this->getVertragsbestandteil_id(),
|
||||
'wochenstunden' => $this->getWochenstunden(),
|
||||
'karenz' => $this->getKarenz()
|
||||
'teilzeittyp_kurzbz' => $this->getTeilzeittyp_kurzbz()
|
||||
);
|
||||
|
||||
$tmp = array_filter($tmp, function($v) {
|
||||
@@ -72,7 +72,7 @@ class VertragsbestandteilStunden extends Vertragsbestandteil
|
||||
{
|
||||
$txt = <<<EOTXT
|
||||
wochenstunden: {$this->getWochenstunden()}
|
||||
karenz: {$this->getKarenz()}
|
||||
teilzeittyp_kurzbz: {$this->getTeilzeittyp_kurzbz()}
|
||||
|
||||
EOTXT;
|
||||
return parent::__toString() . $txt;
|
||||
@@ -80,8 +80,15 @@ EOTXT;
|
||||
|
||||
public function validate()
|
||||
{
|
||||
if( (floatval($this->wochenstunden) < 1 ) ) {
|
||||
$this->validationerrors[] = 'Stunden zu niedrig.';
|
||||
if( !(filter_var($this->wochenstunden, FILTER_VALIDATE_FLOAT,
|
||||
array(
|
||||
'options' => array(
|
||||
'min_range' => 0,
|
||||
'max_range' => 100
|
||||
)
|
||||
)
|
||||
)) ) {
|
||||
$this->validationerrors[] = 'Stunden muss eine Kommazahl im Bereichs 0 bis 100 sein.';
|
||||
}
|
||||
|
||||
return parent::validate();
|
||||
|
||||
Reference in New Issue
Block a user