diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php
index f606484ea..8b87f3c5a 100644
--- a/application/controllers/Cis/Profil.php
+++ b/application/controllers/Cis/Profil.php
@@ -19,7 +19,8 @@ class Profil extends Auth_Controller
'index' => ['student/anrechnung_beantragen:r', 'user:r'], // TODO(chris): permissions?
'foto_sperre_function' => ['student/anrechnung_beantragen:r', 'user:r'],
'getView' => ['student/anrechnung_beantragen:r', 'user:r'],
- 'editProfil' => ['student/anrechnung_beantragen:r', 'user:r'],
+ 'insertProfilRequest' => ['student/anrechnung_beantragen:r', 'user:r'],
+ 'updateProfilRequest' => ['student/anrechnung_beantragen:r', 'user:r'],
]);
@@ -67,13 +68,13 @@ class Profil extends Auth_Controller
- public function editProfil()
+ public function insertProfilRequest()
{
$json = json_decode($this->input->raw_input_stream);
- $data = ["uid" => $this->uid, "requested_change" => json_encode($json->payload), "change_timestamp" => "NOW()", "topic"=>$json->topic];
+ $data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($json->payload), "change_timestamp" => "NOW()" ];
//? gets all the requested changes from a user
$res = $this->ProfilChangeModel->loadWhere(["uid"=>$this->uid]);
@@ -81,13 +82,14 @@ class Profil extends Auth_Controller
//? checks if the user already made a request to change a topic
//! which is an constraint added to the public.tbl_cis_profil_update table
+ if($res){
foreach($res as $update_request){
if($update_request->topic == $json->topic && $update_request->uid == $this->uid){
echo json_encode(error("uid and topic combination exists already"));
return;
}
- }
+ }}
$insert_res = $this->ProfilChangeModel->insert($data);
@@ -119,6 +121,32 @@ class Profil extends Auth_Controller
}
+ public function updateProfilRequest()
+ {
+
+ $json = json_decode($this->input->raw_input_stream);
+
+
+ $data = ["topic"=>$json->topic,"uid" => $this->uid, "requested_change" => json_encode($json->payload), "change_timestamp" => "NOW()" ];
+
+ //? gets all the requested changes from a user
+
+ if(isSuccess($this->ProfilChangeModel->addSelect(["profil_update_id"])) ){
+ $requestID = $this->ProfilChangeModel->loadWhere(["uid"=>$this->uid,"topic"=>$json->topic]);
+ $requestID = hasData($requestID) ? getData($requestID)[0]->profil_update_id : null;
+ };
+
+ $update_res =$this->ProfilChangeModel->update([$requestID],$data);
+ if(isError($update_res)){
+ //catch error
+ }else{
+ $editTimestamp = $this->ProfilChangeModel->getTimestamp($update_res->retval[0]);
+
+ $update_res->retval = date_create($editTimestamp)->format('d.m.Y');
+ echo json_encode($update_res);
+ }
+ }
+
private function viewMitarbeiterProfil($uid)
@@ -414,7 +442,7 @@ class Profil extends Auth_Controller
if (
- isSuccess($adresse_res = $this->AdresseModel->addSelect(array("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"])) &&
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"))
@@ -565,7 +593,11 @@ class Profil extends Auth_Controller
$res->standort_telefon = $telefon_res;
$res->profilUpdates = $profilUpdates?: null;
-
+ if($res->profilUpdates){
+ foreach($res->profilUpdates as $update){
+ $update->requested_change = json_decode($update->requested_change);
+ $update->change_timestamp = date_create($update->change_timestamp)->format('d.m.Y');
+ }}
return $res;
}
@@ -623,7 +655,7 @@ class Profil extends Auth_Controller
if (
- isSuccess($adresse_res = $this->AdresseModel->addSelect(array("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"])) &&
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"))
@@ -767,6 +799,11 @@ class Profil extends Auth_Controller
$res->mailverteiler = $mailverteiler_res;
$res->profilUpdates = $profilUpdates?: null;
+ if($res->profilUpdates){
+ foreach($res->profilUpdates as $update){
+ $update->requested_change = json_decode($update->requested_change);
+ $update->change_timestamp = date_create($update->change_timestamp)->format('d.m.Y');
+ }}
return $res;
diff --git a/public/css/components/Profil.css b/public/css/components/Profil.css
index 0138e5530..797504786 100644
--- a/public/css/components/Profil.css
+++ b/public/css/components/Profil.css
@@ -50,6 +50,9 @@
align-content: space-between;
}
+
+
+
.form-underline .form-underline-content{
border-width: 1px;
border-color: transparent transparent #dee2e6 transparent;
@@ -75,11 +78,7 @@
}
-option:checked{
- background: linear-gradient(#005485, #005485);
-}
-#SelectStyle{
-
-}
\ No newline at end of file
+
+
diff --git a/public/js/apps/api/userdata.js b/public/js/apps/api/userdata.js
index fb3a68a42..df655988c 100644
--- a/public/js/apps/api/userdata.js
+++ b/public/js/apps/api/userdata.js
@@ -3,9 +3,16 @@ export default {
//! API Calls for Profil Views
- editProfil: function(topic, payload) {
+ insertProfilRequest: function(topic, payload) {
const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+
- `/Cis/Profil/editProfil`;
+ `/Cis/Profil/insertProfilRequest`;
+
+ return axios.post(url,{topic, payload});
+ },
+
+ updateProfilRequest: function(topic, payload) {
+ const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router+
+ `/Cis/Profil/updateProfilRequest`;
return axios.post(url,{topic, payload});
},
diff --git a/public/js/components/Cis/Profil/EditProfil.js b/public/js/components/Cis/Profil/EditProfil.js
index fffef6d99..103418fdf 100644
--- a/public/js/components/Cis/Profil/EditProfil.js
+++ b/public/js/components/Cis/Profil/EditProfil.js
@@ -1,14 +1,14 @@
import BsModal from "../../Bootstrap/Modal.js";
import Alert from "../../Bootstrap/Alert.js";
import BreadCrumb from "../Selection/Breadcrumb.js";
-import Select from "../Selection/Select.js";
+import EditProfilSelect from "./EditProfilSelect.js";
export default {
components: {
BsModal,
Alert,
BreadCrumb,
- Select,
+ EditProfilSelect,
},
mixins: [BsModal],
props: {
@@ -37,6 +37,8 @@ export default {
privateKontakte:[{strasse:"strasse1",plz:100},{strasse:"strasse1",plz:100},{strasse:"strasse1",plz:100}],
privateAdressen:[{kontakt:"telefon",anmerkung:"1"},{kontakt:"email",anmerkung:"2"},{kontakt:"telefon",anmerkung:"3"}]
},
+ testSelectedItems:[],
+ profilUpdate:null,
topic:null,
@@ -58,12 +60,11 @@ export default {
},
methods: {
+
- testEvent: function(){
- if(!this.propertySelected){
- this.testListe = this.testListe[this.testValue];
- this.propertySelected = true;
- }
+
+ selectEvent: function (option){
+ this.editData = this.editData[option];
},
createDeepCopy: function(object){
//? using Vue.toRaw because deep clones with structuredClone can not be done on proxies
@@ -83,11 +84,12 @@ export default {
//* only inserts new row if the inputField value is different from the original value
- if(this.isInputFieldChanged && this.topic){
+ if(this.topic && this.profilUpdate){
//? inserts new row in public.tbl_cis_profil_update
-
- Vue.$fhcapi.UserData.editProfil(this.topic,this.inputField).then((res)=>{
+ if(this.editData.update){
+
+ Vue.$fhcapi.UserData.updateProfilRequest(this.topic,this.profilUpdate).then((res)=>{
this.result = {
editData: this.editData,
timestamp: res.data.retval,
@@ -102,116 +104,68 @@ export default {
}
//
});
+ //
- }
+ }else{
+
+ Vue.$fhcapi.UserData.insertProfilRequest(this.topic,this.profilUpdate).then((res)=>{
+ this.result = {
+ editData: this.editData,
+ timestamp: res.data.retval,
+ };
+ this.hide();
+
+ if(res.data.error == 0){
+
+ Alert.popup("Ihre Anfrage wurde erfolgreich gesendet. Bitte warten Sie, während sich das Team um Ihre Anfrage kümmert.");
+ }else{
+ Alert.popup("Ein Fehler ist aufgetreten: "+ JSON.stringify(res.data.retval));
+ }
+ //
+ });
+
+
+ }
+
+ }
},
},
computed: {
-
- isInputFieldChanged: function(){
- if(this.inputField){
- return JSON.stringify(this.inputField) !== JSON.stringify(this.secondSelectedOption);
- }
- return false;
- },
-
- firstSelection(){
- return Object.keys(this.value);
- },
-
- secondSelection(){
- switch(this.firstSelectedOption){
- case "Personen_Informationen": return Object.keys(this.editData[this.firstSelectedOption]);
- case "Private_Kontakte": return this.editData[this.firstSelectedOption];
- case "Private_Adressen": return this.editData[this.firstSelectedOption];
- default: return [];
- }
- },
-
-
},
created() {
+
+ if(this.editData.topic){
+ //? if the topic was passed through the prop add it to the reactive data
+ this.topic = this.editData.topic;
+ }
+
+
},
mounted() {
this.modal = this.$refs.modalContainer.modal;
},
popup(options) {
+ console.log("popup start");
return BsModal.popup.bind(this)(null, options);
},
template: `
{{testValue}}
{{update.requested_change}}
+| Topic | +Date of Request | ++ |
|---|---|---|
| {{item.topic}} | +{{item.change_timestamp}} | ++ |
size:{{optionLength}}
- -