@extends('layouts.app') @section('title', 'Dashboard') @section('page-title', 'Dashboard') @section('content') {{-- Branch context banner for non-admins --}} @if(!$isAdmin && $user->branch)
{{ $user->branch->name }} {{ $user->branch->code }} · You are viewing data for this branch only
@endif {{-- KPI Cards --}}
${{ number_format($todaySales, 2) }}
Today's Sales
${{ number_format($monthlySales, 2) }}
Monthly Sales
{{ number_format($totalProducts) }}
Total Products
${{ number_format($inventoryValue, 0) }}
Inventory Value
{{-- Top row: Charts + Trending --}}
{{-- Sales trend --}}
Sales Trend (6 Months)
{{-- Top 3 Trending Products --}}
Top Trending
Best sellers this month @if(!$isAdmin && $user->branch) · {{ $user->branch->code }} @endif
@forelse($topTrendingProducts as $i => $product) @php $colors = ['#FF6B35','#2EC4B6','#4361EE']; $bgs = ['rgba(255,107,53,0.10)','rgba(46,196,182,0.10)','rgba(67,97,238,0.10)']; @endphp
{{ $i + 1 }}
{{ $product->name }}
{{ number_format($product->total_qty) }} units · {{ $product->order_count }} orders
${{ number_format($product->total_revenue, 2) }}
@if($i < count($topTrendingProducts) - 1)
@endif @empty

No sales recorded this month yet.

@endforelse @if($topTrendingProducts->isNotEmpty()) @endif
{{-- Admin: branch comparison / Manager: quick stats --}}
@if($isAdmin && $branchComparison)
Branch Performance
This month
@foreach($branchComparison as $b)
{{ $b->name }} @if($b->is_headquarters)HQ@endif
${{ number_format($b->monthly_revenue, 0) }}
@php $maxRev = $branchComparison->max('monthly_revenue') ?: 1; @endphp
@endforeach
@else
Stock Alerts
Out of stock {{ $outOfStockCount }}
Low stock {{ $lowStockCount }}
View Products →
@endif
{{-- Bottom row: recent sales + low stock --}}
Recent Sales
View All →
@if($isAdmin)@endif @forelse($recentSales as $sale) @if($isAdmin) @endif @empty @endforelse
InvoiceBranchCustomer Amount
{{ $sale->invoice_number }}{{ $sale->branch?->code ?? '—' }}{{ $sale->customer?->name ?? 'Walk-in' }} ${{ number_format($sale->total_usd, 2) }}
No sales yet.
Low Stock Alerts
@forelse($lowStockProducts as $product)
{{ $product->name }}
{{ $product->category?->name ?? '' }} @if($isAdmin && $product->branch) · {{ $product->branch->code }} @endif
{{ $product->quantity_in_stock }} left
@empty

All stock levels are healthy.

@endforelse
@endsection @push('scripts') @endpush