{{-- Visa utskick, the statistics of one sendout (DESIGN.md Page patterns 4; #2957 slice 3c, card #3017). Same data as before the reskin (SendoutController@show): $sendout, $subHeader, $browserStats, $platformStats, $linksStats, $statsData, $dataOpen and $dataLabels, "dates" picks the period. Actions under the old conditions: Visa mottagare always; Stoppa utskick (DELETE sendout.destroy, confirmed in the native dialog) while neither stopped nor aborted; Skriva ut (sendout.pdf) once stopped and not aborted; an aborted sendout says so in a banner. --}} @extends('layouts.nuhet') @section('_pageTitle', __('sendout.show.pageTitle')) @section('pagename', __('sendout.statsBtn')) @php $longDate = fn ($date) => \App\Support\DisplayDate::timestamp($date); $percent = fn ($part, $whole) => $whole > 0 ? $part / $whole * 100 : 0; $percentText = fn ($value) => formatNumber($value, 1, ',').' %'; $meta = collect($subHeader)->pluck('value', 'label'); $running = is_null($sendout->stop_time) && is_null($sendout->abort_time); $canOpenNewsletter = $sendout->newsletter && Auth::user()->can('newsletterParse', $sendout->newsletter); $printable = ! is_null($sendout->stop_time) && is_null($sendout->abort_time) && $canOpenNewsletter; $consent = optional($sendout->newsletter)->type == 99; $word = $sendout->statusLabelKey(); // The old pie: of the letters sent, opened, bounced, and the rest unknown, each as a share of // every receiver row of the sendout (bounceStickData's COUNT(id)), still queued ones included. $sent = (int) $statsData['sent']; $receiverTotal = (int) $statsData['total']; $outcome = [ [__('sendout.chart.open'), (int) $statsData['open']], [__('sendout.chart.bounce'), (int) $statsData['bounce']], // Clamped: open + bounce can briefly exceed sent while the stat rows land. [__('sendout.chart.unknown'), max(0, $sent - (int) $statsData['open'] - (int) $statsData['bounce'])], ]; // The old browser table: the three most common named browsers, the rest (unknown included) as "Övriga". $browserNames = ['IE' => 'Internet Explorer', 'Mobile Safari UIWebView' => 'iPhone', 'Android WebView' => 'Android']; $browserTotal = array_sum($browserStats); $browsers = collect($browserStats)->filter(fn ($count, $name) => $name !== '')->take(3) ->map(fn ($count, $name) => [$browserNames[$name] ?? $name, $count])->values()->all(); $otherBrowsers = $browserTotal - array_sum(array_column($browsers, 1)); if ($otherBrowsers > 0) { $browsers[] = [__('sendout.stats.otherBrowsers'), $otherBrowsers]; } // The old platform table: always these four, in this order. $platformTotal = array_sum($platformStats); $platforms = collect(['Desktop' => 'computer', 'Mobile' => 'phone', 'Tablet' => 'tablet', '' => 'unknown']) ->map(fn ($type, $key) => [__('sendout.show.platformTypes.'.$type), $platformStats[$key] ?? 0])->values()->all(); $links = $consent ? [] : collect($linksStats)->sortDesc()->all(); $lists = (string) $meta->get(__('taggingSendout.show.headerLabel.lists'), ''); $validRange = in_array((int) request('dates'), [1, 7, 14, 21, 28], true); $range = $validRange ? (int) request('dates') : 1; $age = $sendout->start_time->isPast() ? $sendout->start_time->diffInDays(now()) : -1; $ranges = array_filter([ 1 => __('sendout.show.periodDay'), 7 => $age >= 1 ? __('sendout.show.periodWeek') : null, 14 => $age >= 7 ? __('sendout.show.periodWeeks', ['count' => 2]) : null, 21 => $age >= 14 ? __('sendout.show.periodWeeks', ['count' => 3]) : null, 28 => $age >= 21 ? __('sendout.show.periodWeeks', ['count' => 4]) : null, ]); @endphp @section('page')
{{ __('sendout.show.lead') }}
@if ($word) @endif{{ __('sendout.show.noclicks') }}
@else{{ __('sendout.show.clicksHint') }}
| {{ __('sendout.show.columnLink') }} | {{ __('sendout.show.columnClicks') }} |
|---|---|
| {{ $url }} | {{ formatNumber($total) }} |
{{ __('sendout.show.outcomeHint', ['count' => formatNumber($receiverTotal)]) }}
@foreach ($outcome as [$label, $count]) @include('sendout.partials.share-bar', ['label' => $label.' · '.formatNumber($count), 'value' => $percent($count, $receiverTotal), 'text' => $percentText($percent($count, $receiverTotal)), 'aria' => __('sendout.show.outcomeBar', ['label' => $label, 'count' => formatNumber($count), 'total' => formatNumber($receiverTotal), 'percent' => $percentText($percent($count, $receiverTotal))])]) @endforeach{{ __('sendout.show.noEvents') }}
@endif