@extends('layouts.layout-horizontal') @section('title', ' Products') @section('css') @endsection @section('content') @php $lowThreshold = 10; $todayDate = \Carbon\Carbon::today(); $activeFilter = $filter ?? 'all'; $searchQ = $q ?? ''; $chipUrl = fn($f) => request()->fullUrlWithQuery(['filter' => $f, 'page' => null]); @endphp
{{-- Header --}}
Inventory Master
Products · {{ number_format($stats['total']) }} @if($products->total() !== $stats['total']) · showing {{ number_format($products->total()) }} @endif @if(!empty($searchQ)) · matches for "{{ $searchQ }}" clear @endif
{{-- Filter chips (server-side) --}}
All {{ number_format($stats['total']) }} Low Stock {{ number_format($stats['low']) }} Zero Stock {{ number_format($stats['zero']) }} Negative {{ number_format($stats['neg']) }} No Cost Price {{ number_format($stats['no_mrp']) }} No Tax {{ number_format($stats['no_tax']) }} Stale 90d+ {{ number_format($stats['stale']) }}
{{-- Table --}}
@foreach($stockCompanies as $co) @endforeach @forelse($products as $p) @php $taxRate = optional($p->latestTaxRate)->percentage; $c1 = (float) ($p->c1 ?? 0); $c2 = (float) ($p->c2 ?? 0); $c3 = (float) ($p->c3 ?? 0); $total = $c1 + $c2 + $c3; $stockClass = fn($v) => $v < 0 ? 'pm-stock-neg' : ($v == 0 ? 'pm-stock-zero' : ($v < $lowThreshold ? 'pm-stock-low' : 'pm-stock-ok')); $totalClass = $total < 0 ? 'is-neg' : ($total == 0 ? 'is-zero' : ''); $lastDate = $p->last_movement_date ? \Carbon\Carbon::parse($p->last_movement_date) : null; $daysAgo = $lastDate ? $lastDate->diffInDays($todayDate) : null; $lastClass = $daysAgo === null ? 'pm-last-none' : ($daysAgo > 90 ? 'pm-last-stale' : ($daysAgo > 30 ? 'pm-last-warm' : '')); @endphp {{-- Product (sticky) --}} {{-- HSN --}} {{-- Tax --}} {{-- MRP --}} {{-- Stock per company --}} @foreach($stockCompanies as $co) @php $qty = (float) ($p->{'c' . $co->id} ?? 0); @endphp @endforeach {{-- Last movement --}} {{-- Icon-only actions --}} @empty @endforelse
Product HSN Tax Cost Price{{ $co->name }}Total Last Movement Actions
@if($p->image_path) @else
@endif
{{ $p->name }} {{ $p->product_id }} · {{ $p->unit }}
@if($p->hsn) {{ $p->hsn }} @else @endif @if($taxRate) {{ rtrim(rtrim(number_format($taxRate, 2), '0'), '.') }}% @else @endif @if($p->mrp) ₹{{ number_format($p->mrp, 2) }} @else @endif {{ rtrim(rtrim(number_format($qty, 2), '0'), '.') }} {{ rtrim(rtrim(number_format($total, 2), '0'), '.') }} @if($lastDate) {{ $daysAgo === 0 ? 'Today' : ($daysAgo === 1 ? '1 day ago' : $daysAgo . ' days ago') }} @else Never @endif
@csrf @method('DELETE')
@include('partials._empty-state', [ 'icon' => 'ph-cube', 'title' => 'No products yet', 'subtitle' => 'Add your first product to get started.', 'action' => route('products.create'), 'actionLabel' => 'Add Product', ])
@if($products->hasPages())
{{ $products->links() }}
@endif
{{-- Product Ledger Offcanvas --}}
Product Ledger
Loading ledger…
No movements in this period.
@endsection @section('scripts') @endsection