netzgebiet_id optional for admins; added HW/RW to preorder export

This commit is contained in:
Frank Schubert
2023-08-30 12:52:40 +02:00
parent f787014a4e
commit 9239599d65
5 changed files with 43 additions and 77 deletions
+23 -21
View File
@@ -14,31 +14,33 @@ class ADBHausnummer extends mfBaseModel {
$this->table = "Hausnummer";
}
/*
public static function parseAddresszusatz($text) {
$zusatz = "";
$text = trim($text);
if(!$text) return $data;
$text = " ".$text;
$m = [];
if(preg_match('/((?:gesch(?:ae|ä)ft|betrieb und wohnungen|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle)(?:\s+[a-z0-9]+)?)/i', $text, $m)) {
$zusatz = $m[1];
$text = str_replace($m[0], "", $text);
public function afterSave() {
if($this->netzgebiet_id && !$this->gps_long && !$this->gps_lat) {
$this->getGpsCoords();
}
}
private function getGpsCoords() {
$search = [
'country' => "AT",
'city' => $this->getProperty("strasse")->gemeinde->name,
'zip' => $this->getProperty("plz")->plz,
'street' => $this->getProperty("strasse")->name
];
if(!$search['country'] || !$search['city'] || !$search['zip'] || !$search['street']) {
$this->log->warning(__METHOD__.": Unable to retrieve GPS Coordinates. Search key missing (hausnummer_id: ".$this->id.")");
return false;
}
$coords = Gmaps_Geocoding::getCoords($search);
$text = trim(preg_replace('/\s{2,}/', "", $text));
if($text) {
$data['zusatz'] = $text;
if(is_array($coords) && count($coords) == 2 && $coords[0] && $coords[1]) {
$this->gps_lat = str_replace(",",".",$coords[0]);
$this->gps_long = str_replace(",",".",$coords[1]);
$this->save();
}
return $data;
}*/
return true;
}
public function getAddress() {
$address = "[".$this->getProperty("strasse")->gemeinde->name."]";