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

@section('details')
    <div class="my-4">
        <h4><b>Orders as Client</b></h4>
        <div class="table-responsive">
            <table class="table table-sm table-hover table-striped table-bordered mb-0">
                <thead>
                    <tr>
                        <th>IID</th>
                        <th>Created At</th>
                        <th>Total Amount</th>
                        <th>Trx</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($orders as $order)
                        <tr @if ($order->is_cancelled) class="cancelled-order" @endif>
                            <td><a href="{{ route('admin.orders.view.dashboard', $order) }}">{{ $order->orderNumber() }}</a>
                            </td>
                            <td>{{ friendly_date($order->created_at) }}</td>
                            <td>{{ displayAmount('$', $order->total()) }}</td>
                            <td>
                                <div>
                                    @include('app.my-account.admin.orders.forms.create-charge')
                                </div>
                                <div>
                                    <table class="table table-sm table-hover table-striped table-bordered mb-0">
                                        <thead>
                                            <tr>
                                                <th>Date</th>
                                                <th>Charge/Refund</th>
                                                <th>Amount</th>
                                                <th>Payment Method</th>
                                                <th></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @foreach ($order->financialTransactions as $transaction)
                                                <tr>
                                                    <td>{{ friendly_date($transaction->created_at) }}</td>
                                                    <td>{{ $transaction->charge_or_refund }}</td>
                                                    <td>${{ $transaction->amount }}</td>
                                                    <td>{!! $transaction->paymentMethod->displayName() !!}</td>
                                                    <td>
                                                        @if ($transaction->charge_or_refund == 'CHARGE')
                                                            @include('app.my-account.admin.orders.forms.create-refund')
                                                        @endif
                                                    </td>
                                                </tr>
                                            @endforeach
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>

    <div class="mt-3">
        {{ $orders->appends(request()->input())->links() }}
    </div>
@endsection
