@extends('layouts.app') @section('content')
{{-- Left Section: Icon, Title & Subtitle --}}
{{-- Icon style --}}
{{-- Main Title --}}

Loan Applications

{{-- Subtitle/Description --}}

Manage and review loan applications

{{-- Right Section: Loan Officer Badge (Styled like an action button/badge) --}}
Loan Officer Dashboard
{{-- Row ya Cards --}}
@php // Responsive columns (col-xl inagawa upana sawa kwa kadi 5 kwenye skrini kubwa) $col_class = 'col-6 col-md-4 col-lg-3 col-xl'; // Logic kwa ajili ya Completed (Kama ilivyokuwa kwenye msimbo wa awali) $completed_count = $analytics['total'] - ($analytics['pending'] ?? 0) - ($analytics['rejected'] ?? 0) - ($analytics['processed'] ?? 0); @endphp {{-- Card 1: Total (Blue gradient) --}}

Total Applications

{{ number_format($analytics['total'] ?? 0) }}

{{-- Icon Box (Blue gradient) --}}
{{-- Text/Badge kwa chini --}}
Overall Submissions
{{-- Card 2: Pending Review (Orange gradient) --}}

Pending Review

{{ number_format($analytics['pending'] ?? 0) }}

{{ $analytics['total'] > 0 ? round(($analytics['pending'] / $analytics['total']) * 100, 1) : 0 }}% of total

{{-- Icon Box (Orange gradient) --}}
{{-- Progress Bar na Badge/Action Text --}}
ACTION
{{-- Card 3: Processed (Cyan/Light Blue gradient) --}}

Processed

{{ number_format($analytics['processed'] ?? 0) }}

{{ $analytics['total'] > 0 ? round(($analytics['processed'] / $analytics['total']) * 100, 1) : 0 }}% forwarded

{{-- Icon Box (Cyan/Light Blue gradient) --}}
{{-- Progress Bar na Percentage Text --}}
{{ $analytics['total'] > 0 ? round(($analytics['processed'] / $analytics['total']) * 100, 1) : 0 }}%
{{-- Card 4: Rejected (Red gradient) --}}

Rejected

{{ number_format($analytics['rejected'] ?? 0) }}

{{ $analytics['total'] > 0 ? round(($analytics['rejected'] / $analytics['total']) * 100, 1) : 0 }}% rejected

{{-- Icon Box (Red gradient) --}}
{{-- Progress Bar na Percentage Text --}}
{{ $analytics['total'] > 0 ? round(($analytics['rejected'] / $analytics['total']) * 100, 1) : 0 }}%
{{-- Card 5: Completed (Green gradient) --}}

Completed

{{ number_format($completed_count) }}

{{ $analytics['total'] > 0 ? round(($completed_count / $analytics['total']) * 100, 1) : 0 }}% Completion Rate

{{-- Icon Box (Green gradient) --}}
{{-- Progress Bar na Badge --}}
SUCCESS
Quick Actions @if(request()->anyFilled(['search', 'status', 'date_from', 'date_to'])) Active @endif
Export @if(request()->anyFilled(['search', 'status', 'date_from', 'date_to'])) Clear @endif
@forelse($enquiries as $enquiry) @if($enquiry->type === 'loan_application' && ($enquiry->enquirable || \App\Models\LoanApplication::where('enquiry_id', $enquiry->id)->exists())) @php // Get loan application data (fallback for missing polymorphic relationship) $loanApp = $enquiry->enquirable ?: \App\Models\LoanApplication::where('enquiry_id', $enquiry->id)->first(); @endphp @endif @empty @endforelse
#
Check Number
Member Details
Loan Amount
Duration
Status
Actions
@php // Disable checkbox for rejected and processed statuses $checkboxDisabled = in_array($loanApp->status, ['rejected', 'processed']); @endphp
{{ $loop->iteration }}
{{ $enquiry->check_number }}
{{ strtoupper(substr($enquiry->full_name, 0, 1)) }}
{{ ucwords($enquiry->full_name) }}
{{ $enquiry->district->name ?? 'N/A' }}, {{ $enquiry->region->name ?? 'N/A' }} {{ $enquiry->phone ?? 'No Phone' }}
Tsh {{ number_format($loanApp->loan_amount, 2) }}
Requested Amount
{{ $loanApp->loan_duration }} months
@switch($loanApp->status) @case('rejected') Rejected @break @case('approved') Approved @break @case('pending') Pending @break @case('processed') Processed @break @case('paid') Paid @break @default Unknown @endswitch
No loan applications found

No loan applications assigned to you at this time.

@if($enquiries->hasPages()) @endif
@foreach ($enquiries as $enquiry) @if($enquiry->type === 'loan_application') @php $loanApp = $enquiry->enquirable ?: \App\Models\LoanApplication::where('enquiry_id', $enquiry->id)->first(); @endphp @if($loanApp) @include('modals.view_loan', ['loanApplication' => $loanApp]) @include('modals.process_loan', ['enquiry' => $enquiry, 'loanApplication' => $loanApp]) @include('modals.reject_loan', ['loanApplication' => $loanApp]) @endif @endif @endforeach @endsection