@php $broadcasts = $broadcasts ?? collect(); $stats = $stats ?? [ 'total' => 0, 'sent' => 0, 'delivered' => 0, 'read' => 0, 'failed' => 0, 'processing' => 0, 'queued' => 0, ]; $statusCounts = $statusCounts ?? [ 'all' => 0, 'scheduled' => 0, 'processing' => 0, 'completed' => 0, 'completed_with_errors' => 0, 'failed' => 0, ]; $currentStatus = $currentStatus ?? 'all'; $currentRange = $currentRange ?? 'all'; $currentSearch = $currentSearch ?? ''; $deliveryPct = $stats['sent'] > 0 ? round(($stats['delivered'] / max($stats['sent'], 1)) * 100, 1) : 0; $readPct = $stats['delivered'] > 0 ? round(($stats['read'] / max($stats['delivered'], 1)) * 100, 1) : 0; $failedPct = $stats['sent'] > 0 ? round(($stats['failed'] / max($stats['sent'], 1)) * 100, 1) : 0; $recentBroadcasts = $broadcasts->take(5); // Telegram broadcasts live in their own composer (a bot's audience is its chat // threads, not phone contacts). When Telegram is connected, "New broadcast" // opens a channel chooser instead of jumping straight to the WhatsApp form. $__bcWsId = (int) (auth()->user()?->current_workspace_id ?? 0); $tgBcast = $__bcWsId > 0 && (bool) \App\Models\SystemSetting::get('telegram_enabled', false) && class_exists(\App\Models\TelegramBot::class) && \App\Models\TelegramBot::hasConnected($__bcWsId); // SMS broadcasts reuse the WhatsApp builder (SMS is a sender option), but the // channel chooser gets an SMS card so it's discoverable. Gated on the toggle // + a connected SMS number. $smsBcast = $__bcWsId > 0 && (bool) \App\Models\SystemSetting::get('sms_enabled', false) && \App\Models\WaProviderConfig::query()->forWorkspace($__bcWsId)->connected()->where('provider', 'sms')->exists(); // Instagram broadcasts reuse the SAME create page (?channel=instagram), sending // to existing IG DM chats (reply-only). Card shown when an IG account is linked. $igBcast = $__bcWsId > 0 && class_exists(\App\Models\WorkspaceIgAccount::class) && \App\Models\WorkspaceIgAccount::hasConnected($__bcWsId); // Show the channel chooser when ANY non-default broadcast channel is available. $bcChooser = $tgBcast || $smsBcast || $igBcast; @endphp
{{ __('Workspace') }} · {{ auth()->user()?->currentWorkspace?->name ?: __('Workspace') }}

{{ __('Template') }} {{ __('broadcasts') }}

{{ __('Send approved template messages to selected contacts, then track queued, sent, delivered, read, and failed status per recipient.') }}

@if ($bcChooser) @else New broadcast @endif
@if ($bcChooser) {{-- Channel chooser — WhatsApp (template + phone contacts), SMS (Twilio / MSG91 text), and Telegram (a bot message to its chat threads). Each card shows only when that channel is connected; otherwise "New broadcast" links straight to WhatsApp. --}} @endif
{{ __('Sent') }}
{{ number_format($stats['sent']) }}
{{ number_format($stats['total']) }} broadcasts
{{ __('Delivered') }}
{{ number_format($stats['delivered']) }}
{{ number_format($deliveryPct, 1) }}% delivery
{{ __('Read') }}
{{ number_format($stats['read']) }}
{{ number_format($readPct, 1) }}% read rate
{{ __('Failed') }}
{{ number_format($stats['failed']) }}
{{ number_format($failedPct, 1) }}% failed
{{ __('Processing') }}
{{ number_format($stats['processing']) }}
{{ __('in flight') }}
{{ __('Queued') }}
{{ number_format($stats['queued']) }}
{{ __('awaiting send') }}
{{ __('Broadcast list') }}

{{ __('Recent broadcasts') }}

@foreach ([['all', 'All time'], ['7d', '7d'], ['30d', '30d'], ['90d', '90d']] as [$rk, $rl]) @php $active = $currentRange === $rk; @endphp @endforeach
@include('user.broadcasts._rows', ['broadcasts' => $broadcasts])
{{ __('Name') }} {{ __('Template') }} {{ __('Contacts') }} {{ __('Sent') }} {{ __('Delivered') }} {{ __('Read') }} {{ __('Failed') }} {{ __('Clicked') }} {{ __('Status') }} {{ __('Schedule') }}
@include('user.partials.pagination', [ 'paginator' => $broadcasts, 'dataAttr' => 'data-bc-page', 'label' => 'broadcasts', ])
{{ __('Help - 01') }}
{{ __('What is a broadcast?') }}

{{ __('A template-based send to selected contacts, with per-recipient queued, sent, delivered, read, and failed tracking.') }}

{{ __('Help - 02') }}
{{ __('When should I schedule it?') }}

{{ __('Schedule larger audience sends for quiet support hours, and use smaller immediate sends for urgent updates.') }}

{{ __('Help - 03') }}
{{ __('How do I improve results?') }}

{{ __('Keep the audience focused, choose the most relevant template, and review failed counts before sending again.') }}