add new Job for sent Email to Assistant as Reminder for Manual Deregistration of ExRepeaterWithNewNegativeCommissionalExams

This commit is contained in:
ma0068
2026-05-26 09:38:13 +02:00
parent cb7a0f7669
commit 1ed3031dad
2 changed files with 83 additions and 0 deletions
@@ -673,6 +673,58 @@ class AntragJob extends JOB_Controller
$this->logInfo('Ende Job sendAufforderungWiederholer');
}
/**
* Send Reminder to Assistance of Wiederholer with a Second Negative Commissional Exam
*
*/
public function sendReminderWiederholerWithNegativeCommissionalExam()
{
$this->logInfo('Start Job sendReminderWiederholerWithNegativeCommissionalExam');
$this->load->library('PrestudentLib');
$result = $this->PruefungModel->getAllExRepeaterWithNewNegativeCommissionalExams();
if (isError($result)) {
print_r(getError($result));
}
$dataExrepeater = getData($result) ?: [];
$count = 0;
foreach ($dataExrepeater as $exrepeater) {
$result = $this->PrestudentModel->load($exrepeater->prestudent_id);
if (!hasData($result)) {
$this->logWarning('No Prestudent found');
continue;
}
$prestudent = current(getData($result));
$result = $this->StudiengangModel->load($prestudent->studiengang_kz);
if (!hasData($result)) {
$this->logWarning('No Studiengang found');
continue;
}
$studiengang = current(getData($result));
$result = $this->PersonModel->loadPrestudent($exrepeater->prestudent_id);
if (!hasData($result)) {
$this->logWarning('No Person found');
continue;
}
$person = current(getData($result));
$count++;
$email = $studiengang->email;
$dataMail = array(
'prestudent' => 'PreStudentId: ' . $exrepeater->prestudent_id,
'name' => trim($person->vorname . ' ' . $person->nachname),
//'emailAn' => $email
);
if (!sendSanchoMail('Sancho_Mail_Antrag_W_EX_W', $dataMail, $email, 'Kommissionelle Prüfung ehemalige*r Wiederholer*in')) {
$this->logWarning("Failed to send Notification to " . $email);
}
}
$this->logInfo($count . " Mails sent");
$this->logInfo('End Job sendReminderWiederholerWithNegativeCommissionalExam');
}
protected function prestudentsGetUnique($prestudents)
{
$result = [];
@@ -306,4 +306,35 @@ class Pruefung_model extends DB_Model
return $this->loadWhereCommitteeExamsFailed();
}
/**
*
* @return stdClass
*/
public function getAllExRepeaterWithNewNegativeCommissionalExams()
{
$query = "
SELECT DISTINCT antrag.prestudent_id
FROM lehre.tbl_pruefung p
JOIN lehre.tbl_note n USING (note)
JOIN (
SELECT
stud.student_uid,
antr.datum,
antr.prestudent_id
FROM campus.tbl_studierendenantrag antr
JOIN public.tbl_prestudent ps USING (prestudent_id)
JOIN public.tbl_student stud USING (prestudent_id)
JOIN public.tbl_benutzer ben ON (ben.uid = stud.student_uid)
WHERE antr.typ = 'Wiederholung'
AND ben.aktiv = true
) antrag ON antrag.student_uid = p.student_uid
WHERE n.note IN (20, 13, 5, 15, 14) -- 9 (noch nicht eingetragen ist negativ)
AND p.pruefungstyp_kurzbz IN ('kommPruef', 'zusKommPruef')
AND p.datum > antrag.datum
";
return $this->execQuery($query);
}
}