Online'); define('badge_offline', '
Offline
'); define('sortable_column', ' '); ?>
' // _id is added so it doesn't conflict with AdminLTE tab behavior .'
'.$decoded_icon.'
'.$node_name.'' .$str_port. '
'; echo $str_tab_header; } // Create pane content (displayed inside of the tabs) function createPane($node_mac, $node_name, $node_status, $node_type, $node_ports_count, $node_parent_mac, $activetab){ // online/offline status circle (red/green) $node_badge = ""; if($node_status == 1) // 1 means online, 0 offline { $node_badge = badge_online; } else { $node_badge = badge_offline; } $idFromMac = str_replace(":", "_", $node_mac); $idParentMac = str_replace(":", "_", $node_parent_mac); $str_tab_pane = '
'.lang('Network_Node').' '.$node_name.'
MAC ' .$node_mac. '
'.lang('Device_TableHead_Type').' ' .$node_type. '
'.lang('Network_Table_State').' ' .$node_badge. '
'.lang('Network_Parent').' '.$node_parent_mac.'
'; $str_table = ' '; // Prepare Array for Devices with Port value // If no Port is set, the Port number is set to 0 if ($node_ports_count == "") { $node_ports_count = 0; } // Get all leafs connected to a node based on the node_mac $func_sql = 'SELECT devParentPort as port, devMac as mac, devPresentLastScan as online, devName as name, devType as type, devLastIP as last_ip, (select devType from Devices a where devMac = "'.$node_mac.'") as node_type FROM Devices WHERE devParentMAC = "'.$node_mac.'" and devIsArchived = 0 order by port, name asc'; global $db; $func_result = $db->query($func_sql); // array $tableData = array(); while ($row = $func_result -> fetchArray (SQLITE3_ASSOC)) { // Push row data $tableData[] = array( 'port' => $row['port'], 'mac' => $row['mac'], 'online' => $row['online'], 'name' => $row['name'], 'type' => $row['type'], 'last_ip' => $row['last_ip'], 'node_type' => $row['node_type']); } // Control no rows if (empty($tableData)) { $tableData = []; } $str_table_rows = ""; foreach ($tableData as $row) { if ($row['online'] == 1) { $port_state = badge_online; } else { $port_state = badge_offline; } // prepare HTML for the port table column cell $port_content = "N/A"; if (($row['node_type'] == "WLAN" || $row['node_type'] == "AP" ) && ($row['port'] == NULL || $row['port'] == "") ){ $port_content = ''; } elseif ($row['node_type'] == "Powerline") { $port_content = ''; } elseif ($row['port'] != NULL && $row['port'] != "") { $port_content = $row['port']; } $str_table_rows = $str_table_rows. ''; } $str_table_close = '
Port '.lang('Network_Table_State').' '.lang('Network_Table_Hostname').sortable_column.' '.lang('Network_Table_IP').sortable_column.' '.lang('Network_ManageLeaf').'
'.$port_content.' ' .$port_state. ' '.$row['name'].' ' .$row['last_ip']. '
'; // no connected device - don't render table, just display some info if($str_table_rows == "") { $str_table = "
".lang("Network_NoAssignedDevices")."
"; $str_table_close = ""; } $str_close_pane = '
'; // write the HTML echo ''.$str_tab_pane. $str_table. $str_table_rows. $str_table_close. $str_close_pane; } // Create Top level tabs (List of network devices), explanation of the terminology below: // // Switch 1 (node) // /(p1) \ (p2) <----- port numbers // / \ // Smart TV (leaf) Switch 2 (node (for the PC) and leaf (for Switch 1)) // \ // PC (leaf) <------- leafs are not included in this SQL query $networkDeviceTypes = str_replace("]", "",(str_replace("[", "", getSettingValue("NETWORK_DEVICE_TYPES")))); $sql = "SELECT node_name, node_mac, online, node_type, node_ports_count, parent_mac, node_icon, node_alert FROM ( SELECT a.devName as node_name, a.devMac as node_mac, a.devPresentLastScan as online, a.devType as node_type, a.devParentMAC as parent_mac, a.devIcon as node_icon, a.devAlertDown as node_alert FROM Devices a WHERE a.devType in (".$networkDeviceTypes.") AND devIsArchived = 0 ) t1 LEFT JOIN ( SELECT b.devParentMAC as node_mac_2, count() as node_ports_count FROM Devices b WHERE b.devParentMAC NOT NULL group by b.devParentMAC ) t2 ON (t1.node_mac = t2.node_mac_2); "; $result = $db->query($sql); // array $tableData = array(); while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { // Push row data $tableData[] = array( 'node_mac' => $row['node_mac'], 'node_name' => $row['node_name'], 'online' => $row['online'], 'node_type' => $row['node_type'], 'parent_mac' => $row['parent_mac'], 'node_icon' => $row['node_icon'], 'node_ports_count' => $row['node_ports_count'], 'node_alert' => $row['node_alert'] ); } // Control no rows if (empty($tableData)) { $tableData = []; } echo '
query($func_sql); // array $tableData = array(); while ($row = $func_result -> fetchArray (SQLITE3_ASSOC)) { // Push row data $tableData[] = array( 'mac' => $row['mac'], 'online' => $row['online'], 'name' => $row['name'], 'last_ip' => $row['last_ip']); } // Don't do anything if empty if (!(empty($tableData))) { $str_table_header = '

'.lang('Network_UnassignedDevices').'

'; $str_table_rows = ""; foreach ($tableData as $row) { if ($row['online'] == 1) { $state = badge_online; } else { $state = badge_offline; } $str_table_rows = $str_table_rows. ' '; } $str_table_close = '
'.lang('Network_Table_State').' '.lang('Network_Table_Hostname').sortable_column.' '.lang('Network_Table_IP').sortable_column.' '.lang('Network_Assign').'
' .$state. ' '.$row['name'].' ' .$row['last_ip']. '
'; // write the html echo $str_table_header.$str_table_rows.$str_table_close; } ?>