From e148d8c2f48a25f8da6a00ff099ab04b9f9b170d Mon Sep 17 00:00:00 2001 From: Cris Date: Tue, 6 Dec 2022 13:49:23 +0100 Subject: [PATCH] Added function to get Fachbereich as mail receivers --- .../anrechnung/ApproveAnrechnungDetail.php | 30 +++++++--- .../ApproveAnrechnungUebersicht.php | 57 +++++++++++++++---- 2 files changed, 69 insertions(+), 18 deletions(-) diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index 8bcf3ef7a..bc5f19bd8 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -496,18 +496,24 @@ class approveAnrechnungDetail extends Auth_Controller /** - * Get lectors (prio for LV-Leitung, if not present to all lectors of LV. + * Get mail receivers. + * If config is default (lectors): prio for LV-Leitung, if not present to all lectors of LV. * Anyway this function will receive a unique array to avoid sending more mails to one and the same lector. * **/ - $lector_arr = $this->_getLectors($anrechnung_arr); + if ($this->config->item('fbl') === TRUE) + { + $receiver_arr = $this->_getFachbereichleitung($lehrveranstaltung_id); + } + else + { + $receiver_arr = $this->_getLectors($studiensemester_kurzbz, $lehrveranstaltung_id); + } - - - // Send mail to lectors - foreach ($lector_arr as $lector) + // Send mail + foreach ($receiver_arr as $receiver) { - $to = $lector->uid; - $vorname = $lector->vorname; + $to = $receiver->uid. '@'. DOMAIN;; + $vorname = $receiver->vorname; // Get full name of stgl $this->load->model('person/Person_model', 'PersonModel'); @@ -592,6 +598,14 @@ class approveAnrechnungDetail extends Auth_Controller } + // Get Fachbereichsleitungen + private function _getFachbereichleitung($lehrveranstaltung_id) + { + $result = $this->LehrveranstaltungModel->getFachbereichByLv($lehrveranstaltung_id); + + return hasData($result) ? getData($result) : show_error('Failed retrieving Fachbereichsleitung'); + } + private function _saveEmpfehlungsNotiz($anrechnung_id, $empfehlungstext, $notiz_id) { $this->load->model('person/Notiz_model', 'NotizModel'); diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index 836e7f719..c647138c9 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -328,7 +328,7 @@ class approveAnrechnungUebersicht extends Auth_Controller * @param $mail_params * @return bool */ - private function _sendSanchoMailToLectors($mail_params) + private function _sendSanchoMail($mail_params) { // Get Lehrveranstaltungen $anrechnung_arr = array(); @@ -344,18 +344,25 @@ class approveAnrechnungUebersicht extends Auth_Controller $anrechnung_arr = array_unique($anrechnung_arr, SORT_REGULAR); - - /** - * Get lectors (prio for LV-Leitung, if not present to all lectors of LV. - * Anyway this function will receive a unique array to avoid sending more mails to one and the same lector. - * **/ - $lector_arr = $this->_getLectors($anrechnung_arr); + /** + * Get mail receivers. + * If retrieving lectors: prio for LV-Leitung, if not present to all lectors of LV. + * This function will receive a unique array to avoid sending more mails to one and the same user. + **/ + if($this->config->item('fbl') === TRUE) + { + $receiver_arr = $this->_getFachbereichleitung($anrechnung_arr); + } + else + { + $receiver_arr = $this->_getLectors($anrechnung_arr); + } // Send mail to lectors - foreach ($lector_arr as $lector) + foreach ($receiver_arr as $receiver) { - $to = $lector->uid; - $vorname = $lector->vorname; + $to = $receiver->uid. '@'. DOMAIN; + $vorname = $receiver->vorname; // Get full name of stgl $this->load->model('person/Person_model', 'PersonModel'); @@ -439,4 +446,34 @@ class approveAnrechnungUebersicht extends Auth_Controller return $lector_arr; } + + /** + * Get Fachbereichsleitung with unique uids. + * + * @param $anrechnung_arr + * @return array + */ + private function _getFachbereichleitung($anrechnung_arr) + { + $fbl_arr = array(); + + // Get lectors + foreach($anrechnung_arr as $anrechnung) + { + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $result = $this->LehrveranstaltungModel->getFachbereichByLv($anrechnung['lehrveranstaltung_id']); + + if (!hasData($result)) + { + show_error('No Fachbereichsleitung found'); + } + + $fbl_arr = array_merge($fbl_arr, getData($result)); + } + + // Make Fachbereichsleiter array unique + $fbl_arr = array_unique($fbl_arr, SORT_REGULAR); + + return $fbl_arr; + } }