@extends('layouts.portal') @section('title', 'Reports - Will & Trust Management') @section('page_title', 'Reports Dashboard') @section('page_subtitle', 'Management reports and insights') @section('sidebar') @include('admin.partials.sidebar', ['active' => 'reports']) @endsection @section('content')

Reports Dashboard

Management reports and insights

Report Filters

@if($reportType === 'wills' || $reportType === 'combined')
@endif
@if($reportType === 'wills')

Total Wills

{{ $stats['total'] }}

New

{{ $stats['new'] }}

Payment Pending

{{ $stats['payment_pending'] }}

Completed

{{ $stats['completed'] }}

With Lawyer

{{ $stats['with_lawyer'] }}

Without Lawyer

{{ $stats['without_lawyer'] }}

@elseif($reportType === 'trusts')

Total Trusts

{{ $stats['total'] }}

Pending Review

{{ $stats['pending_review'] }}

Approved

{{ $stats['approved'] }}

Rejected

{{ $stats['rejected'] }}

Completed

{{ $stats['completed'] }}

@else

Total Documents

{{ $stats['total_documents'] }}

Total Wills

{{ $stats['wills_total'] }}

Total Trusts

{{ $stats['trusts_total'] }}

@endif

{{ ucfirst($reportType) }} Report @if($startDate && $endDate) ({{ $startDate }} to {{ $endDate }}) @endif

@if(isset($filters['lawyer_assigned']) && str_starts_with($filters['lawyer_assigned'], 'lawyer_')) @php $lawyerId = str_replace('lawyer_', '', $filters['lawyer_assigned']); $selectedLawyer = \App\Models\User::find($lawyerId); $lawyerWillsCount = \App\Models\Will::where('reviewed_by', $lawyerId)->whereBetween('created_at', [$startDate, $endDate])->count(); @endphp

Lawyer: {{ $selectedLawyer->name }} - {{ $lawyerWillsCount }} wills in selected period

@elseif(isset($filters['client_id'])) @php $selectedClient = \App\Models\Client::find($filters['client_id']); $clientWillsCount = \App\Models\Will::where('client_id', $filters['client_id'])->whereBetween('created_at', [$startDate, $endDate])->count(); @endphp

Client: {{ $selectedClient->full_name }} - {{ $clientWillsCount }} wills in selected period

@endif
@if($reportType === 'wills' || $reportType === 'combined')
@if(isset($wills) && $wills->count() > 0)
@foreach($wills as $will) @endforeach
Will ID Client Name Will Type Status Created Date Updated Date Lawyer Assigned Lawyer Name Assignment Date Lawyer Status Payment Status Payment Date
{{ $will->id }} {{ $will->client->full_name ?? 'N/A' }} {{ $will->is_joint ? 'Joint Will' : ucfirst($will->will_type) }} @if($will->status == 'completed') Completed @elseif($will->status == 'payment_pending') Payment Pending @elseif($will->status == 'dummy') Dummy @else New @endif {{ $will->created_at->format('d M Y, h:i A') }} {{ $will->updated_at->format('d M Y, h:i A') }} @if($will->reviewed_by) Yes @else No @endif {{ $will->reviewedBy->name ?? 'N/A' }} {{ $will->updated_at->format('d M Y, h:i A') }} {{ $will->status ?? 'N/A' }} @if($will->payment_status == 'paid') Paid @elseif($will->payment_status == 'processing') Processing @elseif($will->payment_status == 'failed') Failed @else Pending @endif {{ $will->payment_status == 'paid' && $will->updated_at ? $will->updated_at->format('d M Y, h:i A') : 'N/A' }}
@else

No wills found for the selected criteria.

@endif
@endif @if($reportType === 'trusts' || $reportType === 'combined')
@if(isset($trusts) && $trusts->count() > 0)
@foreach($trusts as $trust) @endforeach
Trust ID Trust Name Client Name Trust Type Status Created Date Updated Date Purpose
{{ $trust->id }} {{ $trust->client->full_name ?? 'N/A' }} {{ $trust->trust_name }} {{ \App\Models\Trust::getTypes()[$trust->trust_type] ?? $trust->trust_type }} @if($trust->status == 'completed') Completed @elseif($trust->status == 'pending_review') Pending Review @elseif($trust->status == 'rejected') Rejected @else New @endif {{ $trust->created_at->format('d M Y, h:i A') }} {{ $trust->updated_at->format('d M Y, h:i A') }} {{ Str::limit($trust->trust_purpose, 50) ?? 'N/A' }}
@else

No trusts found for the selected criteria.

@endif
@endif
@endsection