140 lines
8.9 KiB
PHP
140 lines
8.9 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;
|
|
$cableTitle = htmlspecialchars($cable['cable_name'] . ' (Ports ' . $cable['port_start'] . '-' . $cable['port_end'] . ')', ENT_QUOTES);
|
|
if (!empty($cable['description'])) {
|
|
$cableTitle .= ' | ' . htmlspecialchars($cable['description'], ENT_QUOTES);
|
|
}
|
|
$cellContent .= '<div class="cable-item" title="' . $cableTitle . '" 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) . '">';
|
|
$cellContent .= '<span><b>' . $cable['cable_name'] . "</b></span>";
|
|
if (!empty($cable['description'])) {
|
|
$cellContent .= '<span class="cable-description" >' . htmlspecialchars($cable['description'], ENT_QUOTES) . '</span>';
|
|
}
|
|
$cellContent .= '<div class="port-ranges-container" style="display: flex; justify-content: center; width: 100%; font-size: 10px; gap: 8px;">';
|
|
$cellContent .= '<tool class="port-range">P: ' . $cable['port_start'] . '-' . $cable['port_end'] . '</tool>';
|
|
if (!empty($cable['fiber_start'])) {
|
|
$cellContent .= '<tool class="fiber-range">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%";
|
|
else if ($slots['width'] == "4") $width = "28%";
|
|
else if ($slots['width'] == "3") $width = "21%";
|
|
|
|
|
|
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'] . '" 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; ?>
|