@php $delta = function ($now, $before) { if ($before == 0) return $now > 0 ? '+∞' : null; $p = round(($now - $before) / $before * 100); return ($p >= 0 ? '+' : '').$p.'%'; }; $deltaClass = fn ($now, $before) => $now >= $before ? 'badge-green' : 'badge-red'; @endphp

Rapor

{{ $periodLabel }} — değişimler bir önceki eşit uzunluktaki dönemle karşılaştırılır.

@foreach (['1' => 'Bugün', 'dun' => 'Dün', '7' => '7 Gün', '14' => '14 Gün', '30' => '30 Gün', '60' => '60 Gün', '90' => '90 Gün', 'custom' => 'Özel'] as $key => $label) @endforeach
@if ($range === 'custom')
–
@endif
{{-- KPI kartları --}}
@foreach ([ ['label' => 'Yeni Konuşma', 'key' => 'conversations', 'hint' => null], ['label' => 'Gelen Mesaj', 'key' => 'msg_in', 'hint' => null], ['label' => 'Giden Mesaj', 'key' => 'msg_out', 'hint' => $m['msg_out'] ? $m['bot_out'].' bot · '.($m['msg_out'] - $m['bot_out']).' temsilci' : null], ['label' => 'Yeni Hasta', 'key' => 'contacts', 'hint' => null], ['label' => 'Lead', 'key' => 'leads', 'hint' => $m['conversations'] ? 'Dönüşüm: %'.round($m['leads'] / $m['conversations'] * 100, 1) : null], ['label' => "Meta'ya Bildirilen (CAPI)", 'key' => 'capi', 'hint' => null], ['label' => 'Yorum', 'key' => 'comments', 'hint' => null], ] as $card)

{{ $card['label'] }}

{{ number_format($m[$card['key']], 0, ',', '.') }} @if (($d = $delta($m[$card['key']], $prev[$card['key']])) !== null) {{ $d }} @endif
@if ($card['hint'])

{{ $card['hint'] }}

@endif
@endforeach

Ort. İlk Yanıt

{{ $avgResponse !== null ? ($avgResponse < 60 ? $avgResponse.' dk' : round($avgResponse / 60, 1).' sa') : '—' }}

İlk hasta mesajı → ilk cevap

{{-- Günlük trend --}}

Günlük Trend

Gelen mesaj Lead

@php $n = count($daily); $maxIn = max(1, max(array_column($daily, 'in'))); $maxLead = max(1, max(array_column($daily, 'leads'))); $W = 720; $H = 150; $bw = $W / max(1, $n); $points = []; foreach ($daily as $i => $d) { $points[] = round($i * $bw + $bw / 2, 1).','.round($H - ($d['leads'] / $maxLead) * ($H - 14), 1); } @endphp
@foreach ($daily as $i => $d) @php $h = round(($d['in'] / $maxIn) * ($H - 14), 1); @endphp {{ \Illuminate\Support\Carbon::parse($d['date'])->format('d.m') }}: {{ $d['in'] }} mesaj, {{ $d['leads'] }} lead @if ($n <= 31 && ($n <= 14 || $i % 2 === 0)) {{ \Illuminate\Support\Carbon::parse($d['date'])->format('d.m') }} @endif @endforeach @if ($n > 1) @endif @foreach ($daily as $i => $d) @if ($d['leads'] > 0) {{ $d['leads'] }} lead @endif @endforeach
{{-- Kanal kırılımı --}}

Kanal Kırılımı

@foreach ($channels as $c) @endforeach
Kanal Konuşma Gelen Mesaj Lead Dönüşüm
{{ ['whatsapp' => 'WhatsApp', 'messenger' => 'Messenger', 'instagram' => 'Instagram'][$c['channel']] }} {{ number_format($c['conversations'], 0, ',', '.') }} {{ number_format($c['msg_in'], 0, ',', '.') }} {{ $c['leads'] }} %{{ $c['rate'] }}
{{-- Lead durumları --}}

Lead Durum Dağılımı

@php $leadTotal = max(1, $leadStatuses->sum()); @endphp
@forelse (\App\Models\Lead::STATUSES as $key => $label) @php $c = (int) ($leadStatuses[$key] ?? 0); @endphp
{{ $label }} {{ $c }} (%{{ round($c / $leadTotal * 100) }})
@empty

Bu dönemde lead yok.

@endforelse
{{-- Canlı reklam listesi (Meta'dan) --}}

Reklamlar

@if (! $liveAds['ok'])

Reklam listesi şu an Meta'dan alınamıyor — jeton yenilendiğinde otomatik dolar.

@else @php $rows = $liveAds[$adTab]; @endphp
@forelse ($rows as $ad) @empty @endforelse
Reklam Durum Bütçe / Gün Bugün Harcama Bugün Mesaj Oluşturulma
@if ($ad['media']) @endif {{ \Illuminate\Support\Str::limit($ad['name'], 70) }} @php [$cls, $label] = match ($ad['status']) { 'ACTIVE' => ['badge-green', 'Yayında'], 'PENDING_REVIEW' => ['badge-blue', 'İncelemede'], 'WITH_ISSUES' => ['badge-red', 'Hatalı'], 'PAUSED' => ['badge-slate', 'Durduruldu'], 'CAMPAIGN_PAUSED' => ['badge-slate', 'Kampanya kapalı'], 'ADSET_PAUSED' => ['badge-slate', 'Set kapalı'], default => ['badge-slate', $ad['status']], }; @endphp {{ $label }} {{ $ad['budget'] > 0 ? number_format($ad['budget'], 0, ',', '.').' ₺' : '—' }} {{ $ad['spend'] > 0 ? number_format($ad['spend'], 0, ',', '.').' ₺' : '—' }} {{ $ad['msgs'] ?: '—' }} {{ $ad['created'] ? \Illuminate\Support\Carbon::parse($ad['created'])->format('d.m.Y') : '—' }}
Bu sekmede reklam yok.
@if ($adTab === 'aktif' && count($rows))

Toplam günlük bütçe: {{ number_format(collect($rows)->sum('budget'), 0, ',', '.') }} ₺ · Bugün: {{ number_format(collect($rows)->sum('spend'), 0, ',', '.') }} ₺ / {{ collect($rows)->sum('msgs') }} mesaj · Liste 10 dk'da bir yenilenir

@endif @endif
{{-- Reklam kaynağı --}}

Reklam Performansı

Reklam tıklaması → panele düşen konuşma → lead hunisi

@forelse ($ads as $ad) @empty @endforelse
Reklam Kaynak Harcama Gelen Trafik Lead TL / Lead CAPI Lead Oranı
@if ($ad['media']) @else @endif {{ $ad['headline'] ?? 'Reklam '.substr($ad['ad_id'], -6) }} {{ $ad['ad_id'] }} {{ ['ctwa' => 'WhatsApp', 'ctm' => 'Messenger', 'ig_ad' => 'Instagram'][$ad['source']] ?? 'Reklam' }} {{ $ad['spend'] > 0 ? number_format($ad['spend'], 0, ',', '.').' ₺' : '—' }} {{ number_format($ad['clicks'], 0, ',', '.') }} {{ $ad['leads'] }} {{ $ad['cost_per_lead'] !== null ? number_format($ad['cost_per_lead'], 0, ',', '.').' ₺' : ($ad['spend'] > 0 ? '⚠︎' : '—') }} {{ $ad['capi'] }} @if ($ad['trend'] === 'up') ▲ @elseif ($ad['trend'] === 'down') ▼ @endif %{{ $ad['rate'] }}
Bu dönemde reklam kaynaklı trafik yok.
Organik (reklamsız) Doğrudan mesaj — {{ number_format($organicConvs, 0, ',', '.') }} {{ $organicLeads }} — — %{{ $organicConvs ? round($organicLeads / $organicConvs * 100, 1) : 0 }}
{{-- Reklam değişiklik bekçisi --}} @if (config('alpichat.ads_token'))

Reklam Değişiklikleri

Kampanya/reklam seti durum ve bütçe değişimleri — saatte bir taranır

@if ($adChanges->isEmpty())

Henüz kayıtlı değişiklik yok — bekçi saatte bir tarıyor; bir kampanya durdurulduğunda ya da bütçesi değiştiğinde burada görünecek.

@endif @foreach ($adChanges as $ch)
{{ \Illuminate\Support\Carbon::parse($ch->detected_at)->timezone('Europe/Istanbul')->format('d.m H:i') }} {{ $ch->object_type === 'campaign' ? 'Kampanya' : 'Reklam seti' }} {{ $ch->name }} @if ($ch->field === 'status') durum: {{ $ch->old_value }} → {{ $ch->new_value }} @else bütçe: {{ number_format((int) $ch->old_value / 100, 0, ',', '.') }} ₺ → {{ number_format((int) $ch->new_value / 100, 0, ',', '.') }} ₺/gün @endif
@endforeach
@endif {{-- Yorum istatistikleri --}}

Yorum Durumları

@php $ct = max(1, $commentStatuses->sum()); @endphp
@foreach (\App\Models\Comment::STATUSES as $key => $label) @php $c = (int) ($commentStatuses[$key] ?? 0); @endphp @if ($c > 0)
{{ $label }} {{ $c }} (%{{ round($c / $ct * 100) }})
@endif @endforeach @if ($commentStatuses->isEmpty())

Bu dönemde yorum yok.

@endif

Yorum AI Triyaj Dağılımı

@php $at = max(1, $commentAi->sum()); @endphp
@foreach (\App\Services\CommentClassifier::CATEGORIES as $key => $label) @php $c = (int) ($commentAi[$key] ?? 0); @endphp @if ($c > 0)
{{ $label }} {{ $c }} (%{{ round($c / $at * 100) }})
@endif @endforeach @if ($commentAi->isEmpty())

Bu dönemde sınıflandırılmış yorum yok.

@endif