From f94c622839cdab36788e463a5dc10734a20494d6 Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Thu, 12 Jun 2025 12:31:52 +0200 Subject: [PATCH] added rml unscheduled check --- .../ADBWohneinheitController.php | 19 ++++--- .../ADBWohneinheit/ADBWohneinheitModel.php | 57 ++++++++++++++++++- .../ADBWohneinheitDuplicate.js | 1 + 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/application/ADBWohneinheit/ADBWohneinheitController.php b/application/ADBWohneinheit/ADBWohneinheitController.php index 1289a5e6e..b988db58e 100644 --- a/application/ADBWohneinheit/ADBWohneinheitController.php +++ b/application/ADBWohneinheit/ADBWohneinheitController.php @@ -201,14 +201,10 @@ class ADBWohneinheitController extends mfBaseController { ADBWohneinheitModel::getRimoDeletedHomes([], $address_id) ); - $ADBNetzgebiete = array_map(function($network) { - return [ - "value" => $network->id, - "text" => $network->name, - ]; - }, ADBNetzgebietModel::getAll()); + if ($address_id === "4807" || $this->me->is("Admin")) $duplicateHomes = array_merge($duplicateHomes, ADBWohneinheitModel::getUnscheduledOrderHomes([], 4807)); $networkOwners = []; + $networks = []; foreach ($duplicateHomes as $home) { if ($home['netzgebiet_owner'] && !in_array($home['netzgebiet_owner'], array_column($networkOwners, 'value'))) { $networkOwners[] = [ @@ -216,6 +212,15 @@ class ADBWohneinheitController extends mfBaseController { "text" => $home['netzgebiet_owner'], ]; } + + if ($home['netzgebiet_id'] && !in_array($home['netzgebiet_id'], array_column($networks, 'value'))) { + $network = new ADBNetzgebiet($home['netzgebiet_id']); + $networks[] = [ + "value" => $home['netzgebiet_id'], + "text" => $network->name, + ]; + } + } $JSGlobals = ["BASE_URL" => self::getUrl(""), @@ -227,7 +232,7 @@ class ADBWohneinheitController extends mfBaseController { ["text" => "Doppelte Homes", "href" => self::getUrl("ADBWohneinheit", "duplicate")], ], "DUPLICATE_HOMES" => $duplicateHomes, - "ADB_NETZGEBIETE" => $ADBNetzgebiete, + "ADB_NETZGEBIETE" => $networks, "NETWORK_OWNERS" => $networkOwners, "IS_ADMIN" => $this->me->is("Admin"), ]; diff --git a/application/ADBWohneinheit/ADBWohneinheitModel.php b/application/ADBWohneinheit/ADBWohneinheitModel.php index 5de313a87..521f9aff6 100644 --- a/application/ADBWohneinheit/ADBWohneinheitModel.php +++ b/application/ADBWohneinheit/ADBWohneinheitModel.php @@ -447,7 +447,7 @@ class ADBWohneinheitModel { $counter = 0; $detailRes = $db->query($detailSql); while($homeData = $detailRes->fetch_assoc()) { - if (!$homeData['netzgebiet_owner']) continue; // Skip if no owner is set + if (!$homeData['netzgebiet_owner']) continue; // Skip if no owner is set $counter++; $deletedHomes[$counter] = [ "duplicateType" => "rimo_deleted", @@ -475,5 +475,58 @@ class ADBWohneinheitModel { } return array_values($deletedHomes); - } + } + + public static function getUnscheduledOrderHomes($filter = [], $network_owner = null) { + $deletedHomes = []; + $db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME)->link; + $where = self::getSqlFilter($filter); + + if ($network_owner) $where .= " AND Network.owner_id = '" . FronkDB::singleton()->escape($network_owner) . "'"; + + $detailSql = "SELECT Wohneinheit.*, thetool.Address.company AS company, Hausnummer.rimo_id AS hausnummer_extref, Netzgebiet.name AS netzgebiet_name, Netzgebiet.id AS netzgebiet_id, Address.company as netzgebiet_owner + + FROM ". ADDRESSDB_DBNAME .".Wohneinheit + LEFT JOIN ". ADDRESSDB_DBNAME .".Hausnummer ON (Hausnummer.id = Wohneinheit.hausnummer_id) + LEFT JOIN ". ADDRESSDB_DBNAME .".Netzgebiet ON (Netzgebiet.id = Hausnummer.netzgebiet_id) + LEFT JOIN ". FRONKDB_DBNAME .".Network ON (Network.adb_netzgebiet_id = Netzgebiet.id) + LEFT JOIN ". FRONKDB_DBNAME .".Address ON (Network.owner_id = Address.id) + LEFT JOIN ". FRONKDB_DBNAME .".Preorder ON (Preorder.adb_wohneinheit_id = Wohneinheit.id) + LEFT JOIN ". FRONKDB_DBNAME .".Preorderstatus ON (Preorderstatus.id = Preorder.status_id) + WHERE $where AND Hausnummer.rollout_info LIKE '%unscheduled%' AND Preorder.id IS NOT NULL AND Preorderstatus.code < 501 + ORDER BY Wohneinheit.oaid"; + + $counter = 0; + $detailRes = $db->query($detailSql); + while($homeData = $detailRes->fetch_assoc()) { + if (!$homeData['netzgebiet_owner']) continue; // Skip if no owner is set + $counter++; + $deletedHomes[$counter] = [ + "duplicateType" => "rml_unscheduled_with_order", + 'oaid' => $homeData['oaid'] ?? 'Keine OAID', + 'extref' => $homeData['extref'], + 'netzgebiet_id' => $homeData['netzgebiet_id'], + 'netzgebiet_owner' => $homeData['netzgebiet_owner'], + 'count' => 1, // Each entry is unique in this context + 'homeData' => [] + ]; + $deletedHomes[$counter]['homeData'][] = [ + "id" => $homeData['id'], + 'oaid' => $homeData['oaid'] ?? 'Keine OAID', + "extref" => $homeData['extref'], + "network_company" => $homeData['company'], + "hausnummer_id" => $homeData['hausnummer_id'], + "hausnummer_extref" => $homeData['hausnummer_extref'], + "num" => $homeData['num'], + "nutzung" => $homeData['nutzung'], + "rimo_ex_state" => $homeData['rimo_ex_state'], + "rimo_op_state" => $homeData['rimo_op_state'], + "create" => $homeData['create'], + "edit" => $homeData['edit'], + ]; + } + + return array_values($deletedHomes); + } + } diff --git a/public/js/pages/ADBWohneinheitDuplicate/ADBWohneinheitDuplicate.js b/public/js/pages/ADBWohneinheitDuplicate/ADBWohneinheitDuplicate.js index bb9602b10..53467c1f9 100644 --- a/public/js/pages/ADBWohneinheitDuplicate/ADBWohneinheitDuplicate.js +++ b/public/js/pages/ADBWohneinheitDuplicate/ADBWohneinheitDuplicate.js @@ -76,6 +76,7 @@ Vue.component('a-d-b-wohneinheit-duplicate', { {text: 'HomeID', value: 'extref'}, {text: 'OAID', value: 'oaid'}, {text: 'RIMO gelöscht', value: 'rimo_deleted'}, + {text: 'Unsch. + BE', value: 'rml_unscheduled_with_order'}, ]}, {text: 'Anz. HomeIDs', key: 'count', sortable: true, class: 'text-center', priority: 8}, {