From 6b27c00d30aa474b2d1eef3e5e7888ec7c048b44 Mon Sep 17 00:00:00 2001 From: Simon Gschnell Date: Fri, 17 Nov 2023 13:09:32 +0100 Subject: [PATCH] new data collection --- application/controllers/Cis/Profil.php | 117 ++++++++++++++++++---- public/js/apps/Cis/ProfilApp.js | 3 +- public/js/apps/api/userdata.js | 4 +- public/js/components/Cis/Profil/Profil.js | 43 ++++---- 4 files changed, 119 insertions(+), 48 deletions(-) diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index c4d97b2fd..16446f493 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -16,9 +16,8 @@ class Profil extends Auth_Controller { parent::__construct([ 'index' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions? - 'getUser' => ['student/anrechnung_beantragen:r','user:r'], 'isMitarbeiterOrStudent' => ['student/anrechnung_beantragen:r','user:r'], - 'getPersonInformation' => ['student/anrechnung_beantragen:r','user:r'], + 'getMitarbeiterAnsicht' => ['student/anrechnung_beantragen:r','user:r'], ]); $this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel'); @@ -26,6 +25,8 @@ class Profil extends Auth_Controller $this->load->model('person/Benutzer_model', 'BenutzerModel'); $this->load->model('person/Person_model', 'PersonModel'); $this->load->model('person/Adresse_model', 'AdresseModel'); + $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + } @@ -45,29 +46,107 @@ class Profil extends Auth_Controller } - //? public function getUser returns information related to a user - public function getUser() - { - //* retrieve info from the Mitarbeiter model - $mitarbeiter_result = $this->MitarbeiterModel->load(getAuthUID()); - //* retrieve info from the Benutzer model - $benutzer_result = $this->BenutzerModel->getFromPersonId(getAuthUID()); - //* return JSON with info - //! was removed from $res for testing purposes: 'Benutzer' => $benutzer_result - $res = ['mitarbeiter' => $mitarbeiter_result,'Benutzer' => $benutzer_result - ]; + + + public function getMitarbeiterAnsicht(){ - echo json_encode($res); - } + $benutzer_funktion_res = $this->BenutzerfunktionModel->loadWhere(); + if(isError($benutzer_funktion_res)){ + // error handling + }else{ + $benutzer_funktion_res = hasData($benutzer_funktion_res)? getData($benutzer_funktion_res) : null; + } - public function getPersonInformation($pid){ + //! THERE COULD BE MULTIPLE ADRESSES + $adresse_res = $this->AdresseModel->load(getAuthPersonId()); + if(isError($adresse_res)){ + // error handling + }else{ //! not only one + $adresse_res = hasData($adresse_res)? getData($adresse_res)[0] : null; + } + + $benutzer_res = $this->PersonModel->load(getAuthUID()); + if(isError($benutzer_res)){ + // error handling + }else{ + $benutzer_res = hasData($benutzer_res)? getData($benutzer_res)[0] : null; + } + + $person_res = $this->PersonModel->load(getAuthPersonId()); + if(isError($person_res)){ + // error handling + }else{ + $person_res = hasData($person_res)? getData($person_res)[0] : null; + } + //? get the person information using the benutzer uid - $json_result = $this->PersonModel->getPersonStammdaten($pid)->retval; - + //! verwendet getAuthUID() + $mitarbeiter_res = $this->MitarbeiterModel->load(getAuthUID()); + if(isError($mitarbeiter_res)){ + // error handling + }else{ + //? checks whether the getData does not return null + //? and then checks that the current does return an empty array + $mitarbeiter_res = hasData($mitarbeiter_res)? getData($mitarbeiter_res)[0] : null; + } + $res = new stdClass(); + $res->username = getAuthUID(); + //? Person Info + $res->foto = $person_res->foto; + $res->foto_sperre = $person_res->foto_sperre; + $res->anrede = $person_res->anrede; + $res->titelpre = $person_res->titelpre; + $res->titelpost = $person_res->titelpost; + $res->vorname = $person_res->vorname; + $res->nachname = $person_res->nachname; + //$res->postnomen = $person_res->postnomen; //!POSTNOMEN? + $res->gebdatum = $person_res->gebdatum; + $res->gebort = $person_res->gebort; + //? Mitarbeiter Info + $res->kurzbz = $mitarbeiter_res->kurzbz; + $res->telefonklappe = $mitarbeiter_res->telefonklappe; + //? Benutzer Info + $res->email_intern = getAuthUID() . "@technikum-wien.at"; + $res->email_extern = $benutzer_res->alias . "@technikum-wien.at"; + //? Adresse Info + $res->strasse = $adresse_res->strasse; + $res->heimatadresse = $adresse_res->heimatadresse; + $res->zustelladresse = $adresse_res->zustelladresse; + $res->plz = $adresse_res->plz; + $res->ort = $adresse_res->ort; + //? Benutzerfunktion Info + $res->funktionen = $benutzer_funktion_res; + + + + echo json_encode($res); + + return; + /* + $res = getData($this->PersonModel->getPersonStammdaten($pid)); + $json_result = new stdClass(); + $json_result->anrede = $res->anrede; + $json_result->titelpre = $res->titelpre; + $json_result->titelpost = $res->titelpost; + $json_result->vorname = $res->vorname; + $json_result->nachname = $res->nachname; + $json_result->gebdatum = $res->gebdatum; + $json_result->gebort = $res->gebort; + $json_result->adressen = $res->adressen; + + anrede:this.person_info.anrede, + titelpre:this.person_info.titelpre, + titelpost:this.person_info.titelpost, + vorname:this.person_info.vorname, + nachname:this.person_info.nachname, + gebdatum:this.person_info.gebdatum, + gebort:this.person_info.gebort, + adresse:this.person_info.adressen[0].strasse + " " + this.person_info.adressen[0].plz, + */ //! the following line is not needed because it is already included in the getPersonStammdaten function //$json_result->addresse_info = $this->AdresseModel->getZustellAdresse($pid)->retval; - echo json_encode($json_result); + echo json_encode($res); return; diff --git a/public/js/apps/Cis/ProfilApp.js b/public/js/apps/Cis/ProfilApp.js index d83e46846..7a663f108 100644 --- a/public/js/apps/Cis/ProfilApp.js +++ b/public/js/apps/Cis/ProfilApp.js @@ -2,6 +2,7 @@ import Profil from "../../components/Cis/Profil/Profil.js"; const app = Vue.createApp({ + components: { Profil, }, @@ -15,4 +16,4 @@ const app = Vue.createApp({ }, }); -app.mount('#content'); \ No newline at end of file +app.mount("#content"); \ No newline at end of file diff --git a/public/js/apps/api/userdata.js b/public/js/apps/api/userdata.js index ccd408ae5..63d605230 100644 --- a/public/js/apps/api/userdata.js +++ b/public/js/apps/api/userdata.js @@ -10,9 +10,9 @@ export default { + `Cis/Profil/isMitarbeiterOrStudent/${uid}`; return axios.get(url); }, - getPersonInformation: function(uid) { + getMitarbeiterAnsicht: function() { const url = FHC_JS_DATA_STORAGE_OBJECT.app_root - + `Cis/Profil/getPersonInformation/${uid}`; + + `Cis/Profil/getMitarbeiterAnsicht`; return axios.get(url); }, diff --git a/public/js/components/Cis/Profil/Profil.js b/public/js/components/Cis/Profil/Profil.js index 7f953b150..7a73a6f06 100644 --- a/public/js/components/Cis/Profil/Profil.js +++ b/public/js/components/Cis/Profil/Profil.js @@ -1,45 +1,34 @@ import fhcapifactory from "../../../apps/api/fhcapifactory.js"; + + export default { - - data: function() { + + data() { return { - person: null, + person_info: null, + //? beinhaltet die Information ob der angefragte user ein Student oder Mitarbeiter ist role: null, } }, - //? this prop was passed in the Profil.php view file + //? this props were passed in the Profil.php view file props:['uid','pid'], methods: { }, computed:{ - cis_profil_info(){ + computed_placeholder(){ return { - anrede:this.person_info.anrede, - titelpre:this.person_info.titelpre, - titelpost:this.person_info.titelpost, - vorname:this.person_info.vorname, - nachname:this.person_info.nachname, - gebdatum:this.person_info.gebdatum, - gebort:this.person_info.gebort, - adresse:this.person_info.adressen[0].strasse + " " + this.person_info.adressen[0].plz, - + // }; }, - cis_profil_info_no_foto(){ - return { - ...this.person_info, - foto:null, - - }; - } + }, created(){ - fhcapifactory.UserData.getUser().then(res => this.person = res.data); + //error //! fhcapifactory.UserData.getUser().then(res => this.person = res.data); fhcapifactory.UserData.isMitarbeiterOrStudent(this.uid).then(res => this.role = res.data); - fhcapifactory.UserData.getPersonInformation(this.pid).then(res => this.person_info = res.data); + fhcapifactory.UserData.getMitarbeiterAnsicht().then(res => {this.person_info = res.data;}); }, @@ -52,14 +41,16 @@ export default { //! printing 2 computed functions //* one to output the collected need information for the cis page //* and the other returns all the information retrieved from the model without the foto data - --> +
{{JSON.stringify(cis_profil_info,null,2)}}
{{JSON.stringify(cis_profil_info_no_foto,null,2)}}

{{JSON.stringify(person)}}
-
-
{{JSON.stringify(role)}}
+ --> + + +

test

`, }; \ No newline at end of file