Files
thetool/Layout/default/Pop/_rack_body.php
Daniel Spitzer 68f29ab995 Poprack
Features:

* Komplettes kabelmanagement auf Rack He Modul Basis
2025-12-02 12:48:51 +01:00

167 lines
11 KiB
PHP

<?php
$cellwidth = 227;
$blocktd = 0;
for ($i = 1; $i <= $rack_he; $i++) : ?>
<tr>
<td class="border-right w-10 p-0 pl-1 pr-1 border-bottom font-13 rack-he user-select-none"
data-toggle="modal" data-target="#rackModuleModal"
style="cursor: pointer" data-he="<?= $i; ?>">He<?= $i; ?></td>
<?php
foreach ($modules_to_render as $module) {
if ($module['start_he'] == $i) {
$modulestart = 1;
$modulelenght = $module['end_he'] - $module['start_he'] + 1;
$position = 1;
$slotcounter = 0;
$calcwidth = 0;
$extText = "";
$extTextspan = "";
foreach ($module['slots'] as $slots) {
$extText = "";
$originalName = $slots['modulname'];
$displayName = $originalName;
$colorclass = "";
if ($slots['type'] == '0' && empty(trim($displayName))) {
$displayName = "LWL Patch Panel";
}
if ($slots['type'] == '0') {
if (isset($slots['status']) && $slots['status'] == 'planned') {
$colorclass = "rack-color-lwl-planned";
} else {
$colorclass = "rack-color-lwl";
}
$cellContent = "";
$plugName = isset($plugs[$slots['plug']]) ? $plugs[$slots['plug']] : 'k.A.';
$cellContent .= '<div class="module-header-info">';
$cellContent .= ' <span class="module-name" title="' . $displayName . '">' . $displayName . '</span>';
$cellContent .= ' <span class="port-info">(' . $slots['ports'] . 'x' . $plugName . ')</span>';
$cellContent .= '</div>';
$cellContent .= '<div class="cable-container" style="background-color: #fffbe9;">';
if (!empty($slots['cables'])) {
usort($slots['cables'], function ($a, $b) {
return $a['port_start'] <=> $b['port_start'];
});
$lastPort = 0;
foreach ($slots['cables'] as $cable) {
$freePorts = $cable['port_start'] - $lastPort - 1;
if ($freePorts > 0) {
$freeWidth = ($freePorts / $slots['ports']) * 100;
$cellContent .= '<div class="cable-free" style="width: ' . $freeWidth . '%;" title="Ports ' . ($lastPort + 1) . '-' . ($cable['port_start'] - 1) . ' frei">Ports ' . ($lastPort + 1) . '-' . ($cable['port_start'] - 1) . ' frei</div>';
}
$portCount = $cable['port_end'] - $cable['port_start'] + 1;
$cableWidth = ($portCount / $slots['ports']) * 100;
$popTitle = htmlspecialchars($cable['cable_name'], ENT_QUOTES);
$popContent = '<strong>Ports:</strong> ' . $cable['port_start'] . '-' . $cable['port_end'];
if (!empty($cable['fiber_start'])) {
$popContent .= '<br><strong>Fasern:</strong> ' . $cable['fiber_start'] . '-' . $cable['fiber_end'];
}
if (!empty($cable['description'])) {
$popContent .= '<br><div class="mt-1 text-muted border-top pt-1 small"><em>' . htmlspecialchars($cable['description'], ENT_QUOTES) . '</em></div>';
}
$narrowClass = ($cableWidth < 12) ? 'narrow' : '';
$cellContent .= '<div class="cable-item ' . $narrowClass . '"
data-toggle="popover"
data-trigger="hover"
data-html="true"
data-placement="top"
data-container="body"
title="' . $popTitle . '"
data-content="' . htmlspecialchars($popContent, ENT_QUOTES) . '"
style="width: ' . $cableWidth . '%;"
data-cable-id="' . $cable['id'] . '"
data-cable-name="' . htmlspecialchars($cable['cable_name'], ENT_QUOTES) . '"
data-port-start="' . $cable['port_start'] . '"
data-port-end="' . $cable['port_end'] . '"
data-fiber-start="' . ($cable['fiber_start'] ?? '') . '"
data-fiber-end="' . ($cable['fiber_end'] ?? '') . '"
data-description="' . htmlspecialchars($cable['description'] ?? '', ENT_QUOTES) . '">';
$fontSize = ($cableWidth < 10) ? '10px' : 'inherit';
$cellContent .= '<span style="font-size:'.$fontSize.'; overflow:hidden; text-overflow:ellipsis; max-width:100%; white-space:nowrap;"><b>' . $cable['cable_name'] . "</b></span>";
if (!empty($cable['description'])) {
$descVisibilityClass = ($cableWidth <= 20) ? 'hide-if-narrow' : '';
$cellContent .= '<span class="cable-description ' . $descVisibilityClass . '" >' . htmlspecialchars($cable['description'], ENT_QUOTES) . '</span>';
}
$rangesVisibilityClass = ($cableWidth <= 5) ? 'hide-if-narrow' : '';
$infoSize = '10px';
$infoGap = '8px';
if ($cableWidth < 8) { $infoSize = '8px'; $infoGap = '1px'; }
elseif ($cableWidth < 15) { $infoSize = '9px'; $infoGap = '3px'; }
$toolStyle = 'font-size: ' . $infoSize . '; white-space: nowrap;';
$cellContent .= '<div class="port-ranges-container ' . $rangesVisibilityClass . '" style="display: flex; justify-content: center; width: 100%; line-height: 1.1; gap: ' . $infoGap . ';">';
$cellContent .= '<tool class="port-range" style="' . $toolStyle . '">P: ' . $cable['port_start'] . '-' . $cable['port_end'] . '</tool>';
if (!empty($cable['fiber_start'])) {
$cellContent .= '<tool class="fiber-range" style="' . $toolStyle . '">F: ' . $cable['fiber_start'] . '-' . $cable['fiber_end'] . "</tool>";
}
$cellContent .= '</div>';
$cellContent .= '</div>';
$lastPort = $cable['port_end'];
}
$remainingPorts = $slots['ports'] - $lastPort;
if ($remainingPorts > 0) {
$remainingWidth = ($remainingPorts / $slots['ports']) * 100;
$cellContent .= '<div class="cable-free" style="width: ' . $remainingWidth . '%;" title="Ports ' . ($lastPort + 1) . '-' . $slots['ports'] . ' frei">P: ' . ($lastPort + 1) . '-' . $slots['ports'] . ' frei</div>';
}
} else {
$cellContent .= '<span style="font-size: 12px; font-style: italic; margin: auto;" class="cable-free">Ports ' . '1 -' . $slots['ports'] . ' frei</span>';
}
$cellContent .= '</div>';
$slots['modulname'] = $cellContent;
$extTextspan = "";
} else if ($slots['type'] == '1') {
$slots['modulname'] = '<a style="color: #000000;text-decoration: underline;" target="_self" href="' . self::getUrl("Device", "detail", ["id" => $slots['device_id']]) . '">' . $displayName . '</a>';
$colorclass = "rack-color-device";
} else if ($slots['type'] == '2') {
$colorclass = "rack-color-rpanel";
} else if ($slots['type'] == '3') {
$colorclass = "rack-color-infra";
} else if ($slots['type'] == '4') {
$colorclass = "rack-color-panel";
} else if ($slots['type'] == '5') {
$colorclass = "rack-color-blocked";
}
if ($slots['width'] == "12") $width = "85%";
else if ($slots['width'] == "6") $width = "42.5%";
else if ($slots['width'] == "4") $width = "28.33%";
else if ($slots['width'] == "3") $width = "21.25%";
while ($position < $slots['position']) {
echo '<td colspan="' . $slots['width'] . '" class="text-center border-top border-bottom border-right pl-1 pr-1" rowspan="' . $modulelenght . '">frei</td>';
$position++;
$calcwidth += $slots['width'];
}
echo '<td title="' . strip_tags($displayName) . $extText . '" colspan="' . $slots['width'] . '" class="text-center border-top border-bottom border-right ' . $colorclass . '" data-id="' . $slots['moduleid'] . '" data-type="' . $slots['type'] . '" data-name="' . strip_tags($originalName) . '" data-status="' . ($slots['status'] ?? 'productive') . '" data-starthe="' . $module['start_he'] . '" data-ports="' . $slots['ports'] . '" data-plug="' . $slots['plug'] . '" data-width="' . $slots['width'] . '" rowspan="' . $modulelenght . '" style="width: ' . $width . '; border-color: #797979 !important;">' . $slots['modulname'] . $extTextspan . '</td>';
$position++;
$calcwidth += $slots['width'];
}
if ($calcwidth < 12) {
$remaining_width = 12 - $calcwidth;
echo '<td colspan="' . $remaining_width . '" class="text-center border-top border-bottom border-right pl-1 pr-1" rowspan="' . $modulelenght . '">frei</td>';
}
$blocktd = $modulelenght + $i;
}
}
if ($i >= $blocktd) {
echo '<td colspan="12" style="background-color: #fff;" class="text-center he-free pt-1 pb-1"><span></span> frei</td>';
}
?>
</tr>
<?php endfor; ?>