completes the index view for both student and mitarbeiter

This commit is contained in:
Simon Gschnell
2023-11-28 14:56:42 +01:00
parent e3ec0fc36c
commit c68856b740
2 changed files with 324 additions and 74 deletions
+221 -10
View File
@@ -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);
}
+103 -64
View File
@@ -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 {
<div :class="{'row':true}">
<div :class="{'col':true}">
<img :class="{'img-thumbnail':true}" :src="get_image_base64_src"></img>
<div v-if="person_info?.foto_sperre">
<div v-if="index_information?.foto_sperre">
<p style="margin:0">Profilfoto gesperrt</p>
<a href="#" @click.prevent="sperre_foto_function(false)" style="text-decoration:none">Sperre des Profilfotos aufheben</a>
</div>
@@ -206,8 +244,8 @@ export default {
</div>
<div :class="{'col':true}">
<p v-if="role=='Mitarbeiter'"><b>Mitarbeiter</b></p>
<p v-else ><b>Student</b></p>
<h3 v-if="role=='Mitarbeiter'">Mitarbeiter</h3>
<h3 v-else >Student</h3>
<div v-for="(wert,bezeichnung) in personData">
@@ -240,9 +278,9 @@ export default {
<div class="mb-3" v-if="typeof wert === 'object' && bezeichnung=='Kontakte'">
<p class="mb-0"><b>Private Kontakte</b></p>
<div class="row" v-for="element in wert" >
<div class="col-6">{{element.kontakttyp + " " + element.kontakt+" " }}</div>
<div class="col-3"> {{element?.anmerkung}}</div>
<div class="col-3">
<div class="col-8">{{element.kontakttyp + ": " + element.kontakt+" " }}</div>
<div class="col-2"> {{element?.anmerkung}}</div>
<div class="col-2">
<i v-if="element.zustellung" class="fa-solid fa-check"></i>
<i v-else="element.zustellung" class="fa-solid fa-xmark"></i>
</div>
@@ -260,21 +298,22 @@ export default {
<div :class="{'row':true}">
<div :class="{'col':true}">
<core-filter-cmpt title="Funktionen" ref="funktionenTable" :tabulator-options="funktionen_table_options" :tableOnly />
<!-- order-1 classe wird nur bei der Studentenansicht hinzugefügt um die Zutrittsgruppen Tabelle hinter der Betriebsmittel aufzureihen -->
<div :class="{'col-12':true, 'order-2':role==='Student'}">
</div>
<core-filter-cmpt v-if="role === 'Mitarbeiter'" title="Funktionen" ref="funktionenTable" :tabulator-options="funktionen_table_options" :tableOnly />
<core-filter-cmpt v-else title="Zutrittsgruppen" ref="zutrittsgruppenTable" :tabulator-options="zutrittsgruppen_table_options" :tableOnly :noColFilter />
</div>
<div :class="{'row':true}">
<div :class="{'col':true}">
<div :class="{'col-12':true}">
<core-filter-cmpt title="Entlehnte Betriebsmittel" ref="betriebsmittelTable" :tabulator-options="betriebsmittel_table_options" :tableOnly />
</div>
</div>
</div>
<div :class="{'col-3':true}">
@@ -286,7 +325,7 @@ export default {
<div :class="{'row':true}">
<h5 :class="{'fs-3':true}" style="margin-top:1em">Mailverteilers</h5>
<p :class="{'fs-6':true}">Sie sind Mitgglied in folgenden Verteilern:</p>
<div :class="{'row':true, 'text-break':true}" v-for="verteiler in person_info?.mailverteiler">
<div :class="{'row':true, 'text-break':true}" v-for="verteiler in index_information?.mailverteiler">
<div :class="{'col-6':true}"><a :href="verteiler.mailto"><b>{{verteiler.gruppe_kurzbz}}</b></a></div>
<div :class="{'col-6':true}">{{verteiler.beschreibung}}</div>
</div>