From ac5d6071cd95800017a02d8c656bafeb6e756a45 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Wed, 26 Jul 2023 16:27:34 +0200 Subject: [PATCH] extend VerttragsbestandteilLib to keep track on modified columns and only update dv, vbs and gbs when they differ from the status in the db --- .../AbstractBestandteil.php | 31 ++++++++++++ .../vertragsbestandteil/Dienstverhaeltnis.php | 27 ++++++++-- .../Gehaltsbestandteil.php | 32 +++++++++--- .../GehaltsbestandteilLib.php | 5 ++ .../Vertragsbestandteil.php | 27 +++++++--- .../VertragsbestandteilFactory.php | 16 +++--- .../VertragsbestandteilFreitext.php | 17 ++++--- .../VertragsbestandteilFunktion.php | 13 +++-- .../VertragsbestandteilKarenz.php | 19 ++++--- .../VertragsbestandteilKuendigungsfrist.php | 14 ++++-- .../VertragsbestandteilLib.php | 49 +++++++++++-------- .../VertragsbestandteilStunden.php | 17 ++++--- .../VertragsbestandteilUrlaubsanspruch.php | 13 +++-- .../VertragsbestandteilZeitaufzeichnung.php | 15 ++++-- .../Gehaltsbestandteil_model.php | 4 +- .../Vertragsbestandteil_model.php | 4 +- application/views/templates/FHC-Footer.php | 1 + composer.json | 14 +++--- composer.lock | 16 +++--- 19 files changed, 230 insertions(+), 104 deletions(-) create mode 100644 application/libraries/vertragsbestandteil/AbstractBestandteil.php diff --git a/application/libraries/vertragsbestandteil/AbstractBestandteil.php b/application/libraries/vertragsbestandteil/AbstractBestandteil.php new file mode 100644 index 000000000..72119968b --- /dev/null +++ b/application/libraries/vertragsbestandteil/AbstractBestandteil.php @@ -0,0 +1,31 @@ +modifiedcolumns = array(); + $this->fromdb = false; + } + + public function isDirty() { + return count($this->modifiedcolumns) > 0; + } + + protected function markDirty($columnname, $old_value, $new_value) { + if( !$this->fromdb && ($old_value != $new_value) ) { + $this->modifiedcolumns[$columnname] = $columnname; + } + } + + abstract public function hydrateByStdClass($data, $fromdb=false); +} diff --git a/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php b/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php index 3bd36aa78..d452f3982 100644 --- a/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php +++ b/application/libraries/vertragsbestandteil/Dienstverhaeltnis.php @@ -2,6 +2,10 @@ namespace vertragsbestandteil; require_once __DIR__ . '/IValidation.php'; +require_once __DIR__ . '/AbstractBestandteil.php'; + +use vertragsbestandteil\AbstractBestandteil; +use vertragsbestandteil\IValidation; const TYPE_ECHT = 'echterdv'; const TYPE_STUDENTISCHE_HILFSKRAFT = 'studentischehilfskr'; @@ -12,7 +16,7 @@ const TYPE_ECHT_FREI = 'echterfreier'; const TYPE_WERKVERTRAG = 'werkvertrag'; const TYPE_UEBERLASSUNG = 'ueberlassungsvertrag'; -class Dienstverhaeltnis implements IValidation { +class Dienstverhaeltnis extends AbstractBestandteil implements IValidation { protected $dienstverhaeltnis_id; protected $mitarbeiter_uid; protected $vertragsart_kurzbz; @@ -29,12 +33,14 @@ class Dienstverhaeltnis implements IValidation { public function __construct() { + parent::__construct(); $this->isvalid = false; $this->validationerrors = array(); } - public function hydrateByStdClass($data) + public function hydrateByStdClass($data, $fromdb=false) { + $this->fromdb = $fromdb; isset($data->dienstverhaeltnis_id) && $this->setDienstverhaeltnis_id($data->dienstverhaeltnis_id); isset($data->mitarbeiter_uid) && $this->setMitarbeiter_uid($data->mitarbeiter_uid); isset($data->vertragsart_kurzbz) && $this->setVertragsart_kurzbz($data->vertragsart_kurzbz); @@ -45,6 +51,7 @@ class Dienstverhaeltnis implements IValidation { isset($data->insertvon) && $this->setInsertvon($data->insertvon); isset($data->updateamum) && $this->setUpdateamum($data->updateamum); isset($data->updatevon) && $this->setUpdatevon($data->updatevon); + $this->fromdb = false; } public function toStdClass(): \stdClass @@ -62,9 +69,9 @@ class Dienstverhaeltnis implements IValidation { 'updatevon' => $this->getUpdatevon() ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } @@ -136,60 +143,70 @@ EOTXT; public function setDienstverhaeltnis_id($dienstverhaeltnis_id) { + $this->markDirty('dienstverhaeltnis_id', $this->dienstverhaeltnis_id, $dienstverhaeltnis_id); $this->dienstverhaeltnis_id = $dienstverhaeltnis_id; return $this; } public function setMitarbeiter_uid($mitarbeiter_uid) { + $this->markDirty('mitarbeiter_uid', $this->mitarbeiter_uid, $mitarbeiter_uid); $this->mitarbeiter_uid = $mitarbeiter_uid; return $this; } public function setVertragsart_kurzbz($vertragsart_kurzbz) { + $this->markDirty('vertragsart_kurzbz', $this->vertragsart_kurzbz, $vertragsart_kurzbz); $this->vertragsart_kurzbz = $vertragsart_kurzbz; return $this; } public function setOe_kurzbz($oe_kurzbz) { + $this->markDirty('oe_kurzbz', $this->oe_kurzbz, $oe_kurzbz); $this->oe_kurzbz = $oe_kurzbz; return $this; } public function setVon($von) { + $this->markDirty('von', $this->von, $von); $this->von = $von; return $this; } public function setBis($bis) { + $this->markDirty('bis', $this->bis, $bis); $this->bis = $bis; return $this; } public function setInsertamum($insertamum) { + $this->markDirty('insertamum', $this->insertamum, $insertamum); $this->insertamum = $insertamum; return $this; } public function setInsertvon($insertvon) { + $this->markDirty('insertvon', $this->insertvon, $insertvon); $this->insertvon = $insertvon; return $this; } public function setUpdateamum($updateamum) { + $this->markDirty('updateamum', $this->updateamum, $updateamum); $this->updateamum = $updateamum; return $this; } public function setUpdatevon($updatevon) { + $this->markDirty('updatevon', $this->updatevon, $updatevon); $this->updatevon = $updatevon; return $this; } diff --git a/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php b/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php index 6964907f3..3ad74704b 100644 --- a/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php +++ b/application/libraries/vertragsbestandteil/Gehaltsbestandteil.php @@ -1,12 +1,13 @@ isvalid = false; $this->validationerrors = array(); } - public function hydrateByStdClass($data) - { + public function hydrateByStdClass($data, $fromdb=false) + { + $this->fromdb = $fromdb; isset($data->gehaltsbestandteil_id) && $this->setGehaltsbestandteil_id($data->gehaltsbestandteil_id); isset($data->dienstverhaeltnis_id) && $this->setDienstverhaeltnis_id($data->dienstverhaeltnis_id); isset($data->vertragsbestandteil_id) && $this->setVertragsbestandteil_id($data->vertragsbestandteil_id); @@ -54,6 +57,7 @@ class Gehaltsbestandteil implements IValidation, \JsonSerializable isset($data->insertvon) && $this->setInsertvon($data->insertvon); isset($data->updateamum) && $this->setUpdateamum($data->updateamum); isset($data->updatevon) && $this->setUpdatevon($data->updatevon); + $this->fromdb = false; } public function getGehaltsbestandteil_id() @@ -153,96 +157,112 @@ class Gehaltsbestandteil implements IValidation, \JsonSerializable public function setGehaltsbestandteil_id($gehaltsbestandteil_id) { + $this->markDirty('gehaltsbestandteil_id', $this->gehaltsbestandteil_id, $gehaltsbestandteil_id); $this->gehaltsbestandteil_id = $gehaltsbestandteil_id; return $this; } public function setDienstverhaeltnis_id($dienstverhaeltnis_id) { + $this->markDirty('dienstverhaeltnis_id', $this->dienstverhaeltnis_id, $dienstverhaeltnis_id); $this->dienstverhaeltnis_id = $dienstverhaeltnis_id; return $this; } public function setVertragsbestandteil_id($vertragsbestandteil_id) { + $this->markDirty('vertragsbestandteil_id', $this->vertragsbestandteil_id, $vertragsbestandteil_id); $this->vertragsbestandteil_id = $vertragsbestandteil_id; return $this; } public function setGehaltstyp_kurzbz($gehaltstyp_kurzbz) { + $this->markDirty('gehaltstyp_kurzbz', $this->gehaltstyp_kurzbz, $gehaltstyp_kurzbz); $this->gehaltstyp_kurzbz = $gehaltstyp_kurzbz; return $this; } public function setVon($von) { + $this->markDirty('von', $this->von, $von); $this->von = $von; return $this; } public function setBis($bis) { + $this->markDirty('bis', $this->bis, $bis); $this->bis = $bis; return $this; } public function setAnmerkung($anmerkung) { + $this->markDirty('anmerkung', $this->anmerkung, $anmerkung); $this->anmerkung = $anmerkung; return $this; } public function setGrundbetrag($grundbetrag) { + $this->markDirty('grundbetrag', $this->grundbetrag, $grundbetrag); $this->grundbetrag = $grundbetrag; return $this; } public function setBetrag_valorisiert($betrag_valorisiert) { + $this->markDirty('betrag_valorisiert', $this->betrag_valorisiert, $betrag_valorisiert); $this->betrag_valorisiert = $betrag_valorisiert; return $this; } public function setValorisierungssperre($valorisierungssperre) { + $this->markDirty('valorisierungssperre', $this->valorisierungssperre, $valorisierungssperre); $this->valorisierungssperre = $valorisierungssperre; return $this; } public function setValorisierung($valorisierung) { + $this->markDirty('valorisierung', $this->valorisierung, $valorisierung); $this->valorisierung = $valorisierung; return $this; } public function setAuszahlungen($auszahlungen) { + $this->markDirty('auszahlungen', $this->auszahlungen, $auszahlungen); $this->auszahlungen = $auszahlungen; return $this; } public function setInsertamum($insertamum) { + $this->markDirty('insertamum', $this->insertamum, $insertamum); $this->insertamum = $insertamum; return $this; } public function setInsertvon($insertvon) { + $this->markDirty('insertvon', $this->insertvon, $insertvon); $this->insertvon = $insertvon; return $this; } public function setUpdateamum($updateamum) { + $this->markDirty('updateamum', $this->updateamum, $updateamum); $this->updateamum = $updateamum; return $this; } public function setUpdatevon($updatevon) { + $this->markDirty('updatevon', $this->updatevon, $updatevon); $this->updatevon = $updatevon; return $this; } @@ -275,9 +295,9 @@ class Gehaltsbestandteil implements IValidation, \JsonSerializable 'updatevon' => $this->getUpdatevon() ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } diff --git a/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php b/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php index c8673e5b4..74dc35672 100644 --- a/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/GehaltsbestandteilLib.php @@ -1,5 +1,6 @@ isDirty()) { + return; + } + $gehaltsbestandteil->setUpdatevon($this->loggedInUser) ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); $ret = $this->GehaltsbestandteilModel->update($gehaltsbestandteil->getGehaltsbestandteil_id(), diff --git a/application/libraries/vertragsbestandteil/Vertragsbestandteil.php b/application/libraries/vertragsbestandteil/Vertragsbestandteil.php index cf62966fc..cb3b066f8 100644 --- a/application/libraries/vertragsbestandteil/Vertragsbestandteil.php +++ b/application/libraries/vertragsbestandteil/Vertragsbestandteil.php @@ -1,12 +1,14 @@ gehaltsbestandteile = array(); $this->isvalid = false; $this->validationerrors = array(); } - public function hydrateByStdClass($data) - { + public function hydrateByStdClass($data, $fromdb=false) + { + $this->fromdb = $fromdb; isset($data->vertragsbestandteil_id) && $this->setVertragsbestandteil_id($data->vertragsbestandteil_id); isset($data->dienstverhaeltnis_id) && $this->setDienstverhaeltnis_id($data->dienstverhaeltnis_id); isset($data->von) && $this->setVon($data->von); @@ -40,6 +44,7 @@ abstract class Vertragsbestandteil implements \JsonSerializable, IValidation isset($data->insertvon) && $this->setInsertvon($data->insertvon); isset($data->updateamum) && $this->setUpdateamum($data->updateamum); isset($data->updatevon) && $this->setUpdatevon($data->updatevon); + $this->fromdb = false; } public function addGehaltsbestandteil(Gehaltsbestandteil $gehaltsbestandteil) @@ -108,6 +113,7 @@ abstract class Vertragsbestandteil implements \JsonSerializable, IValidation public function setVertragsbestandteil_id($vertragsbestandteil_id) { + $this->markDirty('vertragsbestandteil_id', $this->vertragsbestandteil_id, $vertragsbestandteil_id); $this->vertragsbestandteil_id = $vertragsbestandteil_id; foreach ($this->gehaltsbestandteile as $gehaltsbestandteil) { @@ -118,6 +124,7 @@ abstract class Vertragsbestandteil implements \JsonSerializable, IValidation public function setDienstverhaeltnis_id($dienstverhaeltnis_id) { + $this->markDirty('dienstverhaeltnis_id', $this->dienstverhaeltnis_id, $dienstverhaeltnis_id); $this->dienstverhaeltnis_id = $dienstverhaeltnis_id; foreach ($this->gehaltsbestandteile as $gehaltsbestandteil) { @@ -128,42 +135,50 @@ abstract class Vertragsbestandteil implements \JsonSerializable, IValidation public function setVon($von) { + $this->markDirty('von', $this->von, $von); $this->von = $von; return $this; } public function setBis($bis) { + $this->markDirty('bis', $this->bis, $bis); $this->bis = $bis; return $this; } public function setVertragsbestandteiltyp_kurzbz($vertragsbestandteiltyp_kurzbz) { + // type should never change and is set in constructor so do not mark dirty + //$this->markDirty('vertragsbestandteiltyp_kurzbz', $this->vertragsbestandteiltyp_kurzbz, $vertragsbestandteiltyp_kurzbz); $this->vertragsbestandteiltyp_kurzbz = $vertragsbestandteiltyp_kurzbz; return $this; } public function setInsertamum($insertamum) { + $this->markDirty('insertamum', $this->insertamum, $insertamum); $this->insertamum = $insertamum; return $this; } public function setInsertvon($insertvon) { + $this->markDirty('insertvon', $this->insertvon, $insertvon); $this->insertvon = $insertvon; return $this; } public function setUpdateamum($updateamum) { + $this->markDirty('updateamum', $this->updateamum, $updateamum); $this->updateamum = $updateamum; return $this; } public function setUpdatevon($updatevon) { + $this->markDirty('updatevon', $this->updatevon, $updatevon); $this->updatevon = $updatevon; return $this; } @@ -181,9 +196,9 @@ abstract class Vertragsbestandteil implements \JsonSerializable, IValidation 'updatevon' => $this->getUpdatevon(), ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php b/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php index 220ee5dff..6e7b0af06 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilFactory.php @@ -23,7 +23,7 @@ class VertragsbestandteilFactory const VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG = 'zeitaufzeichnung'; const VERTRAGSBESTANDTEIL_LEHRE = 'lehre'; - public static function getVertragsbestandteil($data) + public static function getVertragsbestandteil($data, $fromdb=false) { $vertragsbestandteiltyp_kurzbz = isset($data->vertragsbestandteiltyp_kurzbz) ? $data->vertragsbestandteiltyp_kurzbz : false; @@ -37,37 +37,37 @@ class VertragsbestandteilFactory { case self::VERTRAGSBESTANDTEIL_FREITEXT: $vertragsbestandteil = new VertragsbestandteilFreitext(); - $vertragsbestandteil->hydrateByStdClass($data); + $vertragsbestandteil->hydrateByStdClass($data, $fromdb); break; case self::VERTRAGSBESTANDTEIL_FUNKTION: $vertragsbestandteil = new VertragsbestandteilFunktion(); - $vertragsbestandteil->hydrateByStdClass($data); + $vertragsbestandteil->hydrateByStdClass($data, $fromdb); break; case self::VERTRAGSBESTANDTEIL_KARENZ: $vertragsbestandteil = new VertragsbestandteilKarenz(); - $vertragsbestandteil->hydrateByStdClass($data); + $vertragsbestandteil->hydrateByStdClass($data, $fromdb); break; case self::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST: $vertragsbestandteil = new VertragsbestandteilKuendigungsfrist(); - $vertragsbestandteil->hydrateByStdClass($data); + $vertragsbestandteil->hydrateByStdClass($data, $fromdb); break; case self::VERTRAGSBESTANDTEIL_STUNDEN: $vertragsbestandteil = new VertragsbestandteilStunden(); - $vertragsbestandteil->hydrateByStdClass($data); + $vertragsbestandteil->hydrateByStdClass($data, $fromdb); break; case self::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH: $vertragsbestandteil = new VertragsbestandteilUrlaubsanspruch(); - $vertragsbestandteil->hydrateByStdClass($data); + $vertragsbestandteil->hydrateByStdClass($data, $fromdb); break; case self::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG: $vertragsbestandteil = new VertragsbestandteilZeitaufzeichnung(); - $vertragsbestandteil->hydrateByStdClass($data); + $vertragsbestandteil->hydrateByStdClass($data, $fromdb); break; default: diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilFreitext.php b/application/libraries/vertragsbestandteil/VertragsbestandteilFreitext.php index 213067610..8d16e0ef0 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilFreitext.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilFreitext.php @@ -17,14 +17,16 @@ class VertragsbestandteilFreitext extends Vertragsbestandteil VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_FREITEXT); } - public function hydrateByStdClass($data) + public function hydrateByStdClass($data, $fromdb=false) { - parent::hydrateByStdClass($data); + parent::hydrateByStdClass($data, $fromdb); + $this->fromdb = $fromdb; isset($data->freitexttyp) && $this->setFreitexttypKurzbz($data->freitexttyp); isset($data->freitexttyp_kurzbz) && $this->setFreitexttypKurzbz($data->freitexttyp_kurzbz); isset($data->titel) && $this->setTitel($data->titel); isset($data->freitext) && $this->setAnmerkung($data->freitext); isset($data->anmerkung) && $this->setAnmerkung($data->anmerkung); + $this->fromdb = false; } public function toStdClass(): \stdClass @@ -36,9 +38,9 @@ class VertragsbestandteilFreitext extends Vertragsbestandteil 'anmerkung' => $this->getAnmerkung() ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } @@ -67,6 +69,7 @@ EOTXT; */ public function setAnmerkung($anmerkung): self { + $this->markDirty('anmerkung', $this->anmerkung, $anmerkung); $this->anmerkung = $anmerkung; return $this; @@ -85,6 +88,7 @@ EOTXT; */ public function setTitel($titel): self { + $this->markDirty('titel', $this->titel, $titel); $this->titel = $titel; return $this; @@ -94,7 +98,7 @@ EOTXT; * Get the value of freitexttyp_kurzbz */ public function getFreitexttypKurzbz() - { + { return $this->freitexttyp_kurzbz; } @@ -103,6 +107,7 @@ EOTXT; */ public function setFreitexttypKurzbz($freitexttyp_kurzbz): self { + $this->markDirty('freitexttyp_kurzbz', $this->freitexttyp_kurzbz, $freitexttyp_kurzbz); $this->freitexttyp_kurzbz = $freitexttyp_kurzbz; return $this; diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilFunktion.php b/application/libraries/vertragsbestandteil/VertragsbestandteilFunktion.php index 21cb861d4..374db9181 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilFunktion.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilFunktion.php @@ -78,9 +78,9 @@ class VertragsbestandteilFunktion extends Vertragsbestandteil 'benutzerfunktion_id' => $this->getBenutzerfunktion_id() ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } @@ -94,15 +94,17 @@ EOTXT; return parent::__toString() . $txt; } - public function hydrateByStdClass($data) + public function hydrateByStdClass($data, $fromdb=false) { - parent::hydrateByStdClass($data); + parent::hydrateByStdClass($data, $fromdb); + $this->fromdb = $fromdb; isset($data->benutzerfunktionid) && $this->setBenutzerfunktion_id($data->benutzerfunktionid); isset($data->benutzerfunktion_id) && $this->setBenutzerfunktion_id($data->benutzerfunktion_id); isset($data->funktion) && isset($data->orget) && isset($data->mitarbeiter_uid) && $this->createBenutzerfunktionData($data); isset($data->funktion_bezeichnung) && isset($data->oe_bezeichnung) && $this->createBenutzerfunktionData4Display($data); + $this->fromdb = false; } @@ -113,6 +115,7 @@ EOTXT; public function setBenutzerfunktion_id($benutzerfunktion_id) { + $this->markDirty('benutzerfunktion_id', $this->benutzerfunktion_id, $benutzerfunktion_id); $this->benutzerfunktion_id = $benutzerfunktion_id; return $this; } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilKarenz.php b/application/libraries/vertragsbestandteil/VertragsbestandteilKarenz.php index ba123503e..7b49bfe4c 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilKarenz.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilKarenz.php @@ -17,12 +17,14 @@ class VertragsbestandteilKarenz extends Vertragsbestandteil VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_KARENZ); } - public function hydrateByStdClass($data) + public function hydrateByStdClass($data, $fromdb=false) { - parent::hydrateByStdClass($data); + parent::hydrateByStdClass($data, $fromdb); + $this->fromdb = $fromdb; isset($data->karenztyp_kurzbz) && $this->setKarenztypKurzbz($data->karenztyp_kurzbz); isset($data->geplanter_geburtstermin) && $this->setGeplanterGeburtstermin($data->geplanter_geburtstermin); - isset($data->tatsaechlicher_geburtstermin) && $this->setTatsaechlicherGeburtstermin($data->tatsaechlicher_geburtstermin); + isset($data->tatsaechlicher_geburtstermin) && $this->setTatsaechlicherGeburtstermin($data->tatsaechlicher_geburtstermin); + $this->fromdb = false; } /** @@ -38,6 +40,7 @@ class VertragsbestandteilKarenz extends Vertragsbestandteil */ public function setKarenztypKurzbz($karenztyp_kurzbz): self { + $this->markDirty('karenztyp_kurzbz', $this->karenztyp_kurzbz, $karenztyp_kurzbz); $this->karenztyp_kurzbz = $karenztyp_kurzbz; return $this; @@ -47,7 +50,7 @@ class VertragsbestandteilKarenz extends Vertragsbestandteil * Get the value of tatsaechlicher_geburtstermin */ public function getTatsaechlicherGeburtstermin() - { + { return $this->tatsaechlicher_geburtstermin; } @@ -56,6 +59,7 @@ class VertragsbestandteilKarenz extends Vertragsbestandteil */ public function setTatsaechlicherGeburtstermin($tatsaechlicher_geburtstermin): self { + $this->markDirty('tatsaechlicher_geburtstermin', $this->tatsaechlicher_geburtstermin, $tatsaechlicher_geburtstermin); $this->tatsaechlicher_geburtstermin = $tatsaechlicher_geburtstermin; return $this; @@ -74,6 +78,7 @@ class VertragsbestandteilKarenz extends Vertragsbestandteil */ public function setGeplanterGeburtstermin($geplanter_geburtstermin): self { + $this->markDirty('geplanter_geburtstermin', $this->geplanter_geburtstermin, $geplanter_geburtstermin); $this->geplanter_geburtstermin = $geplanter_geburtstermin; return $this; @@ -88,9 +93,9 @@ class VertragsbestandteilKarenz extends Vertragsbestandteil 'geplanter_geburtstermin' => $this->getGeplanterGeburtstermin() ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilKuendigungsfrist.php b/application/libraries/vertragsbestandteil/VertragsbestandteilKuendigungsfrist.php index 1d2788b57..81ea0dcec 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilKuendigungsfrist.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilKuendigungsfrist.php @@ -16,11 +16,13 @@ class VertragsbestandteilKuendigungsfrist extends Vertragsbestandteil VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_KUENDIGUNGSFRIST); } - public function hydrateByStdClass($data) + public function hydrateByStdClass($data, $fromdb=false) { - parent::hydrateByStdClass($data); + parent::hydrateByStdClass($data, $fromdb); + $this->fromdb = $fromdb; isset($data->arbeitgeber_frist) && $this->setArbeitgeberFrist($data->arbeitgeber_frist); isset($data->arbeitnehmer_frist) && $this->setArbeitnehmerFrist($data->arbeitnehmer_frist); + $this->fromdb = false; } /** @@ -36,6 +38,7 @@ class VertragsbestandteilKuendigungsfrist extends Vertragsbestandteil */ public function setArbeitgeberFrist($arbeitgeber_frist): self { + $this->markDirty('arbeitgeber_frist', $this->arbeitgeber_frist, $arbeitgeber_frist); $this->arbeitgeber_frist = $arbeitgeber_frist; return $this; @@ -54,6 +57,7 @@ class VertragsbestandteilKuendigungsfrist extends Vertragsbestandteil */ public function setArbeitnehmerFrist($arbeitnehmer_frist): self { + $this->markDirty('arbeitnehmer_frist', $this->arbeitnehmer_frist, $arbeitnehmer_frist); $this->arbeitnehmer_frist = $arbeitnehmer_frist; return $this; @@ -67,9 +71,9 @@ class VertragsbestandteilKuendigungsfrist extends Vertragsbestandteil 'arbeitnehmer_frist' => $this->getArbeitnehmerFrist() ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php index 56b5760e8..6fbbebac7 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php @@ -1,5 +1,6 @@ hydrateByStdClass($row[0]); + $dv->hydrateByStdClass($row[0], true); } return $dv; } @@ -270,6 +271,10 @@ class VertragsbestandteilLib protected function updateDienstverhaeltnis(Dienstverhaeltnis $dv) { + if(!$dv->isDirty()) { + return; + } + $dv->setUpdatevon($this->loggedInUser) ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); $ret = $this->DienstverhaeltnisModel->update($dv->getDienstverhaeltnis_id(), @@ -315,26 +320,28 @@ class VertragsbestandteilLib protected function updateVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { - $vertragsbestandteil->setUpdatevon($this->loggedInUser) - ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); - $vertragsbestandteil->beforePersist(); - $ret = $this->VertragsbestandteilModel->update($vertragsbestandteil->getVertragsbestandteil_id(), - $vertragsbestandteil->baseToStdClass()); - - if(isError($ret) ) - { - throw new Exception('error updating vertragsbestandteil'); - } - - $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( - $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); - $retspecial = $specialisedModel->update($vertragsbestandteil->getVertragsbestandteil_id(), - $vertragsbestandteil->toStdClass()); - - if(isError($retspecial) ) - { - throw new Exception('error updating vertragsbestandteil ' - . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); + if($vertragsbestandteil->isDirty()) { + $vertragsbestandteil->setUpdatevon($this->loggedInUser) + ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); + $vertragsbestandteil->beforePersist(); + $ret = $this->VertragsbestandteilModel->update($vertragsbestandteil->getVertragsbestandteil_id(), + $vertragsbestandteil->baseToStdClass()); + + if(isError($ret) ) + { + throw new Exception('error updating vertragsbestandteil'); + } + + $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( + $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); + $retspecial = $specialisedModel->update($vertragsbestandteil->getVertragsbestandteil_id(), + $vertragsbestandteil->toStdClass()); + + if(isError($retspecial) ) + { + throw new Exception('error updating vertragsbestandteil ' + . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); + } } try diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilStunden.php b/application/libraries/vertragsbestandteil/VertragsbestandteilStunden.php index ff9318134..e49a227c6 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilStunden.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilStunden.php @@ -24,11 +24,13 @@ class VertragsbestandteilStunden extends Vertragsbestandteil VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_STUNDEN); } - public function hydrateByStdClass($data) + public function hydrateByStdClass($data, $fromdb=false) { - parent::hydrateByStdClass($data); + parent::hydrateByStdClass($data, $fromdb); + $this->fromdb = $fromdb; isset($data->wochenstunden) && $this->setWochenstunden($data->wochenstunden); isset($data->teilzeittyp_kurzbz) && $this->setTeilzeittyp_kurzbz($data->teilzeittyp_kurzbz); + $this->fromdb = false; } public function getWochenstunden() @@ -43,14 +45,17 @@ class VertragsbestandteilStunden extends Vertragsbestandteil public function setWochenstunden($wochenstunden) { + $this->markDirty('wochenstunden', $this->wochenstunden, $wochenstunden); $this->wochenstunden = $wochenstunden; return $this; } public function setTeilzeittyp_kurzbz($teilzeittyp_kurzbz) { - $this->teilzeittyp_kurzbz = ($teilzeittyp_kurzbz !== '') + $teilzeittyp_kurzbz = ($teilzeittyp_kurzbz !== '') ? $teilzeittyp_kurzbz : null; + $this->markDirty('teilzeittyp_kurzbz', $this->teilzeittyp_kurzbz, $teilzeittyp_kurzbz); + $this->teilzeittyp_kurzbz = $teilzeittyp_kurzbz; return $this; } @@ -62,9 +67,9 @@ class VertragsbestandteilStunden extends Vertragsbestandteil 'teilzeittyp_kurzbz' => $this->getTeilzeittyp_kurzbz() ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilUrlaubsanspruch.php b/application/libraries/vertragsbestandteil/VertragsbestandteilUrlaubsanspruch.php index fde150317..fe683211d 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilUrlaubsanspruch.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilUrlaubsanspruch.php @@ -15,10 +15,12 @@ class VertragsbestandteilUrlaubsanspruch extends Vertragsbestandteil VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_URLAUBSANSPRUCH); } - public function hydrateByStdClass($data) + public function hydrateByStdClass($data, $fromdb=false) { - parent::hydrateByStdClass($data); + parent::hydrateByStdClass($data, $fromdb); + $this->fromdb = $fromdb; isset($data->tage) && $this->setTage($data->tage); + $this->fromdb = false; } /** @@ -34,6 +36,7 @@ class VertragsbestandteilUrlaubsanspruch extends Vertragsbestandteil */ public function setTage($tage): self { + $this->markDirty('tage', $this->tage, $tage); $this->tage = $tage; return $this; @@ -46,9 +49,9 @@ class VertragsbestandteilUrlaubsanspruch extends Vertragsbestandteil 'tage' => $this->getTage(), ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung.php b/application/libraries/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung.php index 3fce91995..5bbdaa36f 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilZeitaufzeichnung.php @@ -17,12 +17,14 @@ class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil VertragsbestandteilFactory::VERTRAGSBESTANDTEIL_ZEITAUFZEICHNUNG); } - public function hydrateByStdClass($data) + public function hydrateByStdClass($data, $fromdb=false) { - parent::hydrateByStdClass($data); + parent::hydrateByStdClass($data, $fromdb); + $this->fromdb = $fromdb; isset($data->zeitaufzeichnung) && $this->setZeitaufzeichnung($data->zeitaufzeichnung); isset($data->azgrelevant) && $this->setAzgrelevant($data->azgrelevant); isset($data->homeoffice) && $this->setHomeoffice($data->homeoffice); + $this->fromdb = false; } /** @@ -38,6 +40,7 @@ class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil */ public function setZeitaufzeichnung($zeitaufzeichnung): self { + $this->markDirty('zeitaufzeichnung', $this->zeitaufzeichnung, $zeitaufzeichnung); $this->zeitaufzeichnung = $zeitaufzeichnung; return $this; @@ -56,6 +59,7 @@ class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil */ public function setAzgrelevant($azgrelevant): self { + $this->markDirty('azgrelevant', $this->azgrelevant, $azgrelevant); $this->azgrelevant = $azgrelevant; return $this; @@ -74,6 +78,7 @@ class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil */ public function setHomeoffice($homeoffice): self { + $this->markDirty('homeoffice', $this->homeoffice, $homeoffice); $this->homeoffice = $homeoffice; return $this; @@ -88,9 +93,9 @@ class VertragsbestandteilZeitaufzeichnung extends Vertragsbestandteil 'homeoffice' => $this->getHomeoffice() ); - $tmp = array_filter($tmp, function($v) { - return !is_null($v); - }); + $tmp = array_filter($tmp, function($k) { + return in_array($k, $this->modifiedcolumns); + }, ARRAY_FILTER_USE_KEY); return (object) $tmp; } diff --git a/application/models/vertragsbestandteil/Gehaltsbestandteil_model.php b/application/models/vertragsbestandteil/Gehaltsbestandteil_model.php index f640e25d0..4623e6157 100644 --- a/application/models/vertragsbestandteil/Gehaltsbestandteil_model.php +++ b/application/models/vertragsbestandteil/Gehaltsbestandteil_model.php @@ -121,7 +121,7 @@ EOSQL; { foreach( $rows as $row ) { $tmpgb = new Gehaltsbestandteil(); - $tmpgb->hydrateByStdClass($row); + $tmpgb->hydrateByStdClass($row, true); $gehaltsbestandteile[] = $tmpgb; } } @@ -139,7 +139,7 @@ EOSQL; if( null !== ($row = getData($query)) ) { $gehaltsbestandteil = new Gehaltsbestandteil(); - $gehaltsbestandteil->hydrateByStdClass($row[0]); + $gehaltsbestandteil->hydrateByStdClass($row[0], true); } return $gehaltsbestandteil; diff --git a/application/models/vertragsbestandteil/Vertragsbestandteil_model.php b/application/models/vertragsbestandteil/Vertragsbestandteil_model.php index a5df8ed0d..233df350c 100644 --- a/application/models/vertragsbestandteil/Vertragsbestandteil_model.php +++ b/application/models/vertragsbestandteil/Vertragsbestandteil_model.php @@ -97,7 +97,7 @@ EOSQL; foreach( $data as $row ) { try { - $vertragsbestandteile[] = VertragsbestandteilFactory::getVertragsbestandteil($row); + $vertragsbestandteile[] = VertragsbestandteilFactory::getVertragsbestandteil($row, true); } catch (Exception $ex) { @@ -129,7 +129,7 @@ EOSQL; $data = getData($query)[0]; try { - $vertragsbestandteil = VertragsbestandteilFactory::getVertragsbestandteil($data); // TODO add decryption + $vertragsbestandteil = VertragsbestandteilFactory::getVertragsbestandteil($data, true); // TODO add decryption } catch (Exception $ex) { diff --git a/application/views/templates/FHC-Footer.php b/application/views/templates/FHC-Footer.php index 31ee96950..225c70517 100644 --- a/application/views/templates/FHC-Footer.php +++ b/application/views/templates/FHC-Footer.php @@ -123,6 +123,7 @@ generateJSsInclude('vendor/npm-asset/primevue/calendar/calendar.min.js'); generateJSsInclude('vendor/npm-asset/primevue/skeleton/skeleton.min.js'); generateJSsInclude('vendor/npm-asset/primevue/timeline/timeline.min.js'); + generateJSsInclude('vendor/npm-asset/primevue/autocomplete/autocomplete.min.js'); } // -------------------------------------------------------------------------------------------------------- diff --git a/composer.json b/composer.json index 229b83a98..d9da3b2d8 100644 --- a/composer.json +++ b/composer.json @@ -352,9 +352,9 @@ "type": "package", "package": { "name": "vuejs/vuedatepicker_js", - "version": "4.2.3", + "version": "5.4.0", "dist": { - "url": "https://unpkg.com/@vuepic/vue-datepicker@4.2.3/dist/vue-datepicker.iife.js", + "url": "https://unpkg.com/@vuepic/vue-datepicker@5.4.0/dist/vue-datepicker.iife.js", "type": "file" } } @@ -363,9 +363,9 @@ "type": "package", "package": { "name": "vuejs/vuedatepicker_css", - "version": "4.2.3", + "version": "5.4.0", "dist": { - "url": "https://unpkg.com/@vuepic/vue-datepicker@4.2.3/dist/main.css", + "url": "https://unpkg.com/@vuepic/vue-datepicker@5.4.0/dist/main.css", "type": "file" } } @@ -422,7 +422,7 @@ "nategood/httpful": "0.2.*", "netcarver/textile": "3.7.*", "nicolaskruchten/pivottable": "2.23.0", - "npm-asset/primevue": "3.15.*", + "npm-asset/primevue": "3.29.1", "npm-asset/primeicons": "5.0.0", "olifolkerd/tabulator4": "4.9.*", @@ -443,8 +443,8 @@ "vuejs/vuejs3": "3.2.33", "vuejs/vuerouter4": "4.1.3", - "vuejs/vuedatepicker_js": "4.2.3", - "vuejs/vuedatepicker_css": "4.2.3" + "vuejs/vuedatepicker_js": "5.4.0", + "vuejs/vuedatepicker_css": "5.4.0" }, "config": { "bin-dir": "vendor/bin" diff --git a/composer.lock b/composer.lock index e5a839b3b..645cd0cae 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "12acec21673c71641f7f1a6586ec666f", + "content-hash": "ca679afc87606768c8ae706f9a8ac6b6", "packages": [ { "name": "afarkas/html5shiv", @@ -1490,10 +1490,10 @@ }, { "name": "npm-asset/primevue", - "version": "3.15.0", + "version": "3.29.1", "dist": { "type": "tar", - "url": "https://registry.npmjs.org/primevue/-/primevue-3.15.0.tgz" + "url": "https://registry.npmjs.org/primevue/-/primevue-3.29.1.tgz" }, "type": "npm-asset", "license": [ @@ -1850,19 +1850,19 @@ }, { "name": "vuejs/vuedatepicker_css", - "version": "4.2.3", + "version": "5.4.0", "dist": { "type": "file", - "url": "https://unpkg.com/@vuepic/vue-datepicker@4.2.3/dist/main.css" + "url": "https://unpkg.com/@vuepic/vue-datepicker@5.4.0/dist/main.css" }, "type": "library" }, { "name": "vuejs/vuedatepicker_js", - "version": "4.2.3", + "version": "5.4.0", "dist": { "type": "file", - "url": "https://unpkg.com/@vuepic/vue-datepicker@4.2.3/dist/vue-datepicker.iife.js" + "url": "https://unpkg.com/@vuepic/vue-datepicker@5.4.0/dist/vue-datepicker.iife.js" }, "type": "library" }, @@ -4738,5 +4738,5 @@ "php": ">=5.6.40" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.1.0" }