diff --git a/Layout/default/AddressDB/Index.php b/Layout/default/AddressDB/Index.php
index 549314120..2bb4d1447 100644
--- a/Layout/default/AddressDB/Index.php
+++ b/Layout/default/AddressDB/Index.php
@@ -171,7 +171,14 @@
" />
-
+
+
@@ -225,6 +232,7 @@
Straße |
Hausnr. |
Stiege |
+ FCP |
Homes/Preorders |
Rimo-ID |
Rollout Jahr |
@@ -244,6 +252,7 @@
=$address->strasse->name?> |
=$address->hausnummer?> |
=$address->stiege?> |
+ =$address->rimo_fcp_name ?? 'N/A'?> |
=count($address->wohneinheiten)?>
tool_building_type == 1) ? "EFH" : "MPH")?>">
tool_building_type == 1) ? "fa-home" : "fa-building")?>">
@@ -276,29 +285,66 @@
-
+ const fcpSelect = $("#filter_fcp");
+ const networkSelect = $("#filter_network_id");
+ const apiUrl = "=self::getUrl("AddressDB", "api")?>";
+
+ const updateFcpSelect = (placeholder, data = []) => {
+ fcpSelect.empty().select2({ data, placeholder, allowClear: true });
+ };
+
+ updateFcpSelect("Bitte ein Netzgebiet auswählen");
+
+ networkSelect.on('change', function() {
+ const selectedNets = $(this).val() || [];
+ const hasNull = Array.isArray(selectedNets) && selectedNets.includes("null");
+
+ $('#filter-gemeinde-text, #filter-ortschaft-text').toggle(hasNull);
+ $('#filter-gemeinde-id, #filter-ortschaft-id').toggle(!hasNull);
+ $('#filter_gemeinde, #filter_ortschaft').val("");
+
+ if (hasNull) {
+ $('#filter-gemeinde-id, #filter-ortschaft-id').find('option:first').prop("selected", "selected");
+ }
+
+ if (selectedNets.length !== 1) {
+ updateFcpSelect(selectedNets.length > 1 ? "Bitte genau ein Netzgebiet auswählen" : "Kein Netzgebiet ausgewählt");
+ return;
+ }
+
+ const networkId = selectedNets[0];
+ if (networkId === 'null') {
+ updateFcpSelect("Kein Netzgebiet ausgewählt");
+ return;
+ }
+
+ $.get(apiUrl, { do: "getFCPsForNetwork", network_id: networkId }, (response) => {
+ if (response?.status === "OK" && Array.isArray(response.result)) {
+ let fcpData = response.result;
+ fcpData.unshift({ id: "", text: "" });
+
+ fcpData.sort((a, b) => {
+ const aN = a.text.replace(/\D/g, ""), bN = b.text.replace(/\D/g, "");
+ return aN && bN ? parseInt(aN, 10) - parseInt(bN, 10) : a.text.localeCompare(b.text);
+ });
+
+ updateFcpSelect("FCP auswählen", fcpData);
+
+ const fcpValues = new URLSearchParams(window.location.search).getAll("filter[rimo_fcp_name][]");
+ if (fcpValues.length > 0) {
+ fcpSelect.val(fcpValues).trigger("change");
+ }
+ } else {
+ updateFcpSelect("Keine FCPs gefunden");
+ }
+ }, "json").fail(() => {
+ updateFcpSelect("Fehler beim Laden");
+ });
+ }).trigger('change');
+ });
+
diff --git a/application/ADBHausnummer/ADBHausnummerModel.php b/application/ADBHausnummer/ADBHausnummerModel.php
index d3e771df3..d2993fd92 100644
--- a/application/ADBHausnummer/ADBHausnummerModel.php
+++ b/application/ADBHausnummer/ADBHausnummerModel.php
@@ -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;
}
diff --git a/application/AddressDB/AddressDBController.php b/application/AddressDB/AddressDBController.php
index bf79e30d0..fc5a73dfc 100644
--- a/application/AddressDB/AddressDBController.php
+++ b/application/AddressDB/AddressDBController.php
@@ -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)]) ?? []
+ );
+ }
+
}
\ No newline at end of file
|