@php use App\Support\DocumentBrand; $settings = $businessSettings ?? []; ['brand' => $brand, 'brandDark' => $brandDark] = DocumentBrand::colors($settings); $logoPath = DocumentBrand::logoPath($settings['business_logo'] ?? null); $rows = collect($rows)->map(fn ($row) => array_values((array) $row)); $columns = count($headers); // A column is numeric when every non-empty cell in it looks like a number // (with or without thousands separators). Those columns are right-aligned so // amounts line up; text columns stay left. $numeric = []; foreach (range(0, max($columns - 1, 0)) as $i) { $cells = $rows->pluck($i)->filter(fn ($v) => $v !== null && $v !== '' && $v !== '-'); $numeric[$i] = $cells->isNotEmpty() && $cells->every(fn ($v) => is_numeric(str_replace([',', ' '], '', (string) $v))); } $filterLabels = collect($filters ?? []) ->filter(fn ($v) => $v !== null && $v !== '' && $v !== []) ->map(fn ($v, $k) => ucfirst(str_replace('_', ' ', $k)).': '.(is_array($v) ? implode(', ', $v) : $v)); @endphp {{ $title }} @include('documents._styles', ['brand' => $brand, 'brandDark' => $brandDark])
 
{{ $settings['business_name'] ?? '' }} · {{ $title }} · generated {{ now()->format('d M Y, H:i') }} Page
{{-- Masthead ------------------------------------------------------------ --}}
@if ($logoPath) @endif @if (!empty($settings['business_name']))

{{ $settings['business_name'] }}

@endif @if (!empty($settings['business_address']))

{{ $settings['business_address'] }}

@endif @if (!empty($settings['business_phone']) || !empty($settings['business_email']))

{{ collect([$settings['business_phone'] ?? null, $settings['business_email'] ?? null])->filter()->implode(' · ') }}

@endif

{{ strtoupper($title) }}

Generated {{ now()->format('d M Y, H:i') }} · {{ $rows->count() }} {{ \Illuminate\Support\Str::plural('row', $rows->count()) }}

@if ($filterLabels->isNotEmpty())
Filters applied: {{ $filterLabels->implode(' · ') }}
@endif {{-- Data ------------------------------------------------------------------ --}} @if ($rows->isEmpty())
No records match this report for the selected period.
@else @foreach ($headers as $i => $h) @endforeach @foreach ($rows as $row) @foreach ($row as $i => $col) @endforeach @endforeach
{{ strtoupper($h) }}
{{ $col === null || $col === '' ? '—' : $col }}
@endif {{-- Summary ---------------------------------------------------------------- --}} @if (!empty($summary))

SUMMARY

@foreach ($summary as $k => $v) @endforeach
{{ $k }} {{ $v }}
@endif
{{ $settings['business_name'] ?? 'Report' }} · {{ $title }}
Figures reflect records in the system at the time of generation. Internal document.