@extends('admin.layouts.app') @section('title', 'EMI Card Details | PG Finsev') @section('page-title', 'EMI Card Details') @section( 'page-description', 'View client EMI card information and approval details' ) @push('styles') @endpush @section('content') {{-- ===================================================== BACK ====================================================== --}} ← Back to EMI Cards {{-- ===================================================== ALERTS ====================================================== --}} @if(session('success'))
✓ {{ session('success') }}
@endif @if(session('error'))
✕ {{ session('error') }}
@endif {{-- ===================================================== PAGE HEADING ====================================================== --}}

EMI Card Details

Complete information for this EMI card and client.

{{-- ================================================= LEFT ================================================== --}}
{{-- CARD PREVIEW --}}

Card Preview

@if( $card->expires_at && $card->expires_at->isPast() ) Expired @else @switch($card->status) @case('active') Active @break @case('pending') Pending @break @case('blocked') Blocked @break @default {{ ucfirst( $card->status ) }} @endswitch @endif
PG FINSEV
{{ $card->card_number }}
Card Holder {{ $card->user->name ?? 'CLIENT' }}
Valid Until {{ $card->expires_at ? $card->expires_at->format( 'm/Y' ) : '-' }}
{{-- CARD INFO --}}
Card Limit ₹{{ number_format( $card->card_limit ?? 0, 2 ) }}
Available Limit ₹{{ number_format( $card->available_limit ?? 0, 2 ) }}
Issued Date {{ $card->issued_at ? $card->issued_at->format( 'd M Y' ) : '-' }}
Expiry Date {{ $card->expires_at ? $card->expires_at->format( 'd M Y' ) : '-' }}
{{-- CLIENT DETAILS --}}

Client Information

{{ strtoupper( substr( $card->user->name ?? 'C', 0, 1 ) ) }}
{{ $card->user->name ?? 'Unknown Client' }}
{{ $card->user->email ?? '-' }}
{{ $card->user->mobile ?? '-' }}
Personal Details {{ $card->user->clientProfile ? '✓ Completed' : '✕ Incomplete' }}
KYC {{ $card->user->clientKyc && $card->user->clientKyc->status === 'verified' ? '✓ Verified' : '✕ Not Verified' }}
Job Details {{ $card->user->clientEmployment ? '✓ Completed' : '✕ Incomplete' }}
Card Status {{ ucfirst( $card->status ) }}
{{-- ================================================= RIGHT ================================================== --}}
{{-- ACTION PANEL --}}

Card Actions

@php $hasPaidPayment = $card->user ? $card->user->payments() ->where( 'status', 'paid' ) ->exists() : false; $isExpired = $card->expires_at && $card->expires_at->isPast(); @endphp {{-- PAYMENT STATUS --}}
Payment Status @if($hasPaidPayment) ✓ Payment Completed @else ⏳ Payment Pending @endif
{{-- APPROVAL STATUS --}}
Approval @if($card->approved_at) ✓ Approved @if($card->approver)
By: {{ $card->approver->name }}
{{ $card->approved_at->format( 'd M Y h:i A' ) }}
@endif @else Pending Approval @endif
{{-- LIMIT UPDATE --}} @if(!$isExpired)
@csrf @method('PUT')
@endif {{-- ACTIONS --}}
{{-- APPROVE --}} @if( $card->status === 'pending' ) @if($hasPaidPayment) @if( (float) $card->card_limit > 0 )
@csrf
@else
Please set the loan limit before approval.
@endif @else
Payment must be completed before approval.
@endif @endif {{-- BLOCK --}} @if( $card->status === 'active' )
@csrf
@endif {{-- BLOCKED → ACTIVATE --}} @if( $card->status === 'blocked' && !$isExpired )
@csrf
@endif
{{-- LOAN SUMMARY --}} @if( $card->user && method_exists($card->user, 'loans') ) @php $cardLoans = $card->user->loans() ->latest('created_at') ->get(); @endphp

Loan Summary

@if($cardLoans->count()) @php $activeLoans = $cardLoans->whereIn( 'status', ['approved', 'disbursed', 'active', 'overdue'] ); $totalBorrowed = $cardLoans->sum( fn ($loan) => (float) ($loan->loan_amount ?? 0) ); $totalOutstanding = $cardLoans->sum( fn ($loan) => (float) ($loan->outstanding_amount ?? 0) ); $monthlyEmi = $activeLoans->sum( fn ($loan) => (float) ($loan->emi_amount ?? 0) ); @endphp
Loans {{ $cardLoans->count() }}
Active {{ $activeLoans->count() }}
Total Borrowed ₹{{ number_format($totalBorrowed, 2) }}
Outstanding ₹{{ number_format($totalOutstanding, 2) }}
Monthly EMI ₹{{ number_format($monthlyEmi, 2) }}
@foreach($cardLoans->take(5) as $loan)
{{ $loan->loan_number ?? 'Loan #'.$loan->id }}
{{ ucfirst($loan->status ?? '—') }}
₹{{ number_format($loan->outstanding_amount ?? 0, 2) }}
Outstanding
@endforeach
@else
No loan records found.
@endif
@endif {{-- PAYMENT HISTORY --}}

Payment History

@if( $card->user && $card->user->payments->count() ) @foreach( $card->user->payments ->sortByDesc('created_at') ->take(10) as $payment )
Payment
{{ $payment->created_at ? $payment->created_at->format( 'd M Y h:i A' ) : '-' }}
₹{{ number_format( $payment->amount ?? 0, 2 ) }}
@if( $payment->status === 'paid' ) @else
{{ ucfirst( $payment->status ) }}
@endif
@endforeach @else
No payment records found.
@endif
@endsection