diff --git a/application/controllers/Cis/ProfilUpdate.php b/application/controllers/Cis/ProfilUpdate.php index 503eb2a7e..e4ff7cc93 100755 --- a/application/controllers/Cis/ProfilUpdate.php +++ b/application/controllers/Cis/ProfilUpdate.php @@ -23,6 +23,8 @@ class ProfilUpdate extends Auth_Controller 'selectProfilRequest' => ['student/anrechnung_beantragen:r', 'user:r'], 'insertFile' => ['student/anrechnung_beantragen:r', 'user:r'], 'getProfilRequestFiles' => ['student/anrechnung_beantragen:r', 'user:r'], + 'handleDupplicateZustellKontakte' => ['student/anrechnung_beantragen:r', 'user:r'], + ]); @@ -332,6 +334,7 @@ class ProfilUpdate extends Auth_Controller public function acceptProfilRequest(){ + $_POST = json_decode($this->input->raw_input_stream,true); $id = $this->input->post('profil_update_id',true); @@ -455,6 +458,8 @@ class ProfilUpdate extends Auth_Controller $requested_change['insertamum'] = "NOW()"; $requested_change['insertvon'] = getAuthUID(); $insertID = $this->KontaktModel->insert($requested_change); + //TODO: check if the user has two zustelladressen or zustellkontakte + $this->handleDupplicateZustellKontakte($requested_change['zustellung']); } //! DELETE @@ -485,6 +490,7 @@ class ProfilUpdate extends Auth_Controller //! ADD if(array_key_exists('add',$requested_change) && $requested_change['add']){ + //? removes add flag unset($requested_change['add']); $requested_change['insertamum']="NOW()"; @@ -492,6 +498,7 @@ class ProfilUpdate extends Auth_Controller $requested_change['person_id'] = $personID; //TODO: zustelladresse, heimatadresse, rechnungsadresse und nation werden nicht beachtet $insertID = $this->AdresseModel->insert($requested_change); + } //! DELETE elseif(array_key_exists('delete',$requested_change) && $requested_change['delete']){ @@ -505,4 +512,29 @@ class ProfilUpdate extends Auth_Controller } return isset($insertID)? $insertID : null; } + + + public function handleDupplicateZustellKontakte($zustellung){ + + $this->PersonModel->addSelect("public.tbl_kontakt.kontakt_id"); + $this->PersonModel->addJoin("public.tbl_kontakt","public.tbl_kontakt.person_id = public.tbl_person.person_id"); + $zustellKontakteCount = $this->PersonModel->loadWhere(["public.tbl_person.person_id"=>$this->pid, "zustellung"=>TRUE]); + if(!isSuccess($zustellKontakteCount)){ + return error("error in the query"); + } + $zustellKontakteCount = hasData($zustellKontakteCount) ? getData($zustellKontakteCount) : null; + + + if($zustellung && count($zustellKontakteCount)>0){ + echo $zustellKontakteCount[0]; + } + } + + private function getZustelladressenCount(){ + + } + + public function getZustellkontakteCount(){ + + } } \ No newline at end of file diff --git a/public/js/apps/Cis/Profil.js b/public/js/apps/Cis/Profil.js index 334ffa270..980823e4f 100755 --- a/public/js/apps/Cis/Profil.js +++ b/public/js/apps/Cis/Profil.js @@ -57,8 +57,9 @@ const app = Vue.createApp({ //? use function syntax for provide so that we can access `this` provide() { return { - - + + getZustellkontakteCount: this.zustellKontakteCount, + getZustelladressenCount: this.zustellAdressenCount, collapseFunction: (e, column)=> { //* check if property doesn't exist already and add it to the reactive this properties @@ -121,7 +122,36 @@ const app = Vue.createApp({ } }, + methods:{ + zustellAdressenCount(){ + if(!this.data || !this.data.adressen){ + + return null; + } + + return this.data.adressen.filter(adresse => { + return adresse.zustelladresse; + }).map(adr => { + + return adr.adresse_id; + }); + + }, + + zustellKontakteCount(){ + if(!this.data || !this.data.kontakte){ + return null; + } + + return this.data.kontakte.filter(kontakt => { + return kontakt.zustellung; + }).map(kon =>{ + return kon.kontakt_id; + }); + }, + }, computed:{ + filteredEditData(){ if(!this.data){ @@ -218,13 +248,9 @@ const app = Vue.createApp({ this.notFoundUID=uid; }else{ this.view = res.data?.view; - this.data = res.data?.data; - - } - }); }, template:` diff --git a/public/js/components/Cis/Profil/EditProfil.js b/public/js/components/Cis/Profil/EditProfil.js index 26cf7eeaa..6c7093262 100755 --- a/public/js/components/Cis/Profil/EditProfil.js +++ b/public/js/components/Cis/Profil/EditProfil.js @@ -12,6 +12,8 @@ export default { props: { value: Object, title: String, + zustelladressenCount: Function, + zustellkontakteCount: Function, /* * NOTE(chris): * Hack to expose in "emits" declared events to $props which we use @@ -41,6 +43,8 @@ export default { provide(){ return { updateFileID: this.updateFileIDFunction, + zustellAdresseCount:this.zustelladressenCount, + zustellKontaktCount:this.zustellkontakteCount, } }, @@ -144,6 +148,7 @@ export default { return BsModal.popup.bind(this)(null, options); }, template: ` +