diff --git a/application/controllers/Cis/ProfilUpdate.php b/application/controllers/Cis/ProfilUpdate.php index 98d9e3224..1ea04716e 100755 --- a/application/controllers/Cis/ProfilUpdate.php +++ b/application/controllers/Cis/ProfilUpdate.php @@ -415,7 +415,7 @@ class ProfilUpdate extends Auth_Controller if ($res) { $pending_changes = array_filter($res, function ($element) { - return $element->status == self::$STATUS_PENDING ?: "Pending"; + return $element->status == (self::$STATUS_PENDING ?: "Pending"); }); foreach ($pending_changes as $update_request) { @@ -565,7 +565,7 @@ class ProfilUpdate extends Auth_Controller $requested_change['adresse_id'] = $insertID; $update_res = $this->updateRequestedChange($id, $requested_change); if (isError($update_res)) { - echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_address_error', [$insertID, $id]))); + echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_address_error', [$insertID]))); return; } } @@ -577,7 +577,7 @@ class ProfilUpdate extends Auth_Controller $requested_change['kontakt_id'] = $insertID; $update_res = $this->updateRequestedChange($id, $requested_change); if (isError($update_res)) { - echo json_encode(error("was not able to add kontakt_id " . $insertID . " to profilRequest " . $id)); + echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_kontakt_error', [$insertID]))); return; } } @@ -586,15 +586,21 @@ class ProfilUpdate extends Auth_Controller } else { switch ($topic) { // mapping phrasen to database columns to make the update with the correct column names - case $this->p->t('profilUpdate', 'title'): + case self::$TOPICS['Titel']: $topic = "titelpre"; break; - case $this->p->t('profilUpdate', 'postnomen'): + case self::$TOPICS['Postnomen']: $topic = "titelpost"; break; - case $this->p->t('profilUpdate', 'vorname'): + case self::$TOPICS['Vorname']: $topic = "vorname"; break; + case self::$TOPICS['Nachname']: + $topic = "nachname"; + break; + default: + show_error($this->p->t('profilUpdate', 'profilUpdate_topic_error',[$topic])); + return; } $result = $this->PersonModel->update($personID, [$topic => $requested_change["value"]]); diff --git a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js index 8650f2b55..76a2e2b6a 100755 --- a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js +++ b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js @@ -38,7 +38,6 @@ export default { return { data: this.value, loading: false, - profilUpdateStates: {}, result: false, info: null, files: null, @@ -60,10 +59,14 @@ export default { `/Cis/ProfilUpdate/show/${dms_id}` ); }, - acceptRequest: function () { + handleRequest: function (type) { this.loading = true; this.setLoading(true); - Vue.$fhcapi.ProfilUpdate.acceptProfilRequest(this.data) + Vue.$fhcapi.ProfilUpdate[ + type.toLowerCase() == "accept" + ? "acceptProfilRequest" + : "denyProfilRequest" + ](this.data) .then((res) => { this.setLoading(false); this.loading = false; @@ -76,22 +79,8 @@ export default { this.hide(); }); }, - - denyRequest: async function () { - this.loading = true; - this.setLoading(true); - Vue.$fhcapi.ProfilUpdate.denyProfilRequest(this.data) - .then((res) => { - this.setLoading(false); - this.loading = false; - this.result = true; - }) - .catch((e) => { - Alert.popup(Vue.h("div", { innerHTML: e.response.data })); - }); - this.hide(); - }, }, + computed: { getComponentView: function () { if (this.data.topic.toLowerCase().includes("kontakt")) { @@ -104,20 +93,14 @@ export default { }, }, created() { - // fetching the different ProfilUpdateStates from the db - Vue.$fhcapi.ProfilUpdate.getStatus() - .then((result) => { - this.profilUpdateStates = result.data; - }) - .catch((err) => { - console.error(err); + // only fetching the profilUpdate Attachemnts if the profilUpdate actually has attachments + if (this.value.attachment_id) { + Vue.$fhcapi.ProfilUpdate.getProfilRequestFiles( + this.data.profil_update_id + ).then((res) => { + this.files = res.data; }); - - Vue.$fhcapi.ProfilUpdate.getProfilRequestFiles( - this.data.profil_update_id - ).then((res) => { - this.files = res.data; - }); + } }, mounted() { this.modal = this.$refs.modalContainer.modal; @@ -224,8 +207,8 @@ export default {
- - + +
diff --git a/public/js/components/Cis/ProfilUpdate/ProfilUpdateView.js b/public/js/components/Cis/ProfilUpdate/ProfilUpdateView.js index c83ea816a..9e8194a7e 100644 --- a/public/js/components/Cis/ProfilUpdate/ProfilUpdateView.js +++ b/public/js/components/Cis/ProfilUpdate/ProfilUpdateView.js @@ -263,7 +263,6 @@ export default { }, hideAcceptDenyModal: function () { //? checks the AcceptDenyModal component property result, if the user made a successful request or not - if (this.$refs.AcceptDenyModal.result) { //? refetches the data, if any request was denied or accepted //* setData will call the ajaxURL again to refresh the data diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index 8b7789788..1ff876ae5 100755 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -25780,6 +25780,66 @@ array( ) ) ), + array( + 'app' => 'core', + 'category' => 'profilUpdate', + 'phrase' => 'profilUpdate_topic_error', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Ein Fehler ist aufgetreten, das Topic "{0}" existiert nicht', + 'description' => 'Fehler der auftritt wenn es das Topic nicht in der Datenbank gibt', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'An error occurred, the topic "{0}" is not known', + 'description' => 'error that occurrs when the used topic is not present in the database', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'profilUpdate', + 'phrase' => 'profilUpdate_address_error', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Ein Fehler ist aufgetreten, Es war nicht möglich die Adresse mit ID {0} in der Datenbank anzulegen', + 'description' => 'Fehler der auftritt wenn es nicht möglich war eine neue Adresse anzulegen', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'An error occurred, it wasn\'t possible to add new address with ID {0} to the database', + 'description' => 'error that occurrs when it wasn\'t possible to add new address in db', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'profilUpdate', + 'phrase' => 'profilUpdate_kontakt_error', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Ein Fehler ist aufgetreten, Es war nicht möglich den Kontakt mit ID {0} in der Datenbank anzulegen', + 'description' => 'Fehler der auftritt wenn es nicht möglich war einen neuen Kontakt anzulegen', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'An error occurred, it wasn\'t possible to add new contact with ID {0} to the database', + 'description' => 'error that occurrs when it wasn\'t possible to add new contact in db', + 'insertvon' => 'system' + ) + ) + ),