@extends('admin.layouts.app') @section('title', $client->name . ' | EMI CREDITS Admin') @section('page-title', 'Client Details') @section( 'page-description', 'Complete client profile, KYC, EMI card, loans and payments' ) @php $profile = $client->clientProfile; $kyc = $client->clientKyc; $employment = $client->clientEmployment; $emiCard = $client->emiCard; /* |-------------------------------------------------------------------------- | Currency |-------------------------------------------------------------------------- */ $currencySettings = \App\Models\SystemSetting::query()->first(); $currencySymbol = $currencySettings?->currency_symbol ?? '₹'; /* |-------------------------------------------------------------------------- | Card Unlock Payment |-------------------------------------------------------------------------- */ $hasCardUnlockPayment = isset($cardUnlockPayment) && $cardUnlockPayment; /* |-------------------------------------------------------------------------- | KYC Display |-------------------------------------------------------------------------- | | Aadhaar / PAN remain masked. | */ $aadhaarDisplay = null; $panDisplay = null; if ($kyc) { $aadhaar = $kyc->aadhaar_number ?? null; $pan = $kyc->pan_number ?? null; /* |-------------------------------------------------------------------------- | Try decrypting Aadhaar |-------------------------------------------------------------------------- */ if ($aadhaar) { try { $aadhaar = \Illuminate\Support\Facades\Crypt::decryptString( $aadhaar ); } catch (\Throwable $e) { // Already plain text or different encryption format. } } /* |-------------------------------------------------------------------------- | Try decrypting PAN |-------------------------------------------------------------------------- */ if ($pan) { try { $pan = \Illuminate\Support\Facades\Crypt::decryptString( $pan ); } catch (\Throwable $e) { // Already plain text or different encryption format. } } /* |-------------------------------------------------------------------------- | Mask Aadhaar |-------------------------------------------------------------------------- */ if ($aadhaar) { $aadhaarDigits = preg_replace( '/\D/', '', (string) $aadhaar ); if (strlen($aadhaarDigits) >= 4) { $aadhaarDisplay = 'XXXX XXXX ' . substr( $aadhaarDigits, -4 ); } else { $aadhaarDisplay = 'XXXX'; } } /* |-------------------------------------------------------------------------- | Mask PAN |-------------------------------------------------------------------------- */ if ($pan) { $panString = strtoupper( trim( (string) $pan ) ); if (strlen($panString) >= 4) { $panDisplay = '******' . substr( $panString, -4 ); } else { $panDisplay = '******'; } } } /* |-------------------------------------------------------------------------- | Card Expiry Compatibility |-------------------------------------------------------------------------- */ $cardExpiry = $emiCard?->expiry_date ?? $emiCard?->expires_at ?? null; /* |-------------------------------------------------------------------------- | Loan Summary |-------------------------------------------------------------------------- */ $loanCount = $loanCount ?? $loans->count(); $activeLoanCount = $activeLoanCount ?? 0; $completedLoanCount = $completedLoanCount ?? 0; $totalLoanAmount = $totalLoanAmount ?? 0; $totalDisbursedAmount = $totalDisbursedAmount ?? 0; $totalOutstandingAmount = $totalOutstandingAmount ?? 0; $monthlyEmi = $monthlyEmi ?? 0; $paymentCount = $paymentCount ?? $payments->count(); $paidPaymentCount = $paidPaymentCount ?? 0; $totalPaidAmount = $totalPaidAmount ?? 0; @endphp @section('content') @push('styles') @endpush
{{-- ===================================================== ALERTS ====================================================== --}} @if(session('success'))
✓ {{ session('success') }}
@endif @if(session('error'))
✕ {{ session('error') }}
@endif @if($errors->any())
Please check the following:
@endif {{-- ===================================================== BACK ====================================================== --}} ← Back to Clients {{-- ===================================================== PROFILE HERO ====================================================== --}}
{{ strtoupper( substr( $client->name ?? 'C', 0, 1 ) ) }}

{{ $client->name }}

Client ID #{{ $client->id }}
✉ {{ $client->email }} 📱 {{ $client->mobile ?? 'Not available' }}
CLIENT Registered {{ $client->created_at ? $client->created_at->format('d M Y') : '—' }}
{{-- ===================================================== VERIFICATION STATUS ====================================================== --}}
{{-- PERSONAL --}}
Personal Details
@if($profile)
✓ Complete
@else
! Pending
@endif
{{-- KYC --}}
KYC Verification
@if(!$kyc)
! Not Submitted
@elseif($kyc->status === 'verified')
✓ Verified
@elseif($kyc->status === 'rejected')
✕ Rejected
@else
! Pending
@endif
{{-- EMPLOYMENT --}}
Employment
@if($employment)
✓ Submitted
@else
! Pending
@endif
{{-- CARD --}}
EMI Card
@if(!$emiCard)
Not Generated
@elseif($emiCard->status === 'active')
✓ Active
@elseif($emiCard->status === 'blocked')
Blocked
@elseif($emiCard->status === 'expired')
Expired
@else
{{ ucfirst($emiCard->status) }}
@endif
{{-- ===================================================== FINANCIAL SUMMARY ====================================================== --}}
💰
Total Loans
{{ $loanCount }}
📊
Total Borrowed
{{ money((float)$totalLoanAmount) }}
Outstanding
{{ money((float)$totalOutstandingAmount) }}
💳
Paid Amount
{{ money((float)$totalPaidAmount) }}
{{-- ===================================================== PERSONAL + EMPLOYMENT ====================================================== --}}
{{-- PERSONAL DETAILS --}}
👤

Personal Details

Profile
@if($profile)
Full Name {{ $profile->full_name ?? $client->name }}
Date of Birth @if($profile->date_of_birth) {{ \Carbon\Carbon::parse( $profile->date_of_birth )->format('d M Y') }} @else Not provided @endif
{{-- GENDER --}}
Gender {{ $profile->gender ?? 'Not provided' }}
Mobile {{ $profile->mobile ?? $client->mobile ?? 'Not provided' }}
City {{ $profile->city ?? 'Not provided' }}
State {{ $profile->state ?? 'Not provided' }}
Pincode {{ $profile->pincode ?? 'Not provided' }}
Address {{ $profile->address ?? 'Not provided' }}
@else Personal details have not been submitted yet. @endif
{{-- EMPLOYMENT DETAILS --}}
💼

Employment Details

Work profile
@if($employment)
Employment Type {{ ucfirst( str_replace( '_', ' ', $employment->employment_type ) ) }}
Company {{ $employment->company_name ?? 'Not provided' }}
Job Title {{ $employment->job_title ?? 'Not provided' }}
Monthly Income @if( $employment->monthly_income !== null ) {{ money( (float)$employment->monthly_income ) }} @else Not provided @endif
Work Experience {{ $employment->work_experience ?? 'Not provided' }}
Office City {{ $employment->office_city ?? 'Not provided' }}
@else Employment details have not been submitted yet. @endif
{{-- ===================================================== BANK DETAILS ====================================================== --}}
🏦

Bank Details

Bank account
@if($client->bankDetail)
{{-- Bank Name --}}
Bank Name {{ $client->bankDetail->bank_name ?? 'Not provided' }}
{{-- Branch --}}
Branch {{ $client->bankDetail->branch ?? 'Not provided' }}
{{-- Account Number --}}
Account Number {{ $client->bankDetail->account_number ?? 'Not provided' }}
{{-- IFSC --}}
IFSC Code {{ $client->bankDetail->ifsc_code ?? 'Not provided' }}
@else Bank details have not been submitted yet. @endif
{{-- ===================================================== KYC ====================================================== --}}
🪪

KYC Verification

Identity verification
@if($kyc)
Verification Status
@if($kyc->status === 'verified') Verified @elseif($kyc->status === 'rejected') Rejected @else Pending Verification @endif
Aadhaar Number {{ $aadhaarDisplay ?? 'Not provided' }}
PAN Number {{ $panDisplay ?? 'Not provided' }}
Aadhaar Document @if( !empty( $kyc->aadhaar_document ) ) 👁 View Aadhaar @else Not Uploaded @endif
PAN Document @if( !empty( $kyc->pan_document ) ) 👁 View PAN @else Not Uploaded @endif
Submitted {{ $kyc->created_at ? $kyc->created_at->format( 'd M Y, h:i A' ) : '—' }}
@if($kyc->rejection_reason)
Rejection Reason {{ $kyc->rejection_reason }}
@endif
{{-- KYC ACTIONS --}} @if( $kyc->status !== 'verified' )
@csrf
@if($kyc->status !== 'rejected') @endif
@csrf
@endif
🔒 Privacy protected: Aadhaar and PAN numbers are masked in the admin overview. Only the last four characters are displayed.
@else KYC details have not been submitted yet. @endif
{{-- ===================================================== EMI CARD ====================================================== --}}
💳

EMI Card

Card account
@if($emiCard)
EMI CREDITS EMI CARD
{{ $emiCard->card_number }}
Available Limit {{ money( (float)( $emiCard->available_limit ?? 0 ) ) }}
Card Limit {{ money( (float)( $emiCard->card_limit ?? 0 ) ) }}
Status {{ ucfirst($emiCard->status) }}
Used Limit {{ money( max( 0, (float)( $emiCard->card_limit ?? 0 ) - (float)( $emiCard->available_limit ?? 0 ) ) ) }}
Issued {{ $emiCard->issued_at ? \Carbon\Carbon::parse( $emiCard->issued_at )->format('d M Y') : '—' }}
Expires {{ $cardExpiry ? \Carbon\Carbon::parse( $cardExpiry )->format('d M Y') : '—' }}
Activated {{ $emiCard->activated_at ? \Carbon\Carbon::parse( $emiCard->activated_at )->format('d M Y') : '—' }}
Unlock Payment @if($hasCardUnlockPayment) ✓ Paid @else Not Paid @endif
Total Loans {{ $loanCount }}
Active Loans {{ $activeLoanCount }}
@else
💳
EMI Card Not Generated No EMI card is currently linked to this client.
@endif
{{-- ===================================================== LOAN OVERVIEW ====================================================== --}}
💰

Loan Overview

{{ $loanCount }} loan{{ $loanCount == 1 ? '' : 's' }}
@forelse($loans as $loan) @php $loanStatus = strtolower( (string)$loan->status ); $loanStatusClass = match($loanStatus) { 'active', 'disbursed' => 'status-active', 'approved', 'pending' => 'status-pending', 'overdue', 'rejected' => 'status-danger', default => 'status-gray', }; $loanTotal = (float)( $loan->total_payable ?? 0 ); $loanOutstanding = (float)( $loan->outstanding_amount ?? 0 ); $loanPaid = max( 0, $loanTotal - $loanOutstanding ); $loanPercent = $loanTotal > 0 ? min( 100, max( 0, ( $loanPaid / $loanTotal ) * 100 ) ) : 0; @endphp
{{ $loan->loan_number }}
Applied {{ $loan->applied_at ? \Carbon\Carbon::parse( $loan->applied_at )->format('d M Y') : '—' }}
{{ ucfirst( str_replace( '_', ' ', $loan->status ) ) }}
Loan Amount {{ money( (float)$loan->loan_amount ) }}
Monthly EMI {{ money( (float)$loan->emi_amount ) }}
Tenure {{ $loan->tenure_months }} Months
Outstanding {{ money( $loanOutstanding ) }}
Interest {{ money( (float)( $loan->interest_amount ?? 0 ) ) }}
Processing Fee {{ money( (float)( $loan->processing_fee ?? 0 ) ) }}
Total Payable {{ money( $loanTotal ) }}
Paid {{ money( $loanPaid ) }}
@if( in_array( $loanStatus, [ 'active', 'disbursed', 'overdue', 'completed', ], true ) )
Repayment Progress {{ number_format( $loanPercent, 0 ) }}%
@endif
@empty
💰
No Loans No loan records found for this client.
@endforelse
{{-- ===================================================== EMI INSTALLMENTS ====================================================== --}} @if($loans->contains( fn ($loan) => $loan->installments && $loan->installments->count() ))
📅

EMI Schedule

Installments
@foreach($loans as $loan) @if( $loan->installments && $loan->installments->count() )
{{ $loan->loan_number }} {{ $loan->installments->count() }} installments
@foreach( $loan->installments ->sortBy( 'installment_number' ) as $installment ) @php $installmentStatus = strtolower( (string) $installment->status ); $installmentClass = match( $installmentStatus ) { 'paid', 'completed' => 'status-active', 'overdue' => 'status-danger', 'partial', 'pending' => 'status-pending', default => 'status-gray', }; @endphp @endforeach
# Due Date EMI Paid Outstanding Status
{{ $installment ->installment_number }} {{ $installment->due_date ? \Carbon\Carbon::parse( $installment->due_date )->format('d M Y') : '—' }} {{ money( (float)( $installment ->emi_amount ?? 0 ) ) }} {{ money( (float)( $installment ->paid_amount ?? 0 ) ) }} {{ money( (float)( $installment ->outstanding_amount ?? 0 ) ) }} {{ ucfirst( str_replace( '_', ' ', $installment ->status ) ) }}
@endif @endforeach
@endif {{-- ===================================================== PAYMENT HISTORY ====================================================== --}}

Payment History

{{ $paymentCount }} records
{{-- PAYMENT SUMMARY --}}
Total Payments {{ $paymentCount }}
Successful {{ $paidPaymentCount }}
Total Paid {{ money( (float)$totalPaidAmount ) }}
@if($payments->count())
@foreach($payments as $payment) @php $paymentStatus = strtolower( (string)$payment->status ); $paymentStatusClass = match($paymentStatus) { 'paid' => 'success', 'pending', 'created' => 'pending', default => 'danger', }; $paymentType = $payment->payment_type ?? 'general'; $paymentMethod = $payment->payment_method ?? ( $payment->is_manual ? 'manual' : 'online' ); @endphp @endforeach
Payment Type Loan Amount Method Status Date
{{ $payment->order_id ?? $payment->payment_id ?? 'Payment #' . $payment->id }}
@if($payment->payment_id)
ID: {{ $payment->payment_id }}
@endif
{{ ucfirst( str_replace( '_', ' ', $paymentType ) ) }} @if($payment->loan) {{ $payment->loan->loan_number }} @if($payment->installment)
EMI # {{ $payment ->installment ->installment_number }}
@endif @else — @endif
{{ money( (float)( $payment->amount ?? 0 ) ) }} {{ ucfirst( str_replace( '_', ' ', $paymentMethod ) ) }} @if($payment->is_manual)
Manual
@else
Online
@endif
{{ ucfirst( str_replace( '_', ' ', $payment->status ) ) }} {{ $payment->paid_at ? $payment->paid_at->format( 'd M Y, h:i A' ) : ( $payment->created_at ? $payment->created_at->format( 'd M Y, h:i A' ) : '—' ) }}
@else
No Payment Records No payments have been recorded for this client.
@endif
@endsection @push('scripts') @endpush