SponsionsJob: Umbau auf eine Abfrage

This commit is contained in:
ma0068
2022-09-28 09:30:23 +02:00
parent 11281c1e5f
commit 2706a76b46
3 changed files with 42 additions and 55 deletions
+17 -22
View File
@@ -3,7 +3,7 @@
* FH-Complete
*
*
* Cronjobs to be run for inserting the date of Sponsion as Date ZGV of absolvents
* Cronjobs to be run for inserting the date of Sponsion as Date ZGV
*/
// ------------------------------------------------------------------------
@@ -25,33 +25,28 @@ class SponsionJob extends JOB_Controller
public function insertDate()
{
$allAbsolventsWithDateSponsion = $this->AbschlusspruefungModel->getAbsolventsWithSponsionDate()->retval;
$count = 0;
$countBewerbungen = 0;
//Bewerbungen vom aktuellen Semester + nächstes Semester berücksichtigen
$date_actual = new DateTime('first day of this month midnight'); // date obj of actual date
$month = $date_actual->format('m'); // string month of actual timesheet
$year = $date_actual->format('Y'); // string year of actual timesheet
$nextYear = $year+1;
print_r("-----------------------------------------------------------------\n");
print_r("Cronjob START\n");
print_r("Sponsionsdatum als ZGV-Datum eintragen:\n");
$semester1 = "WS" . $year;
$semester2 = ($month>= 6) ? "SS" . $nextYear : "SS" . $year;
foreach ($allAbsolventsWithDateSponsion as $absolvent)
{
$this->AbschlusspruefungModel->insertDatumSponsionAsZgvmadatum($absolvent->prestudent_id, $absolvent->sponsion);
$allInteressenten = $this->PrestudentModel->getAllInteressentenWithMasterSponsion($semester1, $semester2)->retval;
//get all prestudents of person_id with Status Interessent
$allBewerbungen = $this->PrestudentModel->getPrestudentsOfPersonId($absolvent->person_id, 'Interessent')->retval;
foreach ($allBewerbungen as $bewerbung)
{
$this->AbschlusspruefungModel->insertDatumSponsionAsZgvmadatum($bewerbung->prestudent_id, $absolvent->sponsion);
print_r (" Bewerbung: personId: " . $absolvent->person_id . " prestudentId: " . $bewerbung->prestudent_id. " DateSponsion: " . $absolvent->sponsion."\n");
$countBewerbungen++;
}
$count++;
}
foreach($allInteressenten as $interessent)
{
$this->AbschlusspruefungModel->insertDatumSponsionAsZgvmadatum($interessent->prestudent_id, $interessent->sponsion);
$countBewerbungen++;
}
print_r("\nAnzahl Absolventen: " . $count);
print_r("\nAnzahl Inserts Bewerbungen: " . $countBewerbungen);
print_r("\nCronjob END\n");
print_r("-----------------------------------------------------------------\n");
print_r("Anzahl Inserts Bewerbungen: " . $countBewerbungen);
print_r("\n-----------------------------------------------------------------\n");
return true;
}
+24 -13
View File
@@ -667,25 +667,36 @@ class Prestudent_model extends DB_Model
return $this->execQuery($query, array($prestudent_id));
}
/**
* get all prestudents of a Person_id with certain status
* @param $personId
* @param $prestudentStatus
* @return array all prestudents of the person (with certain status)
* get all Interessenten without ZGVmasdatum and with Sponsionsdate
* @param $semesterkurzbz1 und $semesterkurzbz2
* @return array all prestudents with sponsionsdate
*/
public function getPrestudentsOfPersonId($personId, $prestudentStatus)
public function getAllInteressentenWithMasterSponsion($semesterkurzbz1, $semesterkurzbz2=null)
{
return $this->execQuery(
'SELECT prestudent_id
FROM public.tbl_prestudent
JOIN public.tbl_prestudentstatus USING (prestudent_id)
WHERE person_id = ?
AND get_rolle_prestudent(prestudent_id, null) = ?',
'SELECT ps.prestudent_id, person_id, ap.sponsion
FROM
public.tbl_prestudent ps
JOIN public.tbl_prestudentstatus USING(prestudent_id)
JOIN public.tbl_person p USING (person_id)
JOIN public.tbl_prestudent ps2 USING (person_id)
JOIN public.tbl_student st ON (st.prestudent_id = ps2.prestudent_id)
JOIN lehre.tbl_abschlusspruefung ap USING (student_uid)
JOIN public.tbl_studiengang sg ON (sg.studiengang_kz = ps2.studiengang_kz)
WHERE
get_rolle_prestudent(ps.prestudent_id, null) = \'Interessent\'
AND ps.zgvmadatum is NULL
AND get_rolle_prestudent(ps2.prestudent_id, null) = \'Absolvent\'
AND sg.typ != \'l\'
AND tbl_prestudentstatus.studiensemester_kurzbz in (?,?)',
array(
$personId,
$prestudentStatus
$semesterkurzbz1,
$semesterkurzbz2
)
);
);
}
}
@@ -114,27 +114,8 @@ class Abschlusspruefung_model extends DB_Model
return success($abschlusspruefungdata);
}
/**
* get all Absolvents with a Date Sponsion without filled master zgv field
*/
public function getAbsolventsWithSponsionDate()
{
$qry = "SELECT ps.prestudent_id, ap.sponsion, p.person_id
FROM lehre.tbl_abschlusspruefung ap
JOIN public.tbl_student st USING (student_uid)
JOIN public.tbl_prestudent ps USING (prestudent_id)
JOIN public.tbl_prestudentstatus pstatus USING (prestudent_id)
JOIN public.tbl_person p USING (person_id)
JOIN public.tbl_studiengang sg ON (sg.studiengang_kz = ps.studiengang_kz)
WHERE ap.sponsion < now()
AND ps.zgvmadatum is NULL
AND pstatus.status_kurzbz in ('Absolvent')
AND sg.typ != 'l'
ORDER BY ap.Sponsion DESC";
return $this->execQuery($qry);
}
/**
/**
* update ZGV Master
*/
public function insertDatumSponsionAsZgvmadatum($prestudentId, $datumSponsion)