From 39a23693ba2cb274b14ad895f1e18996c0f52536 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Wed, 18 Dec 2024 16:31:39 +0100 Subject: [PATCH] start Table Mobility --- .../api/frontend/v1/stv/Config.php | 5 + .../api/frontend/v1/stv/Mobility.php | 47 ++ public/js/api/stv.js | 2 + public/js/api/stv/mobility.js | 5 + .../Studentenverwaltung/Details/Mobility.js | 25 + .../Details/Mobility/Mobility.js | 629 ++++++++++++++++++ system/phrasesupdate.php | 25 +- 7 files changed, 737 insertions(+), 1 deletion(-) create mode 100644 application/controllers/api/frontend/v1/stv/Mobility.php create mode 100644 public/js/api/stv/mobility.js create mode 100644 public/js/components/Stv/Studentenverwaltung/Details/Mobility.js create mode 100644 public/js/components/Stv/Studentenverwaltung/Details/Mobility/Mobility.js diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index c28c49485..241292ae0 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -91,6 +91,11 @@ class Config extends FHCAPI_Controller 'title' => $this->p->t('stv', 'tab_resources'), 'component' => './Stv/Studentenverwaltung/Details/Betriebsmittel.js' ]; + $result['mobility'] = [ + 'title' => $this->p->t('stv', 'tab_mobility'), + 'component' => './Stv/Studentenverwaltung/Details/Mobility.js' + ]; + /* TODO(chris): Ausgeblendet für Testing $result['grades'] = [ 'title' => $this->p->t('stv', 'tab_grades'), diff --git a/application/controllers/api/frontend/v1/stv/Mobility.php b/application/controllers/api/frontend/v1/stv/Mobility.php new file mode 100644 index 000000000..49a0ec165 --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Mobility.php @@ -0,0 +1,47 @@ + ['admin:r', 'assistenz:r'], + 'loadMobility' => ['admin:r', 'assistenz:r'], + 'insertMobility' => ['admin:rw', 'assistenz:rw'], + 'updateMobility' => ['admin:rw', 'assistenz:rw'], + 'deleteMobility' => ['admin:rw', 'assistenz:rw'], + 'getTypenMobility' => ['admin:rw', 'assistenz:rw'], + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + $this->load->library('form_validation'); + + // Load language phrases + $this->loadPhrases([ + 'ui' + ]); + + // Load models + $this->load->model('codex/Mobilitaet_model', 'MobilitaetModel'); + } + + public function getMobilitaeten($prestudent_id) + { + $this->MobilitaetModel->addJoin('bis.tbl_mobilitaetsprogramm mp', 'ON (mp.mobilitaetsprogramm_code = bis.tbl_mobilitaet.mobilitaetsprogramm_code)', 'LEFT'); + + $result = $this->MobilitaetModel->loadWhere( + array('prestudent_id' => $prestudent_id) + ); + + $data = $this->getDataOrTerminateWithError($result); + + $this->terminateWithSuccess($data); + + } + +} diff --git a/public/js/api/stv.js b/public/js/api/stv.js index 14fcc6661..5f3f52dab 100644 --- a/public/js/api/stv.js +++ b/public/js/api/stv.js @@ -2,12 +2,14 @@ import verband from './stv/verband.js'; import students from './stv/students.js'; import filter from './stv/filter.js'; import konto from './stv/konto.js'; +import mobility from './stv/mobility.js'; export default { verband, students, filter, konto, + mobility, configStudent() { return this.$fhcApi.get('api/frontend/v1/stv/config/student'); }, diff --git a/public/js/api/stv/mobility.js b/public/js/api/stv/mobility.js new file mode 100644 index 000000000..0aee23fb6 --- /dev/null +++ b/public/js/api/stv/mobility.js @@ -0,0 +1,5 @@ +export default { + getMobilitaeten (url, config, params){ + return this.$fhcApi.get('api/frontend/v1/stv/mobility/getMobilitaeten/' + params.id); + }, +} \ No newline at end of file diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Mobility.js b/public/js/components/Stv/Studentenverwaltung/Details/Mobility.js new file mode 100644 index 000000000..16c229235 --- /dev/null +++ b/public/js/components/Stv/Studentenverwaltung/Details/Mobility.js @@ -0,0 +1,25 @@ +import TableMobility from "./Mobility/Mobility.js"; + +export default { + components: { + TableMobility + }, + provide() { + return { + config: this.config + }; + }, + props: { + modelValue: Object, + }, + data(){ + return {} + }, + template: ` +
+ +

TEST Mob

+ + +
` +}; \ No newline at end of file diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Mobility/Mobility.js b/public/js/components/Stv/Studentenverwaltung/Details/Mobility/Mobility.js new file mode 100644 index 000000000..3f13b372c --- /dev/null +++ b/public/js/components/Stv/Studentenverwaltung/Details/Mobility/Mobility.js @@ -0,0 +1,629 @@ +import {CoreFilterCmpt} from "../../../../filter/Filter.js"; +import BsModal from "../../../../Bootstrap/Modal.js"; +import FormForm from '../../../../Form/Form.js'; +import FormInput from '../../../../Form/Input.js'; + +export default { + components: { + CoreFilterCmpt, + BsModal, + FormForm, + FormInput + }, + inject: { + $reloadList: { + from: '$reloadList', + required: true + } + }, + props: { + prestudent: Object + }, + data() { + return { + tabulatorOptions: { + ajaxURL: 'dummy', + ajaxRequestFunc: this.$fhcApi.factory.stv.mobility.getMobilitaeten, + ajaxParams: () => { + return { + id: this.prestudent.prestudent_id + }; + }, + ajaxResponse: (url, params, response) => response.data, + columns: [ + {title: "Kurzbz", field: "kurzbz"}, + {title: "Nation", field: "beurteilung_bezeichnung"}, + {title: "firma_id", field: "firma_id", visible: false}, + // {title: "prueferIn2", field: "p2_nachname", visible: false}, + // {title: "prueferIn3", field: "p3_nachname", visible: false}, + // {title: "datum", field: "format_datum"}, + // {title: "uhrzeit", field: "uhrzeit"}, + // {title: "freigabe", field: "format_freigabedatum"}, + // {title: "pruefungsantritt", field: "antritt_bezeichnung"}, + // {title: "sponsion", field: "format_sponsion"}, + // {title: "anmerkung", field: "anmerkung"}, + // {title: "mobility_id", field: "mobility_id", visible: false}, + // {title: "typ", field: "pruefungstyp_kurzbz", visible: false}, + + { + title: 'Aktionen', field: 'actions', + minWidth: 150, // Ensures Action-buttons will be always fully displayed + formatter: (cell, formatterParams, onRendered) => { + let container = document.createElement('div'); + container.className = "d-flex gap-2"; + + let button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.title = this.$p.t('ui', 'bearbeiten'); + button.addEventListener('click', (event) => + this.actionEditmobility(cell.getData().mobility_id) + ); + container.append(button); + + button = document.createElement('button'); + button.className = 'btn btn-outline-secondary btn-action'; + button.innerHTML = ''; + button.title = this.$p.t('ui', 'loeschen'); + button.addEventListener('click', () => + this.actionDeletemobility(cell.getData().mobility_id) + ); + container.append(button); + + return container; + }, + frozen: true + }, + ], + layout: 'fitDataFill', + layoutColumnsOnNewData: false, + height: 'auto', + minHeight: '200', + selectable: true, + index: 'mobility_id', + persistenceID: 'stv-details-table_mobiliy' + }, + tabulatorEvents: [ + { + event: 'tableBuilt', + handler: async() => { + await this.$p.loadCategory(['global', 'person', 'stv', 'mobility', 'ui']); + + + let cm = this.$refs.table.tabulator.columnManager; + + // cm.getColumnByField('vorsitz_nachname').component.updateDefinition({ + // title: this.$p.t('mobility', 'vorsitz_header') + // }); + // cm.getColumnByField('beurteilung_bezeichnung').component.updateDefinition({ + // title: this.$p.t('mobility', 'abschlussbeurteilung') + // }); + // cm.getColumnByField('p1_nachname').component.updateDefinition({ + // title: this.$p.t('mobility', 'pruefer1') + // }); + // cm.getColumnByField('p2_nachname').component.updateDefinition({ + // title: this.$p.t('mobility', 'pruefer2') + // }); + // cm.getColumnByField('p3_nachname').component.updateDefinition({ + // title: this.$p.t('mobility', 'pruefer3') + // }); + // cm.getColumnByField('format_datum').component.updateDefinition({ + // title: this.$p.t('global', 'datum') + // }); + // cm.getColumnByField('uhrzeit').component.updateDefinition({ + // title: this.$p.t('global', 'uhrzeit') + // }); + // cm.getColumnByField('format_freigabedatum').component.updateDefinition({ + // title: this.$p.t('mobility', 'freigabe') + // }); + // cm.getColumnByField('antritt_bezeichnung').component.updateDefinition({ + // title: this.$p.t('mobility', 'pruefungsantritt') + // }); + // cm.getColumnByField('format_sponsion').component.updateDefinition({ + // title: this.$p.t('mobility', 'sponsion') + // }); + // cm.getColumnByField('anmerkung').component.updateDefinition({ + // title: this.$p.t('global', 'anmerkung') + // }); + // cm.getColumnByField('pruefungstyp_kurzbz').component.updateDefinition({ + // title: this.$p.t('global', 'typ') + // }); + // cm.getColumnByField('mobility_id').component.updateDefinition({ + // title: this.$p.t('ui', 'mobility_id') + // }); + /* + cm.getColumnByField('actions').component.updateDefinition({ + title: this.$p.t('global', 'aktionen') + }); + */ + } + } + ], + tabulatorData: [], + lastSelected: null, + formData: { + }, + statusNew: true, + arrTypen: [], + arrAntritte: [], + arrBeurteilungen: [], + arrAkadGrad: [], + arrNoten: [], + filteredMitarbeiter: [], + filteredPruefer: [], + abortController: { + mitarbeiter: null, + pruefer: null + }, + stgTyp: null, + stgKz: null, + } + }, + watch: { + student(){ + if (this.$refs.table) { + this.$refs.table.reloadTable(); + } + } + }, + methods: { + getStudiengangsTyp(){ + this.stgTyp = ''; + this.$fhcApi.factory.stv.mobility.getTypStudiengang(this.stg_kz) + .then(result => this.stgTyp = result.data) + .catch(this.$fhcAlert.handleSystemError); + }, + actionNewmobility() { + this.resetForm(); + this.statusNew = true; + this.setDefaultFormData(); + }, + actionEditmobility(mobility_id) { + this.resetForm(); + this.statusNew = false; + this.loadmobility(mobility_id); + }, + actionDeletemobility(mobility_id) { + this.$fhcAlert + .confirmDelete() + .then(result => result + ? mobility_id + : Promise.reject({handled: true})) + .then(this.deletemobility) + .catch(this.$fhcAlert.handleSystemError); + }, + addNewmobility() { + const dataToSend = { + uid: this.student.uid, + formData: this.formData + }; + + return this.$refs.formFinalExam.factory.stv.mobility.addNewmobility(dataToSend) + .then(response => { + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); + this.resetForm(); + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { + this.reload(); + }); + }, + reload() { + this.$refs.table.reloadTable(); + }, + loadmobility(mobility_id) { + return this.$fhcApi.factory.stv.mobility.loadmobility(mobility_id) + .then(result => { + this.formData = result.data; + //TODO(Manu) check if cisRoot is okay + this.formData.link = this.cisRoot + 'index.ci.php/lehre/Pruefungsprotokoll/showProtokoll?mobility_id=' + this.formData.mobility_id + '&fhc_controller_id=67481e5ed5490'; + return result; + }) + .catch(this.$fhcAlert.handleSystemError); + }, + updatemobility(mobility_id) { + const dataToSend = { + id: mobility_id, + formData: this.formData + }; + return this.$refs.formFinalExam.factory.stv.mobility.updatemobility(dataToSend) + .then(response => { + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); + this.resetForm(); + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { + this.reload(); + }); + }, + deletemobility(mobility_id) { + return this.$fhcApi.factory.stv.mobility.deletemobility(mobility_id) + .then(response => { + this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { + this.reload(); + }); + }, + resetForm() { + this.formData = null; + }, + }, + created() { + // this.$fhcApi.factory.stv.mobility.getTypenmobility() + // .then(result => { + // this.arrTypen = result.data; + // }) + // .catch(this.$fhcAlert.handleSystemError); + // this.$fhcApi.factory.stv.mobility.getTypenAntritte() + // .then(result => { + // this.arrAntritte = result.data; + // }) + // .catch(this.$fhcAlert.handleSystemError); + // this.$fhcApi.factory.stv.mobility.getBeurteilungen() + // .then(result => { + // this.arrBeurteilungen = result.data; + // }) + // .catch(this.$fhcAlert.handleSystemError); + // this.$fhcApi.factory.stv.mobility.getNoten() + // .then(result => { + // this.arrNoten = result.data; + // }) + // .catch(this.$fhcAlert.handleSystemError); + // this.$fhcApi.factory.stv.mobility.getAkadGrade(this.student.studiengang_kz) + // .then(result => { + // this.arrAkadGrad = result.data; + // }) + // .catch(this.$fhcAlert.handleSystemError); + // if (!this.student.length) { + // this.$fhcApi.factory.stv.mobility.getTypStudiengang(this.student.studiengang_kz) + // .then(result => { + // this.stgTyp = result.data; + // this.setDefaultFormData(); + // }) + // .catch(this.$fhcAlert.handleSystemError); + // } else + // this.getStudiengangsTyp(); + }, + template: ` +
+

In/out

+ + + + + + + + + + + + +
+` +} + diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 201c231a6..038bb5de5 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -37277,7 +37277,30 @@ array( 'insertvon' => 'system' ) ) - ) + ), + // FHC4 Phrases Mobility Start + array( + 'app' => 'core', + 'category' => 'stv', + 'phrase' => 'tab_mobility', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Mobilität', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Mobility', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + // FHC4 Phrases Mobility Start + );