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: ` +
+ + + +
` +} \ No newline at end of file diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Details.js b/public/js/components/Stv/Studentenverwaltung/Details/Details.js index ece956b64..f6d7d6b40 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Details.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Details.js @@ -1,86 +1,235 @@ +import VueDatePicker from '../../../vueDatepicker.js.php'; +import FormUploadImage from '../../../Form/Upload/Image.js'; +import {CoreRESTClient} from '../../../../RESTClient.js'; + export default { + components: { + VueDatePicker, + FormUploadImage + }, props: { student: Object }, data() { return { - person_id: '', - bpk: '', - anrede: '', - titelpre: '', - titelpost: '', - nachname: '', - vorname: '', - vornamen: '', - wahlname: '', - gebdatum: '', - gebort: '', - gebnation: '' + nations: [], + sprachen: [], + geschlechter: [], + familienstaende: { + "": "--keine Auswahl--", + "g": "geschieden", + "l": "ledig", + "v": "verheiratet", + "w": "verwitwet" + }, + person: null, + studentIn: null } }, watch: { student(n) { - this.person_id = n.person_id; - this.bpk = n.bpk; - this.anrede = n.anrede; - this.titelpre = n.titelpre; - this.titelpost = n.titelpost; - this.nachname = n.nachname; - this.vorname = n.vorname; - this.vornamen = n.vornamen; - this.wahlname = n.wahlname; - this.gebdatum = n.gebdatum; - // TODO(chris): gebdatum > datepicker - // TODO(chris): gebort & getnation? + CoreRESTClient + .get('components/stv/Student/getPerson/' + this.student.person_id) + .then(result => result.data) + .then(result => { + this.person = result; + if (!this.person.familienstand) + this.person.familienstand = ''; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + CoreRESTClient + .get('components/stv/Student/getStudent/' + this.student.uid) + .then(result => result.data) + .then(result => { + // TODO(chris): IMPLEMENT HERE! + console.log(result); + this.studentIn = result; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); } }, + created() { + CoreRESTClient + .get('components/stv/Student/getNations') + .then(result => { + this.nations = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + CoreRESTClient + .get('components/stv/Student/getSprachen') + .then(result => { + this.sprachen = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + CoreRESTClient + .get('components/stv/Student/getGeschlechter') + .then(result => { + this.geschlechter = result.data; + }) + .catch(err => { + console.error(err.response.data || err.message); + }); + }, template: `
Person -
- -
- + +
+ Loading...
-
- -
- -
- -
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
- -
- -
- -
- +
+
+ StudentIn + +
+ Loading...
` diff --git a/public/js/components/Stv/Studentenverwaltung/List.js b/public/js/components/Stv/Studentenverwaltung/List.js index c6eb097d2..61631029e 100644 --- a/public/js/components/Stv/Studentenverwaltung/List.js +++ b/public/js/components/Stv/Studentenverwaltung/List.js @@ -81,7 +81,6 @@ export default { this.$refs.table.tabulator.on("dataProcessed", () => { let rows = this.$refs.table.tabulator.getRows(); if (rows.length && rows.length == 1) { - console.log(); this.$refs.table.tabulator.selectRow(); } }); diff --git a/public/js/components/vueDatepicker.js.php b/public/js/components/vueDatepicker.js.php new file mode 100644 index 000000000..d92bd4a33 --- /dev/null +++ b/public/js/components/vueDatepicker.js.php @@ -0,0 +1,12 @@ +