Hausnummer Frigabe is own table now

This commit is contained in:
Frank Schubert
2022-10-12 17:41:03 +02:00
parent 192e1323df
commit 58ff523492
10 changed files with 221 additions and 16 deletions
+15 -13
View File
@@ -210,22 +210,23 @@ class AddressdbApicontroller extends mfBaseApicontroller {
$sql = "SELECT * FROM view_wohneinheit WHERE $where ORDER BY plz, gemeinde, ortschaft, strasse, LENGTH(hausnummer), hausnummer, block, stiege, stock, LENGTH(tuer), tuer";
$res = $this->db()->query($sql);
$hausnummer_cache = [];
if($this->db()->num_rows($res)) {
while($data = $this->db()->fetch_object($res)) {
if(array_key_exists($data->hausnummer_id,$hausnummer_cache)) {
$hausnummer = $hausnummer_cache[$data->hausnummer_id];
} else {
$hausnummer = new ADBHausnummer($data->hausnummer_id);
$hausnummer_cache[$data->hausnummer_id] = $hausnummer;
}
if(!$hausnummer->id) continue;
$ptypes = [];
switch($data->freigabe) {
case "voll":
if(in_array("order", $this->allowed_preordertypes)) {
$ptypes[] = "order";
}
case "vorsorge":
if(in_array("provision", $this->allowed_preordertypes)) {
$ptypes[] = "provision";
}
case "interesse":
if(in_array("interest", $this->allowed_preordertypes)) {
$ptypes[] = "interest";
}
foreach($hausnummer->freigabe as $freigabe) {
if(in_array($freigabe, $this->allowed_preordertypes)) {
$ptypes[] = $freigabe;
}
}
$addresses[] = [
@@ -240,6 +241,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
'zusatz' => $data->zusatz,
'gps_lat' => $data->gps_lat,
'gps_long' => $data->gps_long,
'rollout_year' => ($data->rollout) ? (int)$data->rollout : null,
'preorderTypes' => $ptypes
];
}