{{-- ===================== HEADER + BREADCRUMB ===================== --}}

{{ $materialId ? __('Edit material') : __('New material') }}

@if ($materialId)
{{ __('Editing') }}
@endif
{{-- ===================== PROGRESS BAR ===================== --}} @php $steps = [ 1 => ['label' => __('Details'), 'icon' => 'cube'], 2 => ['label' => __('Variants'), 'icon' => 'squares-2x2'], 3 => ['label' => __('Review'), 'icon' => 'check-circle'], ]; @endphp
@foreach ($steps as $n => $s) @php $state = $step > $n ? 'done' : ($step === $n ? 'current' : 'todo'); @endphp @if (! $loop->last)
@endif @endforeach
{{-- ===================== STEP 1 · DETAILS ===================== --}} @if ($step === 1)

{{ __('Material details') }}

{{ __('The item you keep in stock, media, ink, blanks, consumables.') }}

@if ($categorySelection === 'new')
@endif

{{ __('Auto-fills each variant’s cost, override per variant if needed.') }}

{{-- Who supplies this material, the buying side of the record. --}}

{{ __('Suppliers') }}

{{ __('Who you buy this from. Add as many as you like, the preferred one is used for reorder suggestions.') }}

@if ($supplierRows === [])

{{ __('No supplier linked yet.') }}

{{ __('You can still buy this material from anyone, the link is created automatically the first time you do.') }}

@else
@foreach ($supplierRows as $i => $row)
@endforeach
@endif
{{-- Stock form, geometry & selling, powers automatic m²/offcut costing. --}} @php $pp = $pricingPreview; @endphp

{{ __('Stock form, size & selling') }}

{{ __('How it’s stocked and priced, powers automatic m²/offcut calculation when costing a job.') }}

{{-- Stock form selector --}}
@foreach (['unit' => __('Unit / each'), 'roll' => __('Roll'), 'sheet' => __('Sheet')] as $val => $lbl) @endforeach
{{-- Roll geometry --}} @if ($stock_dimension === 'roll')

{{ __('One full roll, used for “rolls needed” and remnants.') }}

@endif {{-- Sheet geometry --}} @if ($stock_dimension === 'sheet')
@endif {{-- Weight + waste (area forms) --}} @if ($stock_dimension !== 'unit')

{{ __('Drives weight = area × GSM for delivery.') }}

@endif {{-- Selling rate --}}

{{ __('A quick sell rate, buy price is the cost above.') }}

{{-- Live economics readout --}} @if ($pp['cost_per_area'] !== null || $pp['sell_per_area'] !== null)
{{ __('Per m²') }} @if ($pp['cost_per_area'] !== null) {{ __('Cost') }} {{ $baseCode }} {{ number_format($pp['cost_per_area'], 2) }} @endif @if ($pp['sell_per_area'] !== null) {{ __('Sell') }} {{ $baseCode }} {{ number_format($pp['sell_per_area'], 2) }} @endif @if ($pp['margin'] !== null) {{ __('Margin') }} {{ number_format($pp['margin'], 1) }}% @endif @if ($pp['weight_per_area'] !== null) {{ __('Weight') }} {{ $pp['weight_per_area'] }} kg @endif
@endif
@endif {{-- ===================== STEP 2 · VARIANTS ===================== --}} @if ($step === 2) {{-- Attribute-matrix builder --}}

{{ __('Variants') }}

{{ __('A material needs at least one variant. Leave a single "Default" for flat materials.') }}

{{ __('Build variants by attribute') }}

{{ __('Define attributes (Colour, Size, Sleeve…) and their values, then generate every combination in one go.') }}

@foreach ($attributeDefs as $ai => $def)
@endforeach
{{ __('Adds every new combination below. Duplicates are skipped.') }}
{{-- Variant list --}}

{{ __('Variant list') }} ({{ count($variants) }})

@foreach ($variants as $i => $variant)
@if (! empty($variant['attributes']))
@foreach ($variant['attributes'] as $attrName => $attrValue) @if (trim((string) $attrValue) !== '') {{ $attrName }}:{{ $attrValue }} @endif @endforeach
@endif {{-- All variant inputs on one row (wraps on narrow screens). --}}
@if (empty($variant['attributes']))
@endif
@if (empty($variant['id']))
@endif @if (count($variants) > 1) @endif
@if (! empty($variant['id']))

{{ __('On hand') }}: @qty($variant['on_hand'] ?? 0) · {{ __('Avg') }}: {{ $baseCode }} {{ number_format((float) ($variant['avg_cost'] ?? 0), 2) }}

@endif
@endforeach
@endif {{-- ===================== STEP 3 · REVIEW ===================== --}} @if ($step === 3) @php $activeVariants = collect($variants)->filter(fn ($v) => (bool) ($v['is_active'] ?? true))->count(); $openingRows = collect($variants)->filter(fn ($v) => empty($v['id']) && ($v['opening_qty'] ?? '') !== '' && (float) ($v['opening_qty'] ?? 0) > 0); @endphp

{{ __('Review & save') }}

{{ __('Check the summary, then save this material.') }}

{{-- Summary tiles --}}

{{ __('Base unit') }}

{{ $base_unit }}

{{ __('Variants') }}

{{ count($variants) }} ({{ $activeVariants }} {{ __('active') }})

{{ __('Default cost') }}

{{ $baseCode }} {{ number_format((float) ($default_cost ?: 0), 2) }}

{{ __('Opening stock') }}

{{ $openingRows->count() }} {{ __('rows') }}

{{-- Material line --}}

{{ $name !== '' ? $name : __('(unnamed material)') }}

@php $catName = $categorySelection === 'new' ? trim($newCategory) : optional($categories->firstWhere('id', $material_category_id))->name; @endphp {{ $catName !== '' && $catName !== null ? $catName : __('Uncategorised') }} @if ($sku) · {{ __('SKU') }} {{ $sku }} @endif @unless ($is_active) · {{ __('Inactive') }} @endunless

{{-- Variant table --}}
@foreach ($variants as $variant) @php $vlabel = trim((string) ($variant['label'] ?? '')) ?: 'Default'; $vcost = ($variant['cost'] ?? '') !== '' && $variant['cost'] !== null ? (float) $variant['cost'] : null; $vopen = empty($variant['id']) && ($variant['opening_qty'] ?? '') !== '' ? (float) ($variant['opening_qty'] ?? 0) : null; @endphp @endforeach
{{ __('Variant') }} {{ __('SKU') }} {{ __('Cost') }} {{ __('Opening') }} {{ __('Active') }}
{{ $vlabel }} {{ $variant['sku'] ?: __('auto') }} {{ $vcost !== null ? $baseCode . ' ' . number_format($vcost, 2) : '—' }} {{ $vopen ? \App\Support\Number::qty($vopen) : '—' }} @if ((bool) ($variant['is_active'] ?? true)) @else — @endif
@if ($openingRows->isNotEmpty())

{{ __('Opening quantities will be posted as opening stock movements when you save.') }}

@endif
@endif {{-- ===================== NAV FOOTER (sticky) ===================== --}}
@if ($step > 1) {{ __('Back') }} @endif
{{ __('Cancel') }} @if ($step === 1) {{ __('Continue to variants') }} @elseif ($step === 2) {{ __('Review') }} @elseif ($step === 3) {{ $materialId ? __('Save changes') : __('Create material') }} {{ __('Saving…') }} @endif