Pop Feature Updates
* Vorbereitung für erweiterte Faserdarstellungen * Pop Map Übersicht * Leere Pop Kategorien werden nun als Unbekannt dargestellt
This commit is contained in:
@@ -17,6 +17,25 @@ class PopController extends mfBaseController
|
||||
}
|
||||
}
|
||||
|
||||
private function getMapCategories()
|
||||
{
|
||||
$categories = [];
|
||||
foreach (PopModel::$categoryArray as $id => $cat) {
|
||||
$categories[] = [
|
||||
'id' => $id,
|
||||
'name' => $cat['name'],
|
||||
'icon' => 'assets/img/markers/pop_' . $id . '.png',
|
||||
];
|
||||
}
|
||||
|
||||
$categories[] = [
|
||||
'id' => null,
|
||||
'name' => 'Unbekannt',
|
||||
'icon' => 'assets/img/markers/pop_unknown.png',
|
||||
];
|
||||
return $categories;
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
$networks = array_map(function ($network) {
|
||||
@@ -30,7 +49,7 @@ class PopController extends mfBaseController
|
||||
return [
|
||||
"id" => $pop->id,
|
||||
"name" => $pop->name,
|
||||
"category" => $pop->category,
|
||||
"category" => $pop->category ?: 99,
|
||||
"networkArea" => $pop->networks,
|
||||
"location" => $pop->location,
|
||||
"state" => $pop->state,
|
||||
@@ -45,6 +64,8 @@ class PopController extends mfBaseController
|
||||
];
|
||||
}, PopModel::getAlladv());
|
||||
|
||||
$categories = $this->getMapCategories();
|
||||
|
||||
$JSGlobals = ["BASE_URL" => self::getUrl(""),
|
||||
"DASHBOARD_URL" => self::getUrl("Dashboard"),
|
||||
"MFAPPNAME" => MFAPPNAME_SLUG,
|
||||
@@ -55,11 +76,20 @@ class PopController extends mfBaseController
|
||||
],
|
||||
"NETWORKS" => $networks,
|
||||
"POPS" => $pops,
|
||||
"CATEGORIES" => $categories,
|
||||
"IS_ADMIN" => $this->me->is("Admin"),
|
||||
"MAPBOX_TOKEN" => TT_MAPBOX_TILE_API_TOKEN,
|
||||
];
|
||||
|
||||
$this->layout()->set("vueViewName", "Pop");
|
||||
$this->layout()->set("JSGlobals", $JSGlobals);
|
||||
$this->layout()->set("additionalCSS", [
|
||||
"assets/css/leaflet.css",
|
||||
]);
|
||||
$this->layout()->set("additionalJS", [
|
||||
"assets/js/leaflet.js",
|
||||
"assets/js/leaflet.MakiMarkers.js"
|
||||
]);
|
||||
$this->layout()->setTemplate("VueViews/Vue");
|
||||
|
||||
}
|
||||
@@ -112,6 +142,7 @@ class PopController extends mfBaseController
|
||||
{
|
||||
$network_id = 90;
|
||||
$this->layout()->set("network_id", $network_id);
|
||||
$this->layout()->set("categories", $this->getMapCategories());
|
||||
$this->layout()->setTemplate("Pop/Map");
|
||||
}
|
||||
|
||||
@@ -258,28 +289,23 @@ class PopController extends mfBaseController
|
||||
$home_id = $this->request->home_id;
|
||||
|
||||
if (!$fiber_id && !$home_id) {
|
||||
return mfBaseController::returnJson(mfResponse::BadRequest(['message' => 'Ungültige Faser-ID oder Home-ID']));
|
||||
return mfBaseController::returnJson(mfResponse::BadRequest(['message' => 'Ungültige ID']));
|
||||
}
|
||||
|
||||
if ($home_id) {
|
||||
if ($home_id && !$fiber_id) {
|
||||
$sql = "SELECT id FROM FiberPlanFiber WHERE home_id = '" . $db->escape($home_id) . "' LIMIT 1";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
$row = $db->fetch_array($res);
|
||||
$fiber_id = $row['id'];
|
||||
} else {
|
||||
return mfBaseController::returnJson(mfResponse::NotFound(['message' => 'Keine Faser für Home-ID gefunden']));
|
||||
}
|
||||
}
|
||||
|
||||
$fiber = new FiberPlanFiber($fiber_id);
|
||||
|
||||
if (!$fiber->id) {
|
||||
return mfBaseController::returnJson(mfResponse::NotFound(['message' => 'Faser nicht gefunden']));
|
||||
}
|
||||
|
||||
$this->log->debug("Lade Faser-Strecke für Faser ID: $fiber_id");
|
||||
|
||||
$details = $fiber->toArray();
|
||||
$details['customer_cable_type'] = $fiber->customer_cable_type;
|
||||
$details['customer_cable_fiber_nr'] = $fiber->customer_cable_fiber_nr;
|
||||
@@ -293,26 +319,217 @@ class PopController extends mfBaseController
|
||||
|
||||
if ($fiber->address || $fiber->home_id) {
|
||||
$customerGps = $this->geocodeAddress($fiber->address, $fiber->home_id);
|
||||
if ($customerGps) {
|
||||
$details['customer_gps'] = $customerGps;
|
||||
$this->log->debug("GPS für Kunde gefunden: " . json_encode($customerGps));
|
||||
}
|
||||
if ($customerGps) $details['customer_gps'] = $customerGps;
|
||||
}
|
||||
|
||||
$debug = [];
|
||||
$debug['start_fiber'] = [
|
||||
'id' => $fiber->id,
|
||||
'fiber_nr_cable' => $fiber->fiber_nr_cable,
|
||||
'branch_type' => $fiber->branch_type,
|
||||
'branch_cable_nr' => $fiber->branch_cable_nr,
|
||||
'branch_fiber_nr' => $fiber->branch_fiber_nr
|
||||
];
|
||||
|
||||
if ($home_id) {
|
||||
$this->log->debug("=== MODUS: Rückwärts-Trace (von home_id) ===");
|
||||
$cableChain = $this->buildCompleteCableChain($fiber);
|
||||
if (count($cableChain) > 0) {
|
||||
$mainCable = $cableChain[0]['cable'];
|
||||
$mainFiber = $cableChain[0]['fiber'];
|
||||
$cable_route_data = FiberPlanCableModel::getCableRoute($mainCable->id);
|
||||
$cable_route_array = [];
|
||||
foreach ($cable_route_data as $station) $cable_route_array[] = $station['name'];
|
||||
$allFibers = FiberPlanFiberModel::getByCableAndSheet($mainCable->id, null);
|
||||
$fibersArray = [];
|
||||
foreach ($allFibers as $f) {
|
||||
$fibersArray[] = [
|
||||
'id' => $f->id, 'fiber_nr_cable' => $f->fiber_nr_cable,
|
||||
'fiber_color' => $f->fiber_color, 'fiber_color_hex' => $f->fiber_color_hex,
|
||||
'bundle_nr' => $f->bundle_nr, 'bundle_color' => $f->bundle_color, 'bundle_color_hex' => $f->bundle_color_hex,
|
||||
'branch_type' => $f->branch_type, 'branch_cable_nr' => $f->branch_cable_nr,
|
||||
'branch_from_location' => $f->branch_from_location, 'branch_fiber_nr' => $f->branch_fiber_nr
|
||||
];
|
||||
}
|
||||
|
||||
$branchPoints = [];
|
||||
$sql = "SELECT id, description as name, gps_lat, gps_long, object_type, 'dispatcher' as type
|
||||
FROM FiberPlanDispatcher WHERE network_id = 90 AND object_type = 4 AND gps_lat IS NOT NULL";
|
||||
$res = $db->query($sql);
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$branchPoints[] = ['id' => $data['id'], 'name' => $data['name'], 'gps_lat' => $data['gps_lat'], 'gps_long' => $data['gps_long'], 'object_type' => intval($data['object_type']), 'type' => $data['type']];
|
||||
}
|
||||
|
||||
$details['cable_info'] = [
|
||||
'id' => $mainCable->id, 'description' => $mainCable->description, 'fibers' => $fibersArray,
|
||||
'diameter' => $mainCable->diameter, 'cable_route_array' => $cable_route_array,
|
||||
'cable_route_full' => $cable_route_data, 'coordinates' => $mainCable->coordinates,
|
||||
'location' => $mainFiber->location, 'branch_points' => $branchPoints
|
||||
];
|
||||
|
||||
$allCablesForMatching = [];
|
||||
foreach ($cableChain as $chainItem) {
|
||||
$c = $chainItem['cable'];
|
||||
$coords = json_decode($c->coordinates, true);
|
||||
if ($coords) $allCablesForMatching[] = ['id' => $c->id, 'description' => $c->description, 'coordinates' => $coords];
|
||||
}
|
||||
$sql = "SELECT id, description, coordinates FROM FiberPlanCable WHERE network_id = 90 AND coordinates IS NOT NULL AND coordinates != '' AND coordinates != '[]'";
|
||||
$res = $db->query($sql);
|
||||
while ($c = $db->fetch_array($res)) {
|
||||
$coords = json_decode($c['coordinates'], true);
|
||||
if ($coords) {
|
||||
$exists = false; foreach($allCablesForMatching as $ex) { if($ex['id'] == $c['id']) $exists=true; }
|
||||
if(!$exists) $allCablesForMatching[] = ['id' => $c['id'], 'description' => $c['description'], 'coordinates' => $coords];
|
||||
}
|
||||
}
|
||||
$details['all_cables'] = $allCablesForMatching;
|
||||
}
|
||||
|
||||
if (count($cableChain) > 1) {
|
||||
$details['branch_path'] = $this->buildBranchPathFromChain($cableChain, 1, $debug);
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->log->debug("=== MODUS: Vorwärts-Trace ===");
|
||||
|
||||
if ($fiber->cable_id) {
|
||||
$cable = new FiberPlanCable($fiber->cable_id);
|
||||
if ($cable->id) {
|
||||
$cable_route_data = FiberPlanCableModel::getCableRoute($cable->id);
|
||||
$cable_route_array = [];
|
||||
foreach ($cable_route_data as $station) $cable_route_array[] = $station['name'];
|
||||
|
||||
$branchPoints = [];
|
||||
$sql = "SELECT id, description as name, gps_lat, gps_long, object_type, 'dispatcher' as type
|
||||
FROM FiberPlanDispatcher WHERE network_id = 90 AND object_type = 4 AND gps_lat IS NOT NULL";
|
||||
$res = $db->query($sql);
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$branchPoints[] = ['id' => $data['id'], 'name' => $data['name'], 'gps_lat' => $data['gps_lat'], 'gps_long' => $data['gps_long'], 'object_type' => intval($data['object_type']), 'type' => $data['type']];
|
||||
}
|
||||
|
||||
$allFibers = FiberPlanFiberModel::getByCableAndSheet($cable->id, null);
|
||||
$fibersArray = [];
|
||||
foreach ($allFibers as $f) {
|
||||
$fibersArray[] = [
|
||||
'id' => $f->id, 'fiber_nr_cable' => $f->fiber_nr_cable, 'fiber_color' => $f->fiber_color, 'fiber_color_hex' => $f->fiber_color_hex,
|
||||
'bundle_nr' => $f->bundle_nr, 'bundle_color' => $f->bundle_color, 'bundle_color_hex' => $f->bundle_color_hex,
|
||||
'branch_type' => $f->branch_type, 'branch_cable_nr' => $f->branch_cable_nr,
|
||||
'branch_from_location' => $f->branch_from_location, 'branch_fiber_nr' => $f->branch_fiber_nr
|
||||
];
|
||||
}
|
||||
|
||||
$details['cable_info'] = [
|
||||
'id' => $cable->id, 'description' => $cable->description, 'fibers' => $fibersArray,
|
||||
'diameter' => $cable->diameter, 'cable_route_array' => $cable_route_array,
|
||||
'cable_route_full' => $cable_route_data, 'coordinates' => $cable->coordinates,
|
||||
'location' => $fiber->location, 'branch_points' => $branchPoints
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ($fiber->branch_type === 'Abzweigkabel' && $fiber->branch_cable_nr) {
|
||||
$details['branch_path'] = $this->traceBranchPath($fiber, 0, 10, $debug);
|
||||
}
|
||||
|
||||
$allCablesForMatching = [];
|
||||
$sql = "SELECT id, description, coordinates FROM FiberPlanCable WHERE network_id = 90 AND coordinates IS NOT NULL AND coordinates != '' AND coordinates != '[]'";
|
||||
$res = $db->query($sql);
|
||||
while ($c = $db->fetch_array($res)) {
|
||||
$coords = json_decode($c['coordinates'], true);
|
||||
if ($coords) $allCablesForMatching[] = ['id' => $c['id'], 'description' => $c['description'], 'coordinates' => $coords];
|
||||
}
|
||||
$details['all_cables'] = $allCablesForMatching;
|
||||
}
|
||||
|
||||
$details['debug'] = $debug;
|
||||
return mfBaseController::returnJson(mfResponse::Ok(['fiber' => $details]));
|
||||
}
|
||||
|
||||
protected function getAllFiberPathsForHomeAction()
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
$home_id = $this->request->home_id;
|
||||
|
||||
if (!$home_id) {
|
||||
return mfBaseController::returnJson(mfResponse::BadRequest(['message' => 'Ungültige Home-ID']));
|
||||
}
|
||||
|
||||
$sql = "SELECT id FROM FiberPlanFiber WHERE home_id = '" . $db->escape($home_id) . "'";
|
||||
$res = $db->query($sql);
|
||||
|
||||
$fiberIds = [];
|
||||
if ($db->num_rows($res)) {
|
||||
while ($row = $db->fetch_array($res)) {
|
||||
$fiberIds[] = $row['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($fiberIds)) {
|
||||
return mfBaseController::returnJson(mfResponse::NotFound(['message' => 'Keine Fasern für Home-ID gefunden']));
|
||||
}
|
||||
|
||||
$globalBranchPoints = [];
|
||||
$sqlBP = "SELECT id, description as name, gps_lat, gps_long, object_type, 'dispatcher' as type
|
||||
FROM FiberPlanDispatcher
|
||||
WHERE network_id = 90 AND object_type IN (1,2,3,4)
|
||||
AND gps_lat IS NOT NULL AND gps_long IS NOT NULL";
|
||||
$resBP = $db->query($sqlBP);
|
||||
if ($db->num_rows($resBP)) {
|
||||
while ($data = $db->fetch_array($resBP)) {
|
||||
$globalBranchPoints[] = [
|
||||
'id' => $data['id'],
|
||||
'name' => $data['name'],
|
||||
'gps_lat' => $data['gps_lat'],
|
||||
'gps_long' => $data['gps_long'],
|
||||
'object_type' => intval($data['object_type']),
|
||||
'type' => $data['type']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$globalCablesWithCoords = [];
|
||||
$sqlCables = "SELECT id, description, coordinates
|
||||
FROM FiberPlanCable
|
||||
WHERE network_id = 90
|
||||
AND coordinates IS NOT NULL
|
||||
AND coordinates != ''
|
||||
AND coordinates != '[]'";
|
||||
$resCables = $db->query($sqlCables);
|
||||
while ($cableData = $db->fetch_array($resCables)) {
|
||||
$coords = json_decode($cableData['coordinates'], true);
|
||||
if ($coords && is_array($coords) && count($coords) > 0) {
|
||||
$globalCablesWithCoords[] = [
|
||||
'id' => $cableData['id'],
|
||||
'description' => $cableData['description'],
|
||||
'coordinates' => $coords
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$allPaths = [];
|
||||
|
||||
foreach ($fiberIds as $fiber_id) {
|
||||
$fiber = new FiberPlanFiber($fiber_id);
|
||||
if (!$fiber->id) continue;
|
||||
$details = $fiber->toArray();
|
||||
$details['customer_cable_type'] = $fiber->customer_cable_type;
|
||||
$details['customer_cable_fiber_nr'] = $fiber->customer_cable_fiber_nr;
|
||||
$details['customer_connector_type'] = $fiber->customer_connector_type;
|
||||
$details['customer_cable_spec'] = $fiber->customer_cable_spec;
|
||||
$details['customer_fiber_range'] = $fiber->customer_fiber_range;
|
||||
$details['bundle_nr'] = $fiber->bundle_nr;
|
||||
$details['bundle_color'] = $fiber->bundle_color;
|
||||
$details['bundle_color_hex'] = $fiber->bundle_color_hex;
|
||||
$details['fiber_nr_bundle'] = $fiber->fiber_nr_bundle;
|
||||
|
||||
if ($fiber->address || $fiber->home_id) {
|
||||
$customerGps = $this->geocodeAddress($fiber->address, $fiber->home_id);
|
||||
if ($customerGps) {
|
||||
$details['customer_gps'] = $customerGps;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = [];
|
||||
$debug['start_fiber'] = [
|
||||
'id' => $fiber->id,
|
||||
'fiber_nr_cable' => $fiber->fiber_nr_cable,
|
||||
'branch_type' => $fiber->branch_type
|
||||
];
|
||||
|
||||
$cableChain = $this->buildCompleteCableChain($fiber);
|
||||
$debug['cable_chain_count'] = count($cableChain);
|
||||
|
||||
$debug['cable_chain'] = array_map(function($item) {
|
||||
return [
|
||||
'cable_id' => $item['cable']->id,
|
||||
@@ -333,12 +550,17 @@ class PopController extends mfBaseController
|
||||
$cable_route_array[] = $station['name'];
|
||||
}
|
||||
|
||||
$allFibers = FiberPlanFiberModel::getByCableAndSheet($mainCable->id, null);
|
||||
$allMainFibers = FiberPlanFiberModel::getByCableAndSheet($mainCable->id, null);
|
||||
$fibersArray = [];
|
||||
foreach ($allFibers as $f) {
|
||||
foreach ($allMainFibers as $f) {
|
||||
$fibersArray[] = [
|
||||
'id' => $f->id,
|
||||
'fiber_nr_cable' => $f->fiber_nr_cable,
|
||||
'fiber_color' => $f->fiber_color,
|
||||
'fiber_color_hex' => $f->fiber_color_hex,
|
||||
'bundle_nr' => $f->bundle_nr,
|
||||
'bundle_color' => $f->bundle_color,
|
||||
'bundle_color_hex' => $f->bundle_color_hex,
|
||||
'branch_type' => $f->branch_type,
|
||||
'branch_cable_nr' => $f->branch_cable_nr,
|
||||
'branch_from_location' => $f->branch_from_location,
|
||||
@@ -346,26 +568,6 @@ class PopController extends mfBaseController
|
||||
];
|
||||
}
|
||||
|
||||
$branchPoints = [];
|
||||
$sql = "SELECT id, description as name, gps_lat, gps_long, object_type, 'dispatcher' as type
|
||||
FROM FiberPlanDispatcher
|
||||
WHERE network_id = 90 AND object_type = 4
|
||||
AND gps_lat IS NOT NULL AND gps_long IS NOT NULL";
|
||||
$res = $db->query($sql);
|
||||
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$branchPoints[] = [
|
||||
'id' => $data['id'],
|
||||
'name' => $data['name'],
|
||||
'gps_lat' => $data['gps_lat'],
|
||||
'gps_long' => $data['gps_long'],
|
||||
'object_type' => intval($data['object_type']),
|
||||
'type' => $data['type']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$details['cable_info'] = [
|
||||
'id' => $mainCable->id,
|
||||
'description' => $mainCable->description,
|
||||
@@ -375,139 +577,54 @@ class PopController extends mfBaseController
|
||||
'cable_route_full' => $cable_route_data,
|
||||
'coordinates' => $mainCable->coordinates,
|
||||
'location' => $mainFiber->location,
|
||||
'branch_points' => $branchPoints
|
||||
'branch_points' => $globalBranchPoints
|
||||
];
|
||||
|
||||
$allCablesForMatching = [];
|
||||
|
||||
foreach ($cableChain as $chainItem) {
|
||||
$cable = $chainItem['cable'];
|
||||
|
||||
$coords = $cable->coordinates;
|
||||
$c = $chainItem['cable'];
|
||||
$coords = $c->coordinates;
|
||||
if (is_string($coords)) {
|
||||
$coords = json_decode($coords, true);
|
||||
}
|
||||
|
||||
if ($coords && is_array($coords) && count($coords) > 0) {
|
||||
$allCablesForMatching[] = [
|
||||
'id' => $cable->id,
|
||||
'description' => $cable->description,
|
||||
'id' => $c->id,
|
||||
'description' => $c->description,
|
||||
'coordinates' => $coords
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT id, description, coordinates
|
||||
FROM FiberPlanCable
|
||||
WHERE network_id = 90
|
||||
AND coordinates IS NOT NULL
|
||||
AND coordinates != ''
|
||||
AND coordinates != '[]'";
|
||||
$res = $db->query($sql);
|
||||
|
||||
while ($cableData = $db->fetch_array($res)) {
|
||||
$coords = json_decode($cableData['coordinates'], true);
|
||||
|
||||
if ($coords && is_array($coords) && count($coords) > 0) {
|
||||
$exists = false;
|
||||
foreach ($allCablesForMatching as $existing) {
|
||||
if ($existing['id'] == $cableData['id']) {
|
||||
$exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$exists) {
|
||||
$allCablesForMatching[] = [
|
||||
'id' => $cableData['id'],
|
||||
'description' => $cableData['description'],
|
||||
'coordinates' => $coords
|
||||
];
|
||||
foreach ($globalCablesWithCoords as $gc) {
|
||||
$exists = false;
|
||||
foreach ($allCablesForMatching as $existing) {
|
||||
if ($existing['id'] == $gc['id']) {
|
||||
$exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$exists) {
|
||||
$allCablesForMatching[] = $gc;
|
||||
}
|
||||
}
|
||||
|
||||
$details['all_cables'] = $allCablesForMatching;
|
||||
$this->log->debug("Hausanschluss-Matching: " . count($allCablesForMatching) . " Kabel verfügbar");
|
||||
}
|
||||
|
||||
if (count($cableChain) > 1) {
|
||||
$details['branch_path'] = $this->buildBranchPathFromChain($cableChain, 1, $debug);
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->log->debug("=== MODUS: Vorwärts-Trace (von fiber_id) ===");
|
||||
$details['debug'] = $debug;
|
||||
|
||||
if ($fiber->cable_id) {
|
||||
$cable = new FiberPlanCable($fiber->cable_id);
|
||||
if ($cable->id) {
|
||||
$cable_route_data = FiberPlanCableModel::getCableRoute($cable->id);
|
||||
$cable_route_array = [];
|
||||
foreach ($cable_route_data as $station) {
|
||||
$cable_route_array[] = $station['name'];
|
||||
}
|
||||
|
||||
$branchPoints = [];
|
||||
$sql = "SELECT id, description as name, gps_lat, gps_long, object_type, 'dispatcher' as type
|
||||
FROM FiberPlanDispatcher
|
||||
WHERE network_id = 90 AND object_type = 4
|
||||
AND gps_lat IS NOT NULL AND gps_long IS NOT NULL";
|
||||
$res = $db->query($sql);
|
||||
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$branchPoints[] = [
|
||||
'id' => $data['id'],
|
||||
'name' => $data['name'],
|
||||
'gps_lat' => $data['gps_lat'],
|
||||
'gps_long' => $data['gps_long'],
|
||||
'object_type' => intval($data['object_type']),
|
||||
'type' => $data['type']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$allFibers = FiberPlanFiberModel::getByCableAndSheet($cable->id, null);
|
||||
$fibersArray = [];
|
||||
foreach ($allFibers as $f) {
|
||||
$fibersArray[] = [
|
||||
'id' => $f->id,
|
||||
'fiber_nr_cable' => $f->fiber_nr_cable,
|
||||
'branch_type' => $f->branch_type,
|
||||
'branch_cable_nr' => $f->branch_cable_nr,
|
||||
'branch_from_location' => $f->branch_from_location,
|
||||
'branch_fiber_nr' => $f->branch_fiber_nr
|
||||
];
|
||||
}
|
||||
|
||||
$details['cable_info'] = [
|
||||
'id' => $cable->id,
|
||||
'description' => $cable->description,
|
||||
'fibers' => $fibersArray,
|
||||
'diameter' => $cable->diameter,
|
||||
'cable_route_array' => $cable_route_array,
|
||||
'cable_route_full' => $cable_route_data,
|
||||
'coordinates' => $cable->coordinates,
|
||||
'location' => $fiber->location,
|
||||
'branch_points' => $branchPoints
|
||||
];
|
||||
|
||||
if ($cable->cable_route) {
|
||||
$routeArray = json_decode($cable->cable_route, true);
|
||||
if (is_array($routeArray)) {
|
||||
$details['cable_info']['cable_route_array'] = $routeArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($fiber->branch_type === 'Abzweigkabel' && $fiber->branch_cable_nr) {
|
||||
$details['branch_path'] = $this->traceBranchPath($fiber, 0, 10, $debug);
|
||||
}
|
||||
$allPaths[] = [
|
||||
'fiber' => $details
|
||||
];
|
||||
}
|
||||
|
||||
$details['debug'] = $debug;
|
||||
|
||||
return mfBaseController::returnJson(mfResponse::Ok(['fiber' => $details]));
|
||||
return mfBaseController::returnJson(mfResponse::Ok(['paths' => $allPaths]));
|
||||
}
|
||||
|
||||
private function buildCompleteCableChain($endFiber)
|
||||
@@ -530,10 +647,13 @@ class PopController extends mfBaseController
|
||||
]);
|
||||
|
||||
while ($depth < $maxDepth) {
|
||||
$currentFiberNr = intval($currentFiber->fiber_nr_cable);
|
||||
|
||||
$sql = "SELECT * FROM FiberPlanFiber
|
||||
WHERE branch_type = 'Abzweigkabel'
|
||||
AND branch_cable_nr = '" . $db->escape($currentCable->description) . "'
|
||||
LIMIT 1";
|
||||
WHERE branch_type = 'Abzweigkabel'
|
||||
AND branch_cable_nr = '" . $db->escape($currentCable->description) . "'
|
||||
AND branch_fiber_nr = $currentFiberNr
|
||||
LIMIT 1";
|
||||
|
||||
$this->log->debug("Depth $depth: Suche Parent-Faser für Kabel: {$currentCable->description}");
|
||||
|
||||
@@ -1267,6 +1387,9 @@ class PopController extends mfBaseController
|
||||
case "getFiberPath":
|
||||
return $this->getFiberPathAction();
|
||||
break;
|
||||
case "getAllFiberPathsForHome":
|
||||
return $this->getAllFiberPathsForHomeAction();
|
||||
break;
|
||||
case "saveCableFibers":
|
||||
return $this->saveCableFibersAction();
|
||||
break;
|
||||
@@ -1276,6 +1399,9 @@ class PopController extends mfBaseController
|
||||
case "getNetworkMapData":
|
||||
return $this->getNetworkMapDataAction();
|
||||
break;
|
||||
case "getSplicePlanForElement":
|
||||
return $this->getSplicePlanForElementAction();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -1459,7 +1585,7 @@ class PopController extends mfBaseController
|
||||
$cables = [];
|
||||
$cableRes = $db->select(
|
||||
"FiberPlanCable",
|
||||
"id, description, fibers, diameter, state, coordinates",
|
||||
"id, description, fibers, diameter, state, coordinates, level, cable_type, status",
|
||||
"network_id=$network_id"
|
||||
);
|
||||
|
||||
@@ -1491,7 +1617,10 @@ class PopController extends mfBaseController
|
||||
'coordinates' => $convertedCoords,
|
||||
'fibers' => $cableData->fibers,
|
||||
'diameter' => $cableData->diameter,
|
||||
'state' => $cableData->state
|
||||
'state' => $cableData->state,
|
||||
'level' => $cableData->level,
|
||||
'cable_type' => $cableData->cable_type,
|
||||
'status' => $cableData->status
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1648,4 +1777,126 @@ class PopController extends mfBaseController
|
||||
'customerConnections' => $customerConnections
|
||||
]));
|
||||
}
|
||||
|
||||
protected function getSplicePlanForElementAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
if (!is_numeric($id)) {
|
||||
return mfBaseController::returnJson(mfResponse::BadRequest(['message' => 'Invalid ID']));
|
||||
}
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$dispatcherRes = $db->select("FiberPlanDispatcher", "*", "id=$id");
|
||||
if (!$db->num_rows($dispatcherRes)) {
|
||||
return mfBaseController::returnJson(mfResponse::NotFound(['message' => 'Verteiler nicht gefunden']));
|
||||
}
|
||||
$dispatcher = $db->fetch_object($dispatcherRes);
|
||||
$dispatcherName = $dispatcher->description;
|
||||
|
||||
$cableIds = [];
|
||||
$sql = "SELECT DISTINCT cable_id FROM FiberPlanCableStation WHERE station_type='dispatcher' AND station_id=$id";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($row = $db->fetch_array($res)) {
|
||||
$cableIds[] = $row['cable_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
if (!empty($cableIds)) {
|
||||
$cableIdsStr = implode(',', $cableIds);
|
||||
|
||||
$cableMap = [];
|
||||
$cableRes = $db->select("FiberPlanCable", "id, description", "id IN ($cableIdsStr)");
|
||||
while ($c = $db->fetch_object($cableRes)) {
|
||||
$cableMap[$c->id] = $c->description;
|
||||
}
|
||||
|
||||
$escapedName = $db->escape($dispatcherName);
|
||||
$sqlFibers = "SELECT * FROM FiberPlanFiber WHERE cable_id IN ($cableIdsStr) AND (branch_from_location = '$escapedName' OR location = '$escapedName')";
|
||||
|
||||
$fiberRes = $db->query($sqlFibers);
|
||||
|
||||
$rawFibers = [];
|
||||
$targetCableNames = [];
|
||||
|
||||
while ($fiber = $db->fetch_object($fiberRes)) {
|
||||
$rawFibers[] = $fiber;
|
||||
if ($fiber->branch_cable_nr) {
|
||||
$targetCableNames[$fiber->branch_cable_nr] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$targetColorMap = [];
|
||||
|
||||
if (!empty($targetCableNames)) {
|
||||
$namesList = [];
|
||||
foreach (array_keys($targetCableNames) as $name) {
|
||||
$namesList[] = "'" . $db->escape($name) . "'";
|
||||
}
|
||||
$namesStr = implode(',', $namesList);
|
||||
$targetCablesRes = $db->select("FiberPlanCable", "id, description", "description IN ($namesStr)");
|
||||
$targetCableIds = [];
|
||||
$targetCableIdToName = [];
|
||||
while ($tc = $db->fetch_object($targetCablesRes)) {
|
||||
$targetCableIds[] = $tc->id;
|
||||
$targetCableIdToName[$tc->id] = $tc->description;
|
||||
}
|
||||
|
||||
if (!empty($targetCableIds)) {
|
||||
$tcIdsStr = implode(',', $targetCableIds);
|
||||
$targetFibersRes = $db->select("FiberPlanFiber", "cable_id, fiber_nr_cable, fiber_color, fiber_color_hex", "cable_id IN ($tcIdsStr)");
|
||||
while ($tf = $db->fetch_object($targetFibersRes)) {
|
||||
$cName = $targetCableIdToName[$tf->cable_id] ?? null;
|
||||
if ($cName) {
|
||||
$targetColorMap[$cName][$tf->fiber_nr_cable] = [
|
||||
'color' => $tf->fiber_color,
|
||||
'hex' => $tf->fiber_color_hex
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rawFibers as $fiber) {
|
||||
$targetColorInfo = null;
|
||||
if ($fiber->branch_cable_nr && $fiber->branch_fiber_nr) {
|
||||
$targetColorInfo = $targetColorMap[$fiber->branch_cable_nr][$fiber->branch_fiber_nr] ?? null;
|
||||
}
|
||||
|
||||
$result[] = [
|
||||
'cable_name' => $cableMap[$fiber->cable_id] ?? 'Unknown',
|
||||
'fiber_nr' => $fiber->fiber_nr_cable,
|
||||
'fiber_color' => $fiber->fiber_color,
|
||||
'fiber_color_hex' => $fiber->fiber_color_hex,
|
||||
'bundle_color' => $fiber->bundle_color,
|
||||
'bundle_color_hex' => $fiber->bundle_color_hex,
|
||||
|
||||
'target_cable' => $fiber->branch_cable_nr,
|
||||
'target_fiber' => $fiber->branch_fiber_nr,
|
||||
'target_fiber_color' => $targetColorInfo['color'] ?? null,
|
||||
'target_fiber_color_hex' => $targetColorInfo['hex'] ?? null,
|
||||
'target_bundle_color' => $fiber->branch_bundle_color,
|
||||
'target_bundle_color_hex' => $fiber->branch_bundle_color_hex,
|
||||
|
||||
'connector' => $fiber->connector_nr,
|
||||
'description' => $fiber->comment,
|
||||
'home_id' => $fiber->home_id,
|
||||
'address' => $fiber->address ?? null,
|
||||
'customer_cable_type' => $fiber->customer_cable_type ?? null,
|
||||
'customer_cable_fiber_nr' => $fiber->customer_cable_fiber_nr ?? null,
|
||||
'customer_connector_type' => $fiber->customer_connector_type ?? null,
|
||||
'customer_cable_spec' => $fiber->customer_cable_spec ?? null,
|
||||
'customer_fiber_range' => $fiber->customer_fiber_range ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return mfBaseController::returnJson(mfResponse::Ok([
|
||||
'dispatcher' => $dispatcher,
|
||||
'connections' => $result
|
||||
]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user