mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 08:34:29 +00:00
changes how to display the hr table with all the user update requests and the update request table in the profil view, also adds some new columns to the cis_profil_update table to store the status, status date and status message
This commit is contained in:
@@ -94,7 +94,7 @@ class Profil extends Auth_Controller
|
||||
$payload = $json->payload;
|
||||
$type = isset($json->payload->kontakt_id)? "kontakt_id" : "adresse_id";
|
||||
|
||||
$data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($payload), "change_timestamp" => "NOW()" ];
|
||||
$data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($payload), "change_timestamp" => "NOW()","status"=>"pending" ];
|
||||
|
||||
//? loops over all updateRequests from a user to validate if the new request is valid
|
||||
$res = $this->ProfilChangeModel->loadWhere(["uid"=>$this->uid]);
|
||||
@@ -148,7 +148,7 @@ class Profil extends Auth_Controller
|
||||
$json = json_decode($this->input->raw_input_stream);
|
||||
|
||||
|
||||
$data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($json->payload), "change_timestamp" => "NOW()" ];
|
||||
$data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($json->payload), "change_timestamp" => "NOW()","status"=>"pending" ];
|
||||
|
||||
//? gets all the requested changes from a user
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ class ProfilUpdate extends Auth_Controller
|
||||
parent::__construct([
|
||||
'index' => ['student/anrechnung_beantragen:r', 'user:r'], // TODO(chris): permissions?
|
||||
'getAllRequests' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'acceptProfilRequest'=>['user:r'],
|
||||
'denyProfilRequest'=>['user:r'],
|
||||
|
||||
]);
|
||||
//? put the uid and pid inside the controller to reuse in controller
|
||||
@@ -28,22 +30,39 @@ class ProfilUpdate extends Auth_Controller
|
||||
}
|
||||
|
||||
public function getAllRequests(){
|
||||
|
||||
$res = $this->ProfilChangeModel->load();
|
||||
if(isError($res)){
|
||||
// catch exception
|
||||
echo $res->retval->data;
|
||||
return;
|
||||
}else{
|
||||
if(hasData($res)){
|
||||
$res = getData($res);
|
||||
foreach($res as $element){
|
||||
$element->change_timestamp = date_create($element->change_timestamp)->format('d/m/Y H:i');
|
||||
}
|
||||
}else{
|
||||
$res = null;
|
||||
}
|
||||
}
|
||||
$res = $this->ProfilChangeModel->getProfilUpdate();
|
||||
$res = hasData($res)? getData($res) : null;
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
public function acceptProfilRequest(){
|
||||
$_POST = json_decode($this->input->raw_input_stream,true);
|
||||
|
||||
$id = $this->input->post('requestID',true);
|
||||
|
||||
if(isset($id)){
|
||||
$res =$this->ProfilChangeModel->update([$id], ["status"=>"accepted","status_timestamp"=>"NOW()"]);
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function denyProfilRequest(){
|
||||
$_POST = json_decode($this->input->raw_input_stream,true);
|
||||
|
||||
$id = $this->input->post('requestID',true);
|
||||
|
||||
if(isset($id)){
|
||||
var_dump($id);
|
||||
//! instead of deleting the rejected profil update, the status of the db entry is set to rejected
|
||||
//$res = $this->ProfilChangeModel->delete([$id]);
|
||||
|
||||
|
||||
$res = $this->ProfilChangeModel->update([$id],["status"=>"rejected","status_timestamp"=>"NOW()"]);
|
||||
echo json_encode($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,13 @@ 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,$id=null){
|
||||
$whereClause = ["uid"=>$uid];
|
||||
public function getProfilUpdate($uid=null,$id=null){
|
||||
$whereClause=[];
|
||||
|
||||
if(!is_null($uid)){
|
||||
$whereClause['uid']=$uid;
|
||||
}
|
||||
//?
|
||||
if(!is_null($id)){
|
||||
$whereClause['profil_update_id']=$id;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ $includesArray = array(
|
||||
'title' => 'Stundenplan',
|
||||
'customJSModules' => ['public/js/apps/Cis/Profil.js'],
|
||||
'tabulator5' => true,
|
||||
'customCSSs' => ['public/css/components/calendar.css', 'public/css/components/FilterComponent.css','public/css/components/Profil.css'],
|
||||
'customCSSs' => ['public/css/components/calendar.css', 'public/css/components/FilterComponent.css','public/css/components/Profil.css','public/css/components/FormUnderline.css'],
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
$includesArray = ['title'=> 'Profil Änderungen',
|
||||
'customJSModules'=> ['public/js/apps/Cis/ProfilUpdateRequests.js'],
|
||||
'tabulator5'=> true,
|
||||
'customCSSs'=>['public/css/components/FilterComponent.css'],
|
||||
'customCSSs'=>['public/css/components/FilterComponent.css','public/css/components/FormUnderline.css'],
|
||||
];
|
||||
|
||||
$this->load->view('templates/CISHTML-Header',$includesArray);
|
||||
|
||||
Reference in New Issue
Block a user