@extends('layouts.app') @section('title', 'Analytics') @section('content')
Overview Finance Order
@if ($tab === 'overview')
Sales
Rs {{ number_format($overview['sales_today'], 0) }}
{{ $overview['sales_change_pct'] >= 0 ? '' : '−' }}{{ abs($overview['sales_change_pct']) }}% {{ $overview['sales_change_pct'] >= 0 ? 'More' : 'Less' }} Than Yesterday
Purchase
Rs {{ number_format($overview['purchase_today'], 0) }}
{{ $overview['purchase_change_pct'] >= 0 ? '' : '−' }}{{ abs($overview['purchase_change_pct']) }}% {{ $overview['purchase_change_pct'] >= 0 ? 'more' : 'less' }} than Yesterday
Income
Rs {{ number_format($overview['other_income_today'], 0) }}
non-sales income
Expense
Rs {{ number_format($overview['expense_today'], 0) }}
logged today
Sales Overview — Last 14 Days
@endif @if ($tab === 'finance')
Payment Methods — Today
@forelse ($paymentMethods as $i => $row)
#{{ str_pad($i + 1, 2, '0', STR_PAD_LEFT) }} {{ strtoupper(substr(\App\Models\Payment::methodLabels()[$row->method] ?? $row->method, 0, 2)) }}
{{ \App\Models\Payment::methodLabels()[$row->method] ?? ucfirst($row->method) }}
{{ $row->order_count }} Orders
Rs {{ number_format($row->total, 0) }}
@empty

No payments recorded today.

@endforelse
Transaction History
@forelse ($transactionHistory as $order)
{{ $order->table->name ?? ucfirst(str_replace('_',' ',$order->order_type)) }}
Sales Paid @if ($order->invoice_number)
{{ $order->invoice_number }}
@endif
Rs {{ number_format($order->total, 0) }}
{{ $order->updated_at->format('h:i A') }}
@empty

No transactions yet.

@endforelse
Sales by Staff — Today
@forelse ($salesByStaff as $i => $row)
#{{ str_pad($i + 1, 2, '0', STR_PAD_LEFT) }} {{ strtoupper(substr($row->user->name ?? '?', 0, 2)) }}
{{ $row->user->name ?? 'Unknown' }}
{{ $row->order_count }} Sold
Rs {{ number_format($row->total, 0) }}
@empty

No sales yet today.

@endforelse
Top Customers by Spend
@forelse ($topCustomers as $i => $row)
#{{ str_pad($i + 1, 2, '0', STR_PAD_LEFT) }} {{ strtoupper(substr($row->customer->name ?? '?', 0, 2)) }}
{{ $row->customer->name ?? $row->customer->phone ?? 'Unknown' }}
Rs {{ number_format($row->total, 0) }}
@empty

No customer-linked sales yet.

@endforelse
@endif @if ($tab === 'order')
Sales by Sub Menu — Today
@if ($salesBySubMenu->count())
@php $subMenuTotal = $salesBySubMenu->sum('total') ?: 1; $colors = ['#0d6efd', '#6f42c1', '#ffc107', '#198754', '#fd7e14']; @endphp @foreach ($salesBySubMenu as $i => $row)
@endforeach
@foreach ($salesBySubMenu as $i => $row)
{{ $row->group_name }}
{{ $row->qty }} Rs {{ number_format($row->total, 0) }}
@endforeach @else

No sales yet today.

@endif
Top Selling Category — Today
@forelse ($topCategories as $i => $row)
#{{ str_pad($i + 1, 2, '0', STR_PAD_LEFT) }}
{{ $row->category_name }}
{{ $row->qty }} Sold
Rs {{ number_format($row->total, 0) }}
@empty

No sales yet today.

@endforelse
Top Selling Dishes — Today
@forelse ($topDishes as $i => $row)
#{{ str_pad($i + 1, 2, '0', STR_PAD_LEFT) }} {{ strtoupper(substr($row->name, 0, 2)) }}
{{ $row->name }}
{{ $row->qty }} Sold
Rs {{ number_format($row->total, 0) }}
@empty

No sales yet today.

@endforelse
@endif @endsection @section('scripts') @if ($tab === 'overview') @endif @endsection