mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 10:22:18 +00:00
adds the fields gemeinde and nation to the EditAdresse Component and adds autocomplete for the gemeinde if the nation is A
This commit is contained in:
@@ -25,6 +25,7 @@ class Profil extends Auth_Controller
|
||||
'getZustellAdresse' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'getZustellKontakt' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'getAllNationen' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'getGemeinden' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
|
||||
]);
|
||||
|
||||
@@ -366,49 +367,35 @@ class Profil extends Auth_Controller
|
||||
|
||||
}
|
||||
|
||||
//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;
|
||||
|
||||
public function getGemeinden(){
|
||||
|
||||
$nation = $this->input->get('nation',true);
|
||||
//? json_decode on zip to transform zip from string to integer
|
||||
$zip = json_decode($this->input->get('zip',true));
|
||||
|
||||
$this->load->model('codex/Gemeinde_model',"GemeindeModel");
|
||||
$this->GemeindeModel->addSelect(["name"]);
|
||||
if($nation == "A"){
|
||||
if(isset($zip) && $zip>999 && $zip <32000){
|
||||
|
||||
$gemeinde_res = $this->GemeindeModel->loadWhere(['ortschaftskennziffer'=>$zip]);
|
||||
if(isError($gemeinde_res)){
|
||||
show_error("error while trying to query bis.tbl_gemeinde");
|
||||
}
|
||||
$gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null;
|
||||
$gemeinde_res = array_map(function($obj){
|
||||
return $obj->name;
|
||||
},$gemeinde_res);
|
||||
echo json_encode($gemeinde_res);
|
||||
|
||||
}else{
|
||||
echo json_encode(error("ortschaftskennziffer code was not valid"));
|
||||
}
|
||||
else
|
||||
{
|
||||
$error = true;
|
||||
$errormsg = 'Fehler beim Ermitteln der Gemeinde';
|
||||
$return = false;
|
||||
}
|
||||
}else{
|
||||
echo json_encode(error("Nation was not 'A' (Austria)"));
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user