From db10f785052b5f887b8de172345e3a360c81cfaa Mon Sep 17 00:00:00 2001 From: Cris Date: Tue, 26 Jan 2021 18:49:55 +0100 Subject: [PATCH] Added method getLeitung() to Studiengang_model to retrieve STGL by studiengang_kz Signed-off-by: cris-technikum --- .../models/organisation/Studiengang_model.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index 1c9c6e944..0977bceb2 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -448,4 +448,35 @@ class Studiengang_model extends DB_Model return $this->execQuery($query, array($typ)); } + + /** + * Get Studiengangsleitung + * @param null $studiengang_kz + * @return array + */ + public function getLeitung($studiengang_kz = null) + { + $this->addSelect('uid, studiengang_kz, oe_kurzbz, email'); + $this->addJoin('public.tbl_benutzerfunktion', 'oe_kurzbz'); + + if (is_null($studiengang_kz)) + { + $condition = ' + funktion_kurzbz = \'Leitung\' + AND ( datum_von <= NOW() OR datum_von IS NULL ) + AND ( datum_bis >= NOW() OR datum_bis IS NULL ) + '; + } + elseif (is_numeric($studiengang_kz)) + { + $condition = ' + funktion_kurzbz = \'Leitung\' + AND ( datum_von <= NOW() OR datum_von IS NULL ) + AND ( datum_bis >= NOW() OR datum_bis IS NULL ) + AND studiengang_kz = ' . $this->db->escape($studiengang_kz, FHC_INTEGER) + ; + } + + return $this->loadWhere($condition); + } }