From 2163ddcdf5f73c0adba41d2d528024128cebcdbd Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 25 Apr 2023 09:22:03 +0200 Subject: [PATCH] add Interface IValidation, implement validate stub in all Vertragsbestandteile and Gehaltsbestandteil and DV --- .../vertragsbestandteil/Dienstverhaeltnis.php | 34 ++++++++++- .../Gehaltsbestandteil.php | 34 ++++++++++- .../vertragsbestandteil/IValidation.php | 16 +++++ .../Vertragsbestandteil.php | 2 +- .../VertragsbestandteilBefristung.php | 6 +- .../VertragsbestandteilFreitext.php | 5 ++ .../VertragsbestandteilKarenz.php | 5 +- .../VertragsbestandteilKuendigungsfrist.php | 5 +- .../VertragsbestandteilLehre.php | 5 +- .../VertragsbestandteilStunden.php | 5 ++ .../VertragsbestandteilUrlaubsanspruch.php | 5 +- .../VertragsbestandteilZeitaufzeichnung.php | 5 +- .../Gehaltsbestandteil_model.php | 61 ++++++++++++++++++- 13 files changed, 175 insertions(+), 13 deletions(-) create mode 100644 application/libraries/vertragsbestandteil/IValidation.php diff --git a/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php b/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php index aa89fe781..78efe36b3 100644 --- a/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php +++ b/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php @@ -11,7 +11,7 @@ const TYPE_ECHT_FREI = 'echterfreier'; const TYPE_WERKVERTRAG = 'werkvertrag'; const TYPE_UEBERLASSUNG = 'ueberlassungsvertrag'; -class Dienstverhaeltnis { +class Dienstverhaeltnis implements IValidation { /** @var integer */ protected $dienstverhaeltnis_id; /** @var integer */ @@ -20,7 +20,16 @@ class Dienstverhaeltnis { protected $vertragsart_kurzbz; protected $gueltig_ab; protected $gueltig_bis; + + protected $isvalid; + protected $validationerrors; + public function __construct() + { + $this->isvalid = false; + $this->validationerrors = array(); + } + public function toStdClass(): \stdClass { $tmp = array( @@ -141,4 +150,27 @@ EOTXT; return $this; } + + public function isValid() + { + return $this->isvalid; + } + + public function getValidationErrors() + { + return $this->validationerrors; + } + + public function validate() { + //do Validation here + + // return status after Validation + if( count($this->validationerrors) > 0 ) { + $this->isvalid = false; + } else { + $this->isvalid = true; + } + + return $this->isvalid; + } } \ No newline at end of file diff --git a/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php b/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php index 0fc786124..88fce2e4e 100644 --- a/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php +++ b/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php @@ -4,7 +4,7 @@ namespace vertragsbestandteil; /** * Salary always depends on employment (Dienstverhältnis) and optionally on part of contract (Vetragsbestandteil) */ -class Gehaltsbestandteil +class Gehaltsbestandteil implements IValidation { protected $gehaltsbestandteil_id; protected $dienstverhaeltnis_id; @@ -23,7 +23,16 @@ class Gehaltsbestandteil protected $insertvon; protected $updateamum; protected $updatevon; + + protected $isvalid; + protected $validationerrors; + public function __construct() + { + $this->isvalid = false; + $this->validationerrors = array(); + } + public function hydrateByStdClass($data) { isset($data->gehaltsbestandteil_id) && $this->setGehaltsbestandteil_id($data->gehaltsbestandteil_id); @@ -272,4 +281,27 @@ class Gehaltsbestandteil EOTXT; return $txt; } + + public function isValid() + { + return $this->isvalid; + } + + public function getValidationErrors() + { + return $this->validationerrors; + } + + public function validate() { + //do Validation here + + // return status after Validation + if( count($this->validationerrors) > 0 ) { + $this->isvalid = false; + } else { + $this->isvalid = true; + } + + return $this->isvalid; + } } diff --git a/application/libraries/vertragsbestandteil/IValidation.php b/application/libraries/vertragsbestandteil/IValidation.php new file mode 100644 index 000000000..2898ec41b --- /dev/null +++ b/application/libraries/vertragsbestandteil/IValidation.php @@ -0,0 +1,16 @@ +execQuery($qry, array($dienstverhaeltnis_id), $this->getEncryptedColumns()); - } + + public function getGehaltsbestandteile($dienstverhaeltnis_id=1, $stichtag=null) + { + $stichtagclause = ''; + if( !is_null($stichtag) ) + { + $date = strftime('%Y-%m-%d', strtotime($stichtag)); + $stichtagclause = 'AND ' . $this->escape($date) + . ' BETWEEN COALESCE(v.von, \'1970-01-01\'::date)' + . ' AND COALESCE(v.bis, \'2170-01-01\'::date)'; + } -} \ No newline at end of file + $sql = <<execReadOnlyQuery( + $query, + array($dienstverhaeltnis_id), + $this->getEncryptedColumns() + ); + + $gehaltsbestandteile = array(); + if( null !== ($rows = getData($query)) ) + { + foreach( $rows as $row ) { + $tmpgb = new Gehaltsbestandteil(); + $tmpgb->hydrateByStdClass($row); + $gehaltsbestandteile[] = $tmpgb; + } + } + + return $gehaltsbestandteile; + } + + + public function getGehaltsbestandteil($id) + { + $query = $this->load($id, $this->getEncryptedColumns()); + $gehaltsbestandteil = null; + + if( null !== ($row = getData($query)) ) + { + $gehaltsbestandteil = new Gehaltsbestandteil(); + $gehaltsbestandteil->hydrateByStdClass($row[0]); + } + + return $gehaltsbestandteil; + } +}