@extends('app.my-account.admin.orders.single')

@section('details')
    <?php
        $storeOrderDetailJson = $order->detailJson();
        $storeOrderSelectedOptions = json_decode(@$storeOrderDetailJson->selected_options ?? "{}");
        $selectedLab = @$storeOrderSelectedOptions->lab;
    ?>
    <div class="row">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0 fw-bold">Order Details </h5>
                </div>
                <div class="card-body">
                    <table class="table table-sm table-bordered dashboard-stats-table mb-0">
                        <tbody>
                            <tr>
                                <th class="px-2" colspan="2">
                                    <span class="text-secondary">Created:</span>
                                    {{ friendly_date_time($order->created_at) }}
                                </th>
                            </tr>
                            <tr>
                                <th class="px-2" colspan="2">
                                    <span class="text-secondary">Client:</span>
                                    <a
                                        href="{{ route('admin.users.view.dashboard', $order->user) }}">{{ $order->user->full_name }}</a>
                                </th>
                            </tr>

                                <tr>
                                    <th class="px-2" colspan="2">
                                        <div class="text-secondary">Lab:</div>
                                        @if($selectedLab)
                                            <?= selected_lab_html_address($selectedLab); ?>
                                        @else
                                        ---
                                        @endif
                                    </th>
                                </tr>
                            <tr>
                                <th class="px-2" colspan="2">
                                    <span class="text-secondary">Total:</span>
                                    {{ displayAmount('$', $order->total()) }}
                                </th>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <div class="d-flex align-items-center justify-content-between">
                        <h5 class="mb-0 fw-bold">Tests Requested</h5>
                    </div>
                </div>
                <div class="card-body">
                    <div>
                        <?php
                        $tests = (object) $order->testsRequestedInHumanReadable();
                        ?>

                    </div>
                    <table class="table table-sm table-bordered border w-100 mb-0">
                        <tbody>
                            @foreach ($tests as $test)
                                <tr>
                                    <td class="w-50 w-lg-75 px-2">{{ $test }}</td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>        
    </div>
    <div class="row mt-4">
        <div class="col-md-6">
            <?php
                $orders = [];
                array_push($orders, $order);
            ?>
            @include('app.my-account.admin.users.sub.info.customer-information-orders', ['orders' => $orders, 'title' => 'Order Actions'])
        </div>
        <div class="col-md-6">
             @include('app.my-account.admin.users.sub.info.customer-information', ['user' => $order->user])
        </div>
    </div>
@endsection
