@php /** * One report run on screen: headline cards, then each table with its bars. * Expects $result (ReportResult) and $base (base currency code). */ use App\Services\Crm\Reports\ReportFormat; use App\Services\Crm\Reports\ReportResult; $accents = ['#6366f1', '#0ea5e9', '#10b981', '#f59e0b', '#e11d48', '#8b5cf6']; @endphp @if ($result->kpis !== [])
@foreach ($result->kpis as $i => $kpi)

{{ $kpi['label'] }}

{{ ReportFormat::cell($kpi['value'], $kpi['type'], $base, $kpi['null']) }}

@if ($kpi['sub']) {{ $kpi['sub'] }} @endif
@endforeach
@endif @foreach ($result->notes as $note)
{{ $note }}
@endforeach @foreach ($result->sections as $s => $section) @php $bars = ReportResult::bars($section); @endphp

{{ $section['title'] }}

@if ($section['note'])

{{ $section['note'] }}

@endif
@if (count($bars) > 1)
@foreach ($bars as $bar)
{{ $bar['label'] }}
{{ ReportFormat::cell($bar['value'], $section['columns'][$section['chart']['value']]['type'], $base) }}
@endforeach
@endif
@foreach ($section['columns'] as $column) @endforeach @php // On screen each section pages; a renderer without // pages (the PDF) prints every row. $pageRows = $sectionPages[$s] ?? null; @endphp @forelse ($pageRows ?? $section['rows'] as $r => $row) @foreach ($section['columns'] as $key => $column) @php $value = $row[$key] ?? null; @endphp @endforeach @empty @endforelse @if ($section['totals'] && $section['rows'] !== []) @foreach ($section['columns'] as $key => $column) @endforeach @endif
{{ $column['label'] }}
{{ ReportFormat::cell($value, $column['type'], $base, $column['null']) }}
{{ array_key_exists($key, $section['totals']) ? ReportFormat::cell($section['totals'][$key], $column['type'], $base, $column['null']) : '' }}
@if ($pageRows !== null) @include('livewire.crm.partials.paginator', ['rows' => $pageRows]) @endif
@endforeach