@extends('temple.layouts.app') @section('title', 'Receipt #' . ($receipt->receipt_number ?: str_pad($receipt->id, 6, '0', STR_PAD_LEFT))) @section('content') @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. */ $devotees = $receipt->devotees ?? collect(); if (! $devotees instanceof \Illuminate\Support\Collection) { $devotees = collect($devotees); } $groups = collect(); foreach ($devotees as $devoteeRow) { $groupItems = $devoteeRow->items ?? collect(); if (! $groupItems instanceof \Illuminate\Support\Collection) { $groupItems = collect($groupItems); } $groups->push([ 'name' => $devoteeRow->devotee_name ?: 'Walk-in Devotee', 'nakshatram' => $devoteeRow->nakshatram, 'items' => $groupItems, ]); } if ($groups->isEmpty()) { $legacyItems = $receipt->items ?? collect(); if (! $legacyItems instanceof \Illuminate\Support\Collection) { $legacyItems = collect($legacyItems); } $groups->push([ 'name' => $receipt->devotee_name ?: 'Walk-in Devotee', 'nakshatram' => $receipt->nakshatram, 'items' => $legacyItems, ]); } $groupCount = $groups->count(); $grandTotal = $groups->sum(function ($group) { return $group['items']->sum(function ($item) { return (float) ($item->amount ?? 0); }); }); $grandQuantity = $groups->sum(function ($group) { return $group['items']->sum(function ($item) { return (int) ($item->quantity ?? 0); }); }); $totalAmount = (float) ($receipt->total_amount ?: $grandTotal); $pStatus = strtolower($receipt->payment_status ?? 'pending'); @endphp {{-- ============================================================ PRINT-ONLY STYLES These rules only take effect when printing (window.print()). On screen, nothing below changes — the print voucher stays hidden. ============================================================ --}} {{-- ============================================================ PRINT-ONLY VOUCHER MARKUP — invisible on screen, only rendered when the page is printed. ============================================================ --}}
{{-- Top Action Toolbar --}}
Back to Printing List
Print Voucher Slip Update Payment
@if (session('success'))
{{ session('success') }}
@endif {{-- Main Receipt Details Card --}}

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

{{ $receipt->receipt_number ?: '#RC-' . str_pad($receipt->id, 6, '0', STR_PAD_LEFT) }}
{{-- Devotee & Meta Overview Grid --}}
Devotee Name
{{ $groups->first()['name'] }} @if($groupCount > 1) +{{ $groupCount - 1 }} more @endif
Birth Star (Nakshatram)
@if($groupCount > 1) Multiple — see below @elseif(!empty($groups->first()['nakshatram'])) {{ $groups->first()['nakshatram'] }} @else — @endif
Receipt Date
{{ optional($receipt->receipt_date ?: $receipt->receipts_date)->format('d F Y') ?: 'N/A' }}
Payment Status
{{ $receipt->payment_status_label ?: ucfirst(str_replace('_', ' ', $pStatus)) }}
{{-- Vazhipad Offerings (one table per devotee) --}}
@foreach ($groups as $group) @php $groupNo = $loop->iteration; $groupTotal = $group['items']->sum(fn ($i) => (float) ($i->amount ?? 0)); $groupQty = $group['items']->sum(fn ($i) => (int) ($i->quantity ?? 0)); @endphp

@if($groupCount > 1) Devotee {{ $groupNo }} — {{ $group['name'] }} @if(!empty($group['nakshatram'])) {{ $group['nakshatram'] }} @endif @else Pooja & Vazhipad Line Items @endif

@forelse ($group['items'] as $item) @empty @endforelse @if($groupCount > 1) @endif
# Vazhipad Offering Quantity Amount (₹)
{{ $loop->iteration }} {{ $item->vazhipad?->name ?? $item->vazhipad?->vazhipad_name ?? 'Offering' }} {{ $item->quantity ?? 1 }} ₹{{ number_format((float) ($item->amount ?? 0), 2) }}
No offering items attached to this devotee.
{{ $group['name'] }} Total {{ $groupQty }} ₹{{ number_format($groupTotal, 2) }}
@endforeach {{-- Grand Total --}}
Total Contribution Amount {{ $grandQuantity }} items ₹{{ number_format($totalAmount, 2) }}
{{-- Payment Information Section --}}

Counter Payment Information

Payment Status
{{ $receipt->payment_status_label ?: ucfirst(str_replace('_', ' ', $pStatus)) }}
Payment Method
{{ $receipt->payment_method ? strtoupper($receipt->payment_method) : '—' }}
Transaction ID
{{ $receipt->transaction_id ?: '—' }}
Paid Amount
₹{{ number_format((float) ($receipt->paid_amount ?: $totalAmount), 2) }}
Paid Timestamp
{{ $receipt->paid_at ? \Carbon\Carbon::parse($receipt->paid_at)->format('d M Y, h:i A') : '—' }}
@endsection