Added cluster_id to preorder API endpoints
This commit is contained in:
@@ -80,12 +80,13 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$city = trim($get['city']);
|
||||
$district = trim($get['district']);
|
||||
$zip = trim($get['zip']);
|
||||
$search_cluster_id = trim($get['cluster_id']);
|
||||
|
||||
if(!$city) {
|
||||
$city = $search;
|
||||
}
|
||||
|
||||
if(!$city && !$zip) {
|
||||
if(!$city && !$zip && !$search_cluster_id) {
|
||||
return mfResponse::BadRequest(['message' => "No search parameters"]);
|
||||
}
|
||||
|
||||
@@ -101,6 +102,10 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$city_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
}
|
||||
|
||||
if($search_cluster_id) {
|
||||
$city_search['netzgebiet_extref'] = $search_cluster_id;
|
||||
}
|
||||
|
||||
if($this->district_is_city) {
|
||||
$results = ADBOrtschaftModel::search($city_search);
|
||||
} else {
|
||||
@@ -122,10 +127,11 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = trim($get['search']);
|
||||
$city = trim($get['city']);
|
||||
$district = trim($get['district']);
|
||||
$zip = trim($get['zip']);
|
||||
$search = $this->db()->escape(trim($get['search']));
|
||||
$city = $this->db()->escape(trim($get['city']));
|
||||
$district = $this->db()->escape(trim($get['district']));
|
||||
$zip = $this->db()->escape(trim($get['zip']));
|
||||
$search_cluster_id = $this->db()->escape(trim($get['cluster_id']));
|
||||
|
||||
if(!$district) {
|
||||
$district = $search;
|
||||
@@ -138,23 +144,23 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$where = "1=1";
|
||||
|
||||
if($district && $district != "%") {
|
||||
$city_search = ['ortschaft%' => $district];
|
||||
$where .= " AND ortschaft like '$district%'";
|
||||
}
|
||||
if($city && $city != "%") {
|
||||
$city_search = ['name%' => $city];
|
||||
$where .= " AND gemeinde like '$city%'";
|
||||
}
|
||||
if($zip && $zip != "%") {
|
||||
$city_search['plz%'] = $zip;
|
||||
$where .= " AND plz like '$zip%'";
|
||||
}
|
||||
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$city_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
$where .= " AND netzgebiet_id IN (".join(", ", $this->filter_salescluster_ids).")";
|
||||
}
|
||||
|
||||
if($search_cluster_id) {
|
||||
$where .= " AND netzgebiet_extref='$search_cluster_id'";
|
||||
}
|
||||
|
||||
$cities = [];
|
||||
|
||||
$sql = "SELECT gemeinde, ortschaft FROM view_hausnummer WHERE $where GROUP BY gemeinde,ortschaft_id ORDER BY gemeinde, ortschaft";
|
||||
@@ -169,22 +175,6 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
}
|
||||
|
||||
/*foreach(ADBGemeindeModel::search($city_search) as $gem) {
|
||||
$districts = [];
|
||||
|
||||
if($district) {
|
||||
foreach(ADBOrtschaftModel::search(["gemeinde_id" => $gem->id, "name%" => $district]) as $ort) {
|
||||
$districts[] = $ort->name;
|
||||
}
|
||||
} else {
|
||||
foreach($gem->ortschaften as $ort) {
|
||||
$districts[] = $ort->name;
|
||||
}
|
||||
}
|
||||
|
||||
$cities[$gem->name] = $districts;
|
||||
}*/
|
||||
|
||||
return mfResponse::Ok(['cities' => $cities]);
|
||||
}
|
||||
|
||||
@@ -195,8 +185,9 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
// search parameter is unofficially deprecated but still supported
|
||||
$search = trim($get['search']);
|
||||
$zip = trim($get['zip']);
|
||||
$search_cluster_id = trim($get['cluster_id']);
|
||||
|
||||
if(!$search && !$zip) {
|
||||
if(!$search && !$zip && !$search_cluster_id) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
}
|
||||
|
||||
@@ -209,6 +200,11 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$zip_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
}
|
||||
|
||||
if($search_cluster_id) {
|
||||
$zip_search['netzgebiet_extref'] = $search_cluster_id;
|
||||
}
|
||||
|
||||
//var_dump($zip_search);exit;
|
||||
$results = ADBPlzModel::search($zip_search);
|
||||
|
||||
@@ -227,12 +223,13 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$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']);
|
||||
$zip = trim($get['zip']);
|
||||
$search = $this->db()->escape(trim($get['search']));
|
||||
$street = $this->db()->escape(trim($get['street']));
|
||||
$city = $this->db()->escape(trim($get['city']));
|
||||
$zip = $this->db()->escape(trim($get['zip']));
|
||||
$search_cluster_id = $this->db()->escape(trim($get['cluster_id']));
|
||||
|
||||
if(!$search && !$street && !$city && !$zip) {
|
||||
if(!$search && !$street && !$city && !$zip && !$search_cluster_id) {
|
||||
return mfResponse::BadRequest(['message' => "No search parameters"]);
|
||||
}
|
||||
|
||||
@@ -241,31 +238,26 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
$where = "1=1";
|
||||
$street_search = ["name%" => $street];
|
||||
$street = $this->db()->escape($street);
|
||||
$where .= " AND strasse like '$street%'";
|
||||
if($city) {
|
||||
if($this->district_is_city) {
|
||||
$street_search['ortschaft%'] = $city;
|
||||
$city = $this->db()->escape($city);
|
||||
$where .= " AND ortschaft like '$city%'";
|
||||
} else {
|
||||
$street_search['gemeinde%'] = $city;
|
||||
$city = $this->db()->escape($city);
|
||||
$where .= " AND gemeinde like '$city%'";
|
||||
}
|
||||
}
|
||||
if($zip) {
|
||||
$street_search['plz%'] = $zip;
|
||||
$zip = $this->db()->escape($zip);
|
||||
$where .= " AND plz like '$zip%'";
|
||||
}
|
||||
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$street_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
$where .= " AND netzgebiet_id IN (".join(", ", $this->filter_salescluster_ids).")";
|
||||
}
|
||||
|
||||
if($search_cluster_id) {
|
||||
$where .= " AND netzgebiet_extref='$search_cluster_id'";
|
||||
}
|
||||
|
||||
$streets = [];
|
||||
|
||||
$sql = "SELECT strasse FROM view_hausnummer WHERE $where GROUP BY strasse ORDER BY strasse";
|
||||
@@ -277,13 +269,6 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
}
|
||||
/*$results = ADBStrasseModel::search($street_search);
|
||||
|
||||
|
||||
|
||||
foreach($results as $result) {
|
||||
$streets[] = $result->name;
|
||||
}*/
|
||||
|
||||
$streets = array_unique($streets);
|
||||
sort($streets);
|
||||
@@ -373,6 +358,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$tmp_addresses[$address_key] = [
|
||||
'sort_key' => $sort_key,
|
||||
'oaid' => $data->hausnummer_oaid,
|
||||
'cluster_id' => $data->netzgebiet_extref,
|
||||
'zip' => $data->plz,
|
||||
'city' => ($this->district_is_city) ? $data->ortschaft : $data->gemeinde,
|
||||
'district' => $data->ortschaft,
|
||||
@@ -473,6 +459,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$new_address = [];
|
||||
$new_address['oaid'] = $u['oaid'];
|
||||
$new_address['building_oaid'] = $ta['oaid'];
|
||||
$new_address['cluster_id'] = $ta['cluster_id'];
|
||||
$new_address['street'] = $ta['street'];
|
||||
$new_address['housenumber'] = $ta['housenumber'];
|
||||
$new_address['zip'] = $ta['zip'];
|
||||
@@ -507,6 +494,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
// unofficially supporting GET and POST in v1
|
||||
$get = array_merge($this->post, $this->get);
|
||||
|
||||
$search_cluster_id = $this->db()->escape(trim($get['cluster_id']));
|
||||
$search_street = $this->db()->escape(trim($get['street']));
|
||||
$search_zip = $this->db()->escape(trim($get['zip']));
|
||||
$search_district = $this->db()->escape(trim($get['district']));
|
||||
@@ -549,11 +537,14 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id IN (".implode(",", $this->filter_salescluster_ids).")";
|
||||
}
|
||||
if($search_cluster_id) {
|
||||
$where .= " AND netzgebiet_extref='$search_cluster_idh'";
|
||||
}
|
||||
//echo $where;
|
||||
//var_dump($this->filter_salescluster_ids);exit;
|
||||
|
||||
$sql = AddressDB::$wohneinheit_query;
|
||||
$sql .= " WHERE $where ORDER BY plz, gemeinde, ortschaft, strasse, LENGTH(hausnummer), hausnummer, block, stiege, stock, LENGTH(num), num, LENGTH(tuer), tuer";
|
||||
$sql .= "\n WHERE $where ORDER BY plz, gemeinde, ortschaft, strasse, LENGTH(hausnummer), hausnummer, block, stiege, stock, LENGTH(num), num, LENGTH(tuer), tuer";
|
||||
|
||||
//$sql = "SELECT * FROM view_wohneinheit WHERE $where ORDER BY plz, gemeinde, ortschaft, strasse, LENGTH(hausnummer), hausnummer, block, stiege, stock, LENGTH(num), num, LENGTH(tuer), tuer";
|
||||
$this->log->debug($sql);
|
||||
@@ -590,6 +581,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
|
||||
$tmp_addresses[$address_key] = [
|
||||
'oaid' => $data->hausnummer_oaid,
|
||||
'cluster_id' => $data->netzgebiet_extref,
|
||||
'zip' => $data->plz,
|
||||
'city' => ($this->district_is_city) ? $data->ortschaft : $data->gemeinde,
|
||||
'district' => $data->ortschaft,
|
||||
@@ -629,6 +621,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$new_address = [];
|
||||
$new_address['oaid'] = $u['oaid'];
|
||||
$new_address['building_oaid'] = $ta['oaid'];
|
||||
$new_address['cluster_id'] = $ta['cluster_id'];
|
||||
$new_address['street'] = $ta['street'];
|
||||
$new_address['housenumber'] = $ta['housenumber'];
|
||||
$new_address['zip'] = $ta['zip'];
|
||||
|
||||
Reference in New Issue
Block a user