Fixed always looking for empty string in stiege in submitPreorder()

This commit is contained in:
Frank Schubert
2024-05-17 16:16:29 +02:00
parent 630e618733
commit 80e4921b46
+10 -1
View File
@@ -422,7 +422,6 @@ class PreorderApicontroller extends mfBaseApicontroller {
$address_search_fields = [ $address_search_fields = [
'street' => 'strasse', 'street' => 'strasse',
'housenumber' => "hausnummer", 'housenumber' => "hausnummer",
'stiege' => "hausnummer_stiege",
'zip' => "plz" 'zip' => "plz"
]; ];
if($this->district_is_city) { if($this->district_is_city) {
@@ -436,6 +435,12 @@ class PreorderApicontroller extends mfBaseApicontroller {
$address_search[$field_name] = $this->db()->escape(trim($this->post['address']->$key)); $address_search[$field_name] = $this->db()->escape(trim($this->post['address']->$key));
} }
} }
if(property_exists($this->post['address'], "stiege") && trim($this->post['address']->stiege)) {
$address_search["hausnummer_stiege"] = $this->db()->escape(trim($this->post['address']->stiege));
} else {
$address_search["hausnummer_stiege"] = null;
}
$zusatz = false; $zusatz = false;
if($this->hausnummer_add_zusatz) { if($this->hausnummer_add_zusatz) {
@@ -511,6 +516,10 @@ class PreorderApicontroller extends mfBaseApicontroller {
$where = "1=1 "; $where = "1=1 ";
foreach($address_search as $field => $value) { foreach($address_search as $field => $value) {
if($field == "ortschaft" || $field == "gemeinde") continue; if($field == "ortschaft" || $field == "gemeinde") continue;
if($field == "hausnummer_stiege" && !$value) {
$where .= " AND (`hausnummer_stiege` = '' OR hausnummer_stiege IS NULL)";
continue;
}
$where .= " AND `$field` = '$value'"; $where .= " AND `$field` = '$value'";
} }