funciton that queries the ProfilUpdates now takes a associative array instead of multiple separate parameters

This commit is contained in:
SimonGschnell
2024-02-05 11:17:07 +01:00
parent 6e55382d15
commit a2d0f9e39a
5 changed files with 25 additions and 40 deletions
+7 -13
View File
@@ -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{
+8 -12
View File
@@ -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(){
@@ -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;
}
+5 -5
View File
@@ -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({
<div class="form-underline flex-fill ">
<div class="form-underline-titel">Show Profil Requests</div>
<select class="mb-2 " v-model="showAll" @change="updateData" class="form-select" aria-label="Profil updates display selection">
<option :selected="true" :value="false">Only Pending Requests</option>
<select class="mb-4 " v-model="showAll" @change="updateData" class="form-select" aria-label="Profil updates display selection">
<option :selected="true" :value="false">Pending Requests</option>
<option :value="true">All Requests</option>
</select>
@@ -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 {
<template v-slot:default>
<!-- debugging prints
<pre>{{JSON.stringify(data.profil_update_id,null,2)}}</pre>
<pre>view {{getComponentView}}</pre>
@@ -188,7 +190,7 @@ export default {
<span class="form-underline-content" >{{data.requested_change.value}}</span>
</div>
<div v-if="data.requested_change.files.length" class="ms-2">
<div v-if="data.requested_change.files?.length" class="ms-2">
<!--<p>files:</p>-->
<a v-for="file in data.requested_change.files" target="_blank" :href="getDocumentLink(file.dms_id)" >{{file.name}}</a>
</div>