diff --git a/client_racks.php b/client_racks.php index d070d771..a93fff80 100644 --- a/client_racks.php +++ b/client_racks.php @@ -178,51 +178,142 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
= 1; $i--) { + // Keep track of which device_ids we've already printed + $printedDevices = []; + + for ($i = $rack_units; $i >= 1; $i--) { + + // Find all devices that occupy the current unit $i $unit_devices = []; foreach ($rack_units_data as $unit_data) { - if ($i >= $unit_data['unit_start_number'] && $i <= $unit_data['unit_end_number']) { + $start = (int) $unit_data['unit_start_number']; + $end = (int) $unit_data['unit_end_number']; + + // If $i is between start and end, device occupies this unit + if ($i >= $start && $i <= $end) { $unit_devices[] = [ - 'unit_id' => intval($unit_data['unit_id']), - 'device' => nullable_htmlentities($unit_data['unit_device']), - 'asset_id' => intval($unit_data['asset_id']), - 'asset_name' => nullable_htmlentities($unit_data['asset_name']), - 'asset_type' => nullable_htmlentities($unit_data['asset_type']), - 'icon' => getAssetIcon($unit_data['asset_type']) + 'unit_id' => (int) $unit_data['unit_id'], + 'unit_device' => nullable_htmlentities($unit_data['unit_device']), + 'unit_start_number'=> $start, + 'unit_end_number' => $end, + 'asset_id' => (int) $unit_data['asset_id'], + 'asset_name' => nullable_htmlentities($unit_data['asset_name']), + 'asset_type' => nullable_htmlentities($unit_data['asset_type']), + 'icon' => getAssetIcon($unit_data['asset_type']) ]; } } + ?> - - + + + + + + 1) { + // If your data might have multiple devices in the same row, + // you have to decide how to handle them. + // For now, we can fallback to older logic or display them all in one cell, etc. + ?> + - - + + - + + + + + - +
- - - - - + + + + + + + + + + + + + + + + + +
+ - -
- + - - No device
+