@extends('layouts.client')
@include('client.financing-request._home_theme')
@section('title', ln('Financing Request Details', 'تفاصيل طلب التمويل'))
@section('page_title', ln('Request', 'طلب') . ' #' . ($financingRequest->request_number ?? $financingRequest->id))
@php
$fr = $financingRequest;
$statusMap = [
'new' => ['#e0e7ff', '#4338ca', 'fa-clock', ln('New', 'جديد')],
'pending' => ['#fef3c7', '#a16207', 'fa-hourglass-half', ln('Pending', 'قيد الانتظار')],
'reviewing' => ['#fef3c7', '#a16207', 'fa-magnifying-glass', ln('Under Review', 'قيد المراجعة')],
'approved' => ['#dcfce7', '#166534', 'fa-circle-check', ln('Approved', 'موافق')],
'rejected' => ['#fee2e2', '#991b1b', 'fa-circle-xmark', ln('Rejected', 'مرفوض')],
'completed' => ['#fee2e2', '#b31419', 'fa-trophy', ln('Completed', 'مكتمل')],
];
[$sBg, $sFg, $sIcon, $sLabel] = $statusMap[$fr->status] ?? ['#f3f4f6', '#4b5563', 'fa-circle-info', ucfirst((string)$fr->status)];
$fileFields = [];
foreach ((array) config('financing_documents.documents', []) as $field => $labels) {
$fileFields[$field] = ln($labels[0] ?? $field, $labels[1] ?? $field);
}
$legacyFileFields = [
'bank_statement' => ln('Bank Statement', 'كشف الحساب البنكي'),
'vat_certificate' => ln('VAT Certificate', 'شهادة ض.ق.م'),
'promissory_note_file' => ln('Promissory Note', 'سند لأمر'),
'wc_bank_statement_file' => ln('WC Bank Statement', 'كشف بنكي - ر.م.ع'),
'wc_budget_last_3_years_file' => ln('WC Budget 3y', 'ميزانية ٣ سنوات'),
'wc_articles_of_association_file' => ln('WC Articles', 'عقد التأسيس'),
'wc_commercial_registration_file' => ln('WC CR', 'السجل - ر.م.ع'),
're_income_audited_fs_3y_file' => ln('RE Income Audited FS', 'ميزانية مدققة'),
're_income_bank_statement_12m_file' => ln('RE Income 12m Bank Stmt', 'كشف بنكي ١٢ شهر'),
're_income_commercial_registration_file'=> ln('RE Income CR', 'السجل التجاري'),
're_income_articles_of_association_file'=> ln('RE Income Articles', 'عقد التأسيس'),
're_income_latest_valuation_file' => ln('RE Income Valuation', 'تقييم عقاري'),
're_land_audited_fs_3y_file' => ln('RE Land Audited FS', 'ميزانية مدققة'),
're_land_bank_statement_12m_file' => ln('RE Land 12m Bank Stmt', 'كشف بنكي ١٢ شهر'),
're_land_commercial_registration_file' => ln('RE Land CR', 'السجل التجاري'),
're_land_articles_of_association_file' => ln('RE Land Articles', 'عقد التأسيس'),
're_land_latest_valuation_file' => ln('RE Land Valuation', 'تقييم عقاري'),
];
foreach ($legacyFileFields as $f => $l) {
if (!isset($fileFields[$f])) {
$fileFields[$f] = $l;
}
}
// Bank offers are disabled for now — show the calculated proposed offer instead.
$showProposedOffer = ($fr->payment_status === \App\Models\ClickPayPayments::STATUS_SUCCESS
|| in_array($fr->stage, [
\App\Models\FinancingRequest::STAGE_PAID,
\App\Models\FinancingRequest::STAGE_OFFERS,
\App\Models\FinancingRequest::STAGE_OFFER_SELECTED,
\App\Models\FinancingRequest::STAGE_COMPLETED,
], true))
&& !empty($fr->proposed_offer_amount);
// Kept for backwards compat (rest of the template still references them).
$showOffers = false;
$offersList = collect();
$calcCfg = config('financing_documents.calculation_inputs.' . ($fr->sub_product_id ?? 0));
$hasContact = $fr->mobile_1 || $fr->mobile_2 || $fr->phone_1 || $fr->phone_2 || $fr->category_1;
$hasCommercial = $fr->legal_form || $fr->commercial_name || $fr->commercial_registration;
$hasOwner = $fr->owner_name || $fr->owner_id_number || $fr->nationality;
$hasGuarantee = !empty($fr->guarantee_type) || $fr->coverage_percentage || $fr->property_value || $fr->number_of_shares || $fr->promissory_note_value || $fr->cash_deposit_value;
$docCount = collect($fileFields)->filter(fn ($l, $f) => !empty($fr->{$f}))->count();
@endphp
@push('styles')
@endpush
@section('content')
{{-- HERO --}}
{{ ln('Request', 'طلب') }} #{{ $fr->request_number ?? $fr->id }}
{{ $fr->commercial_name ?? $fr->owner_name ?? ln('Financing Request', 'طلب تمويل') }}
{{ optional($fr->created_at)->format('Y-m-d') ?? '-' }}
{{ $sLabel }}
{{-- STAGE TIMELINE --}}
@php
$stages = [
'pending_payment' => [ln('Submitted','تم الإرسال'), 'fa-paper-plane'],
'paid' => [ln('Payment Confirmed','تأكيد الدفع'),'fa-credit-card'],
'offers' => [ln('Offers Received','استلام العروض'),'fa-handshake'],
'offer_selected' => [ln('Offer Selected','اختيار العرض'), 'fa-circle-check'],
'completed' => [ln('Completed','مكتمل'), 'fa-flag-checkered'],
];
$order = array_keys($stages);
$effectiveStage = ($fr->status === 'completed') ? 'completed' : $fr->stage;
$currentIdx = array_search($effectiveStage, $order, true);
if ($currentIdx === false) $currentIdx = 0;
@endphp
@foreach ($stages as $key => [$label, $icon])
@php
$i = array_search($key, $order, true);
$cls = $i < $currentIdx ? 'done' : ($i === $currentIdx ? 'current done' : '');
@endphp
@endforeach
{{-- RESUME ACTION BANNER --}}
@php
$needsPayment = ($fr->payment_status ?? null) !== \App\Models\ClickPayPayments::STATUS_SUCCESS
&& in_array($fr->stage, [\App\Models\FinancingRequest::STAGE_PENDING_PAYMENT, null], true)
&& $fr->status !== \App\Models\FinancingRequest::STATUS_REJECTED
&& $fr->status !== \App\Models\FinancingRequest::STATUS_CANCELED;
$needsOfferSelect = $showProposedOffer
&& empty($fr->proposed_offer_accepted_at)
&& empty($fr->selected_offer_id)
&& $fr->stage !== \App\Models\FinancingRequest::STAGE_COMPLETED;
@endphp
@php $isCompleted = $fr->stage === \App\Models\FinancingRequest::STAGE_COMPLETED || $fr->status === 'completed'; @endphp
@if($isCompleted)
{{ ln('Congratulations! Your financing is complete', 'مبروك! تم إكمال تمويلك بنجاح') }}
{{ ln('Your financing request has been successfully finalized and the contract is signed. Thank you for choosing Hotspot.', 'تم إتمام طلب التمويل الخاص بك بنجاح وتوقيع العقد. شكراً لاختيارك هوت سبوت.') }}
{{ ln('Request', 'الطلب') }}
#{{ $fr->request_number }}
@if($fr->selectedOffer && $fr->selectedOffer->bank)
{{ ln('Bank', 'البنك') }}
{{ $fr->selectedOffer->bank->name }}
@endif
{{ ln('Completed On', 'تاريخ الإكمال') }}
{{ optional($fr->updated_at)->format('Y-m-d') }}
@elseif($needsPayment)
{{ ln('Complete Your Payment', 'أكمل عملية الدفع') }}
{{ ln('Your request is waiting for payment to proceed to offers.', 'طلبك في انتظار الدفع لإظهار العروض.') }}
@elseif($needsOfferSelect)
@endif
{{-- FACILITATION BANNER --}}
@if($fr->facilitation_requested_at)
{{ ln('Facilitation Service Requested', 'تم طلب خدمة التسهيلات التمويلية') }}
{{ ln('Submitted on', 'تم التقديم في') }} {{ $fr->facilitation_requested_at->format('Y-m-d H:i') }} · {{ ln('Our team will contact you soon', 'سيتواصل معك فريقنا قريباً') }}
{{ ln('Submitted', 'تم التقديم') }}
@endif
{{-- SUMMARY CARDS --}}
{{ ln('Financing Amount', 'مبلغ التمويل') }}
{{ $fr->financing_amount ? number_format((float) $fr->financing_amount) . ' ' . ln('SAR','ر.س') : '—' }}
{{ ln('Term', 'المدة') }}
{{ $fr->financing_period ? $fr->financing_period . ' ' . ln('months','شهر') : ($fr->term_years ? $fr->term_years . ' ' . ln('yrs','سنة') : '—') }}
{{ ln('Documents', 'المستندات') }}
{{ $docCount }}
{{ ln('Coverage', 'التغطية') }}
{{ $fr->coverage_percentage ? $fr->coverage_percentage . '%' : '—' }}
{{-- BUSINESS / ADDRESS --}}
{{ ln('Business & Address', 'العمل والعنوان') }}
@foreach ([
ln('National ID','رقم الهوية') => $fr->national_id,
ln('Residence Number','رقم الإقامة') => $fr->residence_number,
ln('Street','الشارع') => $fr->street_name,
ln('City','المدينة') => $fr->city,
ln('Postal Code','الرمز البريدي') => $fr->postal_code,
ln('District','الحي') => $fr->district_name,
ln('Additional Code','الرمز الإضافي') => $fr->additional_code,
ln('Location Description','وصف الموقع') => $fr->location_description,
] as $k => $v)
@endforeach
{{-- CONTACT --}}
@if($hasContact)
{{ ln('Contact Information', 'بيانات التواصل') }}
@foreach ([
ln('Mobile 1','جوال 1') => $fr->mobile_1,
ln('Mobile 2','جوال 2') => $fr->mobile_2,
ln('Phone 1','هاتف 1') => $fr->phone_1,
ln('Phone 2','هاتف 2') => $fr->phone_2,
ln('Email','البريد الإلكتروني') => $fr->category_1,
] as $k => $v)
@endforeach
@endif
{{-- COMMERCIAL --}}
@if($hasCommercial)
{{ ln('Commercial Registration', 'السجل التجاري') }}
@foreach ([
ln('Legal Form','الشكل القانوني') => $fr->legal_form,
ln('Commercial Name','الاسم التجاري') => $fr->commercial_name,
ln('CR Number','رقم السجل') => $fr->commercial_registration,
ln('CR City','مدينة السجل') => $fr->city_2,
ln('License Expiry (Hijri)','انتهاء الترخيص (هجري)') => $fr->license_expiry_date_hijri,
ln('Establishment (Hijri)','تاريخ التأسيس (هجري)') => $fr->establishment_date_hijri,
] as $k => $v)
@endforeach
@endif
{{-- OWNER --}}
@if($hasOwner)
{{ ln('Owner Details', 'بيانات المالك') }}
@foreach ([
ln('Owner Name','اسم المالك') => $fr->owner_name,
ln('ID Number','رقم الهوية') => $fr->owner_id_number,
ln('Nationality','الجنسية') => $fr->nationality,
ln('Birth Date','تاريخ الميلاد') => $fr->birth_date,
ln('Mobile','الجوال') => $fr->mobile_without_zero,
ln('ID Expiry','انتهاء الهوية') => $fr->id_expiry_date,
] as $k => $v)
@endforeach
@endif
{{-- GUARANTEE --}}
@if($hasGuarantee)
{{ ln('Guarantee', 'الضمان') }}
{{ ln('Types', 'الأنواع') }}
@php $types = (array) ($fr->guarantee_type ?? []); @endphp
@if(count($types))
@foreach($types as $t)
{{ $t }}
@endforeach
@else
—
@endif
{{ ln('Coverage %', 'نسبة التغطية') }}
{{ $fr->coverage_percentage ? $fr->coverage_percentage . '%' : '—' }}
@if($fr->property_value)
{{ ln('Property Value','قيمة العقار') }}
{{ number_format((float)$fr->property_value) }}
@endif
@if($fr->number_of_shares)
{{ ln('Shares','الأسهم') }}
{{ $fr->number_of_shares }} × {{ $fr->share_value }}
@endif
@if($fr->promissory_note_value)
{{ ln('Promissory Note','السند') }}
{{ number_format((float)$fr->promissory_note_value) }}
@endif
@if($fr->cash_deposit_value)
{{ ln('Cash Deposit','الوديعة') }}
{{ number_format((float)$fr->cash_deposit_value) }}
@endif
@endif
{{-- PROPOSED OFFER (calculated from client inputs) --}}
@if($showProposedOffer)
@if(session('success'))
{{ session('success') }}
@endif
@php
$alreadyAccepted = !empty($fr->proposed_offer_accepted_at);
@endphp
{{ ln('Proposed Financing Offer', 'العرض التمويلي المقترح') }}
{{ ln('Proposed Offer Amount', 'قيمة العرض المقترح') }}
{{ number_format((float) $fr->proposed_offer_amount, 2) }}
{{ ln('SAR', 'ريال') }}
@if($alreadyAccepted)
{{ ln('Accepted on', 'تم القبول في') }} {{ $fr->proposed_offer_accepted_at->format('Y-m-d') }}
@endif
@if(!empty($fr->calc_inputs) && is_array($fr->calc_inputs))
@foreach($fr->calc_inputs as $name => $value)
@php
$locKey = app()->getLocale() === 'ar' ? 'ar' : 'en';
$label = $calcCfg['label_overrides'][$name][$locKey]
?? $calcCfg['fields'][$name]['label_' . $locKey]
?? $name;
@endphp
{{ $label }}
{{ number_format((float)$value, 2) }} {{ ln('SAR', 'ريال') }}
@endforeach
@endif
@unless($alreadyAccepted)
@endunless
@endif
{{-- DOCUMENTS --}}
{{ ln('Documents', 'المستندات') }} ({{ $docCount }})
@if($docCount === 0)
{{ ln('No documents uploaded.', 'لا توجد مستندات مرفوعة.') }}
@else
@foreach($fileFields as $field => $label)
@if(!empty($fr->{$field}))
@php
$path = $fr->{$field};
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
$iconMap = ['pdf'=>'fa-file-pdf','jpg'=>'fa-file-image','jpeg'=>'fa-file-image','png'=>'fa-file-image','doc'=>'fa-file-word','docx'=>'fa-file-word'];
$ic = $iconMap[$ext] ?? 'fa-file';
@endphp
{{ $label }}
{{ strtoupper($ext) ?: ln('File','ملف') }} · {{ ln('Open','فتح') }}
@endif
@endforeach
@endif
@endsection