diff --git a/application/ADBNetzgebiet/ADBNetzgebietModel.php b/application/ADBNetzgebiet/ADBNetzgebietModel.php index 1c6b566bd..a77c4a7d0 100644 --- a/application/ADBNetzgebiet/ADBNetzgebietModel.php +++ b/application/ADBNetzgebiet/ADBNetzgebietModel.php @@ -114,6 +114,15 @@ class ADBNetzgebietModel { private static function getSqlFilter($filter) { $where = "1=1 "; + if(array_key_exists("netzgebiet_id", $filter)) { + $netzgebiet_id = $filter['netzgebiet_id']; + if(is_numeric($netzgebiet_id)) { + $where .= " AND Netzgebiet.netzgebiet_id=$netzgebiet_id"; + } elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) { + $where .= " AND Netzgebiet.id IN (". implode(",", $netzgebiet_id).")"; + } + } + if(array_key_exists("name", $filter)) { $name = FronkDB::singleton()->escape($filter['name']); if($name) { diff --git a/application/Api/v1/AddressdbApicontroller.php b/application/Api/v1/AddressdbApicontroller.php index 4555701b3..6a64c3dec 100644 --- a/application/Api/v1/AddressdbApicontroller.php +++ b/application/Api/v1/AddressdbApicontroller.php @@ -11,6 +11,7 @@ class AddressdbApicontroller extends mfBaseApicontroller { protected function init() { $db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME); + $this->addRoute("/addressdb/getClusters", "getClusters", "GET"); $this->addRoute("/addressdb/findAddress", "find", "GET"); $this->addRoute("/addressdb/findAddress", "find", "POST"); $this->addRoute("/addressdb/searchAddress", "search", "GET"); @@ -71,6 +72,23 @@ class AddressdbApicontroller extends mfBaseApicontroller { } + protected function getClusters() { + $cluster_search = []; + if(count($this->filter_salescluster_ids)) { + $cluster_search['netzgebiet_id'] = $this->filter_salescluster_ids; + } + $clusters = []; + foreach(ADBNetzgebietModel::search($cluster_search) as $cluster) { + $c = []; + $c['id'] = $cluster->extref; + $c['name'] = $cluster->name; + $clusters[] = $c; + } + + return mfResponse::Ok(["clusters" => $clusters]); + + } + protected function findCity() { // unofficially supporting GET and POST in v1 $get = array_merge($this->post, $this->get);