@php /* |-------------------------------------------------------------------------- | DEVOTEE GROUPS (same logic as receipts index / receipt view) |-------------------------------------------------------------------------- | One group per devotee, each with its own items. | Old receipts (no devotee rows) fall back to devotee_name + items. */ // Normalise anything (null / array / Eloquent collection) into a base Collection $toCollection = fn ($value) => $value instanceof \Illuminate\Support\Collection ? $value : collect($value); $groups = $toCollection($receipt->devotees ?? [])->map(function ($devoteeRow) use ($toCollection) { return [ 'name' => $devoteeRow->devotee_name ?: 'Walk-in Devotee', 'nakshatram' => $devoteeRow->nakshatram, 'items' => $toCollection($devoteeRow->items ?? []), ]; }); if ($groups->isEmpty()) { $groups->push([ 'name' => $receipt->devotee_name ?: 'Walk-in Devotee', 'nakshatram' => $receipt->nakshatram, 'items' => $toCollection($receipt->items ?? []), ]); } $groupCount = $groups->count(); $sumItems = fn ($items) => $items->sum(fn ($item) => (float) ($item->amount ?? 0)); $grandTotal = $groups->sum(fn ($group) => $sumItems($group['items'])); $totalAmount = (float) ($receipt->total_amount ?: $grandTotal); $receiptNo = $receipt->receipt_number ?: '#RC-' . str_pad($receipt->id, 6, '0', STR_PAD_LEFT); $receiptDate = optional($receipt->display_date)->format('d-m-Y'); $templeName = config('app.temple_name', 'TempleMitra Devasthanam'); @endphp Receipt Voucher — {{ $receipt->receipt_number ?: $receipt->id }} {{-- Fonts: Cormorant Garamond (temple heading), Noto Serif (names), Poppins (body) --}} {{-- Theme variables (--maroon-900, --gold-600 …) and .btn-temple buttons --}} {{-- ============================================================ VOUCHER STYLES — same pv-* classes as the receipt view page, 80mm thermal slip. Change 80mm to 58mm for 58mm rolls. ============================================================ --}} {{-- ══════════════ Toolbar (hidden when printing) ══════════════ --}} {{-- ══════════════ Paper size toggle (hidden when printing) ══════════════ --}}
{{-- ══════════════ Voucher Slip ══════════════ --}}
{{-- ── Header ── --}}
|| ഓം നമഃ ശിവായ || ശുഭം ഭവതു ||

{{ session('temple_name', 'Temple') }}

Vazhipad & Pooja Dakshina Receipt
{{-- ── Receipt meta ── --}}
Receipt No: {{ $receiptNo }}
Date: {{ $receiptDate }}
{{-- ── Devotees + offerings (one self-contained block per devotee) ── --}} @foreach ($groups as $group)
{{-- Devotee header strip: number tag + name + nakshatram --}}
@if ($groupCount > 1) Devotee {{ $loop->iteration }} @endif {{ $group['name'] }} @if (! empty($group['nakshatram'])) {{ $group['nakshatram'] }} @endif
@forelse ($group['items'] as $item) @empty @endforelse
Sl.No Vazhipad Qty Amount
{{ $loop->iteration }} {{ $item->vazhipad?->name ?? $item->vazhipad?->vazhipad_name ?? 'Offering' }} {{ $item->quantity ?? 1 }} ₹{{ number_format((float) ($item->amount ?? 0), 2) }}
No Vazhipad
{{-- Every devotee gets their own subtotal, every time --}}
{{ $group['name'] }} Total ₹{{ number_format($sumItems($group['items']), 2) }}
{{-- /.pv-devotee-block --}} {{-- "Cut here" style divider between devotees only (not after the last one) --}} @if ($groupCount > 1 && ! $loop->last)
✂ next devotee ✂
@endif @endforeach
{{-- ── Grand Total ── --}}
{{ $groupCount > 1 ? 'GRAND TOTAL' : 'TOTAL' }} ₹{{ number_format($totalAmount, 2) }}
{{-- ── Payment info ── --}}
Status: {{ $receipt->payment_status_label ?: ($receipt->payment_status ?: 'Confirmed') }}
@if ($receipt->payment_method)
Method: {{ strtoupper($receipt->payment_method) }}
@endif @if ($receipt->transaction_id)
Txn ID: {{ $receipt->transaction_id }}
@endif @if ($receipt->paid_amount)
Paid: ₹{{ number_format($receipt->paid_amount, 2) }}
@endif
{{-- ── Blessing ── --}}
"May the divine grace and blessings be upon you and your family."
{{-- ── Signature row ── --}}
{{ now()->format('d/m/Y h:i A') }}
Counter Seal
{{-- /.pv-wrapper --}} {{-- ══════════════ Paper mode: A5 sheet ⇄ 80mm thermal roll ══════════════ --}}