@extends('layouts.app') @section('content')

{{ __('loans.page_title') }}

{{ __('loans.cards.total_loans') }}

{{ $totalLoans ?? 0 }}

{{ __('loans.cards.active') }}

{{ $activeLoans ?? 0 }}

{{ __('loans.cards.pending') }}

{{ $pendingLoans ?? 0 }}

{{ __('loans.cards.paid') }}

{{ $paidLoans ?? 0 }}

{{ __('loans.stats.payments_this_month') }}

{{ number_format($totalPaymentsThisMonth ?? 0, 2) }} {{ $currency_name ?? 'د.ك' }}

{{ __('loans.stats.payments_this_year') }}

{{ number_format($totalPaymentsThisYear ?? 0, 2) }} {{ $currency_name ?? 'د.ك' }}

{{ __('loans.stats.deductions_this_month') }}

{{ number_format($totalDeductionsThisMonth ?? 0, 2) }} {{ $currency_name ?? 'د.ك' }}

{{ __('loans.stats.deductions_this_year') }}

{{ number_format($totalDeductionsThisYear ?? 0, 2) }} {{ $currency_name ?? 'د.ك' }}

{{ __('loans.page_title') }}

@can('create', \App\Models\Loan::class) {{ __('loans.buttons.create') }} @endcan
@forelse($loans ?? [] as $loan) @empty @endforelse
{{ __('loans.table.id') }} {{ __('loans.table.employee_name') }} {{ __('loans.table.type') }} {{ __('loans.table.amount_requested') }} {{ __('loans.table.amount_paid') }} {{ __('loans.table.remaining') }} {{ __('loans.table.installments_count') }} {{ __('loans.table.installment_amount') }} {{ __('loans.table.request_date') }} {{ __('loans.table.status') }} {{ __('loans.table.actions') }}
{{ $loan->id }}
@if(isset($loan->employee) && $loan->employee->photo) صورة الموظف @else
{{ isset($loan->employee) ? substr($loan->employee->name ?? '', 0, 1) : '?' }}
@endif
{{ $loan->employee->name ?? __('loans.not_specified') }}
@switch($loan->loan_type ?? '') @case('personal') {{ __('loans.type_labels.personal') }} @break @case('housing') {{ __('loans.type_labels.housing') }} @break @case('car') {{ __('loans.type_labels.car') }} @break @case('emergency') {{ __('loans.type_labels.emergency') }} @break @case('education') {{ __('loans.type_labels.education') }} @break @default {{ $loan->loan_type ? __('loans.type_labels.' . $loan->loan_type) : __('loans.not_specified') }} @endswitch {{ number_format($loan->amount ?? 0, 2) }} {{ $currency_name ?? 'د.ك' }} {{ number_format($loan->paid_amount ?? 0, 2) }} {{ $currency_name ?? 'د.ك' }} {{ number_format($loan->remaining_amount ?? $loan->amount ?? 0, 2) }} {{ $currency_name ?? 'د.ك' }} {{ $loan->installment_count ?? 0 }} {{ number_format($loan->installment_amount ?? 0, 2) }} {{ $currency_name ?? 'د.ك' }} {{ $loan->created_at ? $loan->created_at->format('Y-m-d') : __('loans.not_specified') }} @if(($loan->status ?? '') == 'pending') {{ __('loans.status.pending') }} @elseif(($loan->status ?? '') == 'approved') {{ __('loans.status.approved') }} @elseif(($loan->status ?? '') == 'active') {{ __('loans.status.active') }} @elseif(($loan->status ?? '') == 'rejected') {{ __('loans.status.rejected') }} @elseif(($loan->status ?? '') == 'paid') {{ __('loans.status.paid') }} @elseif(($loan->status ?? '') == 'cancelled') {{ __('loans.status.cancelled') }} @else {{ __('loans.status.unknown') }} @endif
@can('view', $loan) @endcan @if(($loan->status ?? '') == 'pending') @can('approve', $loan)
@csrf
@endcan @can('approve', $loan) @endcan @endif @if(($loan->status ?? '') == 'approved') @can('activate', $loan)
@csrf
@endcan @endif @if(in_array($loan->status ?? '', ['active', 'approved'])) @can('cancel', $loan)
@csrf
@endcan @endif @can('update', $loan) @if(in_array($loan->status ?? '', ['pending', 'approved'])) @endif @endcan @can('delete', $loan) @if(in_array($loan->status ?? '', ['pending', 'rejected', 'cancelled']))
@csrf @method('DELETE')
@endif @endcan @if(($loan->status ?? '') == 'active' && ($loan->remaining_amount ?? $loan->amount ?? 0) > 0) @can('pay', $loan) @endcan @endif
{{ __('loans.empty.title') }}

{{ __('loans.empty.subtitle') }}

@can('create', \App\Models\Loan::class) {{ __('loans.buttons.create') }} @endcan
@if(isset($loans) && $loans->hasPages())
{{ $loans->links() }}
@endif

توزيع القروض حسب النوع

حالة القروض

{{--

الأنشطة الأخيرة للقروض

النشاط الموظف نوع القرض المبلغ الحالة التاريخ
طلب قرض جديد أحمد محمد شخصي 1000.00 {{ $currency_name ?? 'د.ك' }} قيد المراجعة 2025-08-23
موافقة على قرض مدير المالية سكن 5000.00 {{ $currency_name ?? 'د.ك' }} موافق عليه 2025-08-22
دفع قسط سارة علي سيارة 200.00 {{ $currency_name ?? 'د.ك' }} مدفوع 2025-08-21
--}}
@foreach($loans ?? [] as $loan) @if(($loan->status ?? '') == 'pending') @can('approve', $loan) @endcan @endif @endforeach @endsection