diff --git a/application/controllers/Studentenverwaltung.php b/application/controllers/Studentenverwaltung.php index 64db67ef1..f2bb75b71 100644 --- a/application/controllers/Studentenverwaltung.php +++ b/application/controllers/Studentenverwaltung.php @@ -16,11 +16,15 @@ class Studentenverwaltung extends FHC_Controller { $this->load->library('AuthLib'); $this->load->library('PermissionLib'); + $this->load->library('VariableLib', ['uid' => getAuthUID()]); $this->load->view('Studentenverwaltung', [ 'permissions' => [ 'student/bpk' => $this->permissionlib->isBerechtigt('student/bpk'), 'student/alias' => $this->permissionlib->isBerechtigt('student/alias') + ], + 'variables' => [ + 'semester_aktuell' => $this->variablelib->getVar('semester_aktuell') ] ]); } diff --git a/application/controllers/components/stv/Students.php b/application/controllers/components/stv/Students.php index 941441466..ff4558400 100644 --- a/application/controllers/components/stv/Students.php +++ b/application/controllers/components/stv/Students.php @@ -8,6 +8,9 @@ class Students extends FHC_Controller { // TODO(chris): access! parent::__construct(); + + $this->load->library('AuthLib'); + $this->load->library('VariableLib', ['uid' => getAuthUID()]); } /** @@ -169,8 +172,7 @@ class Students extends FHC_Controller */ protected function getStudents($studiengang_kz, $semester = null, $verband = null, $gruppe = null, $gruppe_kurzbz = null, $orgform_kurzbz = null) { - // TODO(chris): stdSem from Variable - $studiensemester_kurzbz='SS2023'; + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); $this->load->model('crm/Prestudent_model', 'PrestudentModel'); @@ -277,8 +279,7 @@ class Students extends FHC_Controller */ protected function getStudent($student_uid) { - // TODO(chris): stdSem from Variable - $studiensemester_kurzbz='SS2023'; + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); $this->load->model('crm/Prestudent_model', 'PrestudentModel'); @@ -353,8 +354,7 @@ class Students extends FHC_Controller */ protected function getPrestudent($prestudent_id) { - // TODO(chris): stdSem from Variable - $studiensemester_kurzbz='SS2023'; + $studiensemester_kurzbz = $this->variablelib->getVar('semester_aktuell'); $this->load->model('crm/Prestudent_model', 'PrestudentModel'); diff --git a/application/controllers/components/stv/Studiensemester.php b/application/controllers/components/stv/Studiensemester.php new file mode 100644 index 000000000..3c23a1534 --- /dev/null +++ b/application/controllers/components/stv/Studiensemester.php @@ -0,0 +1,59 @@ +load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addOrder('start'); + + $result = $this->StudiensemesterModel->load(); + + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } elseif (!hasData($result)) { + $this->output->set_status_header(REST_Controller::HTTP_NOT_FOUND); + $this->outputJson('NOT FOUND'); + } else { + $this->outputJson(getData($result)); + } + } + + public function set() + { + $this->load->library('AuthLib'); + $this->load->library('form_validation'); + + $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); + + $this->form_validation->set_rules('studiensemester', 'Studiensemester', 'required'); + + if ($this->form_validation->run() == false) { + $this->output->set_status_header(HTTP_BAD_REQUEST); + return $this->outputJson($this->form_validation->error_array()); + } + + $stdsem = $this->input->post('studiensemester'); + + $this->load->model('system/Variable_model', 'VariableModel'); + + $result = $this->VariableModel->setVariable(getAuthUID(), 'semester_aktuell', $stdsem); + + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + return $this->outputJson(getError($result)); + } + + $this->outputJsonSuccess(true); + } +} diff --git a/application/views/Studentenverwaltung.php b/application/views/Studentenverwaltung.php index 5928a2b00..50a8ed3c4 100644 --- a/application/views/Studentenverwaltung.php +++ b/application/views/Studentenverwaltung.php @@ -26,6 +26,7 @@
- + +
diff --git a/public/js/components/Stv/Studentenverwaltung/List.js b/public/js/components/Stv/Studentenverwaltung/List.js index 61631029e..f9ba77213 100644 --- a/public/js/components/Stv/Studentenverwaltung/List.js +++ b/public/js/components/Stv/Studentenverwaltung/List.js @@ -78,22 +78,23 @@ export default { this.$emit('update:selected', data); }, updateUrl(url) { - this.$refs.table.tabulator.on("dataProcessed", () => { - let rows = this.$refs.table.tabulator.getRows(); - if (rows.length && rows.length == 1) { - this.$refs.table.tabulator.selectRow(); - } - }); - + if (url) + url = CoreRESTClient._generateRouterURI(url); if (!this.$refs.table.tableBuilt) this.$refs.table.tabulator.on("tableBuilt", () => { - this.$refs.table.tabulator.setData(CoreRESTClient._generateRouterURI(url)); + this.$refs.table.tabulator.setData(url); }); else - this.$refs.table.tabulator.setData(CoreRESTClient._generateRouterURI(url)); + this.$refs.table.tabulator.setData(url); } }, mounted() { + this.$refs.table.tabulator.on("dataProcessed", () => { + let rows = this.$refs.table.tabulator.getRows(); + if (rows.length && rows.length == 1) { + this.$refs.table.tabulator.selectRow(); + } + }); }, template: `
diff --git a/public/js/components/Stv/Studentenverwaltung/Studiensemester.js b/public/js/components/Stv/Studentenverwaltung/Studiensemester.js new file mode 100644 index 000000000..09d0cb532 --- /dev/null +++ b/public/js/components/Stv/Studentenverwaltung/Studiensemester.js @@ -0,0 +1,86 @@ +import {CoreRESTClient} from '../../../RESTClient.js'; + +export default { + emits: [ + 'changed' + ], + props: { + default: { + type: String, + default: '' + } + }, + data() { + return { + current: 0, + loading: true, + list: [] + }; + }, + methods: { + set(n) { + this.loading = true; + let fallback = this.current; + this.current = n; + this.save(fallback); + }, + next() { + this.loading = true; + let fallback = this.current; + if (this.current++ >= this.list.length) + this.current = this.list.length - 1; + this.save(fallback); + }, + prev() { + this.loading = true; + let fallback = this.current; + if (this.current-- < 0) + this.current = 0; + this.save(fallback); + }, + save(fallback) { + CoreRESTClient + .post('components/stv/studiensemester/set', { + studiensemester: this.list[this.current] + }) + .then(() => { + this.loading = false; + this.$emit('changed'); + }) + .catch(() => { + this.current = fallback; + // TODO(chris): emit error + }); + } + }, + created() { + CoreRESTClient + .get('components/stv/studiensemester') + .then(result => result.data) + .then(result => { + this.list = result.map(el => el.studiensemester_kurzbz); + this.loading = false; + this.current = this.list.indexOf(this.default); + }) + .catch(error => { + console.error(error); + }); + }, + template: ` +
+
+ + + + +
+
+ ` +} \ No newline at end of file