@extends('layouts.app')
@section('title', 'Dashboard')
@section('content')
@php
$u = auth()->user();
$showOverview = $u->can('widget.chart_weekly') || $u->can('widget.chart_payments');
$showBreakdown = $u->can('widget.tab_breakdown');
$showStaff = $u->can('widget.staff_cashier') || $u->can('widget.staff_waiter') || $u->can('widget.staff_bartender');
$showStock = $u->can('widget.tab_low_stock');
$firstTab = $showOverview ? 'overview' : ($showBreakdown ? 'breakdown' : ($showStaff ? 'staff' : 'stock'));
@endphp
{{-- Header --}}
{{ ['today' => "Today's Overview", 'week' => "This Week's Overview", 'month' => "This Month's Overview", 'custom' => 'Overview'][$period] ?? 'Overview' }}
@if ($from->isSameDay($to)) {{ $from->format('l, d F Y') }} @else {{ $from->format('d M Y') }} — {{ $to->format('d M Y') }} @endif
· {{ config('pos.company.currency_symbol') }} figures · {{ $areaOptions[$area] ?? 'No area' }}
{{-- Stat cards: each one only appears if this role may see it --}}
@php
$sym = config('pos.company.currency_symbol');
$statCards = collect([
['widget.sales_total', 'Total Sales', $sym.' '.number_format($grossSales, 0), 'trending-up', 'primary'],
['widget.gross_profit', 'Gross Profit', $sym.' '.number_format($grossProfit, 0), 'coins', 'success'],
['widget.transactions', 'Transactions', number_format($transactionCount), 'receipt-text', 'info'],
['widget.levy', 'Levy Collected', $sym.' '.number_format($todaysLevy, 0), 'percent', 'accent'],
['widget.stock_value', 'Stock Value', $sym.' '.number_format($stockValue, 0), 'boxes', 'primary'],
['widget.low_stock_count', 'Low Stock Items', (string) $lowStockCount, 'triangle-alert', 'danger'],
['widget.expenses', 'Expenses', $sym.' '.number_format($expenses, 0), 'wallet', 'accent'],
['widget.departments', 'Departments Active', (string) $salesByDepartment->count(), 'layout-grid', 'info'],
])->filter(fn ($c) => auth()->user()->can($c[0]))
// Expenses aren't tracked per area, so profit is only shown for the whole business.
->reject(fn ($c) => $c[0] === 'widget.gross_profit' && $area !== 'all');
@endphp
@if ($statCards->isNotEmpty())
@foreach ($statCards as [$perm, $label, $value, $icon, $tone])
@endforeach
@endif
{{-- Tabs --}}
@if ($showOverview || $showBreakdown || $showStaff || $showStock)
@if ($showOverview)Overview @endif
@if ($showBreakdown)Sales Breakdown @endif
@if ($showStaff)Staff Performance @endif
@if ($showStock)Low Stock @endif
{{-- Overview tab --}}
@if ($showOverview)
@can('widget.chart_weekly')
@endcan
@can('widget.chart_payments')
@endcan
@endif
{{-- Breakdown tab --}}
@if ($showBreakdown)
@foreach ($salesByDepartment as $dept => $total)
{{ $dept }}
{{ config('pos.company.currency_symbol') }} {{ number_format($total, 0) }}
@endforeach
@if ($salesByDepartment->isEmpty())
No sales recorded for this date yet.
@endif
@endif
{{-- Staff tab --}}
@if ($showStaff)
@can('widget.staff_cashier')
Sales by cashier
Cashier Sales
@forelse ($salesByCashier as $name => $total)
{{ $name }} {{ number_format($total, 0) }}
@empty
No data yet.
@endforelse
@endcan
@can('widget.staff_waiter')
Sales by waiter
Waiter Sales
@forelse ($salesByWaiter as $name => $total)
{{ $name }} {{ number_format($total, 0) }}
@empty
No data yet.
@endforelse
@endcan
@can('widget.staff_bartender')
Sales by bartender
Bartender Sales
@forelse ($salesByBartender as $name => $total)
{{ $name }} {{ number_format($total, 0) }}
@empty
No data yet.
@endforelse
@endcan
@endif
{{-- Low stock tab --}}
@if ($showStock)
@forelse ($lowStockItems as $stock)
{{ $stock->product->name }}
{{ $stock->store->name ?? '—' }}
{{ $stock->quantity_on_hand }} {{ $stock->product->unit->abbreviation ?? '' }}
Reorder
@empty
Nothing is below reorder level. Good shape.
@endforelse
@endif
@endif
{{-- Accordion: quick reference --}}
@can('widget.quick_reference')
Shift-close quick reference
@foreach ([
['q' => 'How is expected cash calculated?', 'a' => 'Opening float + cash sales recorded on the shift − approved expenses paid from the till − withdrawals. Any variance against the actual cash count is flagged for manager review.'],
['q' => 'Where do VAT and levy rates come from?', 'a' => 'Both are read live from Settings → Taxes & Levies. Nothing is hard-coded, so a rate change or a new levy applies to the next sale automatically — no deployment needed.'],
['q' => 'What happens when a recipe-based item is sold?', 'a' => 'The Chicken Burger example: selling one unit automatically deducts bun, chicken, tomato, lettuce and sauce from the kitchen store based on the recipe quantities, and food cost is derived from ingredient cost prices.'],
] as $i => $faq)
{{ $faq['q'] }}
{{ $faq['a'] }}
@endforeach
@endcan
@endsection