@extends('layouts.site')

@section('meta_title', __('Catalog::theme.order.detail.summary.heading'))

@section('content_header')
    @include('partials._components._heading', [
        'heading' => __('Catalog::theme.order.detail.summary.heading'),
        'image' => false,
        'color' => 'blue'
    ])
@endsection

@section('content')
    @parent
    <section class="container mt-2">
        <div class="account-shell catalog-account-shell">
        <div class="account-shell__aside">
            @include('partials._components._user-menu')
        </div>
        <div class="account-shell__content">
            @php
                $statusLabel = $order->isCancelled() ? 'Cancelled' : ($order->isProcessed() ? 'Processed' : 'Processing');
                $statusBadge = $order->isCancelled() ? 'label label-danger' : ($order->isProcessed() ? 'label label-success' : 'label label-warning');
                $participant = $order->participant;
            @endphp

            <div class="panel panel-default panel-squared catalog-account-panel">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8">
                            <h3 class="m-0">{{ __('Catalog::theme.order.detail.summary.heading') }}</h3>
                            <small class="text-muted">#{{ $order->number }}</small>
                        </div>
                        <div class="col-xs-12 col-sm-4 text-right mt-2 mt-sm-0">
                            <span class="{{ $statusBadge }}">{{ $statusLabel }}</span>
                        </div>
                    </div>
                </div>
                <div class="panel-body">
                    <div class="row mb-4">
                        <div class="col-xs-12 col-sm-4">
                            <p class="text-muted m-0">Date</p>
                            <strong>{{ optional($order->created_at)->format('M d, Y g:i A') }}</strong>
                        </div>
                        <div class="col-xs-12 col-sm-4 mt-2 mt-sm-0">
                            <p class="text-muted m-0">Quantity</p>
                            <strong>{{ $order->quantity }}</strong>
                        </div>
                        <div class="col-xs-12 col-sm-4 mt-2 mt-sm-0">
                            <p class="text-muted m-0">{{ trans_choice('Core::core.common.points', $order->points) }}</p>
                            <strong>{{ Format::balance($order->points) }}</strong>
                        </div>
                    </div>

                    <h4 class="mt-0">Order Items</h4>
                        <div class="overflow-x-auto">
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th width="80"></th>
                                        <th>Item</th>
                                        <th class="text-right">Qty</th>
                                        <th class="text-right">{{ trans_choice('Core::core.common.points', 2) }}</th>
                                        <th class="text-right">Total</th>
                                    </tr>
                                </thead>
                                <tbody>
                                @if ($order->items->isNotEmpty())
                                    @foreach($order->items as $item)
                                        <tr>
                                            <td>
                                                @if ($item->item->hasUrl())
                                                    <a href="{{ $item->item->getUrl() }}">
                                                        <img class="catalog-order-item-image" src="{{ $item->getItemImageUrl()  }}" alt="{{ $item->getItemName() }}">
                                                    </a>
                                                @else
                                                    <img class="catalog-order-item-image" src="{{ $item->getItemImageUrl()  }}" alt="{{ $item->getItemName() }}">
                                                @endif
                                            </td>
                                            <td><strong>{{ $item->getItemName() }}</strong></td>
                                            <td class="text-right">{{ $item->getItemQuantity() }}</td>
                                            <td class="text-right">{{ $item->getItemPoints() }}</td>
                                            <td class="text-right">{{ $item->getItemTotal() }}</td>
                                        </tr>
                                    @endforeach
                                @else
                                    <tr>
                                        <td colspan="5" class="text-center text-error">There are no items in order.</td>
                                    </tr>
                                @endif
                                </tbody>
                            </table>
                        </div>
                    <div class="row mt-4">
                        <div class="col-xs-12 col-md-6">
                            <h4 class="mt-0">Participant Information</h4>
                            <table class="table table-condensed catalog-detail-table">
                                <tr><th>Name</th><td>{{ trim(($participant->first ?? '') . ' ' . ($participant->last ?? '')) }}</td></tr>
                                <tr><th>Email</th><td>{{ $participant->email ?? $order->ship_email ?? '' }}</td></tr>
                                <tr><th>Company</th><td>{{ $participant->company ?? '' }}</td></tr>
                            </table>
                        </div>
                        <div class="col-xs-12 col-md-6">
                            <h4 class="mt-0">Shipping Address</h4>
                            <table class="table table-condensed catalog-detail-table">
                                <tr><th>Name</th><td>{{ $order->ship_name ?? '' }}</td></tr>
                                <tr><th>Email</th><td>{{ $order->ship_email ?? '' }}</td></tr>
                                <tr><th>Phone</th><td>{{ $order->ship_phone ?? '' }}</td></tr>
                                <tr><th>Address 1</th><td>{{ $order->ship_address_1 ?? '' }}</td></tr>
                                <tr><th>Address 2</th><td>{{ $order->ship_address_2 ?? '' }}</td></tr>
                                <tr><th>Address 3</th><td>{{ $order->ship_address_3 ?? '' }}</td></tr>
                                <tr><th>City</th><td>{{ $order->ship_city ?? '' }}</td></tr>
                                <tr><th>State</th><td>{{ $order->ship_state ?? '' }}</td></tr>
                                <tr><th>Postal Code</th><td>{{ $order->ship_postal ?? '' }}</td></tr>
                                <tr><th>Country</th><td>{{ $order->ship_country ?? 'US' }}</td></tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </div>
    </section>

@endsection
