mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-20 05:29:29 +00:00
controller functionality to apply profil update requests to the user
This commit is contained in:
@@ -120,9 +120,10 @@ class Profil extends Auth_Controller
|
||||
if(isset($payload->add)){
|
||||
//TODO: add functionality for adding a new kontakt or address
|
||||
|
||||
}elseif($update_request->topic == $json->topic && $update_request->uid == $this->uid){
|
||||
}elseif($update_request->topic == $json->topic ){
|
||||
|
||||
//? if it is not a delete or add request than the topic in combination with the uid of the user have to be unique
|
||||
echo json_encode(error("A request to change " + $json->topic + " is already open"));
|
||||
echo json_encode(error("A request to change " . $json->topic . " is already open"));
|
||||
return;
|
||||
}
|
||||
}}
|
||||
@@ -477,7 +478,7 @@ 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 typ", "plz", "ort"])) &&
|
||||
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"))
|
||||
|
||||
@@ -22,6 +22,10 @@ class ProfilUpdate extends Auth_Controller
|
||||
$this->pid = getAuthPersonID();
|
||||
|
||||
$this->load->model('person/Profil_change_model','ProfilChangeModel');
|
||||
$this->load->model('person/Kontakt_model','KontaktModel');
|
||||
$this->load->model('person/Adresse_model','AdresseModel');
|
||||
$this->load->model('person/Adressentyp_model', 'AdressenTypModel');
|
||||
$this->load->model('person/Person_model','PersonModel');
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +43,60 @@ class ProfilUpdate extends Auth_Controller
|
||||
$_POST = json_decode($this->input->raw_input_stream,true);
|
||||
|
||||
$id = $this->input->post('profil_update_id',true);
|
||||
$uid = $this->input->post('uid',true);
|
||||
$status_message = $this->input->post('status_message',true);
|
||||
$topic = $this->input->post('topic',true);
|
||||
$requested_change = $this->input->post('requested_change',true);
|
||||
|
||||
|
||||
print_r($_POST);
|
||||
//! PROPERTY EXISTS DOES NOT WORK FOR ASSOCIATIVE ARRAYS
|
||||
if(property_exists($requested_change,"adresse_id")){
|
||||
echo 'if';
|
||||
return;
|
||||
|
||||
$this->AdressenTypModel->addSelect(["adressentyp_kurzbz"]);
|
||||
$adr_kurzbz = $this->AdressenTypModel->loadWhere(["bezeichnung"=>$requested_change['typ']]);
|
||||
$adr_kurzbz = hasData($adr_kurzbz)? getData($adr_kurzbz)[0]->adressentyp_kurzbz : null;
|
||||
//? replace the address_typ with its correct kurzbz foreign key
|
||||
$requested_change['typ']= $adr_kurzbz;
|
||||
|
||||
$adresse_id = $requested_change["adresse_id"];
|
||||
//? removes the adresse_id because we don't want to update the kontakt_id in the database
|
||||
unset($requested_change["adresse_id"]);
|
||||
|
||||
$res = $this->AdresseModel->update($adresse_id, $requested_change);
|
||||
echo json_encode($res);
|
||||
}else if (property_exists($requested_change,"kontakt_id")){
|
||||
echo 'else if';
|
||||
return;
|
||||
|
||||
$kontakt_id = $requested_change["kontakt_id"];
|
||||
//? removes the kontakt_id because we don't want to update the kontakt_id in the database
|
||||
unset($requested_change["kontakt_id"]);
|
||||
|
||||
|
||||
$res = $this->KontaktModel->update($kontakt_id,$requested_change);
|
||||
|
||||
echo json_encode($res);
|
||||
|
||||
}else{
|
||||
echo 'else';
|
||||
return;
|
||||
//? fetching person_id using UID
|
||||
$personID = $this->PersonModel->getByUid($uid);
|
||||
$personID = hasData($personID)? getData($personID)[0]->person_id : null;
|
||||
|
||||
switch($topic){
|
||||
case "titel": $topic ="titelpre"; break;
|
||||
case "postnomen": $topic = "titelpost"; break;
|
||||
}
|
||||
$res = $this->PersonModel->update($personID,[$topic=>$requested_change]);
|
||||
|
||||
echo json_encode($res);
|
||||
}
|
||||
|
||||
return;
|
||||
if(isset($id)){
|
||||
$res =$this->ProfilChangeModel->update([$id], ["status"=>"accepted","status_timestamp"=>"NOW()","status_message"=>$status_message]);
|
||||
echo json_encode($res);
|
||||
|
||||
@@ -4,9 +4,7 @@ import AcceptDenyUpdate from "../../components/Cis/ProfilUpdate/AcceptDenyUpdate
|
||||
Vue.$fhcapi = fhcapifactory;
|
||||
|
||||
|
||||
let printIcon= function(cell, formatterParams, onRendered){ //plain text value
|
||||
return "<i class='fa fa-eye'></i>";
|
||||
};
|
||||
|
||||
|
||||
const app = Vue.createApp({
|
||||
components:{
|
||||
@@ -27,12 +25,15 @@ const app = Vue.createApp({
|
||||
field: "topic",
|
||||
resizable: true,
|
||||
minWidth: 200,
|
||||
headerFilter: true,
|
||||
//responsive:0,
|
||||
},
|
||||
{
|
||||
title: "UID",
|
||||
field: "uid",
|
||||
minWidth: 200,
|
||||
resizable:true,
|
||||
headerFilter: true,
|
||||
//responsive:0,
|
||||
},
|
||||
|
||||
@@ -40,6 +41,7 @@ const app = Vue.createApp({
|
||||
title: "Date",
|
||||
field: "change_timestamp",
|
||||
resizable: true,
|
||||
headerFilter: true,
|
||||
minWidth: 200,
|
||||
//responsive:0,
|
||||
},
|
||||
@@ -47,6 +49,7 @@ const app = Vue.createApp({
|
||||
title: "Status",
|
||||
field: "status",
|
||||
hozAlign:'center',
|
||||
headerFilter: true,
|
||||
formatter: function(cell,para){
|
||||
let res =Object.getPrototypeOf(cell);
|
||||
//console.log(res);
|
||||
@@ -65,7 +68,7 @@ const app = Vue.createApp({
|
||||
},
|
||||
{
|
||||
title: "View",
|
||||
formatter:printIcon,
|
||||
formatter:function(){ return "<i class='fa fa-eye'></i>";},
|
||||
resizable: true,
|
||||
minWidth: 200,
|
||||
hozAlign: 'center',
|
||||
|
||||
@@ -53,6 +53,7 @@ export default {
|
||||
}else{
|
||||
this.result= false;
|
||||
this.hide();
|
||||
console.log(res.data);
|
||||
Alert.popup("Ein Fehler ist aufgetreten: "+ JSON.stringify(res.data.retval));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export default {
|
||||
|
||||
<div class="form-underline ">
|
||||
<div class="form-underline-titel">Typ</div>
|
||||
<span class="form-underline-content">{{data.adr_typ}} </span>
|
||||
<span class="form-underline-content">{{data.typ}} </span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,7 @@ export default {
|
||||
},
|
||||
computed:{
|
||||
isChanged: function(){
|
||||
if(!this.data.strasse || !this.data.plz || !this.data.ort || !this.data.adr_typ){
|
||||
if(!this.data.strasse || !this.data.plz || !this.data.ort || !this.data.typ){
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -26,8 +26,7 @@ export default {
|
||||
|
||||
},
|
||||
template:`
|
||||
|
||||
<div class="gy-3 row justify-content-center align-items-center">
|
||||
<div class="gy-3 row justify-content-center align-items-center">
|
||||
|
||||
<!-- column 1 in the address row -->
|
||||
|
||||
@@ -46,23 +45,14 @@ export default {
|
||||
<!-- column 2 in the address row -->
|
||||
<div class=" order-2 order-sm-4 order-xl-3 order-xxl-4 col-12 col-sm-5 col-xl-8 col-xxl-5 ">
|
||||
|
||||
<!-- OLD INPUT FIELD FOR ADDRESS TYPE
|
||||
<template v-if="data.adresse_id">
|
||||
<div class="form-underline ">
|
||||
<div class="form-underline-titel">Typ</div>
|
||||
<input class="form-control" :value="data.adr_typ" @input="updateValue($event,'adr_typ')" :placeholder="data.adr_typ">
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="form-underline">
|
||||
<div class="form-underline-titel">Kontakttyp</div>
|
||||
|
||||
<select :value="data.adr_typ" @change="updateValue($event,'adr_typ')" class="form-select" aria-label="Select Kontakttyp">
|
||||
<select :value="data.typ" @change="updateValue($event,'typ')" class="form-select" aria-label="Select Kontakttyp">
|
||||
<option selected></option>
|
||||
<option value="Rechnungsadresse">Rechnungsadresse</option>
|
||||
<option value="Nebenwohnsitz">Nebenwohnsitz</option>
|
||||
|
||||
Reference in New Issue
Block a user