From 3a8216577ffb5e60557ecfbbacea62a8070fbed1 Mon Sep 17 00:00:00 2001 From: KarpAlex Date: Thu, 9 Nov 2023 10:53:04 +0100 Subject: [PATCH 01/10] added column habilitation to tbl_mitarbeiter --- .../dbupdate_3.4/33003_bis_meldung_personal.php | 15 +++++++++++++++ .../dbupdate_3.4/anrechnung_von_outgoing_lvs.php | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 system/dbupdate_3.4/33003_bis_meldung_personal.php create mode 100644 system/dbupdate_3.4/anrechnung_von_outgoing_lvs.php diff --git a/system/dbupdate_3.4/33003_bis_meldung_personal.php b/system/dbupdate_3.4/33003_bis_meldung_personal.php new file mode 100644 index 000000000..f59d6770e --- /dev/null +++ b/system/dbupdate_3.4/33003_bis_meldung_personal.php @@ -0,0 +1,15 @@ +db_query("SELECT habilitation FROM public.tbl_mitarbeiter LIMIT 1")) +{ + $qry = "ALTER TABLE public.tbl_mitarbeiter ADD COLUMN habilitation boolean NOT NULL DEFAULT false; + COMMENT ON COLUMN public.tbl_mitarbeiter.habilitation IS 'Zeigt an, ob Mitarbeiter habilitiert ist (BIS relevant).'; + "; + + if(!$db->db_query($qry)) + echo 'public.tbl_mitarbeiter '.$db->db_last_error().'
'; + else + echo '
Spalte habilitation zu Tabelle public.tbl_mitarbeiter hinzugefügt'; +} diff --git a/system/dbupdate_3.4/anrechnung_von_outgoing_lvs.php b/system/dbupdate_3.4/anrechnung_von_outgoing_lvs.php new file mode 100644 index 000000000..0af077e66 --- /dev/null +++ b/system/dbupdate_3.4/anrechnung_von_outgoing_lvs.php @@ -0,0 +1,16 @@ +db_query("SELECT 1 FROM system.tbl_app WHERE app='mobilityonline'")) +{ + if($db->db_num_rows($result)==0) + { + $qry = "INSERT INTO system.tbl_app(app) VALUES('mobilityonline');"; + + if(!$db->db_query($qry)) + echo 'App: '.$db->db_last_error().'
'; + else + echo '
Neue App mobilityonline in system.tbl_app hinzugefügt'; + } +} From cf85cb084f60debc4c4437a2a78675d29a323cf6 Mon Sep 17 00:00:00 2001 From: KarpAlex Date: Wed, 15 Nov 2023 20:51:44 +0100 Subject: [PATCH 02/10] dbupdate habilitation: added file to dbupdate3.4, code formatting --- system/dbupdate_3.4.php | 1 + system/dbupdate_3.4/33003_bis_meldung_personal.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/dbupdate_3.4.php b/system/dbupdate_3.4.php index 458f178d4..1b4b67b36 100644 --- a/system/dbupdate_3.4.php +++ b/system/dbupdate_3.4.php @@ -45,6 +45,7 @@ require_once('dbupdate_3.4/30537_anmerkung_in_tbl_rolleberechtigung.php'); require_once('dbupdate_3.4/30181_tabelle_anrechnung_neue_attribute_fuer_begruendung.php'); require_once('dbupdate_3.4/29529_infocenter_anpassungen.php'); require_once('dbupdate_3.4/29835_uhstat1_erfassung_der_uhstat1_daten_ueber_das_bewerbungstool.php'); +require_once('dbupdate_3.4/33003_bis_meldung_personal.php'); // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen diff --git a/system/dbupdate_3.4/33003_bis_meldung_personal.php b/system/dbupdate_3.4/33003_bis_meldung_personal.php index f59d6770e..eb49217ea 100644 --- a/system/dbupdate_3.4/33003_bis_meldung_personal.php +++ b/system/dbupdate_3.4/33003_bis_meldung_personal.php @@ -5,8 +5,7 @@ if (! defined('DB_NAME')) exit('No direct script access allowed'); if(!@$db->db_query("SELECT habilitation FROM public.tbl_mitarbeiter LIMIT 1")) { $qry = "ALTER TABLE public.tbl_mitarbeiter ADD COLUMN habilitation boolean NOT NULL DEFAULT false; - COMMENT ON COLUMN public.tbl_mitarbeiter.habilitation IS 'Zeigt an, ob Mitarbeiter habilitiert ist (BIS relevant).'; - "; + COMMENT ON COLUMN public.tbl_mitarbeiter.habilitation IS 'Zeigt an, ob Mitarbeiter habilitiert ist (BIS relevant).';"; if(!$db->db_query($qry)) echo 'public.tbl_mitarbeiter '.$db->db_last_error().'
'; From 3e7d91718445aec64fdf2845fae46ea894fd4eb0 Mon Sep 17 00:00:00 2001 From: KarpAlex Date: Fri, 22 Dec 2023 19:07:15 +0100 Subject: [PATCH 03/10] deleted anrechnung von outgoing lvs file in dbupdate folder --- .../dbupdate_3.4/anrechnung_von_outgoing_lvs.php | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 system/dbupdate_3.4/anrechnung_von_outgoing_lvs.php diff --git a/system/dbupdate_3.4/anrechnung_von_outgoing_lvs.php b/system/dbupdate_3.4/anrechnung_von_outgoing_lvs.php deleted file mode 100644 index 0af077e66..000000000 --- a/system/dbupdate_3.4/anrechnung_von_outgoing_lvs.php +++ /dev/null @@ -1,16 +0,0 @@ -db_query("SELECT 1 FROM system.tbl_app WHERE app='mobilityonline'")) -{ - if($db->db_num_rows($result)==0) - { - $qry = "INSERT INTO system.tbl_app(app) VALUES('mobilityonline');"; - - if(!$db->db_query($qry)) - echo 'App: '.$db->db_last_error().'
'; - else - echo '
Neue App mobilityonline in system.tbl_app hinzugefügt'; - } -} From 304caf9157f761a9492888bf74b48a676b608447 Mon Sep 17 00:00:00 2001 From: Werner Masik Date: Thu, 18 Jan 2024 12:30:35 +0100 Subject: [PATCH 04/10] added time recording query --- .../ressource/Zeitaufzeichnung_model.php | 22 +++++++++++++++++++ system/phrasesupdate.php | 20 +++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/application/models/ressource/Zeitaufzeichnung_model.php b/application/models/ressource/Zeitaufzeichnung_model.php index b44861d13..8639a716a 100644 --- a/application/models/ressource/Zeitaufzeichnung_model.php +++ b/application/models/ressource/Zeitaufzeichnung_model.php @@ -21,4 +21,26 @@ class Zeitaufzeichnung_model extends DB_Model return $this->execQuery($qry); } + + public function getFullInterval($uid, $fromDate, $toDate) + { + $qry = <<execQuery($qry, array($uid, $fromDate, $toDate, $uid, $fromDate, $toDate, $fromDate, $toDate)); + } } diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 487f5d81a..f472aa9db 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -24035,6 +24035,26 @@ array( ) ) ), + array( + 'app' => 'personalverwaltung', + 'category' => 'zeitaufzeichnung', + 'phrase' => 'id', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'ID', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'ID', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), // Personalverwaltung end array( 'app' => 'core', From 72bcb919aaa98b8d82c0423bf2e0b43626fd39e7 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Thu, 25 Jan 2024 12:41:32 +0100 Subject: [PATCH 05/10] prevent returning html entities in sanitizeProblemChars helper --- application/helpers/hlp_common_helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 707d055ea..3e682e56c 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -356,7 +356,8 @@ function sanitizeProblemChars($str) 'ss' => '/ß/' ); - return preg_replace($acentos, array_keys($acentos), htmlentities($str, ENT_NOQUOTES | ENT_HTML5, $enc)); + $tmp = preg_replace($acentos, array_keys($acentos), htmlentities($str, ENT_NOQUOTES | ENT_HTML5, $enc)); + return html_entity_decode($tmp, ENT_NOQUOTES | ENT_HTML5, $enc); } /** From 1d300a604f59e130040cbc2ffc1ebe1f3ecaca69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 8 Feb 2024 08:03:34 +0100 Subject: [PATCH 06/10] =?UTF-8?q?Funktion=20zum=20Migrieren=20der=20Habili?= =?UTF-8?q?ation=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/system/MigrateContract.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/application/controllers/system/MigrateContract.php b/application/controllers/system/MigrateContract.php index 99b894473..f011be356 100644 --- a/application/controllers/system/MigrateContract.php +++ b/application/controllers/system/MigrateContract.php @@ -677,4 +677,35 @@ class MigrateContract extends CLI_Controller else return 0; } + + /** + * Habilitation wird aus der Tabelle bis.tbl_bisverwendung in die Tabelle public.tbl_mitarbeiter uebernommen + * Sofern die Person einmal in den Verwendungen eine habiliation eingetragen hat wird diese in den MA-Datensatz übernommen + * Da es in der regel öfter vorkommt dass das hakerl vergessen wurde beim Vertragswechsel als dass die person die habiliation verliert. + */ + public function migrateHabilitation() + { + $this->load->model('ressource/Mitarbeiter_model','MitarbeiterModel'); + $db = new DB_Model(); + + $qry = " + SELECT + distinct mitarbeiter_uid + FROM + bis.tbl_bisverwendung + WHERE + habilitation=true"; + + $resultHabilitation = $db->execReadOnlyQuery($qry); + + if (isSuccess($resultHabilitation) && hasData($resultHabilitation)) + { + $habilitationen = getData($resultHabilitation); + + foreach ($habilitationen as $row_habilitationen) + { + $this->MitarbeiterModel->update($row_habilitationen->mitarbeiter_uid, array('habilitation'=>true)); + } + } + } } From cd64df28bb4e1a803b3442be7f4560a34dc1d9c4 Mon Sep 17 00:00:00 2001 From: Werner Masik Date: Tue, 20 Feb 2024 15:02:14 +0100 Subject: [PATCH 07/10] added phrase for habilitation --- system/phrasesupdate.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index f472aa9db..631ca9627 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -23715,6 +23715,26 @@ array( ) ) ), + array( + 'app' => 'personalverwaltung', + 'category' => 'person', + 'phrase' => 'habilitation', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Habilitation', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Habilitation', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), array( 'app' => 'personalverwaltung', 'category' => 'person', From fff0e937cca394103a94c2f08db82d7615366223 Mon Sep 17 00:00:00 2001 From: Werner Masik Date: Wed, 21 Feb 2024 16:23:39 +0100 Subject: [PATCH 08/10] added Method to end DV and deactivate Benutzer --- .../VertragsbestandteilLib.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php index 8fb3900d5..a4111b310 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php @@ -32,6 +32,8 @@ class VertragsbestandteilLib protected $DienstverhaeltnisModel; /** @var Vertragsbestandteil_model */ protected $VertragsbestandteilModel; + /** @var Benutzer_model */ + protected $BenutzerModel; /** * @var GehaltsbestandteilLib */ @@ -49,6 +51,9 @@ class VertragsbestandteilLib $this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model', 'VertragsbestandteilModel'); $this->VertragsbestandteilModel = $this->CI->VertragsbestandteilModel; + $this->CI->load->model('person/benutzer_model', + 'BenutzerModel'); + $this->BenutzerModel = $this->CI->BenutzerModel; $this->CI->load->library('vertragsbestandteil/GehaltsbestandteilLib', null, 'GehaltsbestandteilLib'); $this->GehaltsbestandteilLib = $this->CI->GehaltsbestandteilLib; @@ -383,6 +388,21 @@ class VertragsbestandteilLib ); } + /** + * like endDienstverhaeltnis, but also sets aktiv flag to false + */ + public function deactivateDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate, $deactivate) + { + $result = $this->endDienstverhaeltnis($dv, $enddate); + if ( $result === true) + { + if (!$deactivate) return $result; + $result = $this->BenutzerModel->update(array('uid' => $dv->getMitarbeiter_uid()), array('aktiv' => false)); + } + + return $result; + } + public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate) { if( $dv->getBis() !== null && $dv->getBis() < $enddate ) From 6869c147ef34a03b3c0fa09d6704f2cf22651c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Tue, 5 Mar 2024 11:32:30 +0100 Subject: [PATCH 09/10] Beim deaktivieren von Benutzern wird Updateaktivam und Updateaktivvon gesetzt --- .../VertragsbestandteilLib.php | 151 +++++++++--------- 1 file changed, 79 insertions(+), 72 deletions(-) diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php index a4111b310..0bcede083 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php @@ -26,7 +26,7 @@ class VertragsbestandteilLib { const INCLUDE_FUTURE = true; const DO_NOT_INCLUDE_FUTURE = false; - + protected $CI; /** @var Dienstverhaeltnis_model */ protected $DienstverhaeltnisModel; @@ -34,27 +34,27 @@ class VertragsbestandteilLib protected $VertragsbestandteilModel; /** @var Benutzer_model */ protected $BenutzerModel; - /** + /** * @var GehaltsbestandteilLib */ protected $GehaltsbestandteilLib; - + protected $loggedInUser; - + public function __construct() { $this->loggedInUser = getAuthUID(); $this->CI = get_instance(); - $this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model', + $this->CI->load->model('vertragsbestandteil/Dienstverhaeltnis_model', 'DienstverhaeltnisModel'); $this->DienstverhaeltnisModel = $this->CI->DienstverhaeltnisModel; - $this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model', + $this->CI->load->model('vertragsbestandteil/Vertragsbestandteil_model', 'VertragsbestandteilModel'); $this->VertragsbestandteilModel = $this->CI->VertragsbestandteilModel; - $this->CI->load->model('person/benutzer_model', + $this->CI->load->model('person/benutzer_model', 'BenutzerModel'); $this->BenutzerModel = $this->CI->BenutzerModel; - $this->CI->load->library('vertragsbestandteil/GehaltsbestandteilLib', + $this->CI->load->library('vertragsbestandteil/GehaltsbestandteilLib', null, 'GehaltsbestandteilLib'); $this->GehaltsbestandteilLib = $this->CI->GehaltsbestandteilLib; } @@ -68,7 +68,7 @@ class VertragsbestandteilLib } catch (Exception $ex) { log_message('debug', "Error handling json data from GUI. " . $ex->getMessage()); - } + } return $ret; } @@ -77,40 +77,40 @@ class VertragsbestandteilLib { $result = $this->DienstverhaeltnisModel->load($dienstverhaeltnis_id); $dv = null; - if(null !== ($row = getData($result))) + if(null !== ($row = getData($result))) { $dv = new Dienstverhaeltnis(); $dv->hydrateByStdClass($row[0], true); } return $dv; } - + public function fetchVertragsbestandteile($dienstverhaeltnis_id, $stichtag=null, $includefuture=false) { $vbs = $this->VertragsbestandteilModel->getVertragsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture); $gbs = $this->GehaltsbestandteilLib->fetchGehaltsbestandteile($dienstverhaeltnis_id, $stichtag, $includefuture); - + $gbsByVBid = array(); - foreach( $gbs as $gb ) + foreach( $gbs as $gb ) { - if( intval($gb->getVertragsbestandteil_id()) > 0 ) + if( intval($gb->getVertragsbestandteil_id()) > 0 ) { - if( !isset($gbsByVBid[$gb->getVertragsbestandteil_id()]) + if( !isset($gbsByVBid[$gb->getVertragsbestandteil_id()]) || !is_array($gbsByVBid[$gb->getVertragsbestandteil_id()]) ) { $gbsByVBid[$gb->getVertragsbestandteil_id()] = array(); } $gbsByVBid[$gb->getVertragsbestandteil_id()][] = $gb; } } - + foreach ($vbs as $vb) { - if( isset($gbsByVBid[$vb->getVertragsbestandteil_id()]) ) + if( isset($gbsByVBid[$vb->getVertragsbestandteil_id()]) ) { $vb->setGehaltsbestandteile($gbsByVBid[$vb->getVertragsbestandteil_id()]); } } - + return $vbs; } @@ -118,22 +118,22 @@ class VertragsbestandteilLib { return $this->VertragsbestandteilModel->getVertragsbestandteil($vertragsbestandteil_id); } - + public function storeDienstverhaeltnis(Dienstverhaeltnis $dv) { if( intval($dv->getDienstverhaeltnis_id()) > 0 ) { $this->updateDienstverhaeltnis($dv); } - else + else { - $this->insertDienstverhaeltnis($dv); + $this->insertDienstverhaeltnis($dv); } } - - public function storeVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) + + public function storeVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { - $this->CI->db->trans_begin(); + $this->CI->db->trans_begin(); try { $this->setUIDtoPGSQL(); @@ -149,7 +149,7 @@ class VertragsbestandteilLib { log_message('debug', "Transaction failed"); throw new Exception("Transaction failed"); - } + } $this->CI->db->trans_commit(); } catch (Exception $ex) @@ -157,7 +157,7 @@ class VertragsbestandteilLib log_message('debug', "Transaction rolled back. " . $ex->getMessage()); $this->CI->db->trans_rollback(); throw new Exception('Storing Vertragsbestandteil failed.'); - } + } } public function deleteDienstverhaeltnis(Dienstverhaeltnis $dv) @@ -225,13 +225,13 @@ class VertragsbestandteilLib throw new Exception('Delete Vertragsbestandteil failed.'); } } - + protected function insertDienstverhaeltnis(Dienstverhaeltnis $dv) { $dv->setInsertvon($this->loggedInUser) ->setInsertamum(strftime('%Y-%m-%d %H:%M:%S')); $ret = $this->DienstverhaeltnisModel->insert($dv->toStdClass()); - if( hasData($ret) ) + if( hasData($ret) ) { $dv->setDienstverhaeltnis_id(getData($ret)); } @@ -240,14 +240,14 @@ class VertragsbestandteilLib throw new Exception('error inserting dienstverhaeltnis'); } } - + protected function insertVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { $vertragsbestandteil->setInsertvon($this->loggedInUser) ->setInsertamum(strftime('%Y-%m-%d %H:%M:%S')); $vertragsbestandteil->beforePersist(); $ret = $this->VertragsbestandteilModel->insert($vertragsbestandteil->baseToStdClass()); - if( hasData($ret) ) + if( hasData($ret) ) { $vertragsbestandteil->setVertragsbestandteil_id(getData($ret)); } @@ -259,19 +259,19 @@ class VertragsbestandteilLib $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); $retspecial = $specialisedModel->insert($vertragsbestandteil->toStdClass()); - + if(isError($retspecial) ) { - throw new Exception('error updating vertragsbestandteil ' + throw new Exception('error updating vertragsbestandteil ' . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); } - - try + + try { $gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile(); $this->GehaltsbestandteilLib->storeGehaltsbestandteile($gehaltsbestandteile); - } - catch(Exception $ex) + } + catch(Exception $ex) { throw new Exception('VertragsbestandteilLib insertVertragsbestandteil ' . 'failed to store Gehaltsbestandteile. ' . $ex->getMessage()); @@ -283,7 +283,7 @@ class VertragsbestandteilLib if(!$dv->isDirty()) { return; } - + $dv->setUpdatevon($this->loggedInUser) ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); $ret = $this->DienstverhaeltnisModel->update($dv->getDienstverhaeltnis_id(), @@ -293,20 +293,20 @@ class VertragsbestandteilLib throw new Exception('error updating dienstverhaeltnis'); } } - + private function deleteVertragsbestandteilHelper(Vertragsbestandteil $vertragsbestandteil) { $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); $retspecial = $specialisedModel->delete($vertragsbestandteil->getVertragsbestandteil_id()); - + if(isError($retspecial) ) { throw new Exception('error deleting vertragsbestandteil ' . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); } - + try { $gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile(); @@ -325,69 +325,69 @@ class VertragsbestandteilLib { throw new Exception('error deleting vertragsbestandteil'); } - + $vertragsbestandteil->afterDelete(); } protected function updateVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil) { - if($vertragsbestandteil->isDirty()) { + if($vertragsbestandteil->isDirty()) { $vertragsbestandteil->setUpdatevon($this->loggedInUser) ->setUpdateamum(strftime('%Y-%m-%d %H:%M:%S')); $vertragsbestandteil->beforePersist(); $basedata = $vertragsbestandteil->baseToStdClass(); - if( count((array) $basedata) > 0 ) + if( count((array) $basedata) > 0 ) { $ret = $this->VertragsbestandteilModel->update( - $vertragsbestandteil->getVertragsbestandteil_id(), + $vertragsbestandteil->getVertragsbestandteil_id(), $basedata); if(isError($ret) ) { throw new Exception('error updating vertragsbestandteil'); - } + } } $specialisedData = $vertragsbestandteil->toStdClass(); - if( count((array) $specialisedData) > 0 ) + if( count((array) $specialisedData) > 0 ) { $specialisedModel = VertragsbestandteilFactory::getVertragsbestandteilDBModel( $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); $retspecial = $specialisedModel->update( - $vertragsbestandteil->getVertragsbestandteil_id(), + $vertragsbestandteil->getVertragsbestandteil_id(), $specialisedData); if(isError($retspecial) ) { - throw new Exception('error updating vertragsbestandteil ' + throw new Exception('error updating vertragsbestandteil ' . $vertragsbestandteil->getVertragsbestandteiltyp_kurzbz()); } } } - - try + + try { $gehaltsbestandteile = $vertragsbestandteil->getGehaltsbestandteile(); $this->GehaltsbestandteilLib->storeGehaltsbestandteile($gehaltsbestandteile); - } - catch(Exception $ex) + } + catch(Exception $ex) { throw new Exception('VertragsbestandteilLib updateVertragsbestandteil ' . 'failed to store Gehaltsbestandteile. ' . $ex->getMessage()); } } - - public function isOverlappingExistingDV(Dienstverhaeltnis $dv) + + public function isOverlappingExistingDV(Dienstverhaeltnis $dv) { return $this->DienstverhaeltnisModel->isOverlappingExistingDV( - $dv->getMitarbeiter_uid(), - $dv->getOe_kurzbz(), - $dv->getVon(), + $dv->getMitarbeiter_uid(), + $dv->getOe_kurzbz(), + $dv->getVon(), $dv->getBis(), $dv->getDienstverhaeltnis_id() ); } - + /** * like endDienstverhaeltnis, but also sets aktiv flag to false */ @@ -397,19 +397,26 @@ class VertragsbestandteilLib if ( $result === true) { if (!$deactivate) return $result; - $result = $this->BenutzerModel->update(array('uid' => $dv->getMitarbeiter_uid()), array('aktiv' => false)); - } - + $result = $this->BenutzerModel->update( + array('uid' => $dv->getMitarbeiter_uid()), + array( + 'aktiv' => false, + 'updateaktivam' => date('Y-m-d'), + 'updateaktivvon' => $this->loggedInUser + ) + ); + } + return $result; } public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate) { - if( $dv->getBis() !== null && $dv->getBis() < $enddate ) + if( $dv->getBis() !== null && $dv->getBis() < $enddate ) { return 'Dienstverhältnis ist bereits beendet.'; } - + $this->CI->db->trans_begin(); try { @@ -421,13 +428,13 @@ class VertragsbestandteilLib { $this->GehaltsbestandteilLib->endGehaltsbestandteil($gb, $enddate); } - + $vbs = $this->fetchVertragsbestandteile($dv->getDienstverhaeltnis_id()); foreach ($vbs as $vb) { $this->endVertragsbestandteil($vb, $enddate); - } - + } + $dv->setBis($enddate); $this->updateDienstverhaeltnis($dv); @@ -448,23 +455,23 @@ class VertragsbestandteilLib } return true; } - + public function endVertragsbestandteil(Vertragsbestandteil $vertragsbestandteil, $enddate) { - if( $vertragsbestandteil->getBis() !== null && $vertragsbestandteil->getBis() < $enddate ) + if( $vertragsbestandteil->getBis() !== null && $vertragsbestandteil->getBis() < $enddate ) { return; } - + $vertragsbestandteil->setBis($enddate); $this->updateVertragsbestandteil($vertragsbestandteil); } - + protected function setUIDtoPGSQL() { $ret = $this->VertragsbestandteilModel - ->execReadOnlyQuery('SET LOCAL pv21.uid TO \'' + ->execReadOnlyQuery('SET LOCAL pv21.uid TO \'' . $this->loggedInUser . '\''); - if(isError($ret)) + if(isError($ret)) { throw new Exception('error setting uid to pgsql'); } From ad415ad665b197019c9d1a8ca6b08b1807d4f422 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Mon, 25 Mar 2024 14:04:21 +0100 Subject: [PATCH 10/10] deactivateDienstverhaeltnis: only set user to inactive if no other dv is active --- .../VertragsbestandteilLib.php | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php index 0bcede083..6abbd81f9 100644 --- a/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php +++ b/application/libraries/vertragsbestandteil/VertragsbestandteilLib.php @@ -388,26 +388,46 @@ class VertragsbestandteilLib ); } + protected function hasOtherActiveDV(Dienstverhaeltnis $dv, $duedate) + { + $hasotheractivedv = false; + $result = $this->DienstverhaeltnisModel->getDVByPersonUID($dv->getMitarbeiter_uid(), null, $duedate); + $dvs = getData($result); + foreach ($dvs as $tmpdv) + { + if(intval($tmpdv->dienstverhaeltnis_id) !== intval($dv->getDienstverhaeltnis_id())) + { + $hasotheractivedv = true; + break; + } + } + return $hasotheractivedv; + } + /** * like endDienstverhaeltnis, but also sets aktiv flag to false */ public function deactivateDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate, $deactivate) { - $result = $this->endDienstverhaeltnis($dv, $enddate); - if ( $result === true) - { - if (!$deactivate) return $result; - $result = $this->BenutzerModel->update( - array('uid' => $dv->getMitarbeiter_uid()), - array( - 'aktiv' => false, - 'updateaktivam' => date('Y-m-d'), - 'updateaktivvon' => $this->loggedInUser - ) - ); - } + $result = $this->endDienstverhaeltnis($dv, $enddate); + if ( $result === true) + { + if (!$deactivate) return $result; - return $result; + if(!$this->hasOtherActiveDV($dv, $enddate)) + { + $result = $this->BenutzerModel->update( + array('uid' => $dv->getMitarbeiter_uid()), + array( + 'aktiv' => false, + 'updateaktivam' => date('Y-m-d'), + 'updateaktivvon' => $this->loggedInUser + ) + ); + } + } + + return $result; } public function endDienstverhaeltnis(Dienstverhaeltnis $dv, $enddate)