From 925a6d40ecd91f2f8da02a45af43ad97d1769116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 14 Jan 2019 14:09:42 +0100 Subject: [PATCH] =?UTF-8?q?Neue=20Studienpl=C3=A4ne=20werden=20automatisch?= =?UTF-8?q?=20zu=20Reihungstests=20hinzugef=C3=BCgt=20zu=20denen=20der=20a?= =?UTF-8?q?lte=20Studienplan=20zugeteilt=20war=20sofern=20die=20G=C3=BClti?= =?UTF-8?q?gkeit=20passt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/jobs/Prestudentstatus.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/application/controllers/jobs/Prestudentstatus.php b/application/controllers/jobs/Prestudentstatus.php index 7d2b01b38..3f8a0e903 100644 --- a/application/controllers/jobs/Prestudentstatus.php +++ b/application/controllers/jobs/Prestudentstatus.php @@ -114,6 +114,11 @@ class Prestudentstatus extends FHC_Controller $row_status->person_id, $row_status->studienplan_id, $studienplan->retval[0]->studienplan_id); + + $this->correctReihungstestStudienplan( + $row_status->studiensemester_kurzbz, + $row_status->studienplan_id, + $studienplan->retval[0]->studienplan_id); } } } @@ -188,4 +193,49 @@ class Prestudentstatus extends FHC_Controller } } } + + /** + * When a degree Programm gets a new Studyplan the Placementtests are updated and the + * new studyplan is added + * @param $studiensemester Studiensemester_kurzbz. + * @param $studienplan_id_old Id of the old studyplan + * @param $studienplan_id id of the new studyplan + */ + private function correctReihungstestStudienplan($studiensemester, $studienplan_id_old, $studienplan_id) + { + $this->load->model('crm/RtStudienplan_model', 'RtStudienplanModel'); + + $this->RtStudienplanModel->resetQuery(); + // Correct also Assignments to Placement test + $this->RtStudienplanModel->addJoin( + 'public.tbl_reihungstest', + 'tbl_reihungstest.reihungstest_id = tbl_rt_studienplan.reihungstest_id' + ); + + $rt = $this->RtStudienplanModel->loadWhere(array( + "studienplan_id" => $studienplan_id_old, + "tbl_reihungstest.studiensemester_kurzbz" => $studiensemester + )); + + if(hasData($rt)) + { + foreach($rt->retval as $row_rt) + { + // Add new Studyplan to RtStudienplan if missing + $rt_studienplan = $this->RtStudienplanModel->loadWhere(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $studienplan_id + )); + + if(!hasData($rt_studienplan)) + { + echo "Adding StudienplanId: $studienplan_id to ReihungstestId: $row_rt->reihungstest_id"; + $this->RtStudienplanModel->insert(array( + "reihungstest_id" => $row_rt->reihungstest_id, + "studienplan_id" => $studienplan_id + )); + } + } + } + } }