<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Disbursement Receipt {{ $disbursement->disbursement_number }}</title>
<style>
body{font-family:Arial,sans-serif;color:#111827;margin:0;background:#f5f5f5}.sheet{max-width:760px;margin:24px auto;background:#fff;border:1px solid #d1d5db;padding:28px}.head{display:flex;justify-content:space-between;gap:24px;border-bottom:2px solid #111827;padding-bottom:16px}.brand{display:flex;gap:12px}.logo{max-width:80px;max-height:65px;object-fit:contain}.title{font-size:22px;font-weight:700}.muted{color:#6b7280;font-size:12px}.number{font-size:13px;font-weight:700}.grid{display:grid;grid-template-columns:1fr 1fr;gap:14px 28px;margin-top:22px}.label{font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:#6b7280}.value{font-size:14px;font-weight:600;margin-top:3px}.amount{margin:24px 0;border:1px solid #d1d5db;padding:18px;text-align:center}.amount .value{font-size:26px}.notes{border-top:1px solid #e5e7eb;padding-top:16px;margin-top:20px}.signatures{display:grid;grid-template-columns:1fr 1fr;gap:50px;margin-top:58px}.line{border-top:1px solid #111827;padding-top:6px;font-size:11px}.stamp{max-width:110px;max-height:80px;object-fit:contain}.actions{max-width:760px;margin:0 auto 24px;display:flex;gap:8px}.btn{display:inline-block;padding:9px 13px;border:1px solid #d1d5db;background:#fff;color:#111827;text-decoration:none;font-size:13px;cursor:pointer}@media print{body{background:#fff}.sheet{border:0;margin:0;max-width:none}.actions{display:none}}
</style>
</head>
<body>
@php($business=$disbursement->branch->business)
<div class="actions"><button class="btn" onclick="window.print()">Print Receipt</button><a class="btn" href="{{ route('documents.disbursement-receipt.pdf',$disbursement) }}">Download PDF</a><a class="btn" href="{{ route('loans.show',$disbursement->loan) }}">Open Loan</a><a class="btn" href="{{ route('loan-disbursements.index') }}">Disbursement List</a></div>
<div class="sheet">
<div class="head"><div class="brand">@if($business->logo_path)<img class="logo" src="{{ route('document-branding.asset',[$business,'logo']) }}" alt="Company logo">@endif<div><div class="title">{{ $business->name }}</div><div class="muted">{{ collect([$business->address,$business->phone,$business->email])->filter()->join(' · ') }}</div><div class="muted">Reg {{ $business->registration_number ?: 'N/A' }} · TIN {{ $business->tin ?: 'N/A' }}</div><div class="muted">{{ $disbursement->branch->name }}</div></div></div><div style="text-align:right"><div class="title" style="font-size:18px">Loan Disbursement Receipt</div><div class="number">{{ $disbursement->disbursement_number }}</div><div class="muted">Generated {{ now()->format('d M Y H:i') }}</div></div></div>
<div class="grid">
<div><div class="label">Customer</div><div class="value">{{ $disbursement->loan->customer->full_name }}</div><div class="muted">{{ $disbursement->loan->customer->customer_number }} · {{ $disbursement->loan->customer->phone }}</div></div>
<div><div class="label">Loan Number</div><div class="value">{{ $disbursement->loan->loan_number }}</div><div class="muted">{{ $disbursement->loan->product->name }}</div></div>
<div><div class="label">Disbursement Date</div><div class="value">{{ $disbursement->disbursement_date->format('d M Y') }}</div></div>
<div><div class="label">Financial Account</div><div class="value">{{ $disbursement->financialAccount->name }}</div><div class="muted">{{ str($disbursement->financialAccount->account_type)->replace('_',' ')->title() }}</div></div>
<div><div class="label">Reference</div><div class="value">{{ $disbursement->reference ?: '—' }}</div></div>
<div><div class="label">Disbursed By</div><div class="value">{{ $disbursement->user?->name ?? 'System' }}</div></div>
</div>
<div class="amount"><div class="label">Amount Disbursed</div><div class="value">{{ $business->currency_symbol ?: $business->currency }} {{ number_format((float)$disbursement->amount,2) }}</div><div class="muted">Approved principal released to the customer</div></div>
<div class="notes"><div class="label">Notes</div><div class="value" style="font-weight:400">{{ $disbursement->notes ?: 'No additional notes.' }}</div></div>
<div class="signatures"><div class="line">Customer signature / acknowledgement</div><div class="line">Authorized staff signature</div></div>
@if($business->stamp_path)<div style="text-align:right;margin-top:18px"><img class="stamp" src="{{ route('document-branding.asset',[$business,'stamp']) }}" alt="Company stamp"></div>@endif
<div class="muted" style="margin-top:26px">This receipt is generated from the permanent loan disbursement record. The related financial-account transaction and accounting journal are retained by the system.</div>
</div>
</body>
</html>
