{{-- 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->subject }}

{{ __('sendout.show.lead') }}

@if ($word)

{{ __($word) }} {{ $longDate($sendout->start_time) }}

@endif
@if ($printable) {{ __('feedback_nov3_reports.newsletterPrint') }} @endif @if ($running)
@csrf @method('DELETE') {{ __('sendout.index.stop') }}
@endif
@unless (is_null($sendout->abort_time)) {{ __('sendout.abortedSendoutInfo', ['date' => $longDate($sendout->abort_time)]) }} @endunless @include('partials.nh-report-tabs', ['reportKind' => 'email', 'reportId' => $sendout->id, 'reportTab' => 'overview'])

{{ __('sendout.show.totals') }}

@include('sendout.partials.totals', ['sendout' => $sendout])
@if ($consent)
@else @if (empty($links))

{{ __('sendout.show.noclicks') }}

@else

{{ __('sendout.show.clicksHint') }}

@php $pageLinks = \App\Support\TablePagination::rows($links, 'linkStatsPage'); @endphp @foreach ($pageLinks as $url => $total) @endforeach
{{ __('sendout.show.columnLink') }}{{ __('sendout.show.columnClicks') }}
{{ $url }} {{ formatNumber($total) }}
@endif
@endif

{{ __('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.headerLabel.newsletter') }}
@if ($canOpenNewsletter){{ $meta->get(__('sendout.show.headerLabel.newsletter')) }} {{ __('feedback_nov3_reports.openNewsletter') }}@else {{ $meta->get(__('sendout.show.headerLabel.newsletter')) ?: '-' }} @endif
{{ __('sendout.show.headerLabel.start_time') }}
{{ $longDate($sendout->start_time) }}
{{ __('sendout.show.headerLabel.done_time') }}
{{ $meta->get(__('sendout.show.headerLabel.done_time')) }}
{{ __('sendout.show.headerLabel.stop_time') }}
{{ $sendout->stop_time ? $longDate($sendout->stop_time) : __('sendout.show.notYet') }}
{{ __('taggingSendout.show.headerLabel.lists') }}
@if (mb_strlen($lists) > 300)
{{ \Illuminate\Support\Str::limit($lists, 300) }} {{ __('taggingSendout.expand') }}{{ $lists }}
@else
{{ $lists }}
@endif
{{ __('sendout.show.headerLabel.profile') }}
{{ $meta->get(__('sendout.show.headerLabel.profile')) }}
@foreach ([['nh-show-browsers', 'sendout.show.browsers', $browsers, $browserTotal], ['nh-show-platforms', 'sendout.show.platforms', $platforms, $platformTotal]] as [$id, $title, $rows, $total]) @if ($total > 0) @foreach ($rows as [$label, $count]) @include('sendout.partials.share-bar', ['label' => $label, 'value' => $percent($count, $total), 'text' => $percentText($percent($count, $total)), 'aria' => __('sendout.show.shareBar', ['label' => $label, 'percent' => $percentText($percent($count, $total))])]) @endforeach @else

{{ __('sendout.show.noEvents') }}

@endif
@endforeach
@include('partials.nh-report-action-dialog') @include('sendout.partials.stats-charts', [ 'opens' => ['labels' => array_values($dataLabels), 'data' => array_values((array) $dataOpen), 'label' => __('sendout.chart.open')], 'clicks' => ['labels' => array_keys(array_slice($links, 0, 10, true)), 'data' => array_values(array_slice($links, 0, 10, true)), 'label' => __('sendout.show.columnClicks')], ])
@endsection @push('scripts') @endpush