{{-- Backdrop --}} @if($isOpen)
@endif {{-- Unsaved Changes Confirmation --}}

Unsaved Changes

You have unsaved changes. Are you sure you want to close?

{{-- Slide Panel --}}
@if($isOpen) {{-- Header --}}
@if($isNewOrder)

New Order

@else {{ $customer_po ?: 'No PO' }}

Edit Order

@endif @if($isDirty) Unsaved @endif
{{-- Toast Notifications --}} @if(session()->has('co-message'))
{{ session('co-message') }}
@endif @if(session()->has('co-error'))
{{ session('co-error') }}
@endif {{-- Tabs --}} {{-- Content --}}
{{-- Details Tab --}} @if($activeTab === 'details')
{{-- Summary Cards --}}
Total Qty {{ number_format($this->totalQty) }}
Total Value £{{ number_format($this->totalValue, 2) }}
{{-- Form Grid --}}
@if($this->hasLines) Locked - has lines @endif @error('season_id')
{{ $message }}
@enderror
@if($this->hasLines) Locked - has lines @endif @error('customer_id')
{{ $message }}
@enderror
@error('customer_po')
{{ $message }}
@enderror
@error('order_date')
{{ $message }}
@enderror
@error('discount_percent')
{{ $message }}
@enderror
@error('commission_percent')
{{ $message }}
@enderror
@if(!$isNewOrder && $status)
{{ ucwords(str_replace('_', ' ', $status)) }}
@endif {{-- Source Files (left column) --}}
@if(count($source_files) > 0)
@foreach($source_files as $index => $filePath) {{ basename($filePath) }} @endforeach
@endif
{{-- Order History (right column) --}}
@if($imported_by_name || $forwarded_to_name || $pd_reviewed_by_name || $confirmed_by_name || $this->workflowHistory->count() > 0)
@php // Check which actions we have in workflow history $hasForwardInHistory = $this->workflowHistory->where('action', 'forward_to_pd')->count() > 0; $hasPdApprovedInHistory = $this->workflowHistory->where('action', 'pd_approved')->count() > 0; $hasMerchApprovedInHistory = $this->workflowHistory->where('action', 'merch_approved')->count() > 0; @endphp {{-- Initial import (from order record) --}} @if($imported_by_name)
Imported by {{ $imported_by_name }} {{ $imported_at }}
@endif {{-- Legacy: Forward to PD (if not in workflow history) --}} @if($forwarded_to_name && !$hasForwardInHistory)
Forwarded to PD to {{ $forwarded_to_name }} {{ $forwarded_at }}
@if($forward_notes)
{{ $forward_notes }}
@endif
@endif {{-- Legacy: PD Approved (if not in workflow history but order was approved) --}} @if($pd_reviewed_by_name && !$hasPdApprovedInHistory)
PD Approved by {{ $pd_reviewed_by_name }} {{ $pd_reviewed_at }}
@if($pd_notes)
{{ $pd_notes }}
@endif
@endif {{-- Workflow history from database --}} @foreach($this->workflowHistory as $event) @php $actionClass = match($event->action) { 'forward_to_pd' => 'coe-approval-forward', 'pd_approved' => 'coe-approval-pd', 'merch_approved' => 'coe-approval-confirmed', 'sent_back_to_pd' => 'coe-approval-sendback', default => 'coe-approval-default', }; $actionIcon = match($event->action) { 'forward_to_pd' => 'fa-paper-plane', 'pd_approved' => 'fa-user-check', 'merch_approved' => 'fa-check-double', 'sent_back_to_pd' => 'fa-undo', default => 'fa-circle', }; @endphp
{{ $event->action_label }} @if($event->action === 'forward_to_pd' || $event->action === 'sent_back_to_pd') to {{ $event->toUser?->name ?? 'Unknown' }} @else by {{ $event->fromUser?->name ?? 'Unknown' }} @endif {{ $event->created_at->format('d M Y H:i') }}
@if($event->notes)
{{ $event->notes }}
@endif
@endforeach {{-- Legacy: Merch Confirmed (if not in workflow history but order was confirmed) --}} @if($confirmed_by_name && !$hasMerchApprovedInHistory)
Merch Confirmed by {{ $confirmed_by_name }} {{ $confirmed_at }}
@if($merch_notes)
{{ $merch_notes }}
@endif
@endif
@endif
{{-- Lines Tab --}} @elseif($activeTab === 'lines')
{{-- PD notice --}} @if($this->isPdReviewer)
As PD reviewer, you can change styles and colourways but not quantities.
@endif {{-- Header --}}
@if(!$customer_id || !$season_id) Select season and customer first @endif @if(count($lines) > 0)
@endif
@if(count($lines) === 0)

No lines added yet

Click "Add Style" to add order lines
@else @php // Collect all unique sizes across all lines $allSizes = collect($lines)->flatMap(fn($l) => collect($l['sizes'] ?? []))->pluck('size_name', 'size_id')->unique()->filter()->sortBy(fn($name) => match(strtoupper($name)) { 'XXS' => 1, 'XS' => 2, 'S' => 3, 'M' => 4, 'L' => 5, 'XL' => 6, 'XXL' => 7, '2XL' => 7, '3XL' => 8, default => ord(strtoupper($name[0] ?? 'Z')) }); @endphp
@foreach($allSizes as $sizeId => $sizeName) @endforeach @foreach($lines as $lineIndex => $line) {{-- RT Number (clickable to change) --}} {{-- Customer Ref --}} {{-- Description --}} {{-- Colour --}} {{-- Size quantities --}} @foreach($allSizes as $sizeId => $sizeName) @php $sizeData = collect($line['sizes'] ?? [])->firstWhere('size_id', $sizeId); $qty = $sizeData['qty'] ?? 0; $sizeIndex = collect($line['sizes'] ?? [])->search(fn($s) => $s['size_id'] == $sizeId); @endphp @endforeach {{-- Total --}} {{-- Ex-Factory Date --}} {{-- Delete --}} @endforeach
RT Ref Description Colour{{ $sizeName }}Total Ex-Factory
@if($this->isSkeletonOrder) @else {{ $line['rt_number'] ?? '—' }} @endif {{ $line['customer_ref'] ?? $line['imported_style_ref'] ?? '—' }} {{ Str::limit($line['description'] ?? $line['imported_description'] ?? '', 25) }} {{ $line['colourway_name'] ?? $line['imported_colour'] ?? '—' }} @if($sizeIndex !== false) canEditQuantities ? 'disabled' : '' }}> @else canEditQuantities ? 'disabled' : '' }}> @endif {{ (int) collect($line['sizes'] ?? [])->sum('qty') }} @php $firstDrop = collect($line['drops'] ?? [])->first(); $exftyDate = $firstDrop['due_date'] ?? ''; @endphp
@endif
{{-- History Tab --}} @elseif($activeTab === 'history') @if(!$isNewOrder)
@if($this->auditHistory->isEmpty())

No history available

History tracking was enabled in December 2023
@else @php $hasCreationRecord = $this->auditHistory->contains(fn($a) => $a->event === 'Created' && $a->model_type === 'Order'); @endphp @if(!$hasCreationRecord)
This order was created before history tracking was enabled (Dec 2023)
@endif
@foreach($this->auditHistory as $audit)
@if($audit->event === 'Created') @elseif($audit->event === 'Updated') @elseif($audit->event === 'Deleted') @else @endif
@if(($audit->type ?? 'single') === 'quantity_batch') {{ $audit->count }} Quantities {{ $audit->event }} @else {{ $audit->model_type }}@if($audit->item_name) "{{ Str::limit($audit->item_name, 10) }}"@endif {{ $audit->event }} @endif {{ $audit->user_name }} {{ $audit->created_at->diffForHumans() }}
@if(($audit->type ?? 'single') === 'quantity_batch')
@if($audit->event === 'Updated')@endif @foreach($audit->quantities as $qty) @if($audit->event === 'Updated') @else @endif @endforeach
Colourway Size Qty
{{ Str::limit($qty['line_name'], 12) }} {{ $qty['size'] }}{{ $qty['old_qty'] ?? '—' }} {{ $qty['new_qty'] ?? '—' }}{{ $qty['new_qty'] ?? $qty['old_qty'] ?? '—' }}
@elseif(!empty($audit->changes))
@foreach($audit->changes as $change)
{{ $change['field'] }}: @if($audit->event !== 'Created') {{ $change['old'] }} @endif {{ $change['new'] }}
@endforeach
@endif
@endforeach
@endif
@endif @endif
{{-- Footer --}}
@endif
{{-- Style Picker Modal --}} @if($showStylePicker)

Add Style to Order

@forelse($this->availableStyles as $style)
{{ $style->designs?->id }} {{ $style->designs?->description }} @if($style->customer_ref) {{ $style->customer_ref }} @endif
@foreach($style->style_versions as $version) @foreach($version->colourways as $colourway) @endforeach @endforeach
@empty

No styles found for this customer/season

@endforelse
@endif {{-- Colourway Picker Modal (for changing a line's colourway) --}} @if($showColourwayPicker)

Change Style / Colourway

@if($editingLineIndex !== null && isset($lines[$editingLineIndex]))
Currently: @if($lines[$editingLineIndex]['colourway_id']) RT{{ $lines[$editingLineIndex]['rt_number'] }} - {{ $lines[$editingLineIndex]['colourway_name'] }} @else Unmatched: {{ $lines[$editingLineIndex]['imported_style_ref'] ?? 'Unknown' }} / {{ $lines[$editingLineIndex]['imported_colour'] ?? 'Unknown' }} @endif
@endif
@if(strlen($colourwaySearch) < 2)

Type at least 2 characters to search

@else @forelse($this->searchedStyles as $style)
{{ $style->designs?->id }} {{ $style->designs?->description }} @if($style->customer_ref) {{ $style->customer_ref }} @endif
@foreach($style->style_versions as $version) @foreach($version->colourways as $colourway) @endforeach @endforeach
@empty

No matching styles found

@endforelse @endif
@endif {{-- Create New Colourway Modal --}} @if($showNewColourwayModal)

Add New Colourway

@error('newColourwayStyleId') {{ $message }} @enderror
Separate multiple colourways with commas @error('newColourwayName') {{ $message }} @enderror
@endif {{-- Create New Style Modal --}} @if($showNewStyleModal)

Create New Style

This will create a new design (RT), style, and colourway

@error('newStyleCustomerRef') {{ $message }} @enderror
@error('newStyleDescription') {{ $message }} @enderror
@error('newStyleYarn') {{ $message }} @enderror
@error('newStyleFactoryId') {{ $message }} @enderror
Separate multiple colourways with commas @error('newStyleColourName') {{ $message }} @enderror
@endif {{-- Forward to PD Modal --}} @if($showForwardModal)

Send to PD

Select a PD user to review this order.

@error('forwardToUserId')
{{ $message }}
@enderror
@endif {{-- Approval Modal --}} @if($showApprovalModal)
@if($approvalType === 'pd')

PD Approval

@else

Confirm Order

@endif
@if($approvalError)
{{ $approvalError }}
@endif @if($approvalType === 'pd')

Approving this order will send it to Merch for final confirmation.

@else

Confirming this order will make it visible in the main Orders list and Shipment Schedule.

@endif
@endif {{-- Send Back to PD Modal --}} @if($showSendBackModal)

Send Back to PD

This order will be sent back to PD for further review.

@error('sendBackToUserId')
{{ $message }}
@enderror
@endif