mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
adopting profil controllers/models/views to db table change
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Profil_change_model extends DB_Model
|
||||
class Profil_update_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
@@ -8,7 +8,7 @@ class Profil_change_model extends DB_Model
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->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){
|
||||
@@ -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 => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user