@extends('layouts.app') @section('body_class', 'page-donor') @section('content') @php $firstName = strtok($user->name, ' ') ?: $user->name; $paidDonations = $donations->where('status', 'paid'); $activeMonthly = $subscriptions->filter(fn ($subscription): bool => $subscription->isActive()); $firstGiftAt = optional($paidDonations->last())->paid_at; $lastGiftAt = optional($paidDonations->first())->paid_at; $donationsByYear = $donations->groupBy(fn ($donation): string => optional($donation->paid_at)->format('Y') ?? 'Earlier'); $yearTotal = $givingByMonth->sum('amount'); $monthPeak = max(1, $givingByMonth->max('amount')); $viewingAsAdmin = session()->has(\App\Http\Controllers\Admin\DonorsController::IMPERSONATOR_KEY); @endphp
@if ($viewingAsAdmin)

Admin view. You are seeing {{ $user->name }}’s account exactly as they do.

@csrf
@endif

Hello, {{ $firstName }}

@if ($firstGiftAt)Giving since {{ $firstGiftAt->format('F Y') }} · @endif{{ $user->email }}

Donate again @unless ($viewingAsAdmin)
@csrf
@endunless
@include('partials.flash') @error('subscription')@enderror

Your giving

Last 12 months · {{ \App\Support\Fmt::rupees($yearTotal) }}
    @foreach ($givingByMonth as $month)
  1. $month['is_current']])> ! $month['amount']]) style="--h: {{ $month['amount'] ? max(6, (int) round($month['amount'] / $monthPeak * 100)) : 0 }}%"> {{ $month['title'] }}: {{ \App\Support\Fmt::rupees($month['amount']) }}
  2. @endforeach

Your donations

@if ($donations->isNotEmpty()){{ $donations->count() }}@endif
@if ($donations->isEmpty())

No donations yet

When you give, every donation and its receipt will appear here.

Make your first donation
@else @foreach ($donationsByYear as $year => $yearDonations)

{{ $year }} {{ \App\Support\Fmt::rupees($yearDonations->where('status', 'paid')->sum('amount')) }} given

    @foreach ($yearDonations as $d)
  • $d->frequency === 'monthly', 'is-refunded' => $d->status === 'refunded'])>
    {{ $d->purpose }} {{ optional($d->paid_at)->format('j M Y') }}@if ($d->receipt_no) · {{ $d->receipt_no }}@endif
    {{ \App\Support\Fmt::rupees($d->amount) }} @if ($d->status === 'refunded') Refunded @elseif ($d->frequency === 'monthly') Monthly @endif
    Receipt {{ $d->receipt_no }} (opens in a new tab)
  • @endforeach
@endforeach @endif
@endsection