intval($row['unit_start_number']), 'end' => intval($row['unit_end_number']), 'face' => $row['unit_face'] === 'rear' ? 'rear' : 'front', 'full' => intval($row['unit_full_depth']) === 1, 'name' => rackUnitName($row['asset_name'], $row['unit_device'], $row['unit_type']), ]; } // This client's assets that aren't racked anywhere yet (plus the one already // on this item). An archived asset only stays listed if it's this item's. $asset_options = []; $sql = mysqli_query($mysqli, "SELECT asset_id, asset_name, asset_type, asset_make, asset_model FROM assets WHERE asset_client_id = $client_id AND (asset_id = $unit_asset_id OR ( asset_archived_at IS NULL AND NOT EXISTS (SELECT 1 FROM rack_units WHERE unit_asset_id = asset_id) )) ORDER BY FIELD(asset_type, '" . implode("', '", array_map('escapeSql', ASSET_RACK_TYPES)) . "') = 0, asset_type, asset_name"); while ($row = mysqli_fetch_assoc($sql)) { $asset_options[] = $row; } $unit_is_asset = $unit_asset_id > 0 || ($unit_id === 0 && $unit_device === ''); $item_types = rackItemTypes(); ?>