@extends('layouts.app') @php $editing = $order->exists; // Rows to render: what was just submitted (after an error) or the saved items. $rows = old('items') ?? $items->map(fn ($i) => [ 'design_name' => $i->design_name, 'material' => $i->material, 'color' => $i->color, 'length' => $i->length !== null ? (float) $i->length : null, 'width' => $i->width !== null ? (float) $i->width : null, 'dimension_unit' => $i->dimension_unit ?: 'ft', 'quantity' => (int) $i->quantity, 'pricing' => $i->pricing ?: 'piece', 'unit_price' => $i->unit_price + 0, // legacy rows that only have an area and no length × width 'legacy_area' => ($i->length === null && $i->area_sqft !== null) ? (float) $i->area_sqft : null, ])->all(); $rows = array_values($rows); $formData = [ 'rows' => $rows, 'designs' => $designs, 'errors' => $errors->messages(), 'isEdit' => $editing, 'originalClient' => $editing ? $order->client_id : null, 'originalTotal' => $editing && ! $order->isCancelled() ? (float) $order->total : 0, 'creditError' => $errors->has('confirm_credit'), 'units' => \App\Models\OrderItem::DIMENSION_UNITS, ]; $presets = ['3x5' => '3 × 5 ft', '4x6' => '4 × 6 ft', '5x8' => '5 × 8 ft', '6x9' => '6 × 9 ft', '8x10' => '8 × 10 ft', '9x12' => '9 × 12 ft', '2.5x10' => '2.5 × 10 ft (runner)', '2x6' => '2 × 6 ft (runner)']; @endphp @section('title', $editing ? 'Edit '.$order->order_no : 'New order') @section('content')
@csrf @if ($editing) @method('PUT') @endif @include('partials.error-summary')
@can('clients.create') @endcan
{{ $errors->first('client_id') }}
@foreach (\App\Models\Order::STATUSES as $key => [$label])@endforeach
Items
Size is length × width in feet (change the unit if you need to). Price each item per piece or per sq ft.
0 items 0 pcs 0 sq ft
@error('items')
{{ $message }}
@enderror
@include('partials.assign-to', ['value' => $order->assigned_to])
Summary
Pieces · total area0 pcs · 0 sq ft
Subtotal0.00
{{ config('erp.currency') }}
{{ $errors->first('discount') }}
%
Discount applied0.00
{{ config('erp.tax_label') }}0.00

Total0.00
Cancel Unsaved changes
@foreach ($designs as $d) @endsection @push('modals') @include('partials.quick-add', ['type' => 'client']) @endpush