added new fcp filter
This commit is contained in:
@@ -533,6 +533,35 @@ class ADBHausnummerModel {
|
||||
$where .= ")";
|
||||
}
|
||||
|
||||
if (array_key_exists("rimo_fcp_name", $filter)) {
|
||||
if (is_array($filter['rimo_fcp_name'])) {
|
||||
$escapedNames = array_map(function($name) {
|
||||
return "'" . FronkDB::singleton()->escape($name) . "'";
|
||||
}, $filter['rimo_fcp_name']);
|
||||
$where .= " AND Hausnummer.rimo_fcp_name IN (" . implode(", ", $escapedNames) . ")";
|
||||
} else {
|
||||
$rimo_fcp_name = FronkDB::singleton()->escape($filter['rimo_fcp_name']);
|
||||
if ($rimo_fcp_name) {
|
||||
$where .= " AND Hausnummer.rimo_fcp_name = '$rimo_fcp_name'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("fcp_id", $filter)) {
|
||||
if (is_array($filter['fcp_id'])) {
|
||||
$escapedIds = array_map(function($id) {
|
||||
return "'" . FronkDB::singleton()->escape($id) . "'";
|
||||
}, $filter['fcp_id']);
|
||||
$where .= " AND Hausnummer.fcp_id IN (" . implode(", ", $escapedIds) . ")";
|
||||
} else {
|
||||
$fcp_id = FronkDB::singleton()->escape($filter['fcp_id']);
|
||||
if ($fcp_id) {
|
||||
$where .= " AND Hausnummer.fcp_id = '$fcp_id'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,8 @@ class AddressDBController extends mfBaseController {
|
||||
|
||||
if(is_array($filter) && count($filter)) {
|
||||
foreach($filter as $name => $value) {
|
||||
if(strlen($value) > 0) $new_filter[$name] = $value;
|
||||
if (is_array($value) && count($value)) $new_filter[$name] = $value;
|
||||
else if(strlen($value) > 0) $new_filter[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,6 +822,9 @@ class AddressDBController extends mfBaseController {
|
||||
case 'getUnit':
|
||||
$return = $this->getUnitApi();
|
||||
break;
|
||||
case 'getFCPsForNetwork':
|
||||
$return = $this->getFCPsForNetworkApi();
|
||||
break;
|
||||
case "findUnit":
|
||||
break;
|
||||
default:
|
||||
@@ -1364,4 +1368,14 @@ class AddressDBController extends mfBaseController {
|
||||
return ["count" => count($buildings), "buildings" => $results];
|
||||
|
||||
}
|
||||
|
||||
protected function getFCPsForNetworkApi(): array {
|
||||
if (!$this->request->network_id) return [];
|
||||
|
||||
return array_map(
|
||||
fn($fcp) => ["id" => $fcp->name ?? null, "text" => $fcp->name ?? null, 'lat' => $fcp->gps_lat ?? null, 'lng' => $fcp->gps_long ?? null],
|
||||
ADBRimoFcp::getAll(["netzgebiet_id" => intval($this->request->network_id)]) ?? []
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user