diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index 50a4c21a4..0a6046c1c 100755 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -23,6 +23,7 @@ class Profil extends Auth_Controller 'isMitarbeiter' => ['student/anrechnung_beantragen:r', 'user:r'], 'isStudent' => ['student/anrechnung_beantragen:r', 'user:r'], 'getZustellAdresse' => ['student/anrechnung_beantragen:r', 'user:r'], + 'getZustellKontakt' => ['student/anrechnung_beantragen:r', 'user:r'], ]); @@ -101,6 +102,16 @@ class Profil extends Auth_Controller echo json_encode($adressen_res); } + public function getZustellKontakt(){ + $this->KontaktModel->addSelect(["kontakt_id"]); + $kontakt_res = $this->KontaktModel->loadWhere(['person_id'=>$this->pid, 'zustellung'=>true]); + $kontakt_res = hasData($kontakt_res) ? getData($kontakt_res): null; + $kontakt_res = array_map(function($item){ + return $item->kontakt_id; + },$kontakt_res); + echo json_encode($kontakt_res); + } + private function viewMitarbeiterProfil($uid) { diff --git a/public/js/apps/api/userdata.js b/public/js/apps/api/userdata.js index 0c4c049a7..8395c4ca8 100755 --- a/public/js/apps/api/userdata.js +++ b/public/js/apps/api/userdata.js @@ -43,4 +43,11 @@ export default { `cis.php/Cis/Profil/getZustellAdresse`; return axios.get(url); }, + + getZustellKontakt: function () { + const url = + FHC_JS_DATA_STORAGE_OBJECT.app_root + + `cis.php/Cis/Profil/getZustellKontakt`; + return axios.get(url); + }, }; diff --git a/public/js/components/Cis/Profil/ProfilComponents/EditAdresse.js b/public/js/components/Cis/Profil/ProfilComponents/EditAdresse.js index 4f7240893..6a64452e0 100755 --- a/public/js/components/Cis/Profil/ProfilComponents/EditAdresse.js +++ b/public/js/components/Cis/Profil/ProfilComponents/EditAdresse.js @@ -32,7 +32,7 @@ export default { //? if the adresse was already saved return false; } - return this.zustellAdressenCount > 0 && this.data.zustelladresse; + return this.zustellAdressenCount>0 && this.data.zustelladresse; } //? if this.zustellAdressenCount is still not set by the api call and is still null return false; @@ -62,7 +62,7 @@ export default { created(){ Vue.$fhcapi.UserData.getZustellAdresse().then(res => { - this.zustellAdressenCount = res.data; + this.zustellAdressenCount = res.data?.length; }) this.originalValue = JSON.stringify(this.data); @@ -72,6 +72,7 @@ export default {