@extends('admin.layout') @section('title', 'Dashboard') @php $tile = function (string $label, string $value, string $subHtml = '', string $href = '') { $tag = $href ? 'a href="'.e($href).'"' : 'div'; return '<'.$tag.' class="tile">'.e($label).''.e($value).''.$subHtml.''; }; @endphp @section('content') @include('admin._range', ['action' => '/admin', 'days' => $days]) @if ($todo)

Needs your attention

@else
Nothing needs attention right now.
@endif
{!! $tile('Revenue collected', naira($m['revenue']), \App\Support\Charts::delta($m['revenue'], $m['revenue_prev'])) !!} {!! $tile('Orders', (string) $m['orders'], \App\Support\Charts::delta($m['orders'], $m['orders_prev']).($m['cancelled'] ? ' '.$m['cancelled'].' cancelled' : '')) !!} {!! $tile('Average order', naira($m['aov']), 'per paid order') !!} {!! $tile('Units sold', (string) $m['units'], ''.$m['customers'].' customer'.($m['customers'] === 1 ? '' : 's').'') !!} {!! $tile('Awaiting payment', naira($m['awaiting']), 'Paystack and transfer orders not yet paid', '/admin/orders?pay=unpaid') !!} {!! $tile('Paid rate', $m['pay_rate'] === null ? 'n/a' : $m['pay_rate'].'%', 'of online and transfer orders') !!} @if ($fin) {!! $tile('Gross profit', $m['profit_base'] ? naira($m['profit']) : 'n/a', ''.($m['profit_base'] ? round(100 * $m['profit'] / $m['profit_base'], 1).'% margin' : 'add cost prices to products').'') !!} @endif

Revenue collected per day

{!! \App\Support\Charts::bars($series) !!}

Best sellers (sales value)

{!! \App\Support\Charts::hbars(array_map(fn ($p) => [$p['name'], $p['sales'], \App\Support\Charts::moneyShort($p['sales']).' · '.$p['units'].' sold'], $top)) !!}

Sales by category

{!! \App\Support\Charts::hbars(array_map(fn ($r) => [$r->n, (int) $r->v, \App\Support\Charts::moneyShort((int) $r->v)], $cats), '#3e3d3f') !!}

How customers pay

{!! \App\Support\Charts::hbars(array_map(fn ($r) => [\App\Models\Order::METHODS[$r->n] ?? $r->n, (int) $r->v, \App\Support\Charts::moneyShort((int) $r->v)], $pm), '#3e3d3f') !!}

Order status

{!! \App\Support\Charts::hbars(array_map(fn ($r) => [\App\Models\Order::STATUSES[$r->n] ?? $r->n, (int) $r->v, (string) $r->v], $stt)) !!}

Where orders go

{!! \App\Support\Charts::hbars(array_map(fn ($r) => [$r->n, (int) $r->v, (string) $r->v], $states), '#3e3d3f') !!}

Stock health

{{ $sh['in'] }} in stock{{ $sh['low'] }} low{{ $sh['out'] }} sold out
@if ($sh['tracked'])

{{ $sh['tracked'] }} products have units counted. Stock at selling price: {{ naira($sh['retail_value']) }}@if ($fin); at cost: {{ naira($sh['cost_value']) }}@endif.

@endif @if ($sh['low_list']) @endif @if ($sh['dead']) @php($n = count($sh['dead']))

{{ $n }} product{{ $n > 1 ? 's have' : ' has' }} stock but no sales in 30 days: {{ implode(', ', array_map(fn ($p) => $p->name, array_slice($sh['dead'], 0, 3))) }}{{ $n > 3 ? '…' : '' }}

@endif

Customer reviews

@if ($nrev)

{{ number_format($avg, 1) }} {!! \App\Support\Charts::stars($avg) !!} {{ $nrev }} review{{ $nrev > 1 ? 's' : '' }}

{!! \App\Support\Charts::hbars(array_map(fn ($k) => [$k.' star', $dist[$k], (string) $dist[$k]], [5, 4, 3, 2, 1])) !!} @else

No approved reviews yet.

@endif
@if ($latest !== null)

Latest orders

@include('admin.orders._table', ['orders' => $latest])@endif @endsection