@section('title', 'Orders Management')
@section('orders-management', 'active')
@include('adminDashboard.layout.header')

<div class="main-content">
    <section class="section">
        <div class="section-body">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h4>Orders Management</h4>
                        </div>
                        <div class="card-body p-0">
                            <div class="table-responsive">
                                <table class="table table-striped table-md">
                                    <tr>
                                        <th>ID</th>
                                        <th>Mobile</th>
                                        <th>Title</th>
                                        <th>Amount</th>
                                        <th>Status</th>
                                        <th>Action</th>
                                    </tr>
                                    @foreach($orders as $key => $order)
                                    <tr>
                                        <td>{{++$key}}</td>
                                        <td>
                                            @if(env('DEMO'))
                                            {{substr_replace($order->user->mobile, '*****', 3, 5)}} @else
                                            {{$order->user->mobile}}
                                            @endif

                                        </td>
                                        <td>{{$order->product->title}}</td>
                                        <td>{{$order->amount}}</td>
                                        <td id="status_{{$order->id}}">{{$order->status}}</td>
                                        <td>
                                            <button type="button" onclick="gatherOrderInfo('{{$order->id}}')" class="badge badge-success" style="border:none;" data-toggle="modal" data-target="#exampleModal"><i class="fas fa-ellipsis-h"></i></button>
                                            <a href="{{url('/admin/order/delete/'.$order->id)}}" class="text-decoration-none">
                                                <div class="badge badge-danger"><i class="material-icons font_size_14">delete</i></div>
                                            </a>
                                        </td>
                                    </tr>
                                    @endforeach
                                </table>
                            </div>
                        </div>
                        <div class="card-footer text-right">
                            <nav class="d-inline-block">
                                {{$orders->links('adminDashboard.pagination')}}
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="formModal" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="formModal">Loading...</h5>
                    <button type="button" class="close" id="modal_dismiss" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-12">
                            <div class="row">
                                <div class="col-6">
                                    <p>Product</p>
                                </div>
                                <div class="col-6">
                                    <p id="product_name"></p>
                                </div>
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="row">
                                <div class="col-6">
                                    <p>User Mobile</p>
                                </div>
                                <div class="col-6">
                                    <p id="user_mobile"></p>
                                </div>
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="row">
                                <div class="col-6">
                                    <p>Amount</p>
                                </div>
                                <div class="col-6">
                                    <p id="amount"></p>
                                </div>
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="row">
                                <div class="col-6">
                                    <p>State</p>
                                </div>
                                <div class="col-6">
                                    <p id="state"></p>
                                </div>
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="row">
                                <div class="col-6">
                                    <p>City</p>
                                </div>
                                <div class="col-6">
                                    <p id="city"></p>
                                </div>
                            </div>
                        </div>
                        <div class="col-12">
                            <div class="row">
                                <div class="col-6">
                                    <p>Address</p>
                                </div>
                                <div class="col-6">
                                    <p id="address"></p>
                                </div>
                            </div>
                        </div>
                        <div class="col-12 text-center" id="order_actions">

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
</div>
@include('adminDashboard.layout.footer')