From 1b19a0821fce8e28e7a88bd2ef7efc6da31188aa Mon Sep 17 00:00:00 2001 From: cgfhtw Date: Wed, 24 Apr 2024 14:02:58 +0200 Subject: [PATCH] Konto filters for Student list --- .../controllers/components/stv/Students.php | 51 ++++++++++++++++++ public/css/Studentenverwaltung.css | 4 ++ .../Stv/Studentenverwaltung/List.js | 54 +++++++++++++++++-- public/js/components/filter/Filter.js | 10 +++- 4 files changed, 114 insertions(+), 5 deletions(-) diff --git a/application/controllers/components/stv/Students.php b/application/controllers/components/stv/Students.php index 9bd2df73f..decf1b66a 100644 --- a/application/controllers/components/stv/Students.php +++ b/application/controllers/components/stv/Students.php @@ -320,6 +320,8 @@ class Students extends FHC_Controller break; } + $this->addFilter($studiensemester_kurzbz); + $this->outputJson([]); } @@ -426,6 +428,8 @@ class Students extends FHC_Controller } + $this->addFilter($studiensemester_kurzbz); + $result = $this->PrestudentModel->loadWhere($where); if (isError($result)) { @@ -497,6 +501,8 @@ class Students extends FHC_Controller $this->PrestudentModel->addSelect('p.zugangscode'); $this->PrestudentModel->addSelect('p.bpk'); + $this->addFilter($studiensemester_kurzbz); + $result = $this->PrestudentModel->loadWhere([ 'tbl_prestudent.prestudent_id' => $prestudent_id ]); @@ -570,6 +576,8 @@ class Students extends FHC_Controller $this->PrestudentModel->addSelect('p.zugangscode'); $this->PrestudentModel->addSelect('p.bpk'); + $this->addFilter($studiensemester_kurzbz); + $result = $this->PrestudentModel->loadWhere([ 's.student_uid' => $student_uid ]); @@ -643,6 +651,8 @@ class Students extends FHC_Controller $this->PrestudentModel->addSelect('p.zugangscode'); $this->PrestudentModel->addSelect('p.bpk'); + $this->addFilter($studiensemester_kurzbz); + $result = $this->PrestudentModel->loadWhere([ 'p.person_id' => $person_id ]); @@ -654,4 +664,45 @@ class Students extends FHC_Controller $this->outputJson(getData($result) ?: []); } } + + /** + * Adds additional filters to the query + * + * @param string $studiensemester_kurzbz + * + * @return void + */ + protected function addFilter($studiensemester_kurzbz) + { + $filter = $this->input->get('filter'); + if (isset($filter['konto_count_0'])) { + $bt = $this->PrestudentModel->escape($filter['konto_count_0']); + $stdsem = $this->PrestudentModel->escape($studiensemester_kurzbz); + + $this->PrestudentModel->db->where('( + SELECT count(*) + FROM public.tbl_konto + WHERE person_id=tbl_prestudent.person_id + AND buchungstyp_kurzbz=' . $bt . ' + AND studiensemester_kurzbz=' . $stdsem . ' + ) =', 0); + $this->PrestudentModel->db->where('get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) !=', 'Incoming'); + } + if (isset($filter['konto_missing_counter'])) { + $bt = $this->PrestudentModel->escape($filter['konto_missing_counter']); + $stg = ''; + if ($this->variablelib->getVar('kontofilterstg') == 'true') + $stg = ' AND studiengang_kz=tbl_prestudent.studiengang_kz'; + + $bt = $bt == 'alle' ? '' : ' AND buchungstyp_kurzbz=' . $bt; + + $this->PrestudentModel->db->where('( + SELECT sum(betrag) + FROM public.tbl_konto + WHERE person_id=tbl_prestudent.person_id' . + $bt . + $stg . ' + ) !=', 0); + } + } } diff --git a/public/css/Studentenverwaltung.css b/public/css/Studentenverwaltung.css index d29455097..1fa35623e 100644 --- a/public/css/Studentenverwaltung.css +++ b/public/css/Studentenverwaltung.css @@ -104,3 +104,7 @@ html { background-color: #f8d7da!important; border-color: #f5c2c7!important; } + +.has-filter .fa-filter { + color: var(--bs-success); +} diff --git a/public/js/components/Stv/Studentenverwaltung/List.js b/public/js/components/Stv/Studentenverwaltung/List.js index c9c5ecb26..31f7d0963 100644 --- a/public/js/components/Stv/Studentenverwaltung/List.js +++ b/public/js/components/Stv/Studentenverwaltung/List.js @@ -7,6 +7,9 @@ export default { CoreFilterCmpt, ListNew }, + inject: [ + 'lists' + ], props: { selected: Array, studiengangKz: Number, @@ -79,7 +82,9 @@ export default { } ], focusObj: null, // TODO(chris): this should be in the filter component - lastSelected: null + lastSelected: null, + filterKontoCount0: undefined, + filterKontoMissingCounter: undefined } }, methods: { @@ -110,17 +115,29 @@ export default { }, updateUrl(url, first) { this.lastSelected = first ? undefined : this.selected; + if (url) url = CoreRESTClient._generateRouterURI(url); + + const params = {}, filter = {}; + if (this.filterKontoCount0) + filter.konto_count_0 = this.filterKontoCount0; + if (this.filterKontoMissingCounter) + filter.konto_missing_counter = this.filterKontoMissingCounter; + + if (filter.konto_count_0 || filter.konto_missing_counter) + params.filter = filter; + if (!this.$refs.table.tableBuilt) { if (!this.$refs.table.tabulator) { this.tabulatorOptions.ajaxURL = url; + this.tabulatorOptions.ajaxParams = params; } else this.$refs.table.tabulator.on("tableBuilt", () => { - this.$refs.table.tabulator.setData(url); + this.$refs.table.tabulator.setData(url, params); }); } else - this.$refs.table.tabulator.setData(url); + this.$refs.table.tabulator.setData(url, params); }, onKeydown(e) { // TODO(chris): this should be in the filter component if (!this.focusObj) @@ -179,7 +196,7 @@ export default { // TODO(chris): filter component column chooser has no accessibilty features template: `
-
+
+
diff --git a/public/js/components/filter/Filter.js b/public/js/components/filter/Filter.js index d4c51c37c..1cf6e6425 100644 --- a/public/js/components/filter/Filter.js +++ b/public/js/components/filter/Filter.js @@ -543,7 +543,7 @@ export const CoreFilterCmpt = {