From 1ed3031dad8f92542e14432c5b83184ebed18c60 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Tue, 26 May 2026 09:38:13 +0200 Subject: [PATCH] add new Job for sent Email to Assistant as Reminder for Manual Deregistration of ExRepeaterWithNewNegativeCommissionalExams --- application/controllers/jobs/AntragJob.php | 52 +++++++++++++++++++ .../models/education/Pruefung_model.php | 31 +++++++++++ 2 files changed, 83 insertions(+) diff --git a/application/controllers/jobs/AntragJob.php b/application/controllers/jobs/AntragJob.php index 8dc4870ea..ddeb32686 100644 --- a/application/controllers/jobs/AntragJob.php +++ b/application/controllers/jobs/AntragJob.php @@ -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 = []; diff --git a/application/models/education/Pruefung_model.php b/application/models/education/Pruefung_model.php index 927d83c82..1529c4c2c 100644 --- a/application/models/education/Pruefung_model.php +++ b/application/models/education/Pruefung_model.php @@ -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); + } + }