querying the right data for the EditAdresse Nation and Gemeinde Fields

This commit is contained in:
SimonGschnell
2024-02-20 15:57:17 +01:00
parent 6f7bca6eab
commit 1bed062a01
3 changed files with 93 additions and 7 deletions
+60 -2
View File
@@ -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)) {
+3 -5
View File
@@ -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) {
@@ -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 {
</div>
<div class="col-12 col-sm-9 col-xl-12 col-xxl-9 order-1">
<div class="form-underline ">
@@ -144,6 +155,25 @@ export default {
</div>
</div>
<div class="col-6 order-5">
<div class="form-underline ">
<div class="form-underline-titel">Gemeinde</div>
<input class="form-control" :value="data.gemeinde" @input="updateValue($event,'gemeinde')" :placeholder="data.gemeinde">
</div>
</div>
<div class="col-6 order-5 ">
<div class="form-underline ">
<div class="form-underline-titel">nation</div>
<select :value="data.nation" @change="updateValue($event,'nation')" class="form-select" aria-label="Select Kontakttyp">
<option selected></option>
<option :value="nation.code" v-for="nation in nationenList">{{nation.langtext}}</option>
</select>
</div>
</div>
</div>
`