diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index c7116baf8..207c4de9b 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -118,6 +118,11 @@ class approveAnrechnungUebersicht extends Auth_Controller 'status_kurzbz' => self::ANRECHNUNGSTATUS_APPROVED, 'status_bezeichnung' => $approved ); + + if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], $approved)) + { + show_error('Failed sending mail'); + } } } @@ -161,6 +166,11 @@ class approveAnrechnungUebersicht extends Auth_Controller 'status_kurzbz' => self::ANRECHNUNGSTATUS_REJECTED, 'status_bezeichnung' => $rejected ); + + if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], $rejected)) + { + show_error('Failed sending mail'); + } } } @@ -244,4 +254,33 @@ class approveAnrechnungUebersicht extends Auth_Controller if (!$this->_uid) show_error('User authentification failed'); } + + /** + * Send mail to student to inform if Anrechnung was approved or rejected + * @param $mail_params + */ + private function _sendSanchoMailToStudent($anrechnung_id, $status_bezeichnung) + { + $result = getData($this->anrechnunglib->getStudentData($anrechnung_id))[0]; + + // Get student name and mail address + $to = $result->uid. '@'. DOMAIN; + + + // Prepare mail content + $body_fields = array( + 'vorname' => $result->vorname, + 'lehrveranstaltung_bezeichnung' => $result->lv_bezeichnung, + 'status' => $status_bezeichnung + ); + + sendSanchoMail( + 'AnrechnungGenehmigen', + $body_fields, + $to, + 'Dein Anrechnungsantrag zur LV '. $result->lv_bezeichnung. ' wurde '. $status_bezeichnung + ); + + return true; + } } \ No newline at end of file diff --git a/application/controllers/lehre/anrechnung/RequestAnrechnung.php b/application/controllers/lehre/anrechnung/RequestAnrechnung.php index 77a1b73ef..8ac8683b9 100644 --- a/application/controllers/lehre/anrechnung/RequestAnrechnung.php +++ b/application/controllers/lehre/anrechnung/RequestAnrechnung.php @@ -177,7 +177,6 @@ class requestAnrechnung extends Auth_Controller // Send mail to STGL $mail_params = array( - 'studiensemester_kurzbz' => $studiensemester_kurzbz, 'studiengang_kz' => $prestudent->studiengang_kz, 'lehrveranstaltung_id' => $lehrveranstaltung_id ); diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php index ed2979420..bbf391281 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php @@ -120,7 +120,10 @@ class reviewAnrechnungUebersicht extends Auth_Controller // Output json to ajax if (isset($json) && !isEmptyArray($json)) { - // Send mails to STGL (if not present STGL, send to STGL assistance) + /** + * Send mails to STGL (if not present STGL, send to STGL assistance) + * NOTE: mails are sent at the end to ensure sending only one mail to each STGL + * */ if (!$this->_sendSanchoMails($json, true)) { show_error('Failed sending emails'); diff --git a/application/libraries/AnrechnungLib.php b/application/libraries/AnrechnungLib.php index c77d49c93..17b2538a6 100644 --- a/application/libraries/AnrechnungLib.php +++ b/application/libraries/AnrechnungLib.php @@ -145,6 +145,34 @@ class AnrechnungLib return success($anrechnung_data); } + public function getStudentData($anrechnung_id) + { + if (!is_numeric($anrechnung_id)) + { + show_error('Incorrect parameter'); + } + + $this->ci->AnrechnungModel->addSelect('tbl_benutzer.uid, tbl_prestudent.prestudent_id, tbl_person.person_id, tbl_anrechnung.studiensemester_kurzbz, vorname, nachname, tbl_lehrveranstaltung.bezeichnung AS "lv_bezeichnung"'); + $this->ci->AnrechnungModel->addJoin('public.tbl_prestudent', 'prestudent_id'); + $this->ci->AnrechnungModel->addJoin('public.tbl_person', 'person_id'); + $this->ci->AnrechnungModel->addJoin('public.tbl_benutzer', 'person_id'); + $this->ci->AnrechnungModel->addJoin('lehre.tbl_lehrveranstaltung', 'lehrveranstaltung_id'); + + $result = $this->ci->AnrechnungModel->load($anrechnung_id); + + if (isError($result)) + { + show_error(getError($result)); + } + + if (!hasData($result)) + { + show_error('Failed retrieving students data'); + } + + return $result; + } + /** * Get last Anrechnungstatusbezeichnung in users language. * @param $anrechnung_id