@php use Carbon\Carbon; @endphp @section('main-content')
Total Amount
money stack
{{ number_format($totalLoanAmount) }} Tshs
Paid Amount
money in
{{ number_format($payments->sum('paid_amount')) }} Tshs
Due Amount
money out
{{ number_format($totalLoanAmount - $payments->sum('paid_amount')) }} Tshs
All Users
many users

{{ number_format($user->count()) }} People

Customers with Loans
loan
@php $count = 0; $countedInstallations = []; foreach ($loans as $loan) { $totalAmount = $loan->loan_required_amount; $paidAmount = $loan->payments->sum('paid_amount'); if ($totalAmount > $paidAmount) { if (!in_array($loan->installation_id, $countedInstallations)) { $count++; $countedInstallations[] = $loan->installation_id; } } } @endphp

{{ $count }} People

Fully Paid Customers
paid user
@php $fullyPaidCount = 0; // Iterate through all users to check their loans foreach ($users as $user) { foreach ($user->loans as $loan) { $totalAmount = $loan->loan_required_amount; $paidAmount = $loan->payments->sum('paid_amount'); // Check if the loan is fully paid if ($paidAmount >= $totalAmount) { $fullyPaidCount++; // Increment count for loans with pending amount of 0 break; // No need to check further loans for this user } } } @endphp

{{ $fullyPaidCount }} People

{{-- working map container --}}
{{-- end of working container --}} {{-- testing map container --}}
Payments This Week
@forelse ($paymentsThisWeek as $payment) @php $days = round($payment->time_to_next_payment); @endphp @empty @endforelse
Name Time to Next Payment
{{ $payment->applicant_name }} {{ $days }} {{ Str::plural('day', $days) }}
No payments this week.
Missed Payments
@if ($missedPayments->isEmpty()) @else @foreach ($missedPayments as $missed) @endforeach @endif
Name Days Past Due Phone Number
No missed payments this week.
{{ $missed->applicant_name }} {{ abs(round($missed->days_past_due )) }} days {{ $missed->applicant_phone_number }}
@if ($nearEndLoans->isEmpty())
No loans nearing end date.
@else
Loan Nearing End Date
@foreach ($nearEndLoans as $loan) {{-- --}} @endforeach
Name Required Pending Amount Days Remaining
{{ $loan->applicant_name }} {{ number_format($loan->loan_required_amount) }} Tsh {{ number_format($loan->loan_required_amount - $loan->payments->sum('paid_amount')) }} Tsh @php $now = Carbon::now(); $daysRemaining = $now->floatDiffInDays( $loan->loan_end_date, true, ); echo $daysRemaining < 1 ? round($daysRemaining * 24) . ' hours' : round($daysRemaining) . ' day' . (round($daysRemaining) !== 1 ? 's' : ''); @endphp @php $now = Carbon::now(); $end = Carbon::parse($loan->loan_end_date); $diffDays = $now->diffInDays($end, false); if ($diffDays < 0) { echo 'Expired'; } elseif ($diffDays <= 14) { echo intval(round($diffDays)) . ' day' . (intval(round($diffDays)) !== 1 ? 's' : ''); } else { // Usionyeshe kitu chochote (blank) kama zaidi ya 14 days echo ''; } @endphp
{{ $nearEndLoans->onEachSide(1)->links() }}
@endif
{{-- working styls --}} {{-- end of working styles --}} {{-- working scripts --}} {{-- --}} {{-- end of working scripts --}} @endsection