From 901b6da91bbf454a2b13cd0c13c7f53f2a9d53d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Chili=C5=84ski?= Date: Wed, 15 Feb 2023 17:19:12 +0100 Subject: [PATCH] enhancement: uke/pit: implemented foreign subject export to csv --- modules/ukepit.php | 105 ++++++--------------------------------------- 1 file changed, 14 insertions(+), 91 deletions(-) diff --git a/modules/ukepit.php b/modules/ukepit.php index ba0f2d9daa..5640896704 100644 --- a/modules/ukepit.php +++ b/modules/ukepit.php @@ -1326,7 +1326,6 @@ function find_nodes_for_netdev($customerid, $netdevid, &$customer_nodes, &$custo unset($teryt_cities); unset($teryt_streets); -/* //prepare info about network links (only between different network nodes) $netconnectionid = 1; $processed_netlinks = array(); @@ -1354,12 +1353,16 @@ function find_nodes_for_netdev($customerid, $netdevid, &$customer_nodes, &$custo $srcnetnode = $netdevs[$netlink['src']]; $dstnetnode = $netdevs[$netlink['dst']]; $netnodeids = array($netnodes[$srcnetnode]['id'], $netnodes[$dstnetnode]['id']); + sort($netnodeids); + $netnodelinkid = implode('_', $netnodeids); + if (!isset($processed_netlinks[$netnodelinkid])) { - $linkspeed = $netlink['speed']; - $speed = floor($linkspeed / 1000); - $netintid = ''; + $linkspeed = $netlink['speed']; + $speed = floor($linkspeed / 1000); + $netintid = ''; + if ($netlink['src'] == $netdevice['id']) { if ($netdevnetnode != $dstnetnode) { if ($netdevices[$netlink['src']]['invproject'] == $netdevices[$netlink['dst']]['invproject'] @@ -1377,50 +1380,9 @@ function find_nodes_for_netdev($customerid, $netdevid, &$customer_nodes, &$custo } $processed_netlinks[$netnodelinkid] = true; - //$netnodes[$netdevnetnode]['distports']++; - $foreign = false; - - if ($netnodes[$netdevnetnode]['ownership'] == 2 && $netnodes[$dstnetnode]['ownership'] < 2) { - $invproject = strlen($netnodes[$dstnetnode]['invproject']) ? $netnodes[$dstnetnode]['invproject'] : ''; - $netintid = $netnodes[$dstnetnode]['backbonenetintid'][$invproject][$netnodes[$dstnetnode]['status']][$netlink['type']][$netlink['technology']][$netlink['speed']]; - $data = array( - 'ps_id' => $netconnectionid, - 'ps_wwid' => $netnodes[$dstnetnode]['id'], - 'ps_woid' => $netnodes[$netdevnetnode]['id'], - 'ps_intid' => $netintid, - 'ps_internetusage' => 'Tak', - 'ps_voiceusage' => 'Nie', - 'ps_otherusage' => 'Nie', - 'ps_totalspeed' => $speed, - 'ps_internetspeed' => $speed, - 'ps_invproject' => $netnodes[$netdevnetnode]['invproject'], - 'ps_invstatus' => strlen($netnodes[$netdevnetnode]['invproject']) ? $NETELEMENTSTATUSES[$netnodes[$netdevnetnode]['status']] : '', - ); - $buffer .= 'PS,' . to_csv($data) . EOL; - - $netconnectionid++; - $foreign = true; - } - if ($netnodes[$netdevnetnode]['ownership'] < 2 && $netnodes[$dstnetnode]['ownership'] == 2) { - $invproject = strlen($netnodes[$netdevnetnode]['invproject']) ? $netnodes[$netdevnetnode]['invproject'] : ''; - $netintid = $netnodes[$netdevnetnode]['backbonenetintid'][$invproject][$netnodes[$netdevnetnode]['status']][$netlink['type']][$netlink['technology']][$netlink['speed']]; - $data = array( - 'ps_id' => $netconnectionid, - 'ps_wwid' => $netnodes[$netdevnetnode]['id'], - 'ps_woid' => $netnodes[$dstnetnode]['id'], - 'ps_intid' => $netintid, - 'ps_internetusage' => 'Tak', - 'ps_voiceusage' => 'Nie', - 'ps_otherusage' => 'Nie', - 'ps_totalspeed' => $speed, - 'ps_internetspeed' => $speed, - 'ps_invproject' => $netnodes[$dstnetnode]['invproject'], - 'ps_invstatus' => strlen($netnodes[$dstnetnode]['invproject']) ? $NETELEMENTSTATUSES[$netnodes[$dstnetnode]['status']] : '', - ); - $buffer .= 'PS,' . to_csv($data) . EOL; - $netconnectionid++; - $foreign = true; - } + + $foreign = $netnodes[$netdevnetnode]['ownership'] == 2 && $netnodes[$dstnetnode]['ownership'] < 2 + || $netnodes[$netdevnetnode]['ownership'] < 2 && $netnodes[$dstnetnode]['ownership'] == 2; $netlinks[] = array( 'type' => $netlink['type'], @@ -1451,49 +1413,9 @@ function find_nodes_for_netdev($customerid, $netdevid, &$customer_nodes, &$custo } $processed_netlinks[$netnodelinkid] = true; - //$netnodes[$netdevnetnode]['distports']++; - $foreign = false; - - if ($netnodes[$netdevnetnode]['ownership'] == 2 && $netnodes[$srcnetnode]['ownership'] < 2) { - $invproject = strlen($netnodes[$srcnetnode]['invproject']) ? $netnodes[$srcnetnode]['invproject'] : ''; - $netintid = $netnodes[$srcnetnode]['backbonenetintid'][$invproject][$netnodes[$srcnetnode]['status']][$netlink['type']][$netlink['technology']][$netlink['speed']]; - $data = array( - 'ps_id' => $netconnectionid, - 'ps_wwid' => $netnodes[$srcnetnode]['id'], - 'ps_woid' => $netnodes[$netdevnetnode]['id'], - 'ps_intid' => $netintid, - 'ps_internetusage' => 'Tak', - 'ps_voiceusage' => 'Nie', - 'ps_otherusage' => 'Nie', - 'ps_totalspeed' => $speed, - 'ps_internetspeed' => $speed, - 'ps_invproject' => $netnodes[$netdevnetnode]['invproject'], - 'ps_invstatus' => strlen($netnodes[$netdevnetnode]['invproject']) ? $NETELEMENTSTATUSES[$netnodes[$netdevnetnode]['status']] : '', - ); - $buffer .= 'PS,' . to_csv($data) . EOL; - $netconnectionid++; - $foreign = true; - } - if ($netnodes[$netdevnetnode]['ownership'] < 2 && $netnodes[$srcnetnode]['ownership'] == 2) { - $invproject = strlen($netnodes[$netdevnetnode]['invproject']) ? $netnodes[$netdevnetnode]['invproject'] : ''; - $netintid = $netnodes[$netdevnetnode]['backbonenetintid'][$invproject][$netnodes[$netdevnetnode]['status']][$netlink['type']][$netlink['technology']][$netlink['speed']]; - $data = array( - 'ps_id' => $netconnectionid, - 'ps_wwid' => $netnodes[$netdevnetnode]['id'], - 'ps_woid' => $netnodes[$srcnetnode]['id'], - 'ps_intid' => $netintid, - 'ps_internetusage' => 'Tak', - 'ps_voiceusage' => 'Nie', - 'ps_otherusage' => 'Nie', - 'ps_totalspeed' => $speed, - 'ps_internetspeed' => $speed, - 'ps_invproject' => $netnodes[$srcnetnode]['invproject'], - 'ps_invstatus' => strlen($netnodes[$srcnetnode]['invproject']) ? $NETELEMENTSTATUSES[$netnodes[$srcnetnode]['status']] : '', - ); - $buffer .= 'PS,' . to_csv($data) . EOL; - $netconnectionid++; - $foreign = true; - } + + $foreign = $netnodes[$netdevnetnode]['ownership'] == 2 && $netnodes[$dstnetnode]['ownership'] < 2 + || $netnodes[$netdevnetnode]['ownership'] < 2 && $netnodes[$dstnetnode]['ownership'] == 2; $netlinks[] = array( 'type' => $netlink['type'], @@ -1513,6 +1435,7 @@ function find_nodes_for_netdev($customerid, $netdevid, &$customer_nodes, &$custo } } +/* // save info about network lines $netlineid = 1; $snetcablelines = '';