From fa1871a05946c6a8fbad200c1abab6acc8ad97e0 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Wed, 7 Feb 2024 16:34:00 +0100 Subject: [PATCH] adopting profil controllers/models/views to db table change --- application/controllers/Cis/Profil.php | 22 +++++++++---------- application/controllers/Cis/ProfilUpdate.php | 8 +++---- ...ange_model.php => Profil_update_model.php} | 12 +++++----- public/js/apps/Cis/Profil.js | 4 ++-- .../Cis/Profil/MitarbeiterProfil.js | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) rename application/models/person/{Profil_change_model.php => Profil_update_model.php} (85%) diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index 8e7c1a26a..ab7a60e80 100755 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -42,7 +42,7 @@ class Profil extends Auth_Controller $this->load->model('person/Benutzergruppe_model', 'BenutzergruppeModel'); $this->load->model('ressource/Betriebsmittelperson_model', 'BetriebsmittelpersonModel'); $this->load->model('person/Kontakt_model', 'KontaktModel'); - $this->load->model('person/Profil_change_model', 'ProfilChangeModel'); + $this->load->model('person/Profil_update_model', 'ProfilUpdateModel'); $this->load->model('content/DmsVersion_model', 'DmsVersionModel'); $this->load->model('DmsVersion_model','DmsVersionModel'); @@ -172,7 +172,7 @@ class Profil extends Auth_Controller if(isset($uid)) $whereClause['uid'] = $uid; if(isset($id)) $whereClause['id'] = $id; - $res= $this->ProfilChangeModel->getProfilUpdate($whereClause); + $res= $this->ProfilUpdateModel->getProfilUpdate($whereClause); echo json_encode($res); @@ -181,7 +181,7 @@ class Profil extends Auth_Controller public function getProfilRequestFiles(){ $id = json_decode($this->input->raw_input_stream); - echo json_encode($this->ProfilChangeModel->getFilesFromChangeRequest($id)); + echo json_encode($this->ProfilUpdateModel->getFilesFromChangeRequest($id)); } public function insertProfilRequest() @@ -201,7 +201,7 @@ class Profil extends Auth_Controller $data = ["topic"=>$json->topic,"uid" => $this->uid, "name"=>getData($name), "requested_change" => json_encode($payload), "insertamum" => "NOW()", "insertvon"=>$this->uid,"status"=>"pending" ]; //? loops over all updateRequests from a user to validate if the new request is valid - $res = $this->ProfilChangeModel->loadWhere(["uid"=>$this->uid]); + $res = $this->ProfilUpdateModel->loadWhere(["uid"=>$this->uid]); $res = hasData($res) ? getData($res) : null; if($res){ @@ -225,13 +225,13 @@ class Profil extends Auth_Controller } }} - $insertID = $this->ProfilChangeModel->insert($data); + $insertID = $this->ProfilUpdateModel->insert($data); if(isError($insertID)){ //catch error }else{ $insertID = hasData($insertID)? getData($insertID): null; - $editTimestamp = $this->ProfilChangeModel->getTimestamp($insertID); + $editTimestamp = $this->ProfilUpdateModel->getTimestamp($insertID); $date = success(date_create($editTimestamp)->format('d.m.Y')); echo json_encode($date); @@ -244,12 +244,12 @@ class Profil extends Auth_Controller $json = json_decode($this->input->raw_input_stream); - $updateID =$this->ProfilChangeModel->update([$json->ID],["requested_change" => json_encode($json->payload), "updateamum" => "NOW()", "updatevon" => $this->uid]); + $updateID =$this->ProfilUpdateModel->update([$json->ID],["requested_change" => json_encode($json->payload), "updateamum" => "NOW()", "updatevon" => $this->uid]); if(isError($updateID)){ //catch error }else{ $updateID = hasData($updateID)? getData($updateID)[0]: null; - $editTimestamp = $this->ProfilChangeModel->getTimestamp($updateID,true); + $editTimestamp = $this->ProfilUpdateModel->getTimestamp($updateID,true); $date = success(date_create($editTimestamp)->format('d.m.Y')); echo json_encode($date); @@ -259,7 +259,7 @@ class Profil extends Auth_Controller public function deleteProfilRequest(){ $json = json_decode($this->input->raw_input_stream); - $delete_res = $this->ProfilChangeModel->delete([$json]); + $delete_res = $this->ProfilUpdateModel->delete([$json]); echo json_encode($delete_res); } @@ -659,7 +659,7 @@ class Profil extends Auth_Controller //? querying if the user has profil update requests - $profilUpdates = $this->ProfilChangeModel->getProfilUpdate(['uid'=>$this->uid]); + $profilUpdates = $this->ProfilUpdateModel->getProfilUpdate(['uid'=>$this->uid]); if(isError($profilUpdates)){ //error handling }else{ @@ -865,7 +865,7 @@ class Profil extends Auth_Controller } //? querying if the user has profil update requests - $profilUpdates = $this->ProfilChangeModel->getProfilUpdate(['uid'=>$this->uid]); + $profilUpdates = $this->ProfilUpdateModel->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 17eddfe41..c35b808bd 100755 --- a/application/controllers/Cis/ProfilUpdate.php +++ b/application/controllers/Cis/ProfilUpdate.php @@ -21,7 +21,7 @@ class ProfilUpdate extends Auth_Controller ]); - $this->load->model('person/Profil_change_model','ProfilChangeModel'); + $this->load->model('person/Profil_update_model','ProfilUpdateModel'); $this->load->model('person/Kontakt_model','KontaktModel'); $this->load->model('person/Adresse_model','AdresseModel'); $this->load->model('person/Adressentyp_model', 'AdressenTypModel'); @@ -48,7 +48,7 @@ class ProfilUpdate extends Auth_Controller public function getProfilUpdates($status=null){ - $res = $this->ProfilChangeModel->getProfilUpdate(isset($status)?['status'=>$status]:null); + $res = $this->ProfilUpdateModel->getProfilUpdate(isset($status)?['status'=>$status]:null); echo json_encode($res); } @@ -125,11 +125,11 @@ class ProfilUpdate extends Auth_Controller } private function updateRequestedChange($id, $requested_change){ - return $this->ProfilChangeModel->update([$id], ['requested_change'=>json_encode($requested_change)]); + return $this->ProfilUpdateModel->update([$id], ['requested_change'=>json_encode($requested_change)]); } private function setStatusOnUpdateRequest($id, $status, $status_message ){ - return $this->ProfilChangeModel->update([$id], ["status"=>$status,"status_timestamp"=>"NOW()","status_message"=>$status_message]); + return $this->ProfilUpdateModel->update([$id], ["status"=>$status,"status_timestamp"=>"NOW()","status_message"=>$status_message]); } diff --git a/application/models/person/Profil_change_model.php b/application/models/person/Profil_update_model.php similarity index 85% rename from application/models/person/Profil_change_model.php rename to application/models/person/Profil_update_model.php index 104f17974..c71aa5b98 100755 --- a/application/models/person/Profil_change_model.php +++ b/application/models/person/Profil_update_model.php @@ -1,6 +1,6 @@ dbTable = 'public.tbl_cis_profil_update'; + $this->dbTable = 'public.tbl_profil_update'; $this->pk = ['profil_update_id']; $this->hasSequence = true; @@ -61,8 +61,8 @@ class Profil_change_model extends DB_Model $res =[]; if($studentBerechtigung) { - $this->addJoin('tbl_student','tbl_student.student_uid=tbl_cis_profil_update.uid'); - $studentRequests = $this->loadWhere(isset($whereClause['status']) && $whereClause['status']? ['status'=>$whereClause['status']]:[]); + $this->addJoin('tbl_student','tbl_student.student_uid=tbl_profil_update.uid'); + $studentRequests = $this->loadWhere($whereClause); if(isError($studentRequests)) return error("db error: ". getData($studentRequests)); $studentRequests = getData($studentRequests)?:[]; foreach($studentRequests as $request){ @@ -70,8 +70,8 @@ class Profil_change_model extends DB_Model } } if($mitarbeiterBerechtigung) { - $this->addJoin('tbl_mitarbeiter','tbl_mitarbeiter.mitarbeiter_uid=tbl_cis_profil_update.uid'); - $mitarbeiterRequests = $this->loadWhere(isset($whereClause['status']) && $whereClause['status']? ['status'=>$whereClause['status']]:[]); + $this->addJoin('tbl_mitarbeiter','tbl_mitarbeiter.mitarbeiter_uid=tbl_profil_update.uid'); + $mitarbeiterRequests = $this->loadWhere($whereClause); if(isError($mitarbeiterRequests)) return error("db error: ". getData($mitarbeiterRequests)); $mitarbeiterRequests = getData($mitarbeiterRequests)?:[]; foreach($mitarbeiterRequests as $request){ diff --git a/public/js/apps/Cis/Profil.js b/public/js/apps/Cis/Profil.js index 935dd2ab2..334ffa270 100755 --- a/public/js/apps/Cis/Profil.js +++ b/public/js/apps/Cis/Profil.js @@ -178,7 +178,7 @@ const app = Vue.createApp({ Private_Kontakte: { title:"Private Kontakte" , data:this.data.kontakte.filter(item => { - return !this.data.profilUpdates.some((update) => update.status ==='pending' && update.requested_change?.kontakt_id === item.kontakt_id); + return !this.data.profilUpdates?.some((update) => update.status ==='pending' && update.requested_change?.kontakt_id === item.kontakt_id); }).map(kontakt => { return { listview:'Kontakt', @@ -189,7 +189,7 @@ const app = Vue.createApp({ Private_Adressen: { title: "Private Adressen", data:this.data.adressen.filter(item => { - return !this.data.profilUpdates.some(update => { + return !this.data.profilUpdates?.some(update => { return update.status ==='pending' && update.requested_change?.adresse_id == item.adresse_id; }) }).map(kontakt => { diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index 979246d45..e50ec2429 100755 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -225,7 +225,7 @@ export default { created() { //? sorts the profil Updates: pending -> accepted -> rejected - this.data.profilUpdates.sort(this.sortProfilUpdates); + this.data.profilUpdates?.sort(this.sortProfilUpdates);