{{-- Mailing Report Modal Partial --}} @php $statusColors = [ 'draft' => 'bg-gray-100 text-gray-800', 'scheduled' => 'bg-yellow-100 text-yellow-800', 'sending' => 'bg-blue-100 text-blue-800', 'sent' => 'bg-green-100 text-green-800', 'aborted' => 'bg-red-100 text-red-800', 'cancelled' => 'bg-red-100 text-red-800', ]; $statusColor = $statusColors[$mailing->status] ?? 'bg-gray-100 text-gray-800'; @endphp {{-- Header --}}

{{ $mailing->title }}

{{ $mailing->id }}

@if($mailing->sent_at || $mailing->scheduled_at)

@if($mailing->sent_at) {{ __('Sent') }}: {{ $mailing->sent_at->format('d M Y H:i') }} @else {{ __('Scheduled') }}: {{ $mailing->scheduled_at->format('d M Y H:i') }} @endif

@endif @if($mailing->sending_started_at) @php $endTime = $mailing->sent_at ?? now(); $durationSeconds = (int) $mailing->sending_started_at->diffInSeconds($endTime, true); $durationHours = intdiv($durationSeconds, 3600); $durationMinutes = intdiv($durationSeconds % 3600, 60); $durationSecs = $durationSeconds % 60; $durationStr = $durationHours > 0 ? sprintf('%dh %dm %ds', $durationHours, $durationMinutes, $durationSecs) : ($durationMinutes > 0 ? sprintf('%dm %ds', $durationMinutes, $durationSecs) : sprintf('%ds', $durationSecs)); @endphp

{{ __('Started sending') }}: {{ $mailing->sending_started_at->format('d M Y H:i') }}

{{ $mailing->sent_at ? __('Duration') : __('Running for') }}: {{ $durationStr }}

@endif
{{ __(ucfirst($mailing->status)) }}
{{-- Block 1: Estimated Recipients --}}

{{ __('Recipients by Language & Content') }}

@php $rowsByLocaleLocation = $mailing->getRecipientCountsByLocaleAndLocation(); $fallbackLocale = $mailing->fallback_locale ?? ''; @endphp @if(count($rowsByLocaleLocation) > 0) @php $prevLocale = null; $fallbackLanguageName = \App\Models\Language::where('lang_code', $fallbackLocale)->value('name') ?? strtoupper($fallbackLocale); @endphp @foreach($rowsByLocaleLocation as $row) @php $isFirstForLocale = $row['locale'] !== $prevLocale; $prevLocale = $row['locale']; $language = $isFirstForLocale ? \App\Models\Language::where('lang_code', $row['locale'])->first() : null; $flag = $language ? $language->flag : '🏳️'; $languageName = $language ? $language->name : strtoupper($row['locale']); $nativePosts = $row['content_blocks'] - ($row['fallback_posts'] ?? 0); $fallbackPosts = $row['fallback_posts'] ?? 0; $missingPosts = $row['missing_posts'] ?? 0; @endphp @endforeach
{{ __('Language') }} {{ __('Posts') }} {{ __('Location') }} {{ __('Recipients') }}
@if($isFirstForLocale) {{ $flag }} {{ $languageName }} @endif @if($isFirstForLocale) @if($nativePosts > 0) {{ $nativePosts }} {{ __('native') }} @endif @if($fallbackPosts > 0) {{ $fallbackPosts }} {{ __('fallback in') }} {{ $fallbackLanguageName }} @endif @if($missingPosts > 0) {{ $missingPosts }} {{ __('skipped') }} @endif @if($nativePosts === 0 && $fallbackPosts === 0) {{ __('No content') }} @endif @endif {{ $row['location'] ?: __('Unknown') }} {{ number_format($row['count']) }}
@php $totalEstimated = collect($rowsByLocaleLocation)->sum('count'); $suppressedCount = $mailing->getSuppressedRecipientsCount(); @endphp
{{ __('Total recipients:') }} {{ number_format($totalEstimated) }}
@if($suppressedCount > 0)
{{ __('Skipped (hard bounce):') }} {{ number_format($suppressedCount) }}
@endif
@else

{{ __('No recipients found for this mailing type.') }}

@endif
{{-- Block 2: Send Results (only shown once sending has started) --}} @if(in_array($mailing->status, ['sending', 'sent', 'aborted'])) @php $bounceStats = $this->getReportBounceStats(); $recipientsCount = $mailing->recipients_count ?: 1; $processedCount = $mailing->sent_count + $mailing->failed_count + $mailing->skipped_count + $mailing->aborted_count; $progressPct = min(100, round($processedCount / $recipientsCount * 100)); @endphp

{{ __('Send Results') }}

{{-- Progress bar (while sending) --}} @if($mailing->status === 'sending')
{{ __('Progress') }} {{ number_format($processedCount) }} / {{ number_format($mailing->recipients_count) }}
@endif {{-- Results table --}} @if($mailing->skipped_count > 0) @endif @if($mailing->aborted_count > 0) @endif @if($bounceStats['hard'] > 0) @endif @if($bounceStats['soft'] > 0) @endif @if($bounceStats['complaint'] > 0) @endif
{{ __('Successfully sent') }} {{ number_format($mailing->sent_count) }}
{{ __('Failed (delivery error)') }} @if($mailing->failed_count > 0) {{ number_format($mailing->failed_count) }} @else 0 @endif
{{ __('Skipped (hard bounce)') }} {{ number_format($mailing->skipped_count) }}
{{ __('Not sent (aborted)') }} {{ number_format($mailing->aborted_count) }}
{{ __('Bounced (hard)') }} {{ number_format($bounceStats['hard']) }}
{{ __('Bounced (soft)') }} {{ number_format($bounceStats['soft']) }}
{{ __('Complaints') }} {{ number_format($bounceStats['complaint']) }}
{{-- Totals --}}
{{ __('Total sent to:') }} {{ number_format($mailing->recipients_count) }}
@if($mailing->sent_count > 0 && $mailing->recipients_count > 0)
{{ __('Success rate') }} {{ round($mailing->sent_count / $mailing->recipients_count * 100, 1) }}%
@endif
@endif