@extends('layouts.app')

@section('content')
    <div class="row nomargins">
        <div class="card card-primary">
            <aside class="panel panel-black">
                <div class="panel-heading">
                    <a href="{{route('stockAssign')}}" class="btn btn-raised btn-primary">Distribute</a>
                    <hr/>
                    <h3 class="text-center" id="store_name">All Orders</h3>
                </div>


                <div class="panel-body" id="orderPbd">
                    <form class="form-horizontal" method="POST" action="javascript:void(0);">
                        {!! csrf_field() !!}
                        <div class="form-group">
                            <div class="col-md-4">
                                <label for="storeType">Select Store</label>
                            </div>
                            <div class="col-md-3">
                                <div class="input-group">
                                    <select name="storeT" id="storeT" class="form-control">
                                        <option value="0">All Stores</option>
                                        @foreach(\App\Store::all()->sortBy('name') as $store )
                                            <option class="selecter-options" value="{{$store->id}}">
                                                {{$store->name}}
                                            </option>
                                        @endforeach
                                    </select>
                                    <div class="btn btn-xs btn-primary input-group-addon">
                                        <i class="fa fa-chevron-down"></i>
                                    </div>
                                </div>

                            </div>
                            <div class="col-md-offset-5"></div>
                        </div>
                    </form>
                    <hr>
                    <div class="orderT" id="orderT">

                        <table class="table table-striped table-bordered table-hover" id="dataTables">
                            <thead>
                            <tr>
                                <th>S/No</th>
                                <th>Member</th>
                                {{--<th>Collection Center</th>--}}
                                <th>Team</th>
                                <th>Amount</th>
                                <th>Order Date</th>
                                <th>Status</th>
                                <th>Action</th>
                            </tr>
                            </thead>
                            <tbody>

                            <?php $i = 0; ?>
                            @foreach($orders as $order)
                                <tr>
                                    <td><?= ++$i; ?></td>
                                    <td>{!!$order->membership_id!!}</td>
                                    {{--                                <td>{!!$order->store->name!!}</td>--}}
                                    <td>{!!$order->team!!}</td>
                                    <td>{!!$order->amount!!}</td>
                                    <td>{!!$order->created_at!!}</td>
                                    <td>{!!$order->status!!}</td>
                                    <td>

                                        @if(auth()->user() !== null && auth()->user()->is_admin)
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-primary btn-raised">
                                                    Action</button>
                                                <button type="button" class="btn btn-primary btn-raised dropdown-toggle"
                                                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                    <i class="zmdi zmdi-chevron-down right only"></i>
                                                </button>
                                                <ul class="dropdown-menu dropdown-menu-primary">
                                                    <li>
                                                        <a href="{{route('orderDetails', $order->id)}}">
                                                            Details
                                                        </a>
                                                    </li>
                                                    <li role="separator" class="divider"></li>
                                                </ul>
                                            </div>
                                        @endif

                                        @if(auth()->user() !== null && auth()->user()->store_id)
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-primary btn-raised">Action</button>
                                                <button type="button" class="btn btn-primary btn-raised dropdown-toggle"
                                                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                    <i class="zmdi zmdi-chevron-down right only"></i>
                                                </button>
                                                <ul class="dropdown-menu dropdown-menu-primary">
                                                    <li>
                                                        <a href="{{route('storeOrderDetails', $order->id)}}">Details</a>
                                                    </li>
                                                    <li>
                                                        <a href="{{route('storeOrderIssue', $order->id)}}">Issue Out</a>
                                                    </li>
                                                    <li role="separator" class="divider"></li>
                                                    <li>
                                                    </li>
                                                </ul>
                                            </div>
                                        @endif

                                    </td>
                                </tr>
                            @endforeach
                            </tbody>

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

                <div class="panel-footer">
                    {{--{{$orders->render()}}--}}
                </div>
            </aside>
        </div>
    </div>

@endsection




















