Fix networks duplicating
This commit is contained in:
@@ -85,6 +85,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||||||
ON service_assets.asset_id = logins.login_asset_id
|
ON service_assets.asset_id = logins.login_asset_id
|
||||||
LEFT JOIN networks
|
LEFT JOIN networks
|
||||||
ON assets.asset_network_id = networks.network_id
|
ON assets.asset_network_id = networks.network_id
|
||||||
|
LEFT JOIN locations
|
||||||
|
ON assets.asset_location_id = locations.location_id
|
||||||
WHERE service_id = '$service_id'");
|
WHERE service_id = '$service_id'");
|
||||||
|
|
||||||
// Associated logins
|
// Associated logins
|
||||||
|
|||||||
+44
-10
@@ -38,17 +38,35 @@
|
|||||||
|
|
||||||
<!-- Networks -->
|
<!-- Networks -->
|
||||||
<?php
|
<?php
|
||||||
if($sql_assets){ ?>
|
if($sql_assets){
|
||||||
|
|
||||||
|
$network_names = [];
|
||||||
|
$network_vlans = [];
|
||||||
|
|
||||||
|
// Reset the $sql_assets pointer to the start - as we've already cycled through once
|
||||||
|
mysqli_data_seek($sql_assets, 0);
|
||||||
|
|
||||||
|
// Get networks linked to assets - push their name and vlan to arrays
|
||||||
|
while($row = mysqli_fetch_array($sql_assets)){
|
||||||
|
if(!empty($row['network_name'])){
|
||||||
|
array_push($network_names, $row['network_name']);
|
||||||
|
array_push($network_vlans, $row['network_vlan']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicates
|
||||||
|
$network_names = array_unique($network_names);
|
||||||
|
$network_vlans = array_unique($network_vlans);
|
||||||
|
|
||||||
|
// Display
|
||||||
|
if(!empty($network_names)){ ?>
|
||||||
<h5><i class="nav-icon fas fa-network-wired"></i> Networks</h5>
|
<h5><i class="nav-icon fas fa-network-wired"></i> Networks</h5>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
// Reset the $sql_assets pointer to the start - as we've already cycled this once
|
}
|
||||||
mysqli_data_seek($sql_assets, 0);
|
foreach($network_names as $network){
|
||||||
|
foreach($network_vlans as $vlan){
|
||||||
// Showing networks linked to assets
|
echo "<li><a href=\"client.php?client_id=$client_id&tab=networks&q=$network\">$network (VLAN: $vlan)</a></li>";
|
||||||
while($row = mysqli_fetch_array($sql_assets)){
|
|
||||||
if(!empty($row['network_name'])){
|
|
||||||
echo "<li><a href=\"client.php?client_id=$client_id&tab=networks&q=$row[network_name]\">$row[network_name] (VLAN: $row[network_vlan])</a></li>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,11 +78,27 @@
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<!-- Domains -->
|
||||||
|
<?php
|
||||||
|
if($sql_assets){ ?>
|
||||||
<h5><i class="nav-icon fas fa-map-marker-alt"></i> Locations</h5>
|
<h5><i class="nav-icon fas fa-map-marker-alt"></i> Locations</h5>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Location XYZ</li>
|
<?php
|
||||||
<li>Location DEF</li>
|
|
||||||
|
// Reset the $sql_assets pointer to the start - as we've already cycled through once
|
||||||
|
mysqli_data_seek($sql_assets, 0);
|
||||||
|
|
||||||
|
// Showing linked locations (from assets)
|
||||||
|
while($row = mysqli_fetch_array($sql_assets)){
|
||||||
|
if(!empty($row['location_name'])){
|
||||||
|
echo "<li><a href=\"client.php?client_id=$client_id&tab=locations&q=$row[location_name]\">$row[location_name]</a></li>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<!-- Domains -->
|
<!-- Domains -->
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
Reference in New Issue
Block a user