@extends('admin.admin_dashboard') @section('admin') <<<<<<< HEAD
Send Bulk SMS
@if(session('results')) @endif
@csrf
@error('group')
{{ $message }}
@enderror
1 Message (160 chars), 2 Messages (320 chars), 3 Messages (480 chars), 4 Messages (640 chars)
Characters Used: 0
@error('message')
{{ $message }}
@enderror
@if(session('results'))
Sent Message
{{ session('sent_message') }}
Delivery Results
    @foreach(session('results') as $number => $status)
  • {{ $number }}: {{ is_array($status) ? ($status['Status'] ?? json_encode($status)) : $status }}
  • @endforeach
@endif
@endsection ======= @php $templates = $templates ?? config('sms.templates', []); $audiences = $audiences ?? config('sms.audiences', []); $placeholders = $placeholders ?? config('sms.placeholders', []); $audienceCounts = $audienceCounts ?? []; $dashboardStats = $dashboardStats ?? []; $missingContacts = $missingContacts ?? []; $report = session('sms_report'); $maxLen = config('sms.max_length', 640); $costPerSegment = $costPerSegment ?? config('sms.cost_per_segment_ugx', 35); $senderId = $senderId ?? config('sms.sender_id', 'CHM'); $recentCampaigns = $recentCampaigns ?? collect(); $templatesByCategory = collect($templates)->groupBy(fn ($t) => match ($t['tone'] ?? 'general') { 'accounting' => 'Accounting & debts', 'operations' => 'Operations', 'cfdp' => 'CFDP', default => 'General', }); @endphp
Home SMS Center Sender: {{ $senderId }} @if(session('success')) {{ session('success') }} @endif @if(session('error')) {{ session('error') }} @endif {{-- KPI strip --}}
@foreach([ ['farmers_with_balance', 'Can remind (debt)', 'farmers with balance + phone', 'bx-wallet', 'danger'], ['total_outstanding_ugx', 'Outstanding advances', 'UGX total owed', 'bx-money', 'coffee'], ['farmers_balance_no_phone', 'Missing phones', 'debtors we cannot SMS', 'bx-phone-off', 'warning'], ['payment_queue', 'Payment queue', 'waiting at desk', 'bx-megaphone', 'blue'], ['pending_cash_vouchers', 'Cash ready', 'approved vouchers', 'bx-receipt', 'green'], ['farmers_with_phone', 'Farmer contacts', 'reachable numbers', 'bx-user', 'neutral'], ] as [$key, $label, $sub, $icon, $tone])
@if(str_contains($key, 'ugx') || str_contains($key, 'outstanding')) {{ number_format($dashboardStats[$key] ?? 0, 0) }} @else {{ number_format($dashboardStats[$key] ?? 0) }} @endif
{{ $label }}
{{ $sub }}
@endforeach
@if(count($missingContacts) > 0)
{{ $dashboardStats['farmers_balance_no_phone'] ?? count($missingContacts) }} farmer(s) owe money but have no phone number

Add contacts on their profile before you can SMS them about advances.

@can('farmer.edit') Open farmer register @endcan
@foreach($missingContacts as $row) @endforeach
FarmerNo.Balance
{{ $row['name'] }} {{ $row['farmer_number'] }} UGX {{ $row['balance'] }} @can('farmer.edit') Add phone @endcan
@endif @if($report)
Delivery report

{{ $report['audience'] ?? 'Campaign' }} — {{ $report['sent'] ?? 0 }} sent, {{ $report['failed'] ?? 0 }} failed @if(!empty($report['estimated_cost_ugx'])) · est. UGX {{ number_format($report['estimated_cost_ugx']) }} @endif

@foreach($report['results'] ?? [] as $row) @endforeach
RecipientPhoneStatusMessage
{{ $row['name'] ?? '—' }} {{ $row['phone'] ?? '—' }} {{ ucfirst($row['status'] ?? '') }} {{ \Illuminate\Support\Str::limit($row['message'] ?? '', 100) }}
@endif

Tap to load message + audience

@foreach($templatesByCategory as $category => $items)
{{ $category }}
@foreach($items as $key => $template) @endforeach @endforeach
{{-- Phone mockup --}}
{{ $senderId }}
Select a template or type a message to see how it looks on a phone.
1 SMS · live preview
@csrf
selected recipients
UGX —
0 SMS parts @ UGX {{ number_format($costPerSegment) }}
Only include farmers owing at least this much.
@foreach($placeholders as $token => $hint) @endforeach
{{-- Recipient roster --}}
Recipient roster

Uncheck anyone to exclude them from this send. Each row shows their personalized amount where applicable.

Name Phone Amount / detail Preview
@csrf
@if($recentCampaigns->isNotEmpty())
@foreach($recentCampaigns as $c) @endforeach
WhenAudienceBySentFailedEst. cost
{{ $c->created_at?->format('M j, H:i') }} {{ config('sms.audiences.'.$c->audience.'.label', $c->audience) }} {{ $c->user?->name ?? '—' }} {{ $c->sent_count }} @if($c->failed_count){{ $c->failed_count }}@else — @endif UGX {{ number_format($c->estimated_cost ?? 0) }}
@endif
@endsection @push('styles') @endpush @push('scripts') @endpush >>>>>>> origin/main