@extends('layouts.app') @section('title') Home @endsection @section('content') @if (session('success')) @endif @if (session('error')) @endif

Home

New Application @php use Illuminate\Support\Str; // Status codes below mirror lmsadmin's App\Models\Lead::currentStatus() switch, // which is the source of truth actually driving the shared los_leads.status // column (the info_process_status table's borrower/lender text columns are not // wired into that switch and don't cover these codes, so we don't rely on them). $statusMap = [ 100 => ['label' => 'Application Created', 'badge' => 'secondary'], 1000 => ['label' => 'Application Created', 'badge' => 'secondary'], // legacy/stray value, behaves like 100 101 => ['label' => 'Pending Verification', 'badge' => 'info'], 102 => ['label' => 'Verifying Application', 'badge' => 'info'], 103 => ['label' => 'Verifying Application', 'badge' => 'info'], 105 => ['label' => 'Preparing Term Sheet', 'badge' => 'info'], 106 => ['label' => 'Pending Term Sheet Signature', 'badge' => 'warning'], 107 => ['label' => 'Verifying Term Sheet Signature', 'badge' => 'info'], 108 => ['label' => 'Preparing Credit Paper', 'badge' => 'info'], 109 => ['label' => 'Pending Credit Paper Verification', 'badge' => 'info'], 110 => ['label' => 'Verifying Credit Paper', 'badge' => 'info'], 201 => ['label' => 'Pending Recommendation', 'badge' => 'info'], 210 => ['label' => 'Pending Recommendation Verification', 'badge' => 'info'], 211 => ['label' => 'Verifying Recommendation', 'badge' => 'info'], 202 => ['label' => 'Pending Credit Committee Approval', 'badge' => 'info'], 203 => ['label' => 'Pending Board Approval', 'badge' => 'info'], 204 => ['label' => 'Pending Agreement Upload', 'badge' => 'warning'], 205 => ['label' => 'Verifying Agreement', 'badge' => 'info'], 500 => ['label' => 'Pending Disbursement', 'badge' => 'info'], 501 => ['label' => 'Disbursement Completed', 'badge' => 'success'], ]; @endphp @if ($applications->isEmpty())
You have no applications yet.
@else
@foreach ($applications as $lead) @php $statusInfo = $statusMap[(int) $lead->status] ?? ['label' => 'In Progress', 'badge' => 'secondary']; $status = (int) $lead->status; $hasRejection = $lead->hasRejectedVerification(); $buttons = []; $termsheetRejected = $status === 106 && optional($lead->ilo)->rejected_at; if ($hasRejection) { // A section was rejected during verification - this overrides the // normal status label/actions regardless of which stage it reverted to. $statusInfo = ['label' => 'Rejected - Resubmission Required', 'badge' => 'danger']; $buttons[] = [ 'route' => route('application.full', $lead->serial_no), 'text' => 'Resolve Rejected Section(s)', 'class' => 'btn-danger', ]; } elseif ($termsheetRejected) { // Borrower's manually uploaded signed term sheet was rejected by admin. $statusInfo = ['label' => 'Term Sheet Signature Rejected', 'badge' => 'danger']; $buttons[] = [ 'route' => route('ilo.show', $lead->serial_no), 'text' => 'Re-sign Term Sheet', 'class' => 'btn-danger', ]; } elseif ($status === 100 || $status === 1000) { // Not yet submitted - borrower is still filling in the form. $buttons[] = [ 'route' => route('application.full', $lead->serial_no), 'text' => 'Continue Application', 'class' => 'btn-primary', ]; } else { // Submitted - read-only from here on, so "View Application" is always offered. $buttons[] = [ 'route' => route('application.show', $lead->serial_no), 'text' => 'View Application', 'class' => 'btn-secondary', ]; if ($status === 106 && $lead->ilo) { // Term sheet generated, waiting on the borrower's signature. $buttons[] = [ 'route' => route('ilo.show', $lead->serial_no), 'text' => 'Sign Term Sheet', 'class' => 'btn-primary', ]; } elseif (in_array($status, [107, 108, 109, 110, 201, 210, 211, 202, 203]) && $lead->ilo) { // Signature done; everything after this is internal admin processing // (verification -> credit paper -> recommendation -> committee/board approval). $buttons[] = [ 'route' => route('ilo.display', $lead->serial_no), 'text' => 'View Term Sheet', 'class' => 'btn-secondary', ]; } elseif ($status === 204) { // Approved - borrower needs to upload signed agreement documents. if ($lead->ilo) { $buttons[] = [ 'route' => route('ilo.display', $lead->serial_no), 'text' => 'View Term Sheet', 'class' => 'btn-secondary', ]; } $buttons[] = [ 'route' => route('acceptance.edit', encrypt($lead->serial_no)), 'text' => 'Upload Agreement Documents', 'class' => 'btn-primary', ]; } elseif ($status === 205) { // Signed agreement documents submitted - awaiting admin verification. if ($lead->ilo) { $buttons[] = [ 'route' => route('ilo.display', $lead->serial_no), 'text' => 'View Term Sheet', 'class' => 'btn-secondary', ]; } $buttons[] = [ 'route' => route('acceptance.edit', encrypt($lead->serial_no)), 'text' => 'View Agreements', 'class' => 'btn-secondary', ]; } elseif ($status === 500 || $status === 501) { // Agreement uploaded - disbursement pending (500) or completed (501). if ($lead->ilo) { $buttons[] = [ 'route' => route('ilo.display', $lead->serial_no), 'text' => 'View Term Sheet', 'class' => 'btn-secondary', ]; } $buttons[] = [ 'route' => route('acceptance.edit', encrypt($lead->serial_no)), 'text' => 'View Agreements', 'class' => 'btn-secondary', ]; if ( $status === 501 ){ $buttons[] = [ 'route' => route('disbursement.show', $lead->serial_no), 'text' => 'View Disbursement', 'class' => 'btn-primary', ]; } } // 101/102/103/105 and any other in-process status: "View Application" above is enough. } // Show the primary call-to-action first in the dropdown, secondary/view links after. $buttons = collect($buttons)->sortByDesc(fn ($b) => $b['class'] === 'btn-primary')->values()->all(); @endphp @endforeach
Serial No. Date Loan Summary Factoring Pre-Factoring Applicant Status Actions
{{ $lead->serial_no }} {{ $lead->created_at->format('d M Y') }} {{ Str::limit($lead->title_summary, 60) }} RM {{ number_format($lead->fund_amount ?? 0, 2) }} @if ($lead->pre_facility) RM {{ number_format($lead->pre_fund_amount ?? 0, 2) }} @else - @endif {{ $lead->applicant->applicant_name ?? '-' }} @if (!empty($lead->applicant->type->name))
{{ $lead->applicant->type->name }} @endif
{{ $statusInfo['label'] }}
{{ $applications->links('pagination::bootstrap-4') }}
@endif @endsection