@extends('layouts.app')

@section('content')
    <div class="row nomargins">
        <div class="card card-primary">
            <aside class="panel panel-black">
                <div class="panel-heading">
                    @if(auth()->user() !== null && auth()->user()->is_admin)
                        <a href="{{route('orders')}}" class="btn btn-raised btn-primary">Orders</a>

                    @elseif(auth()->user() !== null && auth()->user()->store_id !== 0)

                        <a href="{{route('storeOrders')}}" class="btn btn-raised btn-primary">Orders</a>
                    @endif

                        <h3 class="text-center">Order Details</h3>
                </div>

                <div class="panel-body" id="itemsPbd">
                    <div class="card animated fadeInLeftTiny animation-delay-5">
                        <div class="card-block card-block-big">
                            <div class="row">
                                <div class="col-md-2">
                                    <strong>Member</strong>
                                </div>
                                <div class="col-md-5">
                                    <p class="no-mt">{{$order->membership_id}}</p>
                                </div>
                                <div class="col-md-5">
                                    <p class="no-mt"><strong>ORDER DATE: </strong>{{$order->created_at}}</p>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-2">
                                    <strong>Collection Center</strong>
                                </div>
                                <div class="col-md-10">
                                    <span href="javascript:void(0)">{{$order->store->name}}</span>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-2">
                                    <strong>Team</strong>
                                </div>
                                <div class="col-md-10">
                                    <div class="">
                                        <span class="">{{ $order->team}}</span>
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-2">
                                    <strong>Amount</strong>
                                </div>
                                <div class="col-md-10">
                                    <p style="text-align:justify;">{!! $order->amount !!}</p>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-2">
                                    <strong>Items Ordered</strong>
                                </div>

                                <div class="col-md-10">

                                    <?php $n = 1; $ident = "issue"; ?>
                                    @if(sizeof($items) > 0)
                                        @foreach($items as $item)
                                            <div class="row">
                                                <div class="col-sm-4">
                                                <span>
                                                 {{$item->name}}
                                                </span>
                                                </div>

                                                <div class="col-sm-4">
                                                <span>
                                                    {{$item->quantity}}
                                                </span>
                                                </div>

                                                <div class="col-sm-4">
                                                    {{--{{$item->status.'-'.$item->id}}--}}
                                                    <div class="checkbox ct_issue">
                                                        <label id="notif">

                                                            @if(auth()->user() !== null && auth()->user()->is_admin)
                                                                <input type="checkbox"  checked  disabled name="collect[]" value="{{$item->id}}" id="{{$ident.$n}}">
                                                                {!! $item->status === 0 ? "<button class='btn btn-raised disabled btn-primary btn-xs issueBtn' data-box='$ident$n'  data-id='".$item->id."'>Issue</button>" : "Collected" !!}


                                                            @elseif(auth()->user() !== null && auth()->user()->store_id !== 0)
                                                                <input type="checkbox"
                                                                       {{$item->status === 0 ? " ":" checked  disabled"}} name="collect[]"
                                                                       value="{{$item->id}}">
                                                                {!! $item->status === 0 ? "<button class='btn btn-raised btn-primary btn-xs issueBtn' data-box='$ident$n'  data-id='".$item->id."'>Issue</button>" : "Collected" !!}
                                                            @endif
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>
                                            <?php $n++; ?>
                                        @endforeach

                                    @else
                                        No Items Ordered
                                    @endif

                                </div>
                            </div>

                        </div>

                        <a href="{{route('storeOrderIssueAll')}}"
                           class="btn btn-raised btn-primary pull-right" id="issueAll">Issue All Items</a>
                    </div>
                </div>
            </aside>
        </div>
    </div>

@endsection