@extends('layouts.app') @section('title', 'Materials & Inventory') @php $f = $filters ?? []; $stats = $stats ?? []; $stockBadge = function (string $label): string { return match ($label) { 'Critical', 'Expired' => 'r', 'Low', 'Reorder', 'Expiring Soon' => 'a', default => 'g', }; }; @endphp @section('content')

Materials & Inventory

Track all materials across all sites

Import Excel PDF
@if($errors->any())
{{ $errors->first() }}
@endif @if(session('success'))
{{ session('success') }}
@endif @if(is_array(session('material_import_errors')) && count(session('material_import_errors')))

Import row notes

@endif

Total Materials

{{ $stats['total_materials'] ?? 0 }}

Low Stock Alerts

{{ $stats['low_stock'] ?? 0 }}

Stock Value

{{ \App\Support\Format::mwkDecimal($stats['stock_value'] ?? 0) }}

Expiring Soon

{{ $stats['expiring_soon'] ?? 0 }}

Stock lines (30 days)

@include('inventory.partials.subnav', ['invActive' => 'materials'])
Clear
@if($materials->isEmpty())

No materials found

Add your first material or import materials from Excel.

Import Materials
@else @foreach($materials as $m) @php $health = $m->stockLevelLabel(); $bc = $stockBadge($health); $availLines = $m->stockLines->where('status', 'Available')->where('quantity_available', '>', 0); $expLine = $m->is_expirable ? $availLines->filter(fn ($l) => $l->expiry_date)->sortBy('expiry_date')->first() : null; @endphp @endforeach
Material SKU Category Stock Min Unit Stock value Expiry Status Action
{{ $m->name }} @if($m->description)

{{ $m->description }}

@endif
{{ $m->sku ?: '—' }} {{ $m->category ?: '—' }} {{ rtrim(rtrim((string) $m->current_stock, '0'), '.') }} {{ rtrim(rtrim((string) $m->minimum_stock_level, '0'), '.') }} {{ $m->unit_of_measure }} {{ \App\Support\Format::mwkDecimal($m->stock_value) }} @if(! $m->is_expirable) Not expirable @elseif($expLine && $expLine->expiry_date) @php $ed = $expLine->expiry_date; $isPast = $ed->isPast(); $soon = ! $isPast && $ed->lte(now()->addDays(30)); @endphp {{ $ed->format('M j, Y') }} @else @endif {{ $health }} {{ $m->status }} View Edit
{{ $materials->links() }}
@endif

Expiry & stock alerts

Critical stock

@include('inventory.partials.alert-materials-table', ['rows' => $criticalMaterials, 'empty' => 'No critical items.'])

Low stock

@include('inventory.partials.alert-materials-table', ['rows' => $lowStockMaterials, 'empty' => 'No low-stock items.'])

Expiring soon (30 days)

@include('inventory.partials.alert-expiry-table', ['rows' => $expiringLines, 'showWriteOff' => false])

Expired on hand

@include('inventory.partials.alert-expiry-table', ['rows' => $expiredLines, 'showWriteOff' => true])
{{-- Add material --}} {{-- Stock in --}} {{-- Issue --}} {{-- Return --}} {{-- Adjustment --}} {{-- Import file --}} @endsection @push('scripts') @endpush