- Deleted `test.php` as it was no longer in use. - Enhanced null safety checks in `Inventory.php`, `StdOut-detail.php`, `Backups.php`, and `SwitchsSAN.php` to prevent potential warnings. - Refactored `SwitchsSAN.php` to improve sorting logic for ports based on errors, vFabric, and Port ID. - Added seasonal snow effect script in `all.php` with toggle functionality for user engagement. - Updated navigation bar (`navbar.html`) to include a new VIO page link. - Introduced a new `VIO.php` page to display VIO monitoring details with table export and sorting features.
191 lines
6.5 KiB
PHP
191 lines
6.5 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
<title>Web Infra Reports IT</title>
|
|
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
|
|
|
|
<script src="/js/jquery-3.6.1.min.js"></script>
|
|
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="/css/bootstrap-icons/bootstrap-icons.css">
|
|
<link rel="stylesheet" href="/css/preloader.css">
|
|
<script src="/js/bootstrap.bundle.min.js"></script>
|
|
<link rel="stylesheet" href="/css/bootstrap-table.min.css">
|
|
<script src="/js/bootstrap-table.min.js"></script>
|
|
<script src="/js/bootstrap-table-fr-FR.min.js"></script>
|
|
<script src="/js/tableExport.min.js"></script>
|
|
<script src="/js/bootstrap-table-export.min.js"></script>
|
|
<script src="/js/libs/js-xlsx/xlsx.core.min.js"></script>
|
|
|
|
<style>
|
|
.cell-multiline {
|
|
white-space: nowrap;
|
|
}
|
|
/* Custom style for VIOErr badges */
|
|
.badge-err {
|
|
background-color: #dc3545 !important;
|
|
color: white;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="bg-light text-dark">
|
|
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?>
|
|
|
|
<?php
|
|
// ==========================================
|
|
// 1. DATA PROCESSING (PHP)
|
|
// ==========================================
|
|
|
|
$rawRows = Invoke_Infra("SELECT * FROM x_cmdb_VIO");
|
|
if (!$rawRows) $rawRows = [];
|
|
|
|
// Grouping
|
|
$groupedData = [];
|
|
foreach ($rawRows as $row) {
|
|
$key = $row['clintname'];
|
|
if (empty($key)) $key = "[No Client Name]";
|
|
if (!isset($groupedData[$key])) $groupedData[$key] = [];
|
|
$groupedData[$key][] = $row;
|
|
}
|
|
|
|
// Flattening for Display (1 Row per Client)
|
|
$displayRows = [];
|
|
|
|
foreach ($groupedData as $clientKey => $rows) {
|
|
// 1. Sort by date desc
|
|
usort($rows, function($a, $b) {
|
|
return strcmp($b['ts'], $a['ts']);
|
|
});
|
|
|
|
// 2. Keep max 2
|
|
if (count($rows) > 2) {
|
|
$rows = array_slice($rows, 0, 2);
|
|
}
|
|
|
|
$names = []; $inerrs = []; $vfcs = []; $vios = [];
|
|
$clintids = []; $fcnames = []; $tss = []; $vioerrs = [];
|
|
|
|
$hasError = false;
|
|
$maxVioErr = 0;
|
|
|
|
foreach ($rows as $r) {
|
|
if ($r['inerr'] != 0 && $r['inerr'] != '0') $hasError = true;
|
|
|
|
// Track VIOErr
|
|
$errVal = (int)($r['VIOErr'] ?? 0);
|
|
if ($errVal > $maxVioErr) $maxVioErr = $errVal;
|
|
|
|
// Format VIOErr for display (Red badge if > 0)
|
|
$vioerrs[] = ($errVal > 0) ? "<span class='badge badge-err'>$errVal</span>" : $errVal;
|
|
|
|
$names[] = $r['name'] ?? '-';
|
|
$inerrs[] = $r['inerr'] ?? '-';
|
|
$vfcs[] = $r['vfcclientname'] ?? '-';
|
|
$vios[] = $r['vio'] ?? '-';
|
|
$clintids[] = $r['clintid'] ?? '-';
|
|
$fcnames[] = $r['fcname'] ?? '-';
|
|
$tss[] = $r['ts'] ?? '-';
|
|
}
|
|
|
|
$displayRows[] = [
|
|
'clintname' => $clientKey,
|
|
'hasError' => $hasError,
|
|
'maxVioErr' => $maxVioErr,
|
|
'name' => implode('<br>', $names),
|
|
'inerr' => implode('<br>', $inerrs),
|
|
'vfc' => implode('<br>', $vfcs),
|
|
'vio' => implode('<br>', $vios),
|
|
'clintid' => implode('<br>', $clintids),
|
|
'fcname' => implode('<br>', $fcnames),
|
|
'ts' => implode('<br>', $tss),
|
|
'vioerr' => implode('<br>', $vioerrs),
|
|
];
|
|
}
|
|
|
|
// 4. Final Sort: 1. Warning (inerr), 2. VIOErr > 0, 3. Alpha
|
|
usort($displayRows, function($a, $b) {
|
|
// Priority 1: InErr (table-warning)
|
|
if ($a['hasError'] && !$b['hasError']) return -1;
|
|
if (!$a['hasError'] && $b['hasError']) return 1;
|
|
|
|
// Priority 2: VIOErr count
|
|
if ($a['maxVioErr'] > 0 && $b['maxVioErr'] == 0) return -1;
|
|
if ($a['maxVioErr'] == 0 && $b['maxVioErr'] > 0) return 1;
|
|
if ($a['maxVioErr'] != $b['maxVioErr']) return $b['maxVioErr'] - $a['maxVioErr'];
|
|
|
|
// Priority 3: Alphabetical
|
|
return strcasecmp($a['clintname'], $b['clintname']);
|
|
});
|
|
?>
|
|
|
|
<div class="container-fluid" id="content">
|
|
<div class="row flex-nowrap">
|
|
<div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark vh-100 position-sticky top-0" style="flex: 0 0 230px;">
|
|
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
|
|
</div>
|
|
|
|
<div class="col py-3">
|
|
<h1><span class="badge text-bg-secondary w-100"><?php echo $ti_13;?></span></h1>
|
|
|
|
<div class="container-fluid">
|
|
<div>
|
|
<table class='table table-bordered table-hover table-sm' id='t1'
|
|
data-toggle="table"
|
|
data-search="true"
|
|
data-show-columns="true"
|
|
data-export-types="['xlsx','csv','json']"
|
|
data-show-export="true"
|
|
data-sortable="true"> <thead>
|
|
<tr>
|
|
<th data-field="clintname" data-sortable="true">Clint Name</th>
|
|
<th data-field="name"><?php echo $w_name;?></th>
|
|
<th data-field="vioerr">VIOErr</th>
|
|
<th data-field="inerr">InErr</th>
|
|
<th data-field="vfcclientname">VFC Client Name</th>
|
|
<th data-field="vio">VIO</th>
|
|
<th data-field="clintid">ClintID</th>
|
|
<th data-field="fcname">FC Name</th>
|
|
<th data-field="ts"><?php echo $w_lastUpdate;?></th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<?php foreach ($displayRows as $row): ?>
|
|
<?php $class = $row['hasError'] ? 'table-warning' : ''; ?>
|
|
<tr class="<?php echo $class; ?>">
|
|
<td class="fw-bold align-middle"><?php echo htmlspecialchars($row['clintname']); ?></td>
|
|
<td class="cell-multiline"><?php echo $row['name']; ?></td>
|
|
<td class="cell-multiline text-center fw-bold"><?php echo $row['vioerr']; ?></td>
|
|
<td class="cell-multiline"><?php echo $row['inerr']; ?></td>
|
|
<td class="cell-multiline"><?php echo $row['vfc']; ?></td>
|
|
<td class="cell-multiline"><?php echo $row['vio']; ?></td>
|
|
<td class="cell-multiline"><?php echo $row['clintid']; ?></td>
|
|
<td class="cell-multiline"><?php echo $row['fcname']; ?></td>
|
|
<td class="cell-multiline small"><?php echo $row['ts']; ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
<script src="/js/switch.js"></script>
|
|
<script>
|
|
var $table = $('#t1');
|
|
function adjustTableHeight() {
|
|
let height = $(window).height() - 170;
|
|
$table.bootstrapTable('resetView', { height: height });
|
|
}
|
|
$(function () {
|
|
adjustTableHeight();
|
|
$(window).resize(function () { adjustTableHeight(); });
|
|
});
|
|
</script>
|
|
</html>
|