WIP GWR Umbau mit Netzgebiet und Adressstatus

This commit is contained in:
Frank Schubert
2022-10-04 12:43:54 +02:00
parent 24840c04d1
commit 9db6ae59c3
12 changed files with 434 additions and 16 deletions
+25 -1
View File
@@ -13,7 +13,31 @@ class ADBHausnummer extends mfBaseModel {
//$this->strasse = new ADBStrasse($this->strasse_id);
//$this->plz = new ADBPlz($this->plz_id);
}
/*
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);
}
$text = trim(preg_replace('/\s{2,}/', "", $text));
if($text) {
$data['zusatz'] = $text;
}
return $data;
}*/
public function getProperty($name) {
if($this->$name == null) {
@@ -1,11 +1,15 @@
<?php
class ADBHausnummerModel {
public $netzgebiet_id;
public $extref;
public $ortschaft_id;
public $plz_id;
public $strasse_id;
public $kennziffer;
public $name;
public $hausnummer;
public $zusatz;
public $gps_lat;
public $gps_long;
public $create_by = null;
public $edit_by = null;
@@ -0,0 +1,51 @@
<?php
class ADBNetzgebiet extends mfBaseModel {
protected function init() {
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->table = "Netzgebiet";
}
public function loadByExtref($extref) {
$extref = $this->db->escape(trim($extref));
if(!$extref) {
return false;
}
$res = $this->db->select("Netzgebiet", "*", "extref='$extref'");
if(!$this->db->num_rows($res)) {
return false;
}
$data = $this->db->fetch_object($res);
$this->load($data);
return true;
}
public function getProperty($name) {
if($this->$name == null) {
if($name == "strasse") {
$this->strasse = new ADBStrasse($this->strasse_id);
return $this->strasse;
}
if($name == "plz") {
$this->plz = new ADBPlz($this->plz_id);
return $this->plz;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}
@@ -115,8 +115,6 @@ class ADBOrtschaftModel {
private static function getSqlFilter($filter) {
$where = "1=1 ";
if(array_key_exists("gemeinde_id", $filter)) {
$gemeinde_id = $filter['gemeinde_id'];
@@ -137,9 +135,14 @@ class ADBOrtschaftModel {
}
if(array_key_exists("name", $filter)) {
$name = FronkDB::singleton()->escape($filter['name']);
if($name) {
$where .= " AND Ortschaft.`name` = '$name'";
if(is_array($filter['name'])) {
$name = $filter['name'];
$where .= " AND Ortschaft.name IN ('". implode("','", $name)."')";
} else {
$name = FronkDB::singleton()->escape($filter['name']);
if($name) {
$where .= " AND Ortschaft.`name` = '$name'";
}
}
}
+1
View File
@@ -1,6 +1,7 @@
<?php
class ADBPlzModel {
public $gemeinde_id;
public $plz;
public $plzstring;
@@ -1,11 +1,14 @@
<?php
class ADBWohneinheitModel {
public $extref;
public $hausnummer_id;
public $num;
public $block;
public $stiege;
public $stock;
public $tuer;
public $zusatz;
public $nutzung;
public $create_by = null;
+21
View File
@@ -9,4 +9,25 @@ class AddressDB {
$this->log = mfLoghandler::singleton();
}
public function import($input) {
$path = __DIR__."/Importer/";
$dir = opendir($path);
while(($file = readdir($dir)) !== false) {
if(substr($file, 0, 1) == ".") continue;
if(substr($file, -4) != ".php") continue;
if(!is_file($path.$file)) continue;
require_once $path.$file;
$classname = "AddressDB_Importer_".ucfirst(substr($file, 0, strlen($file)-4));
if(class_exists($classname)) {
$importer = new $classname();
if($importer->isValid($input)) {
return $importer->import();
}
}
}
}
}
@@ -13,11 +13,7 @@ class AddressDBController extends mfBaseController {
$this->redirect("Dashboard");
}
}
protected function importAction($input) {
}
protected function apiAction() {
if(!$this->me->is(["Admin","netowner"])) {
$this->redirect("Dashboard");
+14 -1
View File
@@ -4,12 +4,25 @@ class AddressDB_Importer_Csv {
private $db;
private $log;
private $input;
public function __construct() {
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->log = mfLoghandler::singleton();
}
public function import($input) {
public function isValid($input) {
if(strlen($input) < 1024 && strpos($input, "\n") === false) {
$this->input = $input;
return true;
}
return false;
}
public function import() {
echo "importing...\n";exit;
$input = $this->input;
if(!$input) {
return false;
}
+1 -1
View File
@@ -6,7 +6,7 @@ class AddressDB_Importer_Rimo {
private $campaign;
public function __construct(Preordercampain $campaign) {
public function __construct() {
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->log = mfLoghandler::singleton();
}
@@ -35,8 +35,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
}
protected function findCity() {
// unofficially supporting GET and POST in v1
$get = array_merge($this->post, $this->get);
// search parameter is unofficially deprecated but still supported
$search = trim($get['search']);
$city = trim($get['city']);
$zip = trim($get['zip']);
@@ -67,8 +69,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
}
protected function findZip() {
// unofficially supporting GET and POST in v1
$get = array_merge($this->post, $this->get);
// search parameter is unofficially deprecated but still supported
$search = trim($get['search']);
$zip = trim($get['zip']);
@@ -93,8 +97,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
}
protected function findStreet() {
// unofficially supporting GET and POST in v1
$get = array_merge($this->post, $this->get);
// search parameter is unofficially deprecated but still supported
$search = trim($get['search']);
$street = trim($get['street']);
$city = trim($get['city']);
@@ -129,6 +135,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
}
protected function find() {
// unofficially supporting GET and POST in v1
$get = array_merge($this->post, $this->get);
$search_street = $this->db()->escape(trim($get['street']));