@extends('layouts.admin-simple')

@section('title', $dispatch->reference_number)

@section('breadcrumb')
    <li class="breadcrumb-item">Warehouse</li>
    <li class="breadcrumb-item">Outgoing</li>
    <li class="breadcrumb-item"><a href="{{ route('warehouse.easy-out.index') }}">Easy Out</a></li>
    <li class="breadcrumb-item active">{{ $dispatch->reference_number }}</li>
@endsection

@section('page-title')
    <div class="d-flex justify-content-between align-items-center w-100">
        <div class="page-title-left">
            <h3 class="mb-1">{{ $dispatch->reference_number }}</h3>
            <p class="text-muted mb-0" style="font-size: 13px;">Easy Out Dispatch — {{ $dispatch->dispatch_date->format('d M Y') }}</p>
        </div>
        <div class="page-actions-right d-flex" style="gap: 8px;">
            <a href="{{ route('warehouse.easy-out.index') }}" class="btn btn-sm btn-outline-secondary">
                <i class="material-icons mr-1" style="font-size: 16px;">arrow_back</i> Back
            </a>
            <form method="POST" action="{{ route('warehouse.easy-out.destroy', $dispatch) }}"
                  onsubmit="return confirm('Delete this record?')">
                @csrf @method('DELETE')
                <button type="submit" class="btn btn-sm btn-outline-danger">
                    <i class="material-icons mr-1" style="font-size: 16px;">delete</i> Delete
                </button>
            </form>
        </div>
    </div>
@endsection

@section('content')
    <div class="row">
        <div class="col-md-7">
            <div class="card mb-3">
                <div class="card-header"><h6 class="mb-0"><i class="material-icons mr-2 align-middle">output</i>Dispatch Information</h6></div>
                <div class="card-body">
                    <table class="table table-sm table-borderless mb-0">
                        <tr>
                            <th style="width: 160px;" class="text-muted">Reference #</th>
                            <td><strong>{{ $dispatch->reference_number }}</strong></td>
                        </tr>
                        <tr>
                            <th class="text-muted">Dispatch Date</th>
                            <td>{{ $dispatch->dispatch_date->format('d M Y') }}</td>
                        </tr>
                        <tr>
                            <th class="text-muted">Bill Number</th>
                            <td>{{ $dispatch->bill_number ?? '-' }}</td>
                        </tr>
                        <tr>
                            <th class="text-muted">MR No.</th>
                            <td>{{ $dispatch->mr_no ?? '-' }}</td>
                        </tr>
                        <tr>
                            <th class="text-muted">Item Description</th>
                            <td>{{ $dispatch->item_description }}</td>
                        </tr>
                        <tr>
                            <th class="text-muted">Unit</th>
                            <td>{{ $dispatch->unit }}</td>
                        </tr>
                        <tr>
                            <th class="text-muted">Quantity</th>
                            <td><strong>{{ number_format($dispatch->quantity, 2) }}</strong></td>
                        </tr>
                        @if($dispatch->purpose)
                        <tr>
                            <th class="text-muted">Purpose</th>
                            <td>{{ $dispatch->purpose }}</td>
                        </tr>
                        @endif
                    </table>
                </div>
            </div>
        </div>
        <div class="col-md-5">
            <div class="card mb-3">
                <div class="card-header"><h6 class="mb-0"><i class="material-icons mr-2 align-middle">location_on</i>Destination</h6></div>
                <div class="card-body">
                    <table class="table table-sm table-borderless mb-0">
                        <tr>
                            <th style="width: 140px;" class="text-muted">Project</th>
                            <td>
                                <small class="text-muted">{{ $dispatch->project?->project_number }}</small><br>
                                {{ $dispatch->project?->project_name ?? '-' }}
                            </td>
                        </tr>
                        <tr>
                            <th class="text-muted">Division</th>
                            <td>{{ $dispatch->division?->division_name ?? '-' }}</td>
                        </tr>
                        <tr>
                            <th class="text-muted">Received By</th>
                            <td>{{ $dispatch->received_by ?? '-' }}</td>
                        </tr>
                        <tr>
                            <th class="text-muted">Recorded By</th>
                            <td>{{ $dispatch->createdBy?->name ?? '-' }}</td>
                        </tr>
                        <tr>
                            <th class="text-muted">Created At</th>
                            <td>{{ $dispatch->created_at->format('d M Y H:i') }}</td>
                        </tr>
                    </table>
                </div>
            </div>
            @if($dispatch->notes)
            <div class="card">
                <div class="card-header"><h6 class="mb-0"><i class="material-icons mr-2 align-middle">notes</i>Notes</h6></div>
                <div class="card-body">
                    <p class="mb-0">{{ $dispatch->notes }}</p>
                </div>
            </div>
            @endif
        </div>
    </div>
@endsection
