From 58005d1832a25d46f4939ae2ccedaab4bdeb1ad0 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Wed, 19 Jun 2024 14:31:47 +0200 Subject: [PATCH] change getStudienplaene from prestudent_id to array prestudent_ids --- .../api/frontend/v1/stv/Prestudent.php | 22 +++++-------------- .../models/organisation/Studienplan_model.php | 16 ++++++++++++++ .../Details/Prestudent/MultiStatus.js | 15 ++++++++----- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/application/controllers/api/frontend/v1/stv/Prestudent.php b/application/controllers/api/frontend/v1/stv/Prestudent.php index e29736288..7c8cf5cfb 100644 --- a/application/controllers/api/frontend/v1/stv/Prestudent.php +++ b/application/controllers/api/frontend/v1/stv/Prestudent.php @@ -279,28 +279,16 @@ class Prestudent extends FHCAPI_Controller return $this->terminateWithSuccess(getData($result) ?: []); } - //TODO(manu) multi - public function getStudienplaene($prestudent_id) + public function getStudienplaene($prestudent_ids) { - $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - - $result = $this->PrestudentModel->loadWhere( - array('prestudent_id' => $prestudent_id) - ); - if (isError($result)) { - $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); - } - - $result = current(getData($result)); - $studiengang_kz = $result->studiengang_kz; + $prestudent_ids = urldecode($prestudent_ids); $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + $result = $this->StudienplanModel->getStudienplaeneByPrestudents($prestudent_ids); - $this->StudienplanModel->addOrder('studienplan_id', 'DESC'); - $result = $this->StudienplanModel->getStudienplaene($studiengang_kz); - - if (isError($result)) { + if (isError($result)) + { $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); } return $this->terminateWithSuccess(getData($result) ?: []); diff --git a/application/models/organisation/Studienplan_model.php b/application/models/organisation/Studienplan_model.php index a142cd19b..3c6e0b2d2 100644 --- a/application/models/organisation/Studienplan_model.php +++ b/application/models/organisation/Studienplan_model.php @@ -119,4 +119,20 @@ class Studienplan_model extends DB_Model 'lv.lehrveranstaltung_id' => $lehrveranstaltung_id ]); } + + public function getStudienplaeneByPrestudents($prestudentIds) + { + $prestudentIds = intVal($prestudentIds); + + $query = " + SELECT so.studienordnung_id, sp.bezeichnung + FROM public.tbl_prestudent ps + JOIN lehre.tbl_studienordnung so ON (ps.studiengang_kz = so.studiengang_kz) + JOIN lehre.tbl_studienplan sp ON (sp.studienordnung_id = so.studienordnung_id) + WHERE ps.prestudent_id IN (?) + ORDER BY so.studienordnung_id DESC + "; + + return $this->execQuery($query, array($prestudentIds)); + } } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js index 5e6a73e7f..4c45c923e 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/MultiStatus.js @@ -55,6 +55,9 @@ export default{ } return this.modelValue.map(e => e.prestudent_id); }, + paramIds(){ + return Array.isArray(this.prestudentIds) ? this.prestudentIds.join(',') : this.prestudentIds; + }, updateData(){ const dataArray = []; if (this.modelValue.prestudent_id) { @@ -636,13 +639,13 @@ export default{ this.listStudiensemester = result; }) .catch(this.$fhcAlert.handleSystemError); -/* this.$fhcApi - .get('api/frontend/v1/stv/prestudent/getStudienplaene/' + this.modelValue.prestudent_id) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/getStudienplaene/' + encodeURIComponent(this.paramIds)) .then(result => result.data) .then(result => { this.listStudienplaene = result; }) - .catch(this.$fhcAlert.handleSystemError);*/ + .catch(this.$fhcAlert.handleSystemError); this.$fhcApi .get('api/frontend/v1/stv/status/getStatusgruende/') .then(result => result.data) @@ -661,7 +664,7 @@ export default{ mounted(){}, template: `
- +