mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 08:52:21 +00:00
Added jobs to send mails to students once per day (info approved/rejected)
. The jobs will send mails to students, whose Anrechnungen were approved/rejected the last day. . Removed former sendMailToStudent functions from Controllers. Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
@@ -16,6 +16,10 @@ if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class AnrechnungJob extends JOB_Controller
|
||||
{
|
||||
const APPROVE_ANRECHNUNG_URI = '/lehre/anrechnung/ApproveAnrechnungUebersicht';
|
||||
|
||||
const ANRECHNUNGSTATUS_APPROVED = 'approved';
|
||||
const ANRECHNUNGSTATUS_REJECTED = 'rejected';
|
||||
const ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_STGL = 'AnrechnungNotizSTGL';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -155,6 +159,120 @@ class AnrechnungJob extends JOB_Controller
|
||||
$this->logInfo('SUCCEDED: Sending emails to STGL about yesterdays new Anrechnungen succeded.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Sancho mail to students, whose Anrechnungen were approved 24 hours ago.
|
||||
*/
|
||||
public function sendMailApproved(){
|
||||
|
||||
$this->logInfo('Start AnrechnungJob to send emails to students, whose Anrechnungen were approved.');
|
||||
|
||||
// Get all yesterdays approvements
|
||||
$this->AnrechnungModel->addSelect('student.student_uid, vorname, nachname, geschlecht, lv.bezeichnung');
|
||||
$this->AnrechnungModel->addJoin('lehre.tbl_anrechnung_anrechnungstatus status', 'anrechnung_id');
|
||||
$this->AnrechnungModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_student student', 'prestudent_id');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_benutzer benutzer', 'ON (benutzer.uid = student.student_uid)');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_person person', 'person_id');
|
||||
|
||||
$result = $this->AnrechnungModel->loadWhere(
|
||||
'(status.insertamum)::date = (NOW() - INTERVAL \'24 HOURS\')::DATE AND
|
||||
status.status_kurzbz = '. $this->db->escape(self::ANRECHNUNGSTATUS_APPROVED)
|
||||
);
|
||||
|
||||
// Exit if there are no approved Anrechnungen
|
||||
if (!hasData($result))
|
||||
{
|
||||
$this->logInfo('ABORTED sending emails to students, whose Anrechnungen were approved. No new approvements found.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Loop through students
|
||||
foreach ($result->retval as $student)
|
||||
{
|
||||
$to = $student->student_uid. '@'. DOMAIN;
|
||||
|
||||
$anrede = $student->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
|
||||
|
||||
$text = 'Ihrem Antrag auf Anerkennung nachgewiesener Kenntnisse der Lehrveranstaltung "'.
|
||||
$student->bezeichnung. '" wurde stattgegeben.';
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'anrede_name' => $anrede. $student->vorname. ' '. $student->nachname,
|
||||
'text' => $text
|
||||
);
|
||||
|
||||
// Send mail
|
||||
sendSanchoMail(
|
||||
'AnrechnungGenehmigen',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Sancho mail to students, whose Anrechnungen were rejected 24 hours ago.
|
||||
*/
|
||||
public function sendMailRejected(){
|
||||
|
||||
$this->logInfo('Start AnrechnungJob to send emails to students, whose Anrechnungen were rejected.');
|
||||
|
||||
// Get all yesterdays rejections
|
||||
$this->AnrechnungModel->addSelect('student.student_uid, vorname, nachname, geschlecht, lv.bezeichnung, notiz.text');
|
||||
$this->AnrechnungModel->addJoin('lehre.tbl_anrechnung_anrechnungstatus status', 'anrechnung_id');
|
||||
$this->AnrechnungModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_student student', 'prestudent_id');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_benutzer benutzer', 'ON (benutzer.uid = student.student_uid)');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_person person', 'person_id');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_notizzuordnung', 'anrechnung_id');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_notiz notiz', 'notiz_id');
|
||||
|
||||
|
||||
$result = $this->AnrechnungModel->loadWhere(
|
||||
'(status.insertamum)::date = (NOW() - INTERVAL \'24 HOURS\')::DATE AND
|
||||
status.status_kurzbz = '. $this->db->escape(self::ANRECHNUNGSTATUS_REJECTED). ' AND
|
||||
notiz.titel = '. $this->db->escape(self::ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_STGL)
|
||||
);
|
||||
|
||||
// Exit if there are no rejected Anrechnungen
|
||||
if (!hasData($result))
|
||||
{
|
||||
$this->logInfo('ABORTED sending emails to students, whose Anrechnungen were rejected. No new rejectments found.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Loop through students
|
||||
foreach ($result->retval as $student)
|
||||
{
|
||||
$to = $student->student_uid. '@'. DOMAIN;
|
||||
|
||||
$anrede = $student->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
|
||||
|
||||
$text = <<<html
|
||||
wir haben Ihren Antrag auf Anerkennung nachgewiesener Kenntnisse geprüft und können die Lehrveranstaltung
|
||||
"$student->bezeichnung" leider nicht anrechnen, weil die Gleichwertigkeit nicht festgestellt werden konnte.<br><br>
|
||||
Begründung: $student->text
|
||||
html;
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'anrede_name' => $anrede. $student->vorname. ' '. $student->nachname,
|
||||
'text' => $text
|
||||
);
|
||||
|
||||
// Send mail
|
||||
sendSanchoMail(
|
||||
'AnrechnungGenehmigen',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get STGL mail address
|
||||
private function _getSTGLMailAddress($studiengang_kz)
|
||||
{
|
||||
|
||||
@@ -137,11 +137,6 @@ class approveAnrechnungDetail extends Auth_Controller
|
||||
'abgeschlossen_am' => (new DateTime())->format('d.m.Y'),
|
||||
'abgeschlossen_von' => $person->vorname. ' '. $person->nachname
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_APPROVED))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,11 +181,6 @@ class approveAnrechnungDetail extends Auth_Controller
|
||||
'abgeschlossen_am' => (new DateTime())->format('d.m.Y'),
|
||||
'abgeschlossen_von' => $person->vorname. ' '. $person->nachname
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_REJECTED))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,42 +461,7 @@ class approveAnrechnungDetail extends Auth_Controller
|
||||
|
||||
show_error('You are not entitled to read this document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to student to inform if Anrechnung was approved or rejected
|
||||
* @param $mail_params
|
||||
*/
|
||||
private function _sendSanchoMailToStudent($anrechnung_id, $status_kurzbz)
|
||||
{
|
||||
$result = getData($this->anrechnunglib->getStudentData($anrechnung_id))[0];
|
||||
|
||||
// Get student name and mail address
|
||||
$to = $result->uid. '@'. DOMAIN;
|
||||
|
||||
$anrede = $result->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
|
||||
|
||||
$text = $status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED
|
||||
? 'Ihrem Antrag auf Anerkennung nachgewiesener Kenntnisse der Lehrveranstaltung "'.
|
||||
$result->lv_bezeichnung. '" wurde stattgegeben.'
|
||||
: 'wir haben Ihren Antrag auf Anerkennung nachgewiesener Kenntnisse geprüft und können die Lehrveranstaltung "'.
|
||||
$result->lv_bezeichnung. '" leider nicht anrechnen, weil die Gleichwertigkeit nicht festgestellt werden konnte.';
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'anrede_name' => $anrede. $result->vorname. ' '. $result->nachname,
|
||||
'text' => $text
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungGenehmigen',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv)
|
||||
* @param $mail_params
|
||||
|
||||
@@ -107,11 +107,6 @@ class approveAnrechnungUebersicht extends Auth_Controller
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_APPROVED,
|
||||
'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_APPROVED)
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_APPROVED))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,11 +143,6 @@ class approveAnrechnungUebersicht extends Auth_Controller
|
||||
'status_kurzbz' => self::ANRECHNUNGSTATUS_REJECTED,
|
||||
'status_bezeichnung' => $this->anrechnunglib->getStatusbezeichnung(self::ANRECHNUNGSTATUS_REJECTED)
|
||||
);
|
||||
|
||||
if(!$this->_sendSanchoMailToStudent($item['anrechnung_id'], self::ANRECHNUNGSTATUS_REJECTED))
|
||||
{
|
||||
show_error('Failed sending mail');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,41 +294,6 @@ class approveAnrechnungUebersicht extends Auth_Controller
|
||||
show_error('You are not entitled to read this document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to student to inform if Anrechnung was approved or rejected
|
||||
* @param $mail_params
|
||||
*/
|
||||
private function _sendSanchoMailToStudent($anrechnung_id, $status_kurzbz)
|
||||
{
|
||||
$result = getData($this->anrechnunglib->getStudentData($anrechnung_id))[0];
|
||||
|
||||
// Get student name and mail address
|
||||
$to = $result->uid. '@'. DOMAIN;
|
||||
|
||||
$anrede = $result->geschlecht == 'w' ? 'Sehr geehrte Frau ' : 'Sehr geehrter Herr ';
|
||||
|
||||
$text = $status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED
|
||||
? 'Ihrem Antrag auf Anerkennung nachgewiesener Kenntnisse der Lehrveranstaltung "'.
|
||||
$result->lv_bezeichnung. '" wurde stattgegeben.'
|
||||
: 'wir haben Ihren Antrag auf Anerkennung nachgewiesener Kenntnisse geprüft und können die Lehrveranstaltung "'.
|
||||
$result->lv_bezeichnung. '" leider nicht anrechnen, weil die Gleichwertigkeit nicht festgestellt werden konnte.';
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'anrede_name' => $anrede. $result->vorname. ' '. $result->nachname,
|
||||
'text' => $text
|
||||
);
|
||||
|
||||
sendSanchoMail(
|
||||
'AnrechnungGenehmigen',
|
||||
$body_fields,
|
||||
$to,
|
||||
'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send mail to lectors asking for recommendation. (first to LV-Leitung, if not present to all lectors of lv)
|
||||
* @param $mail_params
|
||||
|
||||
Reference in New Issue
Block a user