diff --git a/application/controllers/components/stv/Student.php b/application/controllers/components/stv/Student.php new file mode 100644 index 000000000..6268f22e0 --- /dev/null +++ b/application/controllers/components/stv/Student.php @@ -0,0 +1,94 @@ +load->model('person/Person_model', 'PersonModel'); + + $result = $this->PersonModel->load($person_id); + 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(current(getData($result))); + } + } + + public function getStudent($student_uid) + { + // TODO(chris): this is wrong + $this->load->model('crm/Student_model', 'StudentModel'); + + $result = $this->StudentModel->load([$student_uid]); + 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(current(getData($result))); + } + } + + public function getNations() + { + $this->load->model('codex/Nation_model', 'NationModel'); + + $this->NationModel->addOrder('kurztext'); + + $result = $this->NationModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + + public function getSprachen() + { + $this->load->model('system/Sprache_model', 'SpracheModel'); + + $this->SpracheModel->addOrder('sprache'); + + $result = $this->SpracheModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } + + public function getGeschlechter() + { + $this->load->model('person/Geschlecht_model', 'GeschlechtModel'); + + $this->GeschlechtModel->addOrder('sort'); + $this->GeschlechtModel->addOrder('geschlecht'); + + $this->GeschlechtModel->addSelect('*'); + $this->GeschlechtModel->addSelect("bezeichnung_mehrsprachig[(SELECT index FROM public.tbl_sprache WHERE sprache=" . $this->GeschlechtModel->escape(DEFAULT_LANGUAGE) . " LIMIT 1)] AS bezeichnung"); + + $result = $this->GeschlechtModel->load(); + if (isError($result)) { + $this->output->set_status_header(REST_Controller::HTTP_INTERNAL_SERVER_ERROR); + $this->outputJson(getError($result)); + } else { + $this->outputJson(getData($result) ?: []); + } + } +} diff --git a/application/views/Studentenverwaltung.php b/application/views/Studentenverwaltung.php index f156ed32a..ff6f5bfae 100644 --- a/application/views/Studentenverwaltung.php +++ b/application/views/Studentenverwaltung.php @@ -10,7 +10,8 @@ 'tabulator5' => true, 'phrases' => [], 'customCSSs' => [ - 'public/css/Studentenverwaltung.css' + 'public/css/Studentenverwaltung.css', + 'public/css/components/vue-datepicker.css' ], 'customJSModules' => [ 'public/js/apps/Studentenverwaltung.js' diff --git a/composer.json b/composer.json index 825ed5625..a2fd38d68 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,28 @@ "wiki": "https://wiki.fhcomplete.info/doku.php" }, "repositories": [ + { + "type": "package", + "package": { + "name": "vuepic/vue-datepicker-js", + "version": "4.0.0", + "dist": { + "url": "https://unpkg.com/@vuepic/vue-datepicker@4.0.0/dist/vue-datepicker.iife.js", + "type": "file" + } + } + }, + { + "type": "package", + "package": { + "name": "vuepic/vue-datepicker-css", + "version": "4.0.0", + "dist": { + "url": "https://unpkg.com/@vuepic/vue-datepicker@4.0.0/dist/main.css", + "type": "file" + } + } + }, { "type": "package", "package": { @@ -420,7 +442,9 @@ "twbs/bootstrap5": "5.1.*", "vuejs/vuejs3": "3.2.33", - "vuejs/vuerouter4": "4.1.3" + "vuejs/vuerouter4": "4.1.3", + "vuepic/vue-datepicker-js": "4.*", + "vuepic/vue-datepicker-css": "4.*" }, "config": { "bin-dir": "vendor/bin" diff --git a/public/css/components/vue-datepicker.css b/public/css/components/vue-datepicker.css new file mode 100644 index 000000000..0dd87bb0c --- /dev/null +++ b/public/css/components/vue-datepicker.css @@ -0,0 +1,2 @@ +@import '../../../vendor/vuepic/vue-datepicker-css/main.css'; + diff --git a/public/js/components/Form/Upload/Image.js b/public/js/components/Form/Upload/Image.js new file mode 100644 index 000000000..99128f9c5 --- /dev/null +++ b/public/js/components/Form/Upload/Image.js @@ -0,0 +1,62 @@ +export default { + emits: [ + 'update:modelValue' + ], + props: { + modelValue: String + }, + computed: { + valueAsBase64DataString() { + if (!this.modelValue || this.modelValue.substring(0, 10) == 'data:image') + return this.modelValue; + return 'data:image/jpeg;charset=utf-8;base64,' + this.modelValue; + } + }, + methods: { + openUploadDialog() { + this.$refs.fileInput.click(); + }, + pickFile() { + let file = this.$refs.fileInput.files; + if (file && file[0]) { + let reader = new FileReader(); + reader.onload = e => { + this.$emit('update:modelValue', e.target.result); + } + reader.readAsDataURL(file[0]); + } + }, + deleteImage() { + this.$emit('update:modelValue', ''); + } + }, + template: ` +