@php $cols = collect(explode(',', request('columns', ''))); $showHeader = request('show_header') === '1'; $showSummary = request('show_summary') === '1'; $hasCol = fn(string $k) => $cols->contains($k); @endphp

{{ $tab === 'reorder' ? '🔄 Reorder Suggestions' : '💰 High Profit Items' }} — Print Preview

@if($showHeader)

{{ $tab === 'reorder' ? 'Reorder Suggestions Report' : 'High Profit Items Report' }}

Generated: {{ now()->format('d M Y, h:i A') }} Velocity Period: {{ $filters['velocityDays'] }} days @if($tab === 'reorder') Reorder Alert: ≤ {{ $filters['reorderDays'] }} days stock Target Stock: {{ $filters['targetDays'] }} days @endif
@endif @if($tab === 'profit') {{-- ── HIGH PROFIT ──────────────────────────────────────────────────── --}} @if($showSummary)
Total Items
{{ number_format($profitSummary['total_items']) }}
Avg Margin
{{ number_format($profitSummary['avg_margin_pct'], 1) }}%
Top Margin
{{ number_format($profitSummary['top_margin_pct'], 1) }}%
Total Profit Potential
{{ $currency }} {{ number_format($profitSummary['total_profit_potential'], 2) }}
@endif @php $pCols = collect([ 'category_name' => ['label' => 'Category', 'cls' => 'l'], 'total_qty' => ['label' => 'Stock', 'cls' => 'r'], 'avg_cost' => ['label' => 'Avg Cost', 'cls' => 'r'], 'avg_sell' => ['label' => 'Sell Price', 'cls' => 'r'], 'unit_profit' => ['label' => 'Unit Profit', 'cls' => 'r'], 'margin_pct' => ['label' => 'Margin %', 'cls' => 'r'], 'total_profit_potential' => ['label' => 'Profit Potential', 'cls' => 'r'], 'daily_rate' => ['label' => 'Daily Rate', 'cls' => 'r'], 'margin_bar' => ['label' => 'Margin Bar', 'cls' => 'l'], ])->filter(fn($v, $k) => $hasCol($k)); $pCount = $pCols->count() + 2; // +2 for # and Item @endphp @foreach($pCols as $key => $col) @endforeach @forelse($highProfit as $i => $row) @php $m = (float) $row->margin_pct; $col = $m >= 50 ? '#16a34a' : ($m >= 25 ? '#0891b2' : ($m >= 10 ? '#d97706' : '#64748b')); $pct = min(100, $m); @endphp @if($hasCol('category_name')) @endif @if($hasCol('total_qty')) @endif @if($hasCol('avg_cost')) @endif @if($hasCol('avg_sell')) @endif @if($hasCol('unit_profit')) @endif @if($hasCol('margin_pct')) @endif @if($hasCol('total_profit_potential')) @endif @if($hasCol('daily_rate')) @endif @if($hasCol('margin_bar')) @endif @empty @endforelse @if($highProfit->count() > 0) @if($hasCol('category_name'))@endif @if($hasCol('total_qty'))@endif @if($hasCol('avg_cost'))@endif @if($hasCol('avg_sell'))@endif @if($hasCol('unit_profit'))@endif @if($hasCol('margin_pct'))@endif @if($hasCol('total_profit_potential'))@endif @if($hasCol('daily_rate'))@endif @if($hasCol('margin_bar'))@endif @endif
# Item{{ $col['label'] }}
{{ $i + 1 }}
{{ $row->item_name }}
@if($row->sku)
{{ $row->sku }}
@endif
{{ $row->category_name ?? '—' }}{{ number_format($row->total_qty, 0) }}{{ $currency }} {{ number_format($row->avg_cost, 2) }}{{ $currency }} {{ number_format($row->avg_sell, 2) }}{{ $currency }} {{ number_format($row->unit_profit, 2) }}{{ number_format($m, 1) }}%{{ $currency }} {{ number_format($row->total_profit_potential, 2) }}{{ $row->daily_rate > 0 ? number_format($row->daily_rate, 2).'/d' : '—' }}
{{ number_format($m, 1) }}%
No profitable items found.
Total — {{ $profitSummary['total_items'] }} items{{ number_format($highProfit->sum('total_qty'), 0) }}{{ number_format($profitSummary['avg_margin_pct'], 1) }}% avg{{ $currency }} {{ number_format($profitSummary['total_profit_potential'], 2) }}
@else {{-- ── REORDER ──────────────────────────────────────────────────────── --}} @if($showSummary)
Items to Reorder
{{ number_format($reorderSummary['total_items']) }}
Critical (≤7 days)
{{ number_format($reorderSummary['urgent']) }}
Total Reorder Qty
{{ number_format($reorderSummary['total_reorder_qty'], 0) }}
Est. Reorder Cost
{{ $currency }} {{ number_format($reorderSummary['total_reorder_cost'], 2) }}
@endif @php $rCols = collect([ 'category_name' => ['label' => 'Category', 'cls' => 'l'], 'current_qty' => ['label' => 'Current Stock', 'cls' => 'r'], 'alert_quantity' => ['label' => 'Min Stock', 'cls' => 'r'], 'daily_rate' => ['label' => 'Daily Rate', 'cls' => 'r'], 'days_of_stock' => ['label' => 'Days Left', 'cls' => 'c'], 'suggested_reorder_qty' => ['label' => 'Reorder Qty', 'cls' => 'r'], 'avg_cost' => ['label' => 'Unit Cost', 'cls' => 'r'], 'reorder_cost_estimate' => ['label' => 'Est. Cost', 'cls' => 'r'], 'urgency' => ['label' => 'Urgency', 'cls' => 'c'], ])->filter(fn($v, $k) => $hasCol($k)); $rCount = $rCols->count() + 2; @endphp @foreach($rCols as $key => $col) @endforeach @forelse($reorderItems as $i => $row) @php $days = $row->days_of_stock; if ($days === null) { $urg = 'low'; $urgLabel = 'Monitor'; } elseif ($days <= 7) { $urg = 'critical'; $urgLabel = 'Critical'; } elseif ($days <= 14) { $urg = 'high'; $urgLabel = 'Urgent'; } else { $urg = 'medium'; $urgLabel = 'Soon'; } $daysClass = $days === null ? '' : ($days <= 7 ? 'days-critical' : ($days <= 14 ? 'days-high' : ($days <= 30 ? 'days-medium' : 'days-ok'))); $daysLabel = $days !== null ? number_format($days, 1).' days' : '—'; @endphp @if($hasCol('category_name')) @endif @if($hasCol('current_qty')) @endif @if($hasCol('alert_quantity')) @endif @if($hasCol('daily_rate')) @endif @if($hasCol('days_of_stock')) @endif @if($hasCol('suggested_reorder_qty')) @endif @if($hasCol('avg_cost')) @endif @if($hasCol('reorder_cost_estimate')) @endif @if($hasCol('urgency')) @endif @empty @endforelse @if($reorderItems->count() > 0) @if($hasCol('category_name'))@endif @if($hasCol('current_qty'))@endif @if($hasCol('alert_quantity'))@endif @if($hasCol('daily_rate'))@endif @if($hasCol('days_of_stock'))@endif @if($hasCol('suggested_reorder_qty'))@endif @if($hasCol('avg_cost'))@endif @if($hasCol('reorder_cost_estimate'))@endif @if($hasCol('urgency'))@endif @endif
# Item{{ $col['label'] }}
{{ $i + 1 }}
{{ $row->item_name }}
@if($row->sku)
{{ $row->sku }}
@endif
{{ $row->category_name ?? '—' }}{{ number_format($row->current_qty, 0) }}{{ $row->alert_quantity > 0 ? number_format($row->alert_quantity, 0) : '—' }}{{ $row->daily_rate > 0 ? number_format($row->daily_rate, 2).'/d' : '—' }}{{ $daysLabel }} {{ $row->suggested_reorder_qty > 0 ? number_format($row->suggested_reorder_qty, 0).' units' : '—' }} {{ $row->avg_cost > 0 ? $currency.' '.number_format($row->avg_cost, 2) : '—' }} {{ $row->reorder_cost_estimate > 0 ? $currency.' '.number_format($row->reorder_cost_estimate, 2) : '—' }} {{ $urgLabel }}
No reorder items found.
Total — {{ $reorderSummary['total_items'] }} items{{ number_format($reorderSummary['total_reorder_qty'], 0) }} units{{ $currency }} {{ number_format($reorderSummary['total_reorder_cost'], 2) }}
@endif