From 8df802b74a34c394df2178b48608476bb0944500 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Tue, 8 Nov 2022 14:45:02 +0100 Subject: [PATCH] - die Abteilung und das Unternehmen werden im CSV angezeigt --- include/mitarbeiter.class.php | 28 +++++++++++++++++++ include/organisationseinheit.class.php | 37 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/include/mitarbeiter.class.php b/include/mitarbeiter.class.php index b7511a5ad..df5557454 100644 --- a/include/mitarbeiter.class.php +++ b/include/mitarbeiter.class.php @@ -1705,5 +1705,33 @@ class mitarbeiter extends benutzer } } + public function getMitarbeiterKostenstelle($von, $bis, $uid = null) + { + if (is_null($uid)) + $uid = $this->uid; + + $qry = " + SELECT o.oe_kurzbz AS standardkostenstelle, o.bezeichnung + FROM public.tbl_benutzerfunktion bf + JOIN public.tbl_organisationseinheit o USING(oe_kurzbz) + WHERE bf.funktion_kurzbz = 'kstzuordnung' + AND (bf.datum_bis IS NULL OR datum_bis >= ". $this->db_add_param($von). ") + AND (bf.datum_von IS NULL OR datum_von <= ". $this->db_add_param($bis). ") + AND bf.uid = ". $this->db_add_param($uid); + + if ($result = $this->db_query($qry)) + { + while($row = $this->db_fetch_object($result)) + { + $obj = new StdClass(); + $obj->oekurzbz = $row->standardkostenstelle; + $obj->bezeichnung = $row->bezeichnung; + + $this->result []= $obj; + } + return true; + } + } + } ?> diff --git a/include/organisationseinheit.class.php b/include/organisationseinheit.class.php index d58cfd327..1a2e0ca16 100644 --- a/include/organisationseinheit.class.php +++ b/include/organisationseinheit.class.php @@ -938,5 +938,42 @@ class organisationseinheit extends basis_db return false; } } + + public function getOERoot($oe_kurzbz) + { + $qry = ' + WITH RECURSIVE organizations(rid, oe_kurzbz, oe_parent_kurzbz) AS + ( + SELECT 1 AS rid, o.oe_kurzbz, o.oe_parent_kurzbz + FROM public.tbl_organisationseinheit o + WHERE o.oe_kurzbz = '. $this->db_add_param($oe_kurzbz). ' + UNION ALL + SELECT rid + 1 AS rid, oe.oe_kurzbz, oe.oe_parent_kurzbz + FROM organizations org, public.tbl_organisationseinheit oe + WHERE oe.oe_kurzbz = org.oe_parent_kurzbz + AND oe.aktiv = TRUE + ) + SELECT oe_kurzbz + FROM organizations orgs + ORDER BY rid DESC + LIMIT 1 + '; + + if($this->db_query($qry)) + { + if($row = $this->db_fetch_object()) + { + $this->oe_kurzbz = $row->oe_kurzbz; + return true; + } + } + else + { + $this->errormsg = 'Fehler beim Laden der Organisationseinheiten'; + return false; + } + } + + } ?>