From 65c7db7ae4a3eca8e874b1a4fd7ee7d69321e5c8 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Mon, 25 Mar 2024 13:28:28 +0100 Subject: [PATCH] bugfix phrases tabulator, refactor Prestudent.js using FHCAPI_CONTROLLER --- .../api/frontend/v1/stv/Prestudent.php | 301 ++++++++++++++++++ .../api/frontend/v1/stv/Status.php | 0 .../controllers/components/stv/Prestudent.php | 4 +- .../models/crm/Prestudentstatus_model.php | 11 +- .../Studentenverwaltung/Details/Prestudent.js | 86 +++-- .../Details/Prestudent/History.js | 38 ++- .../Details/Prestudent/Status.js | 99 +++--- system/phrasesupdate.php | 19 ++ 8 files changed, 442 insertions(+), 116 deletions(-) create mode 100644 application/controllers/api/frontend/v1/stv/Prestudent.php create mode 100644 application/controllers/api/frontend/v1/stv/Status.php diff --git a/application/controllers/api/frontend/v1/stv/Prestudent.php b/application/controllers/api/frontend/v1/stv/Prestudent.php new file mode 100644 index 000000000..1663e0dae --- /dev/null +++ b/application/controllers/api/frontend/v1/stv/Prestudent.php @@ -0,0 +1,301 @@ + ['admin:r', 'assistenz:r'], + 'updatePrestudent' => ['admin:w', 'assistenz:w'], + 'getHistoryPrestudents' => ['admin:r', 'assistenz:r'], + 'getBezeichnungZGV' => 'admin:r', // TODO(manu): self::PERM_LOGGED + 'getBezeichnungDZgv' => 'admin:r', // TODO(manu): self::PERM_LOGGED + 'getBezeichnungMZgv' => 'admin:r', // TODO(manu): self::PERM_LOGGED + 'getAusbildung' => 'admin:r', // TODO(manu): self::PERM_LOGGED + 'getAufmerksamdurch' => 'admin:r', // TODO(manu): self::PERM_LOGGED + 'getBerufstaetigkeit' => 'admin:r', // TODO(manu): self::PERM_LOGGED + 'getTypenStg' => 'admin:r', // TODO(manu): self::PERM_LOGGED + 'getStudiensemester' => 'admin:r', // TODO(manu): self::PERM_LOGGED + 'getStudienplaene' => 'admin:r', // TODO(manu): self::PERM_LOGGED + ]); + + // Load Libraries + $this->load->library('VariableLib', ['uid' => getAuthUID()]); + + + // Load language phrases + $this->loadPhrases([ + 'ui', 'studierendenantrag' + ]); + } + + public function get($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $this->PrestudentModel->addSelect('*'); + $result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } elseif (!hasData($result)) { + return show_404(); + } else { + $this->terminateWithSuccess(current(getData($result))); + } + } + + public function updatePrestudent($prestudent_id) + { + $this->load->library('form_validation'); + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + //get Studiengang von prestudent_id + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + $result = $this->PrestudentModel->load([ + 'prestudent_id'=> $prestudent_id, + ]); + if(isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $result = current(getData($result)); + + $stg = $result->studiengang_kz; + + //Form validation + $this->form_validation->set_rules('priorisierung', 'Priorisierung', 'numeric', [ + 'numeric' => $this->p->t('ui','error_fieldNotNumeric',['field' => 'Priorisierung']) + ]); + + if ($this->form_validation->run() == false) + { + $this->terminateWithValidationErrors($this->form_validation->error_array()); + } + + $deltaData = $_POST; + + $uid = getAuthUID(); + + $array_allowed_props_prestudent = [ + 'aufmerksamdurch_kurzbz', + 'studiengang_kz', + 'gsstudientyp_kurzbz', + 'person_id', + 'berufstaetigkeit_code', + 'ausbildungcode', + 'zgv_code', + 'zgvort', + 'zgvdatum', + 'zgvnation', + 'zgvmas_code', + 'zgvmaort', + 'zgvmadatum', + 'zgvmanation', + 'facheinschlberuf', + 'bismelden', + 'anmerkung', + 'dual', + 'zgvdoktor_code', + 'zgvdoktorort', + 'zgvdoktordatum', + 'zgvdoktornation', + 'aufnahmegruppe_kurzbz', + 'priorisierung', + 'foerderrelevant', + 'zgv_erfuellt', + 'zgvmas_erfuellt', + 'zgvdoktor_erfuellt', + 'mentor', + 'aufnahmeschluessel', + 'standort_code' + ]; + + $update_prestudent = array(); + foreach ($array_allowed_props_prestudent as $prop) + { + $val = isset($deltaData[$prop]) ? $deltaData[$prop] : null; + if ($val !== null || $prop == 'foerderrelevant') { + $update_prestudent[$prop] = $val; + } + } + + $update_prestudent['updateamum'] = date('c'); + $update_prestudent['updatevon'] = $uid; + + //utf8-decode for special chars (eg tag der offenen Tür, FH-Führer) + function utf8_decode_if_string($value) + { + if (is_string($value)) { + return utf8_decode($value); + } else { + return $value; + } + } + $update_prestudent_encoded = array_map('utf8_decode_if_string', $update_prestudent); + + if (count($update_prestudent)) + { + $result = $this->PrestudentModel->update( + $prestudent_id, + $update_prestudent_encoded + ); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(true); + } + } + + public function getHistoryPrestudents($person_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $result = $this->PrestudentModel->getHistoryPrestudents($person_id); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getBezeichnungZGV() + { + $this->load->model('codex/Zgv_model', 'ZgvModel'); + + $this->ZgvModel->addOrder('zgv_code'); + + $result = $this->ZgvModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getBezeichnungDZgv() + { + $this->load->model('codex/Zgvdoktor_model', 'ZgvdoktorModel'); + + $this->ZgvdoktorModel->addOrder('zgvdoktor_code'); + + $result = $this->ZgvdoktorModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getBezeichnungMZgv() + { + $this->load->model('codex/Zgvmaster_model', 'ZgvmasterModel'); + + $this->ZgvmasterModel->addOrder('zgvmas_code'); + + $result = $this->ZgvmasterModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getAusbildung() + { + $this->load->model('codex/Ausbildung_model', 'AusbildungModel'); + + $this->AusbildungModel->addOrder('ausbildungcode'); + + $result = $this->AusbildungModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getAufmerksamdurch() + { + $this->load->model('codex/Aufmerksamdurch_model', 'AufmerksamdurchModel'); + + $this->AufmerksamdurchModel->addOrder('aufmerksamdurch_kurzbz'); + + $result = $this->AufmerksamdurchModel->load(); + if (isError($result)) + { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getBerufstaetigkeit() + { + $this->load->model('codex/Berufstaetigkeit_model', 'BerufstaetigkeitModel'); + + $this->BerufstaetigkeitModel->addOrder('berufstaetigkeit_code'); + + $result = $this->BerufstaetigkeitModel->load(); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getTypenStg() + { + $this->load->model('education/Gsstudientyp_model', 'GsstudientypModel'); + + $this->GsstudientypModel->addOrder('gsstudientyp_kurzbz'); + + $result = $this->GsstudientypModel->load(); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getStudiensemester() + { + $this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel'); + + $this->StudiensemesterModel->addOrder('start', 'DESC'); + $this->StudiensemesterModel->addLimit(20); + + $result = $this->StudiensemesterModel->load(); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } + + public function getStudienplaene($prestudent_id) + { + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); + + $result = $this->PrestudentModel->loadWhere( + array('prestudent_id' => $prestudent_id) + ); + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $result = current(getData($result)); + $studiengang_kz = $result->studiengang_kz; + + $this->load->model('organisation/Studienplan_model', 'StudienplanModel'); + + $this->StudienplanModel->addOrder('studienplan_id', 'DESC'); + + $result = $this->StudienplanModel->getStudienplaene($studiengang_kz); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + return $this->terminateWithSuccess(getData($result) ?: []); + } +} diff --git a/application/controllers/api/frontend/v1/stv/Status.php b/application/controllers/api/frontend/v1/stv/Status.php new file mode 100644 index 000000000..e69de29bb diff --git a/application/controllers/components/stv/Prestudent.php b/application/controllers/components/stv/Prestudent.php index 093126272..2a1364c87 100644 --- a/application/controllers/components/stv/Prestudent.php +++ b/application/controllers/components/stv/Prestudent.php @@ -13,7 +13,7 @@ class Prestudent extends FHC_Controller // Load Libraries $this->load->library('AuthLib'); $this->load->library('VariableLib', ['uid' => getAuthUID()]); - $this->load->library('PermissionLib'); + // Load language phrases $this->loadPhrases([ @@ -65,7 +65,7 @@ class Prestudent extends FHC_Controller return $this->outputJson($result); } - //TODO(Manu) neuer API Controller + //TODO(Manu) API Controller $_POST = json_decode(utf8_encode($this->input->raw_input_stream), true); diff --git a/application/models/crm/Prestudentstatus_model.php b/application/models/crm/Prestudentstatus_model.php index d3f99801c..db860f1e6 100644 --- a/application/models/crm/Prestudentstatus_model.php +++ b/application/models/crm/Prestudentstatus_model.php @@ -15,6 +15,15 @@ class Prestudentstatus_model extends DB_Model $this->dbTable = 'public.tbl_prestudentstatus'; $this->pk = array('ausbildungssemester', 'studiensemester_kurzbz', 'status_kurzbz', 'prestudent_id'); $this->hasSequence = false; + +/* $CI =& get_instance(); + + $CI->load->library('PhrasesLib'); + + // Load language phrases + $CI->loadPhrases([ + 'ui', 'lehre' + ]);*/ } /** @@ -375,7 +384,7 @@ class Prestudentstatus_model extends DB_Model } else { - return success("1","Diese Rolle ist bereits vorhanden!"); + return success("1", $this->p->t('studierendenantrag','error_rolleBereitsVorhanden')); } } diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js index 3c33c7d55..cd3afe91a 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent.js @@ -90,8 +90,8 @@ export default { methods: { loadPrestudent() { - CoreRESTClient - .get('components/stv/Prestudent/get/' + this.modelValue.prestudent_id) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/get/' + this.modelValue.prestudent_id) .then(result => result.data) .then(result => { this.data = result; @@ -101,85 +101,73 @@ export default { .catch(this.$fhcAlert.handleSystemError); }, updatePrestudent(){ - CoreRESTClient.post('components/stv/Prestudent/updatePrestudent/' + this.modelValue.prestudent_id, - this.deltaArray - ).then(response => { - if (!response.data.error) { - this.$fhcAlert.alertSuccess('Speichern erfolgreich'); - this.deltaArray = []; - this.actionUpdate = false; - } else { - const errorData = response.data.retval; - Object.entries(errorData).forEach(entry => { - const [key, value] = entry; - this.$fhcAlert.alertError(value); - }); - } - }).catch(error => { - if (error.response && error.response.data) { - this.$fhcAlert.alertError(error.response.data); - } else { - this.$fhcAlert.alertError("Fehler bei Speicherroutine aufgetreten"); - } - }).finally(() => { - window.scrollTo(0, 0); - }); + this.$refs.form + .post('api/frontend/v1/stv/prestudent/updatePrestudent/' + this.modelValue.prestudent_id, this.deltaArray) + .then(response => { + this.$fhcAlert.alertSuccess('Speichern erfolgreich'); + this.deltaArray = []; + this.actionUpdate = false; + }) + .catch(this.$fhcAlert.handleSystemError) + .finally(() => { + window.scrollTo(0, 0); + }); }, }, created() { this.loadPrestudent(); - CoreRESTClient - .get('components/stv/Prestudent/getBezeichnungZGV') - .then(result => CoreRESTClient.getData(result.data) || []) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/getBezeichnungZGV') + .then(result => result.data) .then(result => { this.listZgvs = result; }) .catch(this.$fhcAlert.handleSystemError); - CoreRESTClient - .get('components/stv/Prestudent/getBezeichnungMZGV') - .then(result => CoreRESTClient.getData(result.data) || []) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/getBezeichnungMZgv') + .then(result => result.data) .then(result => { this.listZgvsmaster = result; }) .catch(this.$fhcAlert.handleSystemError); - CoreRESTClient - .get('components/stv/Prestudent/getBezeichnungDZGV') - .then(result => CoreRESTClient.getData(result.data) || []) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/getBezeichnungDZgv') + .then(result => result.data) .then(result => { this.listZgvsdoktor = result; }) .catch(this.$fhcAlert.handleSystemError); - CoreRESTClient + CoreRESTClient //TODO(manu) FHCAPI .get('components/stv/Lists/getStgs') .then(result => CoreRESTClient.getData(result.data) || []) .then(result => { this.listStgs = result; }) .catch(this.$fhcAlert.handleSystemError); - CoreRESTClient - .get('components/stv/Prestudent/getAusbildung') - .then(result => CoreRESTClient.getData(result.data) || []) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/getAusbildung') + .then(result => result.data) .then(result => { this.listAusbildung = result; }) .catch(this.$fhcAlert.handleSystemError); - CoreRESTClient - .get('components/stv/Prestudent/getAufmerksamdurch') - .then(result => CoreRESTClient.getData(result.data) || []) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/getAufmerksamdurch') + .then(result => result.data) .then(result => { this.listAufmerksamdurch = result; }) .catch(this.$fhcAlert.handleSystemError); - CoreRESTClient - .get('components/stv/Prestudent/getBerufstaetigkeit') - .then(result => CoreRESTClient.getData(result.data) || []) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/getBerufstaetigkeit') + .then(result => result.data) .then(result => { this.listBerufe = result; }) .catch(this.$fhcAlert.handleSystemError); - CoreRESTClient - .get('components/stv/Prestudent/getTypenStg') - .then(result => CoreRESTClient.getData(result.data) || []) + this.$fhcApi + .get('api/frontend/v1/stv/prestudent/getTypenStg') + .then(result => result.data) .then(result => { this.listStgTyp = result; }) @@ -192,7 +180,7 @@ export default {
-
+
{{$p.t('lehre', 'title_zgv')}} {{modelValue.nachname}} {{modelValue.vorname}}
@@ -383,7 +371,7 @@ export default {
-
+
PrestudentIn
diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/History.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/History.js index 54a42bba8..41a5241db 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/History.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/History.js @@ -1,5 +1,4 @@ import {CoreFilterCmpt} from "../../../../filter/Filter.js"; -import {CoreRESTClient} from "../../../../../RESTClient"; export default{ components: { @@ -11,7 +10,9 @@ export default{ data() { return { tabulatorOptions: { - ajaxURL: CoreRESTClient._generateRouterURI('components/stv/Prestudent/getHistoryPrestudents/' + this.person_id), + ajaxURL: 'api/frontend/v1/stv/Prestudent/getHistoryPrestudents/' + this.person_id, + ajaxRequestFunc: this.$fhcApi.get, + ajaxResponse: (url, params, response) => response.data, //autoColumns: true, columns:[ {title:"StSem", field:"studiensemester_kurzbz"}, @@ -22,7 +23,24 @@ export default{ {title:"UID", field:"student_uid"}, {title:"Status", field:"status"} ], - // tabulatorEvents: [], + tabulatorEvents: [ + { + event: 'tableBuilt', + handler: async () => { + await this.$p.loadCategory(['lehre']); + + let cm = this.$refs.table.tabulator.columnManager; + + cm.getColumnByField('orgform_kurzbz').component.updateDefinition({ + title: this.$p.t('lehre', 'organisationsform') + }); + + cm.getColumnByField('bezeichnung').component.updateDefinition({ + title: this.$p.t('lehre', 'studienplan') + }); + } + } + ], layout: 'fitDataFill', layoutColumnsOnNewData: false, height: 'auto', @@ -30,24 +48,12 @@ export default{ }, } }, - async mounted(){ - await this.$p.loadCategory(['lehre']); - - let cm = this.$refs.table.tabulator.columnManager; - - cm.getColumnByField('orgform_kurzbz').component.updateDefinition({ - title: this.$p.t('lehre', 'organisationsform') - }); - - cm.getColumnByField('bezeichnung').component.updateDefinition({ - title: this.$p.t('lehre', 'studienplan') - }); - }, template: `
diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/Status.js b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/Status.js index 22b64a393..2fc00a642 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/Status.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Prestudent/Status.js @@ -149,7 +149,56 @@ export default{ height: 'auto', selectable: false, }, - tabulatorEvents: [], + tabulatorEvents: [ + { + event: 'tableBuilt', + handler: async () => { + await this.$p.loadCategory(['lehre','global','person']); + + let cm = this.$refs.table.tabulator.columnManager; + + /* cm.getColumnByField('lehrverband').component.updateDefinition({ + title: this.$p.t('lehre', 'lehrverband') + });*/ + + cm.getColumnByField('format_bestaetigtam').component.updateDefinition({ + title: this.$p.t('lehre', 'bestaetigt_am') + }); + + cm.getColumnByField('format_bewerbung_abgeschicktamum').component.updateDefinition({ + title: this.$p.t('lehre', 'bewerbung_abgeschickt_am') + }); + + cm.getColumnByField('bezeichnung').component.updateDefinition({ + title: this.$p.t('lehre', 'studienplan') + }); + + cm.getColumnByField('actions').component.updateDefinition({ + title: this.$p.t('global', 'aktionen') + }); + + cm.getColumnByField('format_datum').component.updateDefinition({ + title: this.$p.t('global', 'datum') + }); + + cm.getColumnByField('anmerkung').component.updateDefinition({ + title: this.$p.t('global', 'anmerkung') + }); + + cm.getColumnByField('bestaetigtvon').component.updateDefinition({ + title: this.$p.t('lehre', 'bestaetigt_von') + }); + + cm.getColumnByField('format_insertamum').component.updateDefinition({ + title: this.$p.t('lehre', 'insert_am') + }); + + cm.getColumnByField('insertvon').component.updateDefinition({ + title: this.$p.t('lehre', 'insert_von') + }); + } + } + ], statusData: {}, listStudiensemester: [], maxSem: Array.from({ length: 11 }, (_, index) => index), @@ -472,54 +521,8 @@ export default{ }) .catch(this.$fhcAlert.handleSystemError); }, - async mounted(){ - await this.$p.loadCategory(['lehre','global','person']); + mounted(){ - let cm = this.$refs.table.tabulator.columnManager; - -/* cm.getColumnByField('lehrverband').component.updateDefinition({ - title: this.$p.t('lehre', 'lehrverband') - });*/ - - cm.getColumnByField('format_bestaetigtam').component.updateDefinition({ - title: this.$p.t('lehre', 'bestaetigt_am') - }); - - cm.getColumnByField('format_bewerbung_abgeschicktamum').component.updateDefinition({ - title: this.$p.t('lehre', 'bewerbung_abgeschickt_am') - }); - - cm.getColumnByField('bezeichnung').component.updateDefinition({ - title: this.$p.t('lehre', 'studienplan') - }); - - cm.getColumnByField('actions').component.updateDefinition({ - title: this.$p.t('global', 'aktionen') - }); - - cm.getColumnByField('format_datum').component.updateDefinition({ - title: this.$p.t('global', 'datum') - }); - - cm.getColumnByField('anmerkung').component.updateDefinition({ - title: this.$p.t('global', 'anmerkung') - }); - -/* cm.getColumnByField('format_bestaetigtam').component.updateDefinition({ - title: this.$p.t('lehre', 'bestaetigt_am') - });*/ - - cm.getColumnByField('bestaetigtvon').component.updateDefinition({ - title: this.$p.t('lehre', 'bestaetigt_von') - }); - - cm.getColumnByField('format_insertamum').component.updateDefinition({ - title: this.$p.t('lehre', 'insert_am') - }); - - cm.getColumnByField('insertvon').component.updateDefinition({ - title: this.$p.t('lehre', 'insert_von') - }); }, template: `
diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 8f53c4bf6..753991992 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -25905,6 +25905,25 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'lehre', + 'phrase' => 'error_rolleBereitsVorhanden', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Diese Rolle ist bereits vorhanden!', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'This role already exists!', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), );