queries full name of user that created profil_update using join in Profil_update_model

This commit is contained in:
SimonGschnell
2024-02-12 15:58:52 +01:00
parent 78bffb1348
commit 4b898bd976
6 changed files with 52 additions and 28 deletions
+2 -2
View File
@@ -367,7 +367,7 @@ class Profil extends Auth_Controller
if (
isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort","zustelladresse"])) &&
isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort","zustelladresse","heimatadresse"])) &&
isSuccess($adresse_res = $this->AdresseModel->addOrder("zustelladresse", "DESC")) &&
isSuccess($adresse_res = $this->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz"))
) {
@@ -578,7 +578,7 @@ class Profil extends Auth_Controller
if (
isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort","zustelladresse"])) &&
isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort","zustelladresse","heimatadresse"])) &&
isSuccess($adresse_res = $this->AdresseModel->addOrder("zustelladresse", "DESC")) &&
isSuccess($adresse_res = $this->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz"))
) {
+9 -7
View File
@@ -213,19 +213,21 @@ class ProfilUpdate extends Auth_Controller
public function insertProfilRequest()
{
//! deprecated code
//? Name of user is now queried in the database table model Profil_update_model.php
/* $name = $this->PersonModel->getFullName($this->uid);
if(isError($name)){
// error handling
var_dump($name);
return;
} */
$json = json_decode($this->input->raw_input_stream);
$payload = $json->payload;
$identifier = property_exists($json->payload,"kontakt_id")? "kontakt_id" : (property_exists($json->payload,"adresse_id")? "adresse_id" : null);
$name = $this->PersonModel->getFullName($this->uid);
if(isError($name)){
// error handling
var_dump($name);
return;
}
$data = ["topic"=>$json->topic,"uid" => $this->uid, "name"=>getData($name), "requested_change" => json_encode($payload), "insertamum" => "NOW()", "insertvon"=>$this->uid,"status"=>"pending" ];
$data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($payload), "insertamum" => "NOW()", "insertvon"=>$this->uid,"status"=>"pending" ];
//? insert fileID in the dataset if sent with post request
if(isset($json->fileID)){
$data['attachment_id'] = $json->fileID;
@@ -51,7 +51,13 @@ class Profil_update_model extends DB_Model
//? queries the tbl_profil_updates without permissions of the user
public function getProfilUpdatesWhere($whereClause){
if(array_key_exists("uid",$whereClause)){
$whereClause["public.tbl_profil_update.uid"]= $whereClause["uid"];
unset($whereClause["uid"]);
}
$this->addSelect(["public.tbl_profil_update.*","public.tbl_person.vorname"]);
$this->addJoin("public.tbl_benutzer","public.tbl_benutzer.uid = public.tbl_profil_update.uid");
$this->addJoin("public.tbl_person","public.tbl_person.person_id = public.tbl_benutzer.person_id");
$res = $this->loadWhere($whereClause);
if(isError($res)){
return error("Could not load public.tbl_profil_update with whereClause");
@@ -86,10 +92,11 @@ class Profil_update_model extends DB_Model
$parameters = [];
$query="
SELECT
profil_update_id, uid, name, topic, requested_change, tbl_profil_update.updateamum, tbl_profil_update.updatevon, tbl_profil_update.insertamum, tbl_profil_update.insertvon, status, status_timestamp, status_message, attachment_id
profil_update_id, tbl_profil_update.uid, (tbl_person.vorname || ' ' || tbl_person.nachname) AS name , topic, requested_change, tbl_profil_update.updateamum, tbl_profil_update.updatevon, tbl_profil_update.insertamum, tbl_profil_update.insertvon, status, status_timestamp, status_message, attachment_id
FROM public.tbl_profil_update
JOIN public.tbl_student ON public.tbl_student.student_uid=public.tbl_profil_update.uid
JOIN public.tbl_prestudent ON public.tbl_prestudent.prestudent_id=public.tbl_student.prestudent_id
JOIN public.tbl_person ON public.tbl_prestudent.person_id=public.tbl_person.person_id
JOIN public.tbl_studiengang ON public.tbl_studiengang.studiengang_kz=public.tbl_prestudent.studiengang_kz
JOIN public.tbl_organisationseinheit ON public.tbl_organisationseinheit.oe_kurzbz=public.tbl_studiengang.oe_kurzbz
Where public.tbl_studiengang.oe_kurzbz IN ? ";
@@ -110,8 +117,10 @@ class Profil_update_model extends DB_Model
}
}
if($mitarbeiterBerechtigung) {
$this->addSelect(["profil_update_id", "uid", "name", "topic", "requested_change", "tbl_profil_update.updateamum", "tbl_profil_update.updatevon", "tbl_profil_update.insertamum", "tbl_profil_update.insertvon", "status", "status_timestamp", "status_message", "attachment_id"]);
$this->addSelect(["profil_update_id", "tbl_profil_update.uid", "(tbl_person.vorname || ' ' || tbl_person.nachname) AS name", "topic", "requested_change", "tbl_profil_update.updateamum", "tbl_profil_update.updatevon", "tbl_profil_update.insertamum", "tbl_profil_update.insertvon", "status", "status_timestamp", "status_message", "attachment_id"]);
$this->addJoin('tbl_mitarbeiter','tbl_mitarbeiter.mitarbeiter_uid=tbl_profil_update.uid');
$this->addJoin('tbl_benutzer','tbl_benutzer.uid=tbl_profil_update.uid');
$this->addJoin('tbl_person','tbl_benutzer.person_id=tbl_person.person_id');
$mitarbeiterRequests = $this->loadWhere($whereClause);
if(isError($mitarbeiterRequests)) return error("db error: ". getData($mitarbeiterRequests));
$mitarbeiterRequests = getData($mitarbeiterRequests)?:[];
+5 -4
View File
@@ -55,7 +55,7 @@ const app = Vue.createApp({
},
//? adds tooltip with the status message of a profil update request if its status is not pending
columnDefaults: {
tooltip: function (e, cell, onRendered) {
tooltip: (e, cell, onRendered) =>{
//e - mouseover event
//cell - cell component
//onRendered - onRendered callback registration function
@@ -68,7 +68,8 @@ const app = Vue.createApp({
let el = document.createElement("div");
el.classList.add("border", "border-dark");
let statusDateEl = document.createElement("p");
let statusDateEl = document.createElement("span");
statusDateEl.classList.add("d-block","mb-1");
statusDateEl.innerHTML =
"Request was " + status + " on " + statusDate;
let statusMessageEl = document.createElement("span");
@@ -240,7 +241,7 @@ const app = Vue.createApp({
updateData: function (event) {
this.$refs.UpdatesTable.tabulator.setData();
//? store the selected view in the session storage of the browser
sessionStorage.setItem("showAll", JSON.stringify(event.target.value));
sessionStorage.setItem("showAll", event.target.value);
},
},
mounted() {
@@ -252,7 +253,7 @@ const app = Vue.createApp({
},
template: `
<div>
<div class="form-underline flex-fill ">
<div class="form-underline-titel">Show </div>
@@ -84,14 +84,14 @@ export default {
this.topic,
this.profilUpdate,
this.editData.updateID,
this.fileID[0]
this.fileID? this.fileID[0]: null
).then((res) => {
handleApiResponse(res);
})
: Vue.$fhcapi.ProfilUpdate.insertProfilRequest(
this.topic,
this.profilUpdate,
this.fileID[0]
this.fileID? this.fileID[0]: null
).then((res) => {
handleApiResponse(res);
@@ -8,7 +8,7 @@ export default {
methods:{
updateValue: function(event,bind){
//? sets the value of a property to null when an empty string is entered to keep the isChanged function valid
if(bind ==="zustelladresse"){
if(bind ==="zustelladresse" || bind ==="heimatadresse"){
this.data[bind] = event.target.checked;
}else{
this.data[bind] = event.target.value === "" ? null : event.target.value;
@@ -46,7 +46,26 @@ export default {
<div class="gy-3 row justify-content-center align-items-center">
<div class="col-12 ">
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" @change="updateValue($event,'zustelladresse')" :checked="data.zustelladresse" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault">
Zustelladresse
</label>
</div>
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" @change="updateValue($event,'heimatadresse')" :checked="data.heimatadresse" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault">
Heimatadresse
</label>
</div>
</div>
<div class="col-12 col-sm-9 col-xl-12 col-xxl-9 order-1">
@@ -92,14 +111,7 @@ export default {
</div>
</div>
<div class="col-12 order-5">
<div class="form-check">
<input class="form-check-input" type="checkbox" @change="updateValue($event,'zustelladresse')" :checked="data.zustelladresse" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault">
Zustelladresse
</label>
</div>
</div>
</div>
`