@php $headerOption = [ 'title' => 'Sponsorship Details', 'header_buttons' => [], 'filters' => [], 'data' => [] ]; $sponsorship = $sponsorship ?? null; $beneficiary = $sponsorship->beneficiary ?? null; $sponsor = $sponsorship->sponsor ?? null; $installments = $sponsorship->installments ?? collect(); // Calculate statistics $totalMilestones = $installments->count(); $completedMilestones = $installments->whereIn('payment_status', [ \App\Models\Users\SponsorshipInstallment::STATUS_PAID, \App\Models\Users\SponsorshipInstallment::STATUS_APPROVED_AND_RELEASED ])->count(); $totalPaid = $installments->whereIn('payment_status', [ \App\Models\Users\SponsorshipInstallment::STATUS_PAID, \App\Models\Users\SponsorshipInstallment::STATUS_APPROVED_AND_RELEASED ])->sum('installment_amount'); $disputedMilestones = $installments->where('payment_status', \App\Models\Users\SponsorshipInstallment::STATUS_DISPUTE); $disputedCount = $disputedMilestones->count(); // Format offer type $offerTypeMap = [ 1 => 'Endorsement Deal', 2 => 'Brand Ambassador', 3 => 'Team Partnership', 4 => 'Product Sponsorship', 5 => 'Event Sponsor', 6 => 'Media Partnership', ]; $offerTypeName = $sponsorship->offer_type && isset($offerTypeMap[$sponsorship->offer_type]) ? $offerTypeMap[$sponsorship->offer_type] : 'N/A'; // Beneficiary info $beneficiaryName = $beneficiary ? ($beneficiary->full_name ?? $beneficiary->name ?? 'N/A') : 'N/A'; $beneficiaryType = ucfirst($sponsorship->beneficiary_type ?? 'N/A'); $beneficiaryInitials = strtoupper(substr($beneficiaryName, 0, 1) . substr($beneficiaryName, strpos($beneficiaryName, ' ') + 1, 1)); if (strpos($beneficiaryName, ' ') === false) { $beneficiaryInitials = strtoupper(substr($beneficiaryName, 0, 2)); } // Get beneficiary location/organization $beneficiaryLocation = ''; if ($sponsorship->beneficiary_type === 'athlete' && $beneficiary) { $athleteProfile = $beneficiary->athleteProfile; if ($athleteProfile && isset($athleteProfile->organization_name)) { $beneficiaryLocation = $athleteProfile->organization_name; } } elseif ($sponsorship->beneficiary_type === 'team') { $beneficiaryLocation = $sponsorship->team_organization ?? ''; } // Get sport info $sportName = ''; if ($beneficiary && $beneficiary->sports && $beneficiary->sports->count() > 0) { $sport = $beneficiary->sports->first(); $sportName = $sport->sport->title ?? ''; } // Sponsor info $sponsorName = $sponsor ? ($sponsor->full_name ?? $sponsor->name ?? 'N/A') : 'N/A'; // Status $statusClass = 'badge-secondary'; $statusText = ($sponsorship->is_withdrawal == 1) ? 'Withdrawn' : (ucfirst($sponsorship->status ?? 'pending')); if ($sponsorship->status === 'active') { $statusClass = 'badge-success'; } elseif ($sponsorship->status === 'pending') { $statusClass = 'badge-warning'; } elseif (in_array($sponsorship->status, ['declined', 'cancelled', 'withdrawn'])) { $statusClass = 'badge-danger'; } // Calculate percentage for each milestone $totalAmount = $sponsorship->funding_amount ?? 1; @endphp @extends('admin.layouts.layout', $headerOption) @push('page_css') @endpush @section('content')
{{ $beneficiaryInitials }}

{{ $beneficiaryName }}

@if($sportName) {{ $beneficiaryType }} - {{ $sportName }} @else {{ $beneficiaryType }} @endif @if($beneficiaryLocation) {{ $beneficiaryLocation }} @endif
{{ $statusText }}
SPONSOR
DEAL TITLE
{{ $sponsorship->offer_title ?? 'N/A' }}
TYPE
{{ $offerTypeName }}
TOTAL VALUE
{!! \App\Helpers\Helper::price($sponsorship->funding_amount ?? 0, $sponsorship->currency ?? 'USD') !!}
DURATION
{{ $sponsorship->duration ?: 0 }} months
PAID SO FAR
{!! \App\Helpers\Helper::price($totalPaid, $sponsorship->currency ?? 'USD') !!}

Milestones & Payment Schedule

@foreach($installments as $index => $installment) @php $isDisputed = $installment->payment_status === \App\Models\Users\SponsorshipInstallment::STATUS_DISPUTE; $isCompleted = in_array($installment->payment_status, [ \App\Models\Users\SponsorshipInstallment::STATUS_PAID, \App\Models\Users\SponsorshipInstallment::STATUS_APPROVED_AND_RELEASED ]); $isPending = $installment->payment_status === \App\Models\Users\SponsorshipInstallment::STATUS_PENDING; $isSubmitted = $installment->payment_status === \App\Models\Users\SponsorshipInstallment::STATUS_SUBMITTED_FOR_APPROVAL; $percentage = $totalAmount > 0 ? round(($installment->installment_amount / $totalAmount) * 100, 0) : 0; $dueDate = $installment->installment_date ? \App\Helpers\Helper::showdate($installment->installment_date, false) : 'N/A'; $completedDate = null; $paidDate = null; if ($isCompleted) { $completedDate = $installment->approval_release_date ? \App\Helpers\Helper::showdate($installment->approval_release_date, false) : ($installment->paid_at ? \App\Helpers\Helper::showdate($installment->paid_at, false) : null); $paidDate = $installment->paid_at ? \App\Helpers\Helper::showdate($installment->paid_at, false) : ($installment->approval_release_date ? \App\Helpers\Helper::showdate($installment->approval_release_date, false) : null); } $disputeDate = $installment->dispute_date ? \App\Helpers\Helper::showdate($installment->dispute_date, false) : null; $disputeReason = $installment->disput_reason ?? null; $isResolved = $installment->admin_disput_resolved_at ? true : false; $resolvedDate = $installment->admin_disput_resolved_at ? \App\Helpers\Helper::showdate($installment->admin_disput_resolved_at, false) : null; @endphp
@if($isCompleted)
@else
{{ $installment->installment_number }}
@endif @if($index < $installments->count() - 1)
@endif

{{ $installment->fund_purpose ?? 'Milestone ' . $installment->installment_number }}

{!! \App\Helpers\Helper::price($installment->installment_amount, $sponsorship->currency ?? 'USD') !!} ({{ $percentage }}%)
Due: {{ $dueDate }}
@if($isCompleted) Completed @elseif($isDisputed) Disputed @elseif($isSubmitted) Submitted @else Pending @endif
@if($isCompleted && $completedDate && $paidDate)
Completed: {{ $completedDate }}
Paid: {{ $paidDate }}
@elseif($isDisputed)
Disputed: {{ $disputeDate ?? 'N/A' }}
@if($disputeReason) @endif @php $evidenceText = $installment->fund_description ?? $installment->fund_purpose ?? 'Evidence submitted'; $submittedDate = $installment->approval_request_date ? \App\Helpers\Helper::showdate($installment->approval_request_date, false) : 'N/A'; @endphp
Athlete/Team Evidence:
{{ $evidenceText }}
Submitted: {{ $submittedDate }}
@if($isResolved)
Resolved: {{ $resolvedDate }}
@else
@endif
@endif
@endforeach
@if($sponsorship->funding_start_date && $sponsorship->funding_end_date)
START DATE
{{ \App\Helpers\Helper::showdate($sponsorship->funding_start_date, false) }}
END DATE
{{ \App\Helpers\Helper::showdate($sponsorship->funding_end_date, false) }}
@endif
@endsection @push('page_script') @endpush