@extends('layouts.admin.master') @section('head') @endsection @section('title') BBH Dashboard @endsection @section('body')
📚 Bargain Book Hut — Analytics Hub
Sales, Retention & Inventory Intelligence
{{ now()->format('d M Y, H:i') }}
{{-- ══ TAB 1 — OVERVIEW ══ --}}
🛒
Total Orders
{{ number_format((int)$totalOrders ?? 0) }}
Completed
📦
Units Sold
{{ number_format((int)$totalUnits ?? 0) }}
All time
💰
Total Revenue
₹{{ number_format((float)$revAllTime ?? 0, 0) }}
Since Jan 2021
👤
Users Ordered
{{ number_format((int)$usersOrdered ?? 0) }}
of {{ number_format((int)$totalUsers ?? 0) }} registered
📅
Today's Orders
{{ number_format((int)$todaysOrders ?? 0) }}
{{ now()->format('d M Y') }}
🔖
Pre-Orders
{{ number_format((int)$preOrders ?? 0) }}
{{ ($totalOrders > 0) ? number_format(($preOrders ?? 0) / $totalOrders * 100, 1) : '0.0' }}% of all
Today
₹{{ number_format((float)$revToday ?? 0, 0) }}
Yesterday
₹{{ number_format((float)$revYesterday ?? 0, 0) }}
Last 7 Days
₹{{ number_format((float)$revWeek ?? 0, 0) }}
This Month
₹{{ number_format((float)$revMonth ?? 0, 0) }}
All Time
₹{{ number_format((float)$revAllTime ?? 0, 0) }}
Monthly Sales Volume Books sold per month — last 30 months
Top Categories by units
{{-- ══ TAB 2 — RETENTION ══ --}}
🎯
Repeat Purchase Rate
{{ $repeatPurchaseRate ?? 0 }}%
Last 90 days
{{ number_format($repeatCustomers ?? 0) }} of {{ number_format($firstTimeUsers ?? 0) }} users
💚
Avg Order Value
₹{{ number_format((float)$avgOrderValue ?? 0, 0) }}
Per transaction
💎
Customer LTV
₹{{ number_format((float)$avgCustomerLTV ?? 0, 0) }}
Lifetime value
😴
Dormant Users
{{ number_format((int)$dormantUsers ?? 0) }}
No orders in 90 days
🔥
Active (30d)
{{ number_format((int)$activeUsers30 ?? 0) }}
Last month
📊
Active (90d)
{{ number_format((int)$activeUsers90 ?? 0) }}
3-month cohort
User Activity Cohort 30/60/90 day active users
Purchase Frequency Order distribution
Purchase Frequency Distribution Customer segmentation
@php $totalFreqUsers = ($purchaseFrequency ?? collect())->sum('user_count'); @endphp @forelse($purchaseFrequency ?? [] as $freq) @empty @endforelse
SegmentUser CountAvg LTV% of Customers
{{ $freq->frequency ?? 'N/A' }} {{ number_format((int)($freq->user_count ?? 0)) }} ₹{{ number_format((float)($freq->avg_ltv ?? 0), 0) }} {{ ($totalFreqUsers > 0) ? number_format((($freq->user_count ?? 0) / $totalFreqUsers) * 100, 1) : '0' }}%
No data available
{{-- ══ TAB 3 — INVENTORY AGING ══ --}}
⏰
Stale Stock (30d)
{{ number_format((int)$stalStock30days ?? 0) }}
Not sold in 30 days
🚨
Stale Stock (90d)
{{ number_format((int)$stalStock90days ?? 0) }}
No sales in 90 days
📉
Overstock Risk
{{ number_format(($overstockRisk ?? collect())->count()) }}
Low velocity items
🔥
Restock Alerts
{{ number_format(($understockAlert ?? collect())->count()) }}
Fast-moving items
Top 15 Sales Velocity All-time units per title
Category Health Score Avg velocity by category
🚨 Overstock Risk {{ count($overstockRisk ?? []) }} items need attention
@forelse($overstockRisk ?? [] as $i => $item) @empty @endforelse
#Title90-Day SalesStatusAction
{{ $i + 1 }} {{ $item->title ?? 'N/A' }} {{ (int)($item->units_sold_90d ?? 0) }} units @if(($item->movement_status ?? null) === 'STALE') 🔴 STALE @else 🟡 SLOW @endif Discount / Archive
✓ All inventory healthy
🔥 Restock Urgency {{ count($understockAlert ?? []) }} fast-movers to reorder
@forelse($understockAlert ?? [] as $i => $item) @empty @endforelse
#Title30-Day SalesUrgencyRecommendation
{{ $i + 1 }} {{ $item->title ?? 'N/A' }} {{ (int)($item->units_sold_30d ?? 0) }} units @if(($item->restock_urgency ?? null) === 'CRITICAL') 🔴 CRITICAL @else 🟠 HIGH @endif Place order now
✓ All fast-movers well-stocked
📊 Category Health Report 90-day inventory status by category
@forelse($categoryHealth ?? [] as $cat) @empty @endforelse
CategoryTotal SKUStale ItemsSlow MovingAvg Velocity
{{ $cat->category ?? 'Unknown' }} {{ (int)($cat->total_sku ?? 0) }} {{ (int)($cat->stale_count ?? 0) }} {{ (int)($cat->slow_moving_count ?? 0) }} {{ number_format((float)($cat->avg_velocity ?? 0), 2) }} units/item
No data
{{-- ══ TAB 4 — CATEGORIES ══ --}}
Top 10 Categories — Units Sold
Orders vs Units efficiency
Category Breakdown Top 15 by units
@forelse($categoryStats ?? [] as $i => $row) @empty @endforelse
#CategoryUnits SoldOrdersUnits / Order
{{ $i + 1 }} {{ $row->category ?? 'N/A' }} {{ number_format((int)($row->units ?? 0)) }} {{ number_format((int)($row->orders_count ?? 0)) }} {{ (($row->orders_count ?? 0) > 0) ? number_format(($row->units ?? 0) / $row->orders_count, 2) : '-' }}
No data available
{{-- ══ TAB 5 — TOP TITLES ══ --}}
Best-Selling Titles Top 30 by units sold
@forelse($topTitles ?? [] as $i => $row) @empty @endforelse
#TitleCategoryUnits Sold
{{ $i + 1 }} {{ $row->title ?? 'N/A' }} {{ $row->category ?? 'N/A' }} {{ number_format((int)($row->units ?? 0)) }}
No data available
{{-- ══ TAB 6 — PRE-ORDERS ══ --}}
🔖
Pre-Orders
{{ number_format((int)$preOrders ?? 0) }}
Unique orders
📦
Pre-Order Units
{{ number_format((int)$preUnits ?? 0) }}
{{ ($totalUnits > 0) ? number_format(($preUnits ?? 0) / $totalUnits * 100, 1) : '0.0' }}% of total
💰
Pre-Order Revenue
₹{{ number_format((float)$preRevenue ?? 0, 0) }}
Matched to orders
📊
% of All Orders
{{ ($totalOrders > 0) ? number_format(($preOrders ?? 0) / $totalOrders * 100, 1) : '0.0' }}%
Nearly 1 in 5
Pre-Order Volume — Monthly units per month
Pre-Order Categories
Top Pre-Order Titles Best sellers via pre-order
@forelse($topPreOrderTitles ?? [] as $i => $row) @empty @endforelse
#TitleCategoryPre-Order Units
{{ $i + 1 }} {{ $row->title ?? 'N/A' }} {{ $row->category ?? 'N/A' }} {{ number_format((int)($row->units ?? 0)) }}
No data available
{{-- ══ TAB 7 — INVENTORY & LINKS ══ --}}
{{-- ══ TAB 8 — ALERTS & RECOMMENDATIONS ══ --}}
{{-- ── Low Stock ── --}}
⚠️ LOW STOCK ALERTS Top {{ $inventoryHealth['low_total'] ?? 0 }} items with ≤ 5 units remaining  |  See Full Report →
@if(isset($inventoryHealth['low_stock']) && $inventoryHealth['low_stock']->count() > 0) @foreach($inventoryHealth['low_stock'] as $i => $item) @endforeach
# Product Initial Stock Sold Current Stock Reorder Qty
{{ $i + 1 }} {{ $item->product_name ?? 'N/A' }} {{ (int)($item->initial_stock ?? 0) }} {{ (int)($item->sold_quantity ?? 0) }} {{ (int)($item->current_stock ?? 0) }} units {{ max(10, (int)($item->sold_quantity ?? 0) * 2) }} units
View All Low Stock Items with Search & Filters →
@else
✅ All products are well-stocked! No low stock alerts.
@endif
{{-- ── Out of Stock ── --}}
🔴 OUT OF STOCK Top {{ $inventoryHealth['out_total'] ?? 0 }} items with zero stock  |  See Full Report →
@if(isset($inventoryHealth['out_of_stock']) && $inventoryHealth['out_of_stock']->count() > 0) @foreach($inventoryHealth['out_of_stock'] as $i => $item) @endforeach
# Product Initial Stock Total Sold Status Action
{{ $i + 1 }} {{ $item->product_name ?? 'N/A' }} {{ (int)($item->initial_stock ?? 0) }} {{ (int)($item->sold_quantity ?? 0) }} 🔴 OUT OF STOCK Restock immediately
View All Out of Stock Items with Search & Filters →
@else
✅ All products currently in stock.
@endif
{{-- ── Inventory Aging ── --}} @if(isset($inventoryHealth['aging_report']) && $inventoryHealth['aging_report']->count() > 0)
📊 INVENTORY AGING ANALYSIS Stale & slow-moving stock — top 15
@foreach($inventoryHealth['aging_report']->take(15) as $item) @php $status = $item->stock_status ?? ''; @endphp @endforeach
Product Category Current Stock Sales (30d) Sales (90d) Days Since Last Sale Status Action
{{ $item->product_name ?? 'N/A' }} {{ $item->category ?? 'Uncategorized' }} {{ (int)($item->current_stock ?? 0) }} units {{ (int)($item->sales_last_30d ?? 0) }} {{ (int)($item->sales_last_90d ?? 0) }} {{ (int)($item->days_since_last_sale ?? 0) }} days @if($status === 'STALE') 🔴 STALE @elseif($status === 'SLOW_MOVING') 🟡 SLOW MOVING @elseif($status === 'OVERSTOCK') 📦 OVERSTOCK @elseif($status === 'UNDERSTOCK') ⚠️ UNDERSTOCK @else HEALTHY @endif {{ $item->recommended_action ?? 'Monitor normally' }}
@endif {{-- ── Product Recommendations ── --}} @if(isset($userRecommendations) && count($userRecommendations) > 0)
🎯 PERSONALIZED FOR YOU Based on purchase history
@foreach($userRecommendations as $rec)
{{ $rec->product_name ?? 'N/A' }}
{{ $rec->category ?? 'Popular' }}
Recommended for you
@endforeach
@endif {{-- ── Inventory Health Summary Cards ── --}} @if(isset($inventoryHealth) && is_array($inventoryHealth)) @php $summary = $inventoryHealth['summary'] ?? []; $issueCount = (int)($summary['stale_items'] ?? 0) + (int)($summary['slow_moving_items'] ?? 0) + (int)($summary['overstock_items'] ?? 0) + (int)($summary['understock_items'] ?? 0); @endphp
🔴
Out of Stock
{{ (int)($summary['out_of_stock_count'] ?? 0) }}
Click → full report
⚠️
Low Stock (≤ 5 units)
{{ (int)($summary['low_stock_count'] ?? 0) }}
Click → full report
📦
Stale Stock
{{ (int)($summary['stale_items'] ?? 0) }}
No sales in 90+ days
🐢
Slow Moving
{{ (int)($summary['slow_moving_items'] ?? 0) }}
No sales this month
📈
Overstock
{{ (int)($summary['overstock_items'] ?? 0) }}
Excess vs velocity
🔥
Understock
{{ (int)($summary['understock_items'] ?? 0) }}
Fast movers running low
🔄
Total Issues
{{ $issueCount }}
Items needing attention
💰
Revenue at Risk
₹{{ number_format((float)($summary['estimated_revenue_at_risk'] ?? 0), 0) }}
From understocked fast-movers
@endif
@endsection @section('script') @endsection