diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index 32d1f7900..c163ee6cf 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -193,15 +193,24 @@ class approveAnrechnungUebersicht extends Auth_Controller // Continue loop, if LV has no lector continue; } - + // Request Recommendation if($this->anrechnunglib->requestRecommendation($item['anrechnung_id'])) { + // Get full name of LV Leitung. + // If LV Leitung is not present, get full name of LV lectors. + $lector_arr = self::_getLVLectors($item['anrechnung_id']); + $empfehlungsanfrage_an = !isEmptyArray($lector_arr) + ? implode(', ', array_column($lector_arr, 'fullname')) + : ''; + $retval[]= array( 'anrechnung_id' => $item['anrechnung_id'], 'status_kurzbz' => self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR, 'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR), - 'empfehlung_anrechnung' => null + 'empfehlung_anrechnung' => null, + 'empfehlungsanfrage_am' => (new DateTime())->format('Y-m-d H:i:s'), + 'empfehlungsanfrage_an' => $empfehlungsanfrage_an ); } } @@ -446,4 +455,65 @@ class approveAnrechnungUebersicht extends Auth_Controller return $lector_arr; } + + /** + * Get LV Leitung. If not present, get all LV lectors. + * + * @param $anrechnung_id + * @return array|bool + */ + private function _getLVLectors($anrechnung_id) + { + $this->AnrechnungModel->addSelect('lehrveranstaltung_id, studiensemester_kurzbz'); + $result = $this->AnrechnungModel->load($anrechnung_id); + + if (!hasData($result)) + { + return false; + } + + $lehrveranstaltung_id = getData($result)[0]->lehrveranstaltung_id; + $studiensemester_kurzbz = getData($result)[0]->studiensemester_kurzbz; + + // Get lectors + $lector_arr = array(); + + $this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel'); + $result = $this->LehrveranstaltungModel->getLecturersByLv($studiensemester_kurzbz, $lehrveranstaltung_id); + + if (!$result = getData($result)) + { + return false; + } + + // Check if lv has LV-Leitung + $key = array_search(true, array_column($result, 'lvleiter')); + + // If lv has LV-Leitung, keep only the one + if ($key !== false) + { + $lector_arr[]= $result[$key]; + } + // ...otherwise keep all lectors + else + { + $lector_arr = array_merge($lector_arr, $result); + } + + /** + * NOTE: This step is only done to make the array unique by uid, vorname and nachname in the following step + * (e.g. if same lector is ones LV-Leitung and another time not, then array_unique would leave both. + * But we wish to send only one email by to that one person) + * **/ + foreach ($lector_arr as $lector) + { + unset($lector->lvleiter); + $lector->fullname = $lector->vorname. ' '. $lector->nachname; + } + + // Now make the lector array aka mail receivers unique + $lector_arr = array_unique($lector_arr, SORT_REGULAR); + + return $lector_arr; + } } \ No newline at end of file diff --git a/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php b/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php index 089846d55..9e221b94f 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php +++ b/application/views/lehre/anrechnung/approveAnrechnungUebersicht.php @@ -19,6 +19,8 @@ $this->load->view( 'anrechnung' => array( 'nachweisdokumente', 'empfehlung', + 'empfehlungsanfrageAn', + 'empfehlungsanfrageAm', 'confirmTextAntragHatBereitsEmpfehlung', 'herkunft' ), diff --git a/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php b/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php index ce95cc0c0..b2a519dab 100644 --- a/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php +++ b/application/views/lehre/anrechnung/approveAnrechnungUebersichtData.php @@ -1,4 +1,7 @@ >' . $LANGUAGE_INDEX . ' AS "status_bezeichnung" + array_to_json(anrechnungstatus.bezeichnung_mehrsprachig::varchar[])->>' . $LANGUAGE_INDEX . ' AS "status_bezeichnung", + CASE + WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL + ELSE + (SELECT insertamum::date + FROM lehre.tbl_anrechnungstatus + JOIN lehre.tbl_anrechnung_anrechnungstatus USING (status_kurzbz) + WHERE anrechnung_id = anrechnungen.anrechnung_id + AND status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR . '\' + ORDER BY insertamum DESC + LIMIT 1) + END empfehlungsanfrage_am, + CASE + WHEN (anrechnungen.empfehlung_anrechnung IS NULL AND anrechnungen.status_kurzbz = \'' . ANRECHNUNGSTATUS_PROGRESSED_BY_STGL . '\') THEN NULL + ELSE + (SELECT COALESCE( + STRING_AGG(CONCAT_WS(\' \', vorname, nachname), \', \') FILTER (WHERE lvleiter = TRUE), + STRING_AGG(CONCAT_WS(\' \', vorname, nachname), \', \') FILTER (WHERE lvleiter = FALSE) + ) empfehlungsanfrage_an + FROM ( + SELECT DISTINCT ON (benutzer.uid) uid, vorname, nachname, + CASE WHEN lehrfunktion_kurzbz = \'LV-Leitung\' THEN TRUE ELSE FALSE END AS lvleiter + FROM lehre.tbl_lehreinheit + JOIN lehre.tbl_lehreinheitmitarbeiter lema USING (lehreinheit_id) + JOIN public.tbl_benutzer benutzer ON lema.mitarbeiter_uid = benutzer.uid + JOIN public.tbl_person USING (person_id) + WHERE studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' + AND lehrveranstaltung_id = anrechnungen.lehrveranstaltung_id + AND lema.mitarbeiter_uid NOT like \'_Dummy%\' + AND benutzer.aktiv = TRUE + AND tbl_person.aktiv = TRUE + ORDER BY benutzer.uid, lvleiter DESC, nachname, vorname + ) as tmp_lvlektoren + ) + END empfehlungsanfrage_an FROM anrechnungen JOIN lehre.tbl_anrechnungstatus as anrechnungstatus ON (anrechnungstatus.status_kurzbz = anrechnungen.status_kurzbz) WHERE studiensemester_kurzbz = \'' . $STUDIENSEMESTER . '\' @@ -86,7 +123,9 @@ $filterWidgetArray = array( ucfirst($this->p->t('anrechnung', 'antragdatum')), ucfirst($this->p->t('anrechnung', 'empfehlung')), 'status_kurzbz', - 'Status' + 'Status', + ucfirst($this->p->t('anrechnung', 'empfehlungsanfrageAm')), + ucfirst($this->p->t('anrechnung', 'empfehlungsanfrageAn')) ), 'datasetRepOptions' => '{ height: func_height(this), @@ -143,7 +182,9 @@ $filterWidgetArray = array( antragsdatum: {align:"center", headerFilter:"input", mutator: mut_formatStringDate}, empfehlung_anrechnung: {headerFilter:"input", align:"center", formatter: format_empfehlung_anrechnung, headerFilterFunc: hf_filterTrueFalse}, status_kurzbz: {visible: false}, - status_bezeichnung: {headerFilter:"input"} + status_bezeichnung: {headerFilter:"input"}, + empfehlungsanfrage_am: {visible: false, align:"center", headerFilter:"input", mutator: mut_formatStringDate}, + empfehlungsanfrage_an: {visible: false, headerFilter:"input"} }', // col properties ); diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 243ed971f..c2c916ac9 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -10550,6 +10550,46 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'anrechnung', + 'phrase' => 'empfehlungsanfrageAn', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => "Empfehlungsanfrage an", + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => "Request Recommend. to", + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'anrechnung', + 'phrase' => 'empfehlungsanfrageAm', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => "Empfehlungsanfrage am", + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => "Request Recommend. on", + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), );