{{-- Smart Report v2 - Summary report. --}} {{-- Ports: getSummaryPDF + setSummaryInfo + getDescritpionSummryMaxFourResults --}} {{-- + getDescritpionSummryMaxEightResults + getStatusImageSummary --}} {{-- Page 1 (Summary-Report.pdf bg): 6 category cards in 2-col × 3-row grid. --}} {{-- Overflow (Summary-Report-complete.pdf bg): 12 cards per page. --}} @php /** @var array $group Group array from controller (contains 'summaryModel') */ /** @var object $Order */ /** @var object $Profile */ $summaryModel = $group['summaryModel'] ?? []; $trueIcon = public_path('img/smart-report-pdf/true-icon.png'); $pendingIcon = public_path('img/smart-report-pdf/pending-icon.png'); // First page card slot positions (renderX, renderY) derived from v1 coordinate math: // counter=1: (145,164); =2:(55,164); =3:(145,206); =4:(55,206); =5:(145,248); =6:(55,248) $page1Slots = [ ['rx' => 145, 'ry' => 164], ['rx' => 55, 'ry' => 164], ['rx' => 145, 'ry' => 206], ['rx' => 55, 'ry' => 206], ['rx' => 145, 'ry' => 248], ['rx' => 55, 'ry' => 248], ]; // Overflow page card slot positions (6 rows × 2 cols = 12 slots per page) // are computed per page below: v1 subtracts a different offset per page // (y-215 on page 2, y-470 on page 3, y-725 on page 4), so the first row // sits at 28mm on the first overflow page, then 3mm higher on each // subsequent one (25mm, 22mm, ...). Columns: rx 144/54 (v1 x=170/80 - 26). @endphp @foreach ($summaryModel['pages'] as $page) @php $patient = $page['patient'] ?? null; $cards = $page['cards']; if ($page['type'] === 'first') { $slots = $page1Slots; } else { $overflowPageNo = max(1, (int) $loop->index); // 1st overflow page = 1 $rowBase = 28 - 3 * ($overflowPageNo - 1); // 28, 25, 22, ... per v1 $slots = []; for ($r = 0; $r < 6; $r++) { $ry = $rowBase + 42 * $r; $slots[] = ['rx' => 144, 'ry' => $ry]; $slots[] = ['rx' => 54, 'ry' => $ry]; } } @endphp
@include('pdf.smart_report.components.backgrounds.bg', [ 'template' => ($page['type'] === 'first') ? 'summary' : 'summary-complete', 'page' => 1, ]) {{-- ---------------------------------------------------------- --}} {{-- Patient header — first page only --}} {{-- ---------------------------------------------------------- --}} @if ($patient) {{-- Profile logos — mirrors setSummaryInfo lines 14808-14828. --}} {{-- Priority: REPORT_HEADER full-width (8,7,190mm) > individual logos. --}} @if ($patient['report_header']) @else @if ($patient['logo_left']) {{-- LOGO when LEFT_LOGO also present: left:7mm w:80mm --}} @elseif ($patient['logo_center']) {{-- LOGO alone: left:65mm w:80mm --}} @endif @if ($patient['logo_left_small']) {{-- LEFT_LOGO: left:92mm w:50mm --}} @endif @if ($patient['logo_right']) {{-- RIGHT_LOGO: left:145mm w:30mm --}} @endif @endif {{-- ============================================================ --}} {{-- Figma patient header (same design as the per-test pages). The --}} {{-- summary background carries logos at the very top, so the whole --}} {{-- lockup sits ~30mm lower than on the analysis pages: avatar + --}} {{-- name on one line, a hairline under the name, then the icon + --}} {{-- label + value field grid below it. --}} {{-- ============================================================ --}} @php $sumBaseY = 47; // top of the avatar / name band on this page // Inline-SVG line icons (teal, 1.6px stroke) — identical set to // patient_header.blade.php. $st = 'rgb(1,156,167)'; $sumIcons = [ 'gender' => '', 'age' => '', 'id' => '', 'phone' => '', 'order' => '', 'date' => '', 'lab' => '', ]; foreach ($sumIcons as $k => $svg) { $sumIcons[$k] = str_replace(' @endif {{-- Patient name: black, bold, single line to the right of the avatar. --}} @php $sumNameLen = mb_strlen($patient['name'] ?? '', 'UTF-8'); $sumNameSize = $sumNameLen > 40 ? 11 : ($sumNameLen > 30 ? 12.5 : 13.9); @endphp
{{ $patient['name'] }}
{{-- Hairline under the name. --}}
{{-- Icon + label + value field grid. Drop empty-value fields FIRST, --}} {{-- then pack the survivors into consecutive column slots so an empty --}} {{-- field never leaves a gap — the next field shifts left to fill it. --}} @foreach ($sumRows as $r => $row) @php $rowFields = array_values(array_filter($row, fn ($f) => $f[2] !== '' && $f[2] !== null)); @endphp @foreach ($rowFields as $i => $f) @php [$ik, $label, $value] = $f; $fx = $sumRowX[$r][$i] ?? $sumRowX[$r][count($sumRowX[$r]) - 1]; $fy = $sumRowTop[$r]; @endphp
{!! $sumIcons[$ik] !!}
{{ $label }}
{{ $value }}
@endforeach @endforeach {{-- Blazma logo at (202, 130) w=7mm --}} @if ($patient['blazma_logo']) @endif @endif {{-- ---------------------------------------------------------- --}} {{-- Category cards --}} {{-- ---------------------------------------------------------- --}} @foreach ($cards as $cardIdx => $card) @php $slot = $slots[$cardIdx] ?? null; if (!$slot) continue; $rx = $slot['rx']; // renderX in mm $ry = $slot['ry']; // renderY in mm $nameLen = mb_strlen($card['name'], 'UTF-8'); @endphp {{-- Category name: (rx+4, ry-12) right-aligned 22mm cell — bold mirrors v1 setFont('bold'). --}} {{-- TCPDF cells never wrap: long names overflow to the LEFT of the 22mm box, so keep --}} {{-- nowrap here (page dir=rtl anchors the overflow on the right edge like v1's 'R' cell). --}}
{!! app(\App\Services\SmartReportV2Service::class)->isolateLtrRuns($card['name']) !!}
{{-- Category icon: pushed ~3mm right of the title (text ends at --}} {{-- rx+26) so there is a clear gap between the title and its icon. --}} @if ($card['icon']) @endif {{-- Result items (up to 6 inline; overflow items at different position) --}} @php $itemY = $ry+2; @endphp @foreach ($card['items'] as $itemIdx => $item) @php $isOverflow = $itemIdx >= 6; $statusX = $isOverflow ? ($rx - 31) : ($rx + 4); $labelX = $isOverflow ? ($rx - 33) : ($rx + 2); // v1 advances y by 5mm for EVERY item, so overflow item N // sits at ry + 5*N - 35, not at a fixed ry - 35. $labelY = $isOverflow ? ($itemY - 35) : ($itemY - 5); // Vertically centre the 4mm status icon on its text line. The // DIN-Arabic glyph sits low in its line box, so the icon needs // to sit slightly BELOW the text-box top to line up with the // glyph's visual middle (a negative nudge left it too high). $statusY = $labelY + 0.3; $itemNameLen = mb_strlen($item['name'], 'UTF-8'); @endphp @if ($item['has_status']) @php $iconPath = $item['is_normal'] ? $trueIcon : $pendingIcon; @endphp @if (is_file($iconPath)) @endif @endif {{-- Same no-wrap rule as the category title: v1's 22mm 'R' cell overflows left. --}} {{-- Latin runs (IgE, C0919, …) are LTR-isolated so RTL order keeps --}} {{-- them intact instead of detaching them into the Arabic. --}}
{!! app(\App\Services\SmartReportV2Service::class)->isolateLtrRuns($item['name']) !!}
{{-- v1 increments y by 5 after every item, overflow included --}} @php $itemY += 5; @endphp @endforeach @endforeach
@endforeach