From c68856b7407adb3a1b5311747abda231f5bc4ce5 Mon Sep 17 00:00:00 2001 From: Simon Gschnell Date: Tue, 28 Nov 2023 14:56:42 +0100 Subject: [PATCH] completes the index view for both student and mitarbeiter --- application/controllers/Cis/Profil.php | 231 +++++++++++++++++++++- public/js/components/Cis/Profil/Profil.js | 167 ++++++++++------ 2 files changed, 324 insertions(+), 74 deletions(-) diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index 048c25959..d6ec53a1a 100644 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -19,6 +19,10 @@ class Profil extends Auth_Controller 'isMitarbeiterOrStudent' => ['student/anrechnung_beantragen:r','user:r'], 'getMitarbeiterAnsicht' => ['student/anrechnung_beantragen:r','user:r'], 'foto_sperre_function' => ['student/anrechnung_beantragen:r','user:r'], + 'indexProfilInformaion' => ['student/anrechnung_beantragen:r','user:r'], + 'mitarbeiterProfil' => ['student/anrechnung_beantragen:r','user:r'], + 'studentProfil' => ['student/anrechnung_beantragen:r','user:r'], + @@ -29,8 +33,11 @@ class Profil extends Auth_Controller $this->load->model('person/Person_model', 'PersonModel'); $this->load->model('person/Adresse_model', 'AdresseModel'); $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); + $this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel'); $this->load->model('ressource/Betriebsmittelperson_model', 'BetriebsmittelpersonModel'); $this->load->model('person/Kontakt_model', 'KontaktModel'); + $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); + $this->load->model('crm/Prestudent_model', 'PrestudentModel'); } @@ -51,10 +58,223 @@ class Profil extends Auth_Controller } + public function studentProfil(){ + + if( + isSuccess($this->BenutzergruppeModel->addSelect(['bezeichnung'])) + && isSuccess($this->BenutzergruppeModel->addJoin('tbl_gruppe', 'gruppe_kurzbz' )) + ){ + $zutrittsgruppe_res = $this->BenutzergruppeModel->loadWhere(array("uid"=>getAuthUID(), "zutrittssystem"=>true)); + if(isError($zutrittsgruppe_res)){ + // catch error + } + $zutrittsgruppe_res = hasData($zutrittsgruppe_res) ? getData($zutrittsgruppe_res) : null; + + } + + + + //? personenkennzeichen ist die Spalte Matrikelnr in der Tabelle Student + if(isSuccess($this->StudentModel->addSelect(['tbl_studiengang.bezeichnung as studiengang','tbl_student.semester', 'tbl_student.verband', 'tbl_student.gruppe' ,'tbl_student.matrikelnr as personenkennzeichen'])) + && isSuccess($this->StudentModel->addJoin('tbl_studiengang', "tbl_studiengang.studiengang_kz=tbl_student.studiengang_kz"))) + { + $student_res = $this->StudentModel->load([getAuthUID()]); + if(isError($student_res)){ + // catch error + } + $student_res = hasData($student_res)?getData($student_res)[0]:null; + + } + + + + //? Matrikelnummer ist die Spalte matr_nr in Person + if(isSuccess($this->StudentModel->addSelect(["matr_nr"]))){ + $person_res = $this->PersonModel->load(getAuthPersonID()); + if(isError($person_res)){ + // catch error + }else{ + $person_res = hasData($person_res)? getData($person_res)[0] : []; + + } + } + + $res = new stdClass(); + $res->matrikelnummer = $person_res->matr_nr; + foreach($student_res as $key => $value){ + $res->$key = $value; + } + $res->zuttritsgruppen = $zutrittsgruppe_res; + + echo json_encode($res); + + + + } + + public function mitarbeiterProfil(){ + //? informationen die nur für den Mitarbeiter verfügbar sind + + + if( + //! Summe der Wochenstunden wird jetzt in der hr/tbl_dienstverhaeltnis gespeichert + isSuccess($this->BenutzerfunktionModel->addSelect(["tbl_benutzerfunktion.bezeichnung as Bezeichnung","tbl_organisationseinheit.bezeichnung as Organisationseinheit","datum_von as Gültig_von","datum_bis as Gültig_bis","wochenstunden as Wochenstunden"]))&& + isSuccess($this->BenutzerfunktionModel->addJoin("tbl_organisationseinheit","oe_kurzbz")) + ){ + $benutzer_funktion_res = $this->BenutzerfunktionModel->loadWhere(array('uid'=>getAuthUID())); + if(isError($benutzer_funktion_res)){ + // error handling + }else{ + $benutzer_funktion_res = hasData($benutzer_funktion_res)? getData($benutzer_funktion_res) : null; + } + } + + + + if(isSuccess($this->MitarbeiterModel->addSelect(["kurzbz","telefonklappe", "alias"])) + && isSuccess($this->MitarbeiterModel->addJoin("tbl_benutzer", "tbl_benutzer.uid = tbl_mitarbeiter.mitarbeiter_uid")) + ){ + $mitarbeiter_res = $this->MitarbeiterModel->load(getAuthUID()); + if(isError($mitarbeiter_res)){ + // error handling + }else{ + $mitarbeiter_res = hasData($mitarbeiter_res)? getData($mitarbeiter_res)[0] : null; + } + } + $res = new stdClass(); + foreach($mitarbeiter_res as $key => $value){ + $res->$key = $value; + } + $intern_email = array(); + $intern_email+=array("type" => "intern"); + $intern_email+=array("email"=> getAuthUID() . "@" . DOMAIN); + $extern_email=array(); + $extern_email+=array("type" => "alias"); + $extern_email+=array("email" => $mitarbeiter_res->alias . "@" . DOMAIN); + $res->emails = array($intern_email,$extern_email); + + $res->funktionen = $benutzer_funktion_res; + echo json_encode($res); + } + + public function indexProfilInformaion(){ + //? funktion returns all data needed for the student and the mitarbeiter profil view + + + + if( + isSuccess($this->PersonModel->addSelect('gruppe_kurzbz, beschreibung'))&& + isSuccess($this->PersonModel->addJoin('tbl_benutzer', 'person_id')) && + isSuccess($this->PersonModel->addJoin('tbl_benutzergruppe', 'uid')) && + isSuccess($this->PersonModel->addJoin('tbl_gruppe', 'gruppe_kurzbz'))){ + + $mailverteiler_res = $this->PersonModel->loadWhere(array('mailgrp' => true, 'uid'=>getAuthUID())); + if( isError($mailverteiler_res)){ + // catch error + } + $mailverteiler_res = hasData($mailverteiler_res)? getData($mailverteiler_res) : null; + + $mailverteiler_res = array_map(function($element) { $element->mailto="mailto:".$element->gruppe_kurzbz."@".DOMAIN; return $element;},$mailverteiler_res); + } + + + + if( + isSuccess($this->BetriebsmittelpersonModel->addSelect(["CONCAT(betriebsmitteltyp, ' ' ,beschreibung) as Betriebsmittel","nummer as Nummer","ausgegebenam as Ausgegeben_am"])) + + ){ + $betriebsmittelperson_res = $this->BetriebsmittelpersonModel->getBetriebsmittel(getAuthPersonId()); + if(isError($betriebsmittelperson_res)){ + // error handling + }else{ + $betriebsmittelperson_res = hasData($betriebsmittelperson_res)? getData($betriebsmittelperson_res) : null; + } + } + + + if(isSuccess($this->KontaktModel->addSelect('DISTINCT ON (kontakttyp) kontakttyp, kontakt, tbl_kontakt.anmerkung, tbl_kontakt.zustellung')) && + isSuccess($this->KontaktModel->addJoin('public.tbl_standort', 'standort_id', 'LEFT')) && + isSuccess($this->KontaktModel->addJoin('public.tbl_firma', 'firma_id', 'LEFT'))&& + isSuccess($this->KontaktModel->addOrder('kontakttyp, kontakt, tbl_kontakt.updateamum, tbl_kontakt.insertamum')) + ){ + $kontakte_res = $this->KontaktModel->loadWhere(array('person_id' => getAuthPersonID())); + if(isError($kontakte_res)){ + // handle error + }else{ + $kontakte_res = hasData($kontakte_res)? getData($kontakte_res) : null; + } + + } + + $zutrittskarte_ausgegebenam = $this->BetriebsmittelpersonModel->getBetriebsmittelByUid(getAuthUID(),"Zutrittskarte"); + if(isError($zutrittskarte_ausgegebenam)){ + // error handling + }else{ + $zutrittskarte_ausgegebenam = hasData($zutrittskarte_ausgegebenam)? getData($zutrittskarte_ausgegebenam)[0]->ausgegebenam : null; + //? formats the date from 01-01-2000 to 01.01.2000 + $zutrittskarte_ausgegebenam = str_replace("-",".",$zutrittskarte_ausgegebenam); + } + + if( + isSuccess($adresse_res = $this->AdresseModel->addSelect(array("strasse","tbl_adressentyp.bezeichnung as adr_typ","plz","ort")))&& + isSuccess($adresse_res = $this->AdresseModel->addOrder("zustelladresse","DESC"))&& + isSuccess($adresse_res = $this->AdresseModel->addOrder("sort"))&& + isSuccess($adresse_res = $this->AdresseModel->addJoin("tbl_adressentyp","typ=adressentyp_kurzbz")) + ){ + $adresse_res = $this->AdresseModel->loadWhere(array("person_id"=>getAuthPersonID())); + if(isError($adresse_res)){ + // error handling + }else{ + $adresse_res = hasData($adresse_res)? getData($adresse_res) : null; + } + } + + if(isSuccess($this->PersonModel->addSelect(["foto","foto_sperre","anrede","titelpost","titelpre","vorname","nachname", "gebort", "gebdatum"]))){ + + $person_res = $this->PersonModel->load(getAuthPersonId()); + if(isError($person_res)){ + // error handling + }else{ + $person_res = hasData($person_res)? getData($person_res)[0] : null; + } + } + + + + $res = new stdClass(); + $res->foto = $person_res->foto; + $res->foto_sperre = $person_res->foto_sperre; + $res->username = getAuthUID(); + + $res->anrede = $person_res->anrede; + $res->titel = $person_res->titelpre ." " . $person_res->titelpost; + $res->vorname = $person_res->vorname; + $res->nachname = $person_res->nachname; + $res->gebort = $person_res->gebort; + $res->gebdatum = $person_res->gebdatum; + $res->adressen = $adresse_res; + $res->zutrittsdatum = $zutrittskarte_ausgegebenam; + //$res->postnomen = $person_res->postnomen; //! still not found + $intern_email = array(); + $intern_email+=array("type" => "intern"); + $intern_email+=array("email"=> getAuthUID() . "@" . DOMAIN); + $res->emails = array($intern_email); + + $res->kontakte = $kontakte_res; + $res->mittel = $betriebsmittelperson_res; + $res->mailverteiler = $mailverteiler_res; + + + + echo json_encode($res); + + } public function getMitarbeiterAnsicht(){ + + if( isSuccess($this->PersonModel->addSelect('gruppe_kurzbz, beschreibung'))&& isSuccess($this->PersonModel->addJoin('tbl_benutzer', 'person_id')) && @@ -158,15 +378,6 @@ class Profil extends Auth_Controller $mitarbeiter_res = hasData($mitarbeiter_res)? getData($mitarbeiter_res)[0] : null; } - // collection for the first collumn - $first_column = new stdClass(); - $first_column->username = getAuthUID(); - $first_column->anrede = $person_res->anrede; - $first_column->titelpre = $person_res->titelpre; - $first_column->titelpost = $person_res->titelpost; - $first_column->vorname = $person_res->vorname; - $first_column->nachname = $person_res->nachname; - $res = new stdClass(); $res->username = getAuthUID(); @@ -208,7 +419,7 @@ class Profil extends Auth_Controller $res->kontakte = $kontakte_res; //? Mailverteiler Info $res->mailverteiler = $mailverteiler_res; - + echo json_encode($res); } diff --git a/public/js/components/Cis/Profil/Profil.js b/public/js/components/Cis/Profil/Profil.js index 476677368..c27893551 100644 --- a/public/js/components/Cis/Profil/Profil.js +++ b/public/js/components/Cis/Profil/Profil.js @@ -23,8 +23,9 @@ export default { }, data() { return { - - person_info: null, + index_information: null, + mitarbeiter_info: null, + student_info:null, //? beinhaltet die Information ob der angefragte user ein Student oder Mitarbeiter ist role: null, //"bf_bezeichnung", "oe_bezeichnung", "datum_von", "datum_bis", "wochenstunden" ] @@ -32,10 +33,7 @@ export default { funktionen_table_options: { height: 300, layout: 'fitColumns', - //ajaxUrl: FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+ - //"/Cis/Profil/getBenutzerFunktionen", data:[{Bezeichnung:"test1",Organisationseinheit:"test2",Gültig_von:"test3",Gültig_bis:"test4",Wochenstunden:"test5"}], - columns: [{title: 'Bezeichnung', field: 'Bezeichnung', headerFilter: true}, {title: 'Organisationseinheit', field: 'Organisationseinheit', headerFilter: true}, {title: 'Gültig_von', field: 'Gültig_von', headerFilter: true}, @@ -47,12 +45,17 @@ export default { height: 300, layout: 'fitColumns', data:[{betriebsmittel:"test1",Nummer:"test2",Ausgegeben_am:"test3"}], - columns: [{title: 'Betriebsmittel', field: 'betriebsmittel', headerFilter: true}, {title: 'Nummer', field: 'Nummer', headerFilter: true}, {title: 'Ausgegeben_am', field: 'Ausgegeben_am', headerFilter: true},] }, + zutrittsgruppen_table_options:{ + height: 300, + layout: 'fitColumns', + data:[{bezeichnung:"test1"}], + columns: [{title: 'Zutritt', field: 'bezeichnung'}] + } } }, @@ -80,12 +83,12 @@ export default { return result; }, sperre_foto_function(value){ - if(!this.person_info){ + if(!(this.mitarbeiter_info && this.index_information && this.student_info) ){ return; } fhcapifactory.UserData.sperre_foto_function(value).then(res => { - this.person_info.foto_sperre = res.data.foto_sperre; + this.index_information.foto_sperre = res.data.foto_sperre; }); @@ -94,56 +97,63 @@ export default { }, computed:{ - test_computed(){ - return "test_computed"; - }, - get_Functions_Tabulator_Columns(){ - if(!this.person_info){ - return []; - } - return Object.keys(this.person_info.funktionen[0]).map(key => {return {title: key,field:key, headerFilter:true}}); - }, + + get_image_base64_src(){ - if(!this.person_info){ + if(!this.index_information){ return ""; } - return "data:image/jpeg;base64,"+(this.person_info ? this.person_info.foto : ""); + return "data:image/jpeg;base64,"+this.index_information.foto; }, personData(){ - if(!this.person_info){ + if(!this.index_information){ return {}; } - //! postnomen is still missing + return { - Allgemein: { - Username:this.uid, - Anrede:this.person_info.anrede, - Titel:(this.person_info.titelpre&&this.person_info.titelpost)?this.person_info.titelpre.concat(this.person_info.titelpost):"null", - Vorname:this.person_info.vorname, - Nachname:this.person_info.nachname, + Allgemein: this.role =='Mitarbeiter'?{ + Username:this.index_information.username, + Anrede:this.index_information.anrede, + Titel:this.index_information.titel, + Vorname:this.index_information.vorname, + Nachname:this.index_information.nachname, + Postnomen:null, + }:{ + Username:this.index_information.username, + Matrikelnummer: this.student_info?.matrikelnummer, + Anrede:this.index_information.anrede, + Titel:this.index_information.titel, + Vorname:this.index_information.vorname, + Nachname:this.index_information.nachname, Postnomen:null, }, GeburtsDaten:{ - Geburtsdatum:this.person_info.gebdatum, - Geburtsort: this.person_info.gebort, + Geburtsdatum:this.index_information.gebdatum, + Geburtsort: this.index_information.gebort, }, - Adressen: this.person_info.adressen, - SpecialInformation: { - Kurzzeichen: this.person_info.kurzbz, - Telefon: this.person_info.telefonklappe, + Adressen: this.index_information.adressen, + SpecialInformation: this.role =='Mitarbeiter'? { + Kurzzeichen: this.mitarbeiter_info?.kurzbz, + Telefon: this.mitarbeiter_info?.telefonklappe, + } : { + Studiengang:this.student_info?.studiengang, + Semester:this.student_info?.semester, + Verband:this.student_info?.verband, + Gruppe:this.student_info?.gruppe, + Personenkennzeichen:this.student_info?.personenkennzeichen }, }; }, //? this computed conains all the information that is used for the second column that displays the information of the person kontaktInfo(){ - if(!this.person_info){ + if(!this.index_information){ return {}; } - //! postnomen is still missing + return { - FhAusweisStatus: this.person_info.zutrittskarte_ausgegebenam, - emails:this.person_info.emails, - Kontakte:this.person_info.kontakte, + FhAusweisStatus: this.index_information.zutrittsdatum, + emails: this.role === 'Mitarbeiter'? this.mitarbeiter_info?.emails: this.index_information.emails, + Kontakte:this.index_information.kontakte, }; }, @@ -151,26 +161,54 @@ export default { created(){ - //error //! fhcapifactory.UserData.getUser().then(res => this.person = res.data); - fhcapifactory.UserData.isMitarbeiterOrStudent(this.uid).then(res => {this.role = res.data;}); + + - //.tabulator.setData(this.person_info?.funktionen); }, mounted(){ + + console.log(this.uid); + console.log(this.pid); + //? this function is to update the tabulator information only when the tabulator was build checking the tableBulit event //! only the tableBuilt event of the second tabulator was used to update the table informations - this.$refs.betriebsmittelTable.tabulator.on('tableBuilt', () => { - fhcapifactory.UserData.getMitarbeiterAnsicht().then((res)=>{ - this.person_info = res.data; - this.$refs.funktionenTable.tabulator.setData(res.data.funktionen); - this.$refs.betriebsmittelTable.tabulator.setData(res.data.mittel); + this.$refs.betriebsmittelTable.tabulator.on('tableBuilt', () => { + + fhcapifactory.UserData.isMitarbeiterOrStudent(this.uid).then((res) => { + this.role = res.data; + + + //? Die anderen api calls werden erst gemacht wenn der call zu isMitarbeiterOrStudent gemacht worden ist + + + //! indexProfilInformationen werden immer gefetcht + fhcapifactory.UserData.indexProfilInformaion().then((res) => { + this.index_information = res.data; + this.$refs.betriebsmittelTable.tabulator.setData(res.data.mittel); + }); - }) - }) - - + + //? Danach werden die Informationen der Role gefetcht + if(this.role === 'Student'){ + fhcapifactory.UserData.studentProfil().then((res)=> { + this.student_info = res.data; + this.$refs.zutrittsgruppenTable.tabulator.setData(res.data.zuttritsgruppen); + }) + } + + if(this.role === 'Mitarbeiter'){ + fhcapifactory.UserData.mitarbeiterProfil().then((res)=> { + this.mitarbeiter_info = res.data; + this.$refs.funktionenTable.tabulator.setData(res.data.funktionen); + }) + } + }); + + + }) + }, @@ -196,7 +234,7 @@ export default {
-
+

Profilfoto gesperrt

Sperre des Profilfotos aufheben
@@ -206,8 +244,8 @@ export default {
-

Mitarbeiter

-

Student

+

Mitarbeiter

+

Student

@@ -240,9 +278,9 @@ export default {

Private Kontakte

-
{{element.kontakttyp + " " + element.kontakt+" " }}
-
{{element?.anmerkung}}
-
+
{{element.kontakttyp + ": " + element.kontakt+" " }}
+
{{element?.anmerkung}}
+
@@ -260,21 +298,22 @@ export default {
-
- + +
-
+ +
- -
- -
+
+
+ +
@@ -286,7 +325,7 @@ export default {
Mailverteilers

Sie sind Mitgglied in folgenden Verteilern:

-
+
{{verteiler.beschreibung}}