From a2d0f9e39abac80c12994d12c1294ef9e953fb7d Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 5 Feb 2024 11:17:07 +0100 Subject: [PATCH] funciton that queries the ProfilUpdates now takes a associative array instead of multiple separate parameters --- application/controllers/Cis/Profil.php | 20 +++++++------------ application/controllers/Cis/ProfilUpdate.php | 20 ++++++++----------- .../models/person/Profil_change_model.php | 11 ++-------- public/js/apps/Cis/ProfilUpdateRequests.js | 10 +++++----- .../Cis/ProfilUpdate/AcceptDenyUpdate.js | 4 +++- 5 files changed, 25 insertions(+), 40 deletions(-) diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index f2afcff1b..5f69264ed 100755 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -162,17 +162,12 @@ class Profil extends Auth_Controller $_GET = json_decode($this->input->raw_input_stream, true); $uid = $this->input->get('uid'); $id = $this->input->get('id'); + $whereClause=['uid'=> $this->uid]; + if(isset($uid)) $whereClause['uid'] = $uid; + if(isset($id)) $whereClause['id'] = $id; - if($uid && $id){ - $res= $this->ProfilChangeModel->getProfilUpdate($uid, $id); - }elseif($uid){ - $res= $this->ProfilChangeModel->getProfilUpdate($uid); - }elseif($id){ - $res= $this->ProfilChangeModel->getProfilUpdate($this->uid, $id); - }else{ - $res= $this->ProfilChangeModel->getProfilUpdate($this->uid); - } + $res= $this->ProfilChangeModel->getProfilUpdate($whereClause); echo json_encode($res); @@ -659,7 +654,7 @@ class Profil extends Auth_Controller //? querying if the user has profil update requests - $profilUpdates = $this->ProfilChangeModel->getProfilUpdate($this->uid); + $profilUpdates = $this->ProfilChangeModel->getProfilUpdate(['uid'=>$this->uid]); if(isError($profilUpdates)){ //error handling }else{ @@ -769,9 +764,8 @@ class Profil extends Auth_Controller if ( - isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as adr_typ", "plz", "ort"])) && + isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as adr_typ", "plz", "ort","zustelladresse"])) && 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" => $this->pid)); @@ -866,7 +860,7 @@ class Profil extends Auth_Controller } //? querying if the user has profil update requests - $profilUpdates = $this->ProfilChangeModel->getProfilUpdate($this->uid); + $profilUpdates = $this->ProfilChangeModel->getProfilUpdate(['uid'=>$this->uid]); if(isError($profilUpdates)){ //error handling }else{ diff --git a/application/controllers/Cis/ProfilUpdate.php b/application/controllers/Cis/ProfilUpdate.php index ac1815d6e..9411640f7 100755 --- a/application/controllers/Cis/ProfilUpdate.php +++ b/application/controllers/Cis/ProfilUpdate.php @@ -12,11 +12,11 @@ class ProfilUpdate extends Auth_Controller public function __construct(){ parent::__construct([ 'index' => ['student/anrechnung_beantragen:r', 'user:r'], // TODO(chris): permissions? - 'getAllRequests' => ['student/anrechnung_beantragen:r', 'user:r'], + 'getProfilUpdates' => ['student/anrechnung_beantragen:r', 'user:r'], 'acceptProfilRequest'=>['user:r'], 'denyProfilRequest'=>['user:r'], 'show'=>['user:r'], - 'getPendingRequests'=>['user:r'], + ]); @@ -45,20 +45,16 @@ class ProfilUpdate extends Auth_Controller echo json_encode($res); } - public function getAllRequests(){ - $res = $this->ProfilChangeModel->getProfilUpdate(); + public function getProfilUpdates($status=null){ + if(isset($status)){ + $res = $this->ProfilChangeModel->getProfilUpdate(["status"=>$status]); + }else{ + $res = $this->ProfilChangeModel->getProfilUpdate(); + } $res = hasData($res)? getData($res) : null; echo json_encode($res); } - public function getPendingRequests(){ - $res = $this->ProfilChangeModel->loadWhere(["status"=>"pending"]); - - $res = hasData($res)? getData($res) : []; - - - echo json_encode($res); - } public function acceptProfilRequest(){ diff --git a/application/models/person/Profil_change_model.php b/application/models/person/Profil_change_model.php index b207db716..134395dd6 100755 --- a/application/models/person/Profil_change_model.php +++ b/application/models/person/Profil_change_model.php @@ -49,15 +49,7 @@ class Profil_change_model extends DB_Model * returns a profil update with id * returns all profil updates if id is set to null */ - public function getProfilUpdate($uid=null,$id=null){ - $whereClause=[]; - - if(!is_null($uid)){ - $whereClause['uid']=$uid; - } - if(!is_null($id)){ - $whereClause['profil_update_id']=$id; - } + public function getProfilUpdate($whereClause=null){ $res = $this->loadWhere($whereClause); if(isError($res)){ @@ -68,6 +60,7 @@ class Profil_change_model extends DB_Model foreach($res->retval as $update){ $update->requested_change = json_decode($update->requested_change); $update->insertamum = !is_null($update->insertamum)?date_create($update->insertamum)->format('d.m.Y'):null; + $update->updateamum = !is_null($update->updateamum)?date_create($update->updateamum)->format('d.m.Y'):null; $update->status_timestamp = !is_null($update->status_timestamp)?date_create($update->status_timestamp)->format('d.m.Y'):null; } diff --git a/public/js/apps/Cis/ProfilUpdateRequests.js b/public/js/apps/Cis/ProfilUpdateRequests.js index 7ce7e130e..9b7ad48d4 100755 --- a/public/js/apps/Cis/ProfilUpdateRequests.js +++ b/public/js/apps/Cis/ProfilUpdateRequests.js @@ -18,9 +18,9 @@ const app = Vue.createApp({ ajaxURLGenerator: (url,config,params)=>{ //? this function needs to be an array function in order to access the this properties of the Vue component if(this.showAll){ - return url +"getAllRequests"; + return url +"getProfilUpdates"; }else{ - return url +"getPendingRequests"; + return url +"getProfilUpdates/pending"; } }, @@ -97,7 +97,7 @@ const app = Vue.createApp({ //! function that is called when clicking on a row in the table let cellData = cell.getRow().getData(); - + console.log("cellData",cellData); AcceptDenyUpdate.popup({ value: cellData }) .then((res) => { console.log("res of the modal: ", res); @@ -146,8 +146,8 @@ const app = Vue.createApp({
Show Profil Requests
- + diff --git a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js index ee0b48241..ca05ae500 100755 --- a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js +++ b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js @@ -3,6 +3,7 @@ import Alert from "../../Bootstrap/Alert.js"; import Kontakt from "../Profil/ProfilComponents/Kontakt.js"; import Adresse from "../Profil/ProfilComponents/Adresse.js"; + export default { components: { BsModal, @@ -119,6 +120,7 @@ export default {