Added sending Sanchomail to student when Anrechnung was approved/rejected

Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
Cris
2021-01-27 14:46:02 +01:00
committed by cris-technikum
parent 697e5057cf
commit 35009097f1
4 changed files with 71 additions and 2 deletions
@@ -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;
}
}
@@ -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
);
@@ -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');
+28
View File
@@ -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