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)?:[];