<x-app-layout><x-slot name="header"><div><h1 class="text-2xl font-bold">Reports</h1><p class="text-sm text-slate-500">Statements, collections, income and outstanding balances.</p></div></x-slot><div class="mx-auto max-w-7xl space-y-6 px-4 py-8 sm:px-6 lg:px-8"><form method="GET" class="grid gap-4 rounded-2xl border border-slate-200 bg-white p-5 sm:grid-cols-2 lg:grid-cols-5 dark:border-slate-800 dark:bg-slate-900">@php($input='rounded-xl border-slate-300 bg-transparent dark:border-slate-700')<select name="type" class="{{ $input }}">@foreach(['daily','weekly','monthly','annual','outstanding','income','group','member'] as $type)<option value="{{ $type }}" @selected(($report['filters']['type']??'monthly')===$type)>{{ ucfirst($type) }}</option>@endforeach</select><input type="date" name="date" value="{{ $report['filters']['date']??today()->toDateString() }}" class="{{ $input }}"><select name="group_id" class="{{ $input }}"><option value="">All groups</option>@foreach($groups as $group)<option value="{{ $group->id }}" @selected(($report['filters']['group_id']??null)===$group->id)>{{ $group->name }}</option>@endforeach</select><select name="member_id" class="{{ $input }}"><option value="">All members</option>@foreach($members as $member)<option value="{{ $member->id }}" @selected(($report['filters']['member_id']??null)===$member->id)>{{ $member->full_name }}</option>@endforeach</select><button class="rounded-xl bg-emerald-600 px-4 py-2 font-semibold text-white">Generate report</button></form><div class="grid gap-4 sm:grid-cols-4">@foreach([['Records',$report['summary']['records']],['Expected','₦'.number_format($report['summary']['expected']/100,2)],['Collected','₦'.number_format($report['summary']['collected']/100,2)],['Outstanding','₦'.number_format($report['summary']['outstanding']/100,2)]] as [$label,$value])<div class="rounded-2xl border border-slate-200 bg-white p-4 dark:border-slate-800 dark:bg-slate-900"><p class="text-xs uppercase text-slate-500">{{ $label }}</p><p class="mt-1 text-xl font-bold">{{ $value }}</p></div>@endforeach</div><div class="flex justify-between"><h2 class="text-xl font-semibold">{{ $report['title'] }}</h2><div class="flex gap-2"><a href="{{ route('reports.export',[...request()->query(),'format'=>'pdf']) }}" class="rounded-xl border border-slate-300 px-3 py-2 text-sm">Export PDF</a><a href="{{ route('reports.export',[...request()->query(),'format'=>'xls']) }}" class="rounded-xl border border-slate-300 px-3 py-2 text-sm">Export Excel</a></div></div><div class="overflow-hidden rounded-2xl border border-slate-200 bg-white dark:border-slate-800 dark:bg-slate-900"><div class="overflow-x-auto"><table class="w-full text-left text-sm"><thead class="bg-slate-50 text-xs uppercase text-slate-500 dark:bg-slate-800"><tr><th class="p-4">Due</th><th class="p-4">Member</th><th class="p-4">Group</th><th class="p-4">Expected</th><th class="p-4">Collected</th><th class="p-4">Balance</th><th class="p-4">Status</th></tr></thead><tbody class="divide-y divide-slate-100 dark:divide-slate-800">@forelse($report['rows'] as $item)<tr><td class="p-4">{{ $item->due_date->format('d M Y') }}</td><td class="p-4">{{ $item->member->full_name }}</td><td class="p-4">{{ $item->group->name }}</td><td class="p-4">₦{{ number_format($item->amount_due/100,2) }}</td><td class="p-4">₦{{ number_format($item->amount_paid/100,2) }}</td><td class="p-4">₦{{ number_format($item->outstanding_amount/100,2) }}</td><td class="p-4 capitalize">{{ $item->status->value }}</td></tr>@empty<tr><td colspan="7" class="p-12 text-center text-slate-500">No records match this report.</td></tr>@endforelse</tbody></table></div></div></div></x-app-layout>
