mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-16 22:42:16 +00:00
Bugfix Anrechnung Rejected Mails
This commit is contained in:
@@ -16,7 +16,7 @@ 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';
|
||||
@@ -30,7 +30,7 @@ class AnrechnungJob extends JOB_Controller
|
||||
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
|
||||
$this->load->model('education/Anrechnung_model', 'AnrechnungModel');
|
||||
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
||||
|
||||
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('hlp_sancho_helper');
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class AnrechnungJob extends JOB_Controller
|
||||
}
|
||||
$this->logInfo('End Anrechnung Grades Job', array('Number of Grades added'=>$cnt));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes Zeugnisnoten 'angerechnet', when Anrechnung is rejected afterwards.
|
||||
* E.g., when STGL first accepts, then withdraws and finally rejects the approvement.
|
||||
@@ -102,7 +102,7 @@ class AnrechnungJob extends JOB_Controller
|
||||
public function deleteAnrechnungGrades()
|
||||
{
|
||||
$this->logInfo('Start AnrechnungJob to delete Grades');
|
||||
|
||||
|
||||
// Get all Zeungisnoten,
|
||||
// WHERE note is angerechnet
|
||||
// AND Anrechnung was rejected AFTER the Zeugnisnote was created
|
||||
@@ -127,15 +127,15 @@ class AnrechnungJob extends JOB_Controller
|
||||
AND status.status_kurzbz = '. $this->db->escape(self::ANRECHNUNGSTATUS_REJECTED). '
|
||||
ORDER BY status.anrechnung_id, status.insertamum DESC
|
||||
';
|
||||
|
||||
|
||||
$db = new DB_Model();
|
||||
$result = $db->execReadOnlyQuery($qry);
|
||||
$cnt = 0;
|
||||
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
$this->load->model('education/Zeugnisnote_model', 'ZeugnisnoteModel');
|
||||
|
||||
|
||||
foreach (getData($result) as $row)
|
||||
{
|
||||
// Delete Zeugnisnote
|
||||
@@ -144,20 +144,20 @@ class AnrechnungJob extends JOB_Controller
|
||||
'student_uid' => $row->student_uid,
|
||||
'studiensemester_kurzbz' => $row->studiensemester_kurzbz
|
||||
));
|
||||
|
||||
|
||||
// Count up
|
||||
$cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->logInfo('End AnrechnungJob to delete Grades', array('Number of Grades deleted: ' => $cnt));
|
||||
}
|
||||
|
||||
|
||||
// Send Sancho mail to STGL with yesterdays new Anrechnungen
|
||||
public function sendMailToSTGL()
|
||||
{
|
||||
$this->logInfo('Start AnrechnungJob to send emails to STGL about yesterdays new Anrechnungen.');
|
||||
|
||||
|
||||
// Get all yesterdays Anrechnungen, that did not process further than first status
|
||||
// (If Anrechnung is new, but STGL already started the process yesterday,
|
||||
// he does not need to be informed about this new Anrechnung anymore)
|
||||
@@ -167,38 +167,38 @@ class AnrechnungJob extends JOB_Controller
|
||||
$this->AnrechnungModel->addJoin('public.tbl_benutzer benutzer', 'ON (benutzer.uid = student.student_uid)');
|
||||
$this->AnrechnungModel->addJoin('public.tbl_person person', 'person_id');
|
||||
$this->AnrechnungModel->addOrder('lv.studiengang_kz, lv.bezeichnung');
|
||||
|
||||
|
||||
$result = $this->AnrechnungModel->loadWhere(
|
||||
'(lehre.tbl_anrechnung.insertamum)::date = (NOW() - INTERVAL \'24 HOURS\')::DATE
|
||||
AND 1 = (SELECT COUNT(*) FROM lehre.tbl_anrechnung_anrechnungstatus status WHERE status.anrechnung_id = tbl_anrechnung.anrechnung_id)'
|
||||
);
|
||||
|
||||
|
||||
// Exit if there are no Anrechnungen
|
||||
if (!$anrechnungen = getData($result)) {
|
||||
$this->logInfo('ABORTED: Sending emails to STGL about yesterdays new Anrechnungen aborted - No new Anrechnungen found.');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$unique_studiengang_kz_arr = array_unique(array_column($anrechnungen, 'studiengang_kz'));
|
||||
|
||||
|
||||
foreach ($unique_studiengang_kz_arr as $studiengang_kz)
|
||||
{
|
||||
// Get STG bezeichnung
|
||||
$this->StudiengangModel->addSelect('UPPER( typ || kurzbz ) AS "stg_bezeichnung"');
|
||||
$studiengang_bezeichnung = $this->StudiengangModel->load($studiengang_kz)->retval[0]->stg_bezeichnung;
|
||||
|
||||
|
||||
// Get STGL mail address
|
||||
list ($to, $vorname) = self::_getSTGLMailAddress($studiengang_kz);
|
||||
|
||||
|
||||
// Get HTML table with new Anrechnungen of that STG plus amount of them
|
||||
list ($anrechnungen_amount, $anrechnungen_table) = self::_getSTGLMailDataTable($studiengang_kz, $anrechnungen);
|
||||
|
||||
|
||||
// Link to Antrag genehmigen dashboard
|
||||
$url =
|
||||
CIS_ROOT. 'cis/index.php?menu='.
|
||||
CIS_ROOT. 'cis/menu.php?content_id=&content='.
|
||||
CIS_ROOT. index_page(). self::APPROVE_ANRECHNUNG_URI;
|
||||
|
||||
|
||||
// Prepare mail content
|
||||
$body_fields = array(
|
||||
'vorname' => $vorname,
|
||||
@@ -207,7 +207,7 @@ class AnrechnungJob extends JOB_Controller
|
||||
'datentabelle' => $anrechnungen_table,
|
||||
'link' => anchor($url, 'Anrechnungsanträge Übersicht')
|
||||
);
|
||||
|
||||
|
||||
// Send mail
|
||||
sendSanchoMail(
|
||||
'AnrechnungAntragStellen',
|
||||
@@ -216,17 +216,17 @@ class AnrechnungJob extends JOB_Controller
|
||||
'Anerkennung nachgewiesener Kenntnisse: Neuer Antrag wurde gestellt'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$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');
|
||||
@@ -234,35 +234,35 @@ class AnrechnungJob extends JOB_Controller
|
||||
$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',
|
||||
@@ -272,33 +272,35 @@ class AnrechnungJob extends JOB_Controller
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
$this->AnrechnungModel->addOrder('notiz.insertamum', 'DESC');
|
||||
$this->AnrechnungModel->addLimit(1);
|
||||
|
||||
|
||||
$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)
|
||||
);
|
||||
|
||||
$qry = '
|
||||
SELECT
|
||||
student.student_uid, vorname, nachname, geschlecht, lv.bezeichnung,
|
||||
(SELECT text FROM public.tbl_notizzuordnung JOIN public.tbl_notiz USING(notiz_id)
|
||||
WHERE tbl_notizzuordnung.anrechnung_id=tbl_anrechnung.anrechnung_id
|
||||
AND tbl_notiz.titel='. $this->db->escape(self::ANRECHNUNG_NOTIZTITEL_NOTIZ_BY_STGL).'
|
||||
ORDER BY tbl_notiz.insertamum DESC LIMIT 1) as text
|
||||
FROM lehre.tbl_anrechnung
|
||||
JOIN lehre.tbl_lehrveranstaltung lv USING(lehrveranstaltung_id)
|
||||
JOIN public.tbl_student student USING(prestudent_id)
|
||||
JOIN public.tbl_benutzer benutzer ON (benutzer.uid = student.student_uid)
|
||||
JOIN public.tbl_person person USING(person_id)
|
||||
|
||||
WHERE EXISTS(SELECT 1 FROM lehre.tbl_anrechnung_anrechnungstatus status WHERE
|
||||
anrechnung_id=tbl_anrechnung.anrechnung_id AND
|
||||
(status.insertamum)::date = (NOW() - INTERVAL \'24 HOURS\')::DATE AND
|
||||
status_kurzbz = '. $this->db->escape(self::ANRECHNUNGSTATUS_REJECTED). ')
|
||||
';
|
||||
|
||||
$db = new DB_Model();
|
||||
$result = $db->execReadOnlyQuery($qry);
|
||||
|
||||
// Exit if there are no rejected Anrechnungen
|
||||
if (!hasData($result))
|
||||
@@ -306,26 +308,26 @@ class AnrechnungJob extends JOB_Controller
|
||||
$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',
|
||||
@@ -334,14 +336,14 @@ html;
|
||||
'Anerkennung nachgewiesener Kenntnisse: Ihr Antrag ist abgeschlossen'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Get STGL mail address
|
||||
private function _getSTGLMailAddress($studiengang_kz)
|
||||
{
|
||||
$result = $this->StudiengangModel->getLeitung($studiengang_kz);
|
||||
|
||||
|
||||
// Get STGL mail address
|
||||
if (hasData($result))
|
||||
{
|
||||
@@ -354,7 +356,7 @@ html;
|
||||
else
|
||||
{
|
||||
$result = $this->StudiengangModel->load($studiengang_kz);
|
||||
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
return array(
|
||||
@@ -364,7 +366,7 @@ html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Build HTML table with yesterdays new Anrechnungen of the given STG
|
||||
private function _getSTGLMailDataTable($studiengang_kz, $anrechnungen)
|
||||
{
|
||||
@@ -377,7 +379,7 @@ html;
|
||||
function ($anrechnung) use (&$studiengang_kz) {
|
||||
return $anrechnung->studiengang_kz == $studiengang_kz;
|
||||
});
|
||||
|
||||
|
||||
// Amount of Anrechnungen
|
||||
$amount = count($anrechnungen);
|
||||
|
||||
@@ -386,7 +388,7 @@ html;
|
||||
<table style="width: 60%; border-collapse: collapse;" border="1" cellpadding="5">
|
||||
<tbody>
|
||||
';
|
||||
|
||||
|
||||
foreach ($anrechnungen as $anrechnung)
|
||||
{
|
||||
// Head line for each LV bezeichnung
|
||||
@@ -394,18 +396,18 @@ html;
|
||||
{
|
||||
$html .= '<tr><td><span><strong>' . $anrechnung->bezeichnung . '</strong></span></td></tr>';
|
||||
}
|
||||
|
||||
|
||||
$lv_bezeichnung = $anrechnung->bezeichnung;
|
||||
|
||||
|
||||
// Row for each Anrechnung / student
|
||||
$html .= '<tr><td><span>'. $anrechnung->vorname. ' '. $anrechnung->nachname. '</span></td></tr>';
|
||||
}
|
||||
|
||||
|
||||
$html .= '
|
||||
</tbody>
|
||||
</table>
|
||||
';
|
||||
|
||||
|
||||
return array($amount, $html);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user