= 2; $can_delete = lookupUserPermission('module_support') >= 3; // Archived - from All Client Docs, an archived client's racks count as archived too $archived = (isset($_GET['archived']) && $_GET['archived'] == 1) ? 1 : 0; if ($client_url) { $archive_query = $archived ? "rack_archived_at IS NOT NULL" : "rack_archived_at IS NULL"; } else { $archive_query = $archived ? "(rack_archived_at IS NOT NULL OR client_archived_at IS NOT NULL)" : "(rack_archived_at IS NULL AND client_archived_at IS NULL)"; } // Client filter (All Client Docs only) $client_filter = 0; if (!$client_url && !empty($_GET['client'])) { $client_filter = intval($_GET['client']); $client_query = "AND rack_client_id = $client_filter"; } // Location filter (one client only) $location_filter = 0; $location_query = ''; if ($client_url && !empty($_GET['location'])) { $location_filter = intval($_GET['location']); $location_query = "AND rack_location_id = $location_filter"; } // Type filter - the rack types (Admin > Categories), held by name $type_filter = trim(strip_tags((string) ($_GET['type'] ?? ''))); $type_query = $type_filter !== '' ? "AND rack_type = '" . escapeSql($type_filter) . "'" : ''; // Only these sort - filter_header.php will hand through any lowercase word if (!in_array($sort, ['rack_name', 'rack_units', 'client_name', 'location_name', 'rack_created_at'], true)) { $sort = 'rack_name'; } $sql = mysqli_query( $mysqli, "SELECT SQL_CALC_FOUND_ROWS client_id, client_name, location_name, rack_id, rack_client_id, rack_name, rack_type, rack_model, rack_units, rack_units_descending, rack_power_capacity, rack_physical_location, rack_archived_at FROM racks LEFT JOIN clients ON client_id = rack_client_id LEFT JOIN locations ON location_id = rack_location_id WHERE $archive_query AND (rack_name LIKE '%$q%' OR rack_type LIKE '%$q%' OR rack_model LIKE '%$q%' OR rack_description LIKE '%$q%' OR rack_physical_location LIKE '%$q%' OR location_name LIKE '%$q%' OR client_name LIKE '%$q%' OR EXISTS (SELECT 1 FROM rack_units LEFT JOIN assets ON asset_id = unit_asset_id WHERE unit_rack_id = rack_id AND (unit_device LIKE '%$q%' OR asset_name LIKE '%$q%' OR asset_serial LIKE '%$q%'))) " . clientScopeSql('rack_client_id') . " $client_query $location_query $type_query ORDER BY $sort $order LIMIT $record_from, $record_to" ); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $racks = []; while ($row = mysqli_fetch_assoc($sql)) { $racks[intval($row['rack_id'])] = $row; } // Every item on the page in one query, not one per rack $racks_units = rackLoadUnits(array_keys($racks)); // Totals across what's listed, for the summary line $total_units = 0; $total_used = 0; $total_items = 0; foreach ($racks as $rack_id => $row) { $racks[$rack_id]['occupancy'] = rackOccupancy($racks_units[$rack_id], max(1, intval($row['rack_units']))); $total_units += max(1, intval($row['rack_units'])); $total_used += $racks[$rack_id]['occupancy']['any']; $total_items += count($racks_units[$rack_id]); } ?>

Racks

of U in use · items count($racks) ? ' on this page' : '' ?> Archived
'racks', 'icon' => 'fa-server', 'filtered' => $q || $location_filter || $client_filter || $type_filter !== '', 'archived' => $archived, 'text' => "Document the comms closet: what's racked where, front and rear, and how much room and power is left.", 'actions' => $client_url && $can_edit ? [['label' => 'New Rack', 'modal' => "modals/rack/rack_add.php?client_id=$client_id", 'size' => 'lg']] : [], ]) ?>
$row) { $rack_client_id = intval($row['rack_client_id']); $rack_name = escapeHtml($row['rack_name']); $rack_type = escapeHtml($row['rack_type']); $rack_units = max(1, intval($row['rack_units'])); $rack_units_descending = intval($row['rack_units_descending']); $rack_power_capacity = intval($row['rack_power_capacity']); $rack_physical_location = escapeHtml($row['rack_physical_location']); $rack_location_name = escapeHtml($row['location_name']); $rack_client_name = escapeHtml($row['client_name']); $rack_archived_at = $row['rack_archived_at']; $occupancy = $row['occupancy']; $used_percent = (int) round($occupancy['any'] / $rack_units * 100); $usage_tone = $used_percent >= 90 ? 'danger' : ($used_percent >= 75 ? 'warning' : 'primary'); $rack_items = array_map('rackUnitView', $racks_units[$rack_id]); $power_used = array_sum(array_column($rack_items, 'power')); $rack_url = "rack.php?client_id=$rack_client_id&rack_id=$rack_id"; ?>
/ U used %
item U gap W
0) { require_once "../includes/filter_footer.php"; } ?>