@php $proofActivityCodes = ['online_ads_posted', 'outdoor_display', 'prospecting']; $monthSelectOptions = \App\Support\ReportingPeriod::monthSelectOptions(); $yearSelectOptions = \App\Support\ReportingPeriod::yearSelectOptions(); $activityTypeFilterOptions = [['value' => '', 'label' => 'All types']]; foreach (($activityTypes ?? []) as $type) { $typeLabel = $type->code === 'online_ads_posted' ? 'Online Ad' : $type->name; $activityTypeFilterOptions[] = [ 'value' => (string) $type->id, 'label' => $typeLabel, ]; } $selectedActivityTypeStr = $selectedActivityTypeId !== null ? (string) $selectedActivityTypeId : ''; $summaryCards = [ ['key' => 'calls', 'label' => 'Calls'], ['key' => 'whatsapp_messages', 'label' => 'WhatsApp messages'], ['key' => 'emails', 'label' => 'Emails'], ['key' => 'walk_ins', 'label' => 'Walk-ins'], ['key' => 'test_drives', 'label' => 'Test drives'], ['key' => 'appointments', 'label' => 'Appointments'], ['key' => 'online_ads_posted', 'label' => 'Online ad proofs'], ['key' => 'outdoor_display', 'label' => 'Outdoor displays'], ['key' => 'prospecting', 'label' => 'Prospecting'], ['key' => 'sale', 'label' => 'Sales (converted leads)'], ]; $totalActivitiesNum = (int) ($totalActivities ?? 0); $totalPointsNum = (int) ($totalPoints ?? 0); $summaryMetrics = [ ['label' => 'Total activities', 'value' => number_format($totalActivitiesNum)], ['label' => 'Total points', 'value' => number_format($totalPointsNum)], ]; foreach ($summaryCards as $card) { $stats = $summaryByType[$card['key']] ?? ['count' => 0, 'points' => 0]; $summaryMetrics[] = ['label' => $card['label'], 'value' => number_format((int) ($stats['count'] ?? 0))]; } @endphp {{ __('My Activities') }}
@foreach ($summaryMetrics as $metric)
{{ $metric['label'] }}
{{ $metric['value'] }}
@endforeach
Clear

{{ number_format(count($activities ?? [])) }} record(s)

@forelse (($activities ?? []) as $activity) @php $typeCode = (string) ($activity->activityType?->code ?? ''); $typeLabel = $typeCode === 'online_ads_posted' ? 'Online Ad' : ($activity->activityType?->name ?? '—'); $leadLabel = $activity->lead ? $activity->lead->displayName() : ''; $leadLabel = ($leadLabel === '' || $leadLabel === '—') ? 'Lead' : $leadLabel; $hasStoredDescription = $activity->description !== null && trim((string) $activity->description) !== ''; $descriptionCell = $hasStoredDescription ? trim((string) $activity->description) : trim((string) ($activity->notes ?? '')); $notesCell = $hasStoredDescription ? trim((string) ($activity->notes ?? '')) : ''; $latestProof = $activity->proofSubmissions->sortByDesc('id')->first(); if ($latestProof) { $proofStatusLabel = ucfirst((string) $latestProof->status); } elseif (in_array($typeCode, $proofActivityCodes, true)) { $proofStatusLabel = 'None'; } else { $proofStatusLabel = 'Not required'; } @endphp @empty @endforelse
Date Activity type Points Lead Description Notes Proof status
{{ optional($activity->activity_date)->format('Y-m-d') ?? $activity->activity_date }} {{ $typeLabel }}
{{ (int) $activity->points }}
@if ($activity->pointsStatusLabel() !== '')
{{ $activity->pointsStatusLabel() }}
@endif
@if ($activity->lead_id) #{{ $activity->lead_id }} {{ $leadLabel }} @else @endif
{{ $descriptionCell !== '' ? $descriptionCell : '—' }}
@if ($hasStoredDescription)
{{ $notesCell }}
@endif
{{ $proofStatusLabel }} @if ($latestProof && $latestProof->status === 'rejected' && filled($latestProof->review_notes)) Reason: {{ $latestProof->review_notes }} @endif
No activities for this selection.