From 1bed062a014bb80dd703999b7bf1e74b13c08a33 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 20 Feb 2024 15:57:17 +0100 Subject: [PATCH] querying the right data for the EditAdresse Nation and Gemeinde Fields --- application/controllers/Cis/Profil.php | 62 ++++++++++++++++++- public/js/apps/api/userdata.js | 8 +-- .../Profil/ProfilComponents/EditAdresse.js | 30 +++++++++ 3 files changed, 93 insertions(+), 7 deletions(-) diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php index 050490220..defb753a7 100755 --- a/application/controllers/Cis/Profil.php +++ b/application/controllers/Cis/Profil.php @@ -24,6 +24,7 @@ class Profil extends Auth_Controller 'isStudent' => ['student/anrechnung_beantragen:r', 'user:r'], 'getZustellAdresse' => ['student/anrechnung_beantragen:r', 'user:r'], 'getZustellKontakt' => ['student/anrechnung_beantragen:r', 'user:r'], + 'getAllNationen' => ['student/anrechnung_beantragen:r', 'user:r'], ]); @@ -353,6 +354,63 @@ class Profil extends Auth_Controller } + public function getAllNationen(){ + $this->load->model('codex/Nation_model',"NationModel"); + $this->NationModel->addSelect(["nation_code as code","langtext"]); + $nation_res = $this->NationModel->load(); + if(isError($nation_res)){ + show_error("error while trying to query table codex.tbl_nation"); + } + $nation_res = hasData($nation_res) ? getData($nation_res) : null; + echo json_encode($nation_res); + + } + + //TODO: use the old query check to get the correct values to display for the user in case he selected the nation Austria (A) + /* if($_POST['nation']=='A') + { + if(is_numeric($_POST['plz']) && $_POST['plz']<32000) + { + $qry = "SELECT * FROM bis.tbl_gemeinde WHERE lower(name)=lower(".$db->db_add_param($_POST['gemeinde']).") + AND plz=".$db->db_add_param($_POST['plz']); + if($db->db_query($qry)) + { + if($row = $db->db_fetch_object()) + { + $adresse->gemeinde = $row->name; + } + else + { + $error = true; + $errormsg = 'Gemeinde ist ungueltig'; + $return = false; + } + } + else + { + $error = true; + $errormsg = 'Fehler beim Ermitteln der Gemeinde'; + $return = false; + } + } + else + { + $error = true; + $errormsg = 'Postleitzahl ist fuer diese Nation ungueltig'; + $return = false; + } + } */ + public function getAllGemeinden(){ + $this->load->model('public/Gemeinde_model',"NationModel"); + $this->NationModel->addSelect(["langtext"]); + $nation_res = $this->NationModel->load(); + if(isError($nation_res)){ + show_error("error while trying to query table codex.tbl_nation"); + } + $nation_res = hasData($nation_res) ? getData($nation_res) : null; + echo json_encode($nation_res); + + } //? queries the Mailverteiler of a benutzer @@ -564,9 +622,9 @@ class Profil extends Auth_Controller $adresse_res = null; if ( - isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort","zustelladresse"])) && + isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort","zustelladresse","gemeinde","nation"])) && isSuccess($adresse_res = $this->AdresseModel->addOrder("zustelladresse", "DESC")) && - isSuccess($adresse_res = $this->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz")) + isSuccess($adresse_res = $this->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz")) ) { $adresse_res = $this->AdresseModel->loadWhere(array("person_id" => $pid)); if (isError($adresse_res)) { diff --git a/public/js/apps/api/userdata.js b/public/js/apps/api/userdata.js index 8395c4ca8..1fdc9c661 100755 --- a/public/js/apps/api/userdata.js +++ b/public/js/apps/api/userdata.js @@ -1,13 +1,11 @@ export default { //! API Calls for Profil Views - - - getMitarbeiter: function (student_id) { + getAllNationen:function(){ const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + - `cis.php/api/v1/crm/Student/getStudent`; - return axios.get(url,{student_id:student_id}); + `cis.php/Cis/Profil/getAllNationen`; + return axios.get(url); }, getView: function (uid) { diff --git a/public/js/components/Cis/Profil/ProfilComponents/EditAdresse.js b/public/js/components/Cis/Profil/ProfilComponents/EditAdresse.js index 0726f8580..e6fb3877f 100755 --- a/public/js/components/Cis/Profil/ProfilComponents/EditAdresse.js +++ b/public/js/components/Cis/Profil/ProfilComponents/EditAdresse.js @@ -9,6 +9,7 @@ export default { inject:["zustellAdresseCount"], data(){ return{ + nationenList:[], originalValue:null, zustellAdressenCount:null, } @@ -61,6 +62,15 @@ export default { }, }, created(){ + + Vue.$fhcapi.UserData.getAllNationen().then(res => { + this.nationenList = res.data; + }); + + //? same for Gemeinde + /* Vue.$fhcapi.UserData.getAllNationen().then(res => { + this.nationenList = res.data; + }); */ this.originalValue = JSON.stringify(this.data); this.zustellAdressenCount = this.zustellAdresseCount(); @@ -96,6 +106,7 @@ export default { +
@@ -144,6 +155,25 @@ export default {
+
+
+
Gemeinde
+ + + +
+
+
+
+
nation
+ + +
+
`