@extends('store.layouts.container')

@section('content')
    <div class="side-title">
        <h3>{{ $head ?? '' }}</h3>
    </div>


    <div class="border-item">
        <ul class="nav nav-pills bg-nav-pills nav-justified mb-3">
            <li class="nav-item">
                <a href="#user_info" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0 active">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('orders.user_info')}}</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="#store_info" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('orders.store_info')}}</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="#details" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('orders.details')}}</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="#payment_info" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('orders.payment_info')}}</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="#address" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('orders.address_details')}}</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="#products" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('orders.products')}}</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="#rates" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('orders.rates')}}</span>
                </a>
            </li>
            <li class="nav-item">
                <a href="#complaints" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                    <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                    <span class="d-none d-lg-block">{{__('orders.complaints')}}</span>
                </a>
            </li>

        </ul>
        <section class="form-row" >


            <div class="tab-content col-lg-12">
                <div class="tab-pane active" id="user_info">
                    <div class="row">
                        <div class="col-lg-12">
                            <h3>
                                {{__('orders.user_info')}}
                            </h3>
                            <hr>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{  __('orders.user_name') }} </label>
                            <p class="form-control" style="height: auto">{{$order->user->name ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{  __('orders.user_phone') }} </label>
                            <p class="form-control" style="height: auto">{{$order->user->phone ?? ''}}</p>
                        </div>

                    </div>
                </div>
                <div class="tab-pane" id="store_info">
                    <div class="row">
                        <div class="col-lg-12">
                            <h3>
                                {{__('orders.store_info')}}
                            </h3>
                            <hr>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{  __('orders.store.name') }} </label>
                            <p class="form-control" style="height: auto">{{$order->store->name ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{  __('orders.store.branch') }} </label>
                            <p class="form-control" style="height: auto">{{$order->branch->name ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{  __('orders.status') }} </label>
                            <p class="form-control" style="height: auto">{{ __('orders.statuses.'.$order->status) }}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{  __('orders.order_date') }} </label>
                            <p class="form-control" style="height: auto">{{$order->date ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6" >
                            <h4>{{ __('orders.store.logo') }} </h4>
                            <img style="width: 100%;height: 30pc" src="{{asset($order->store->logo)}}"/>
                        </div>

                    </div>
                </div>
                <div class="tab-pane " id="details">
                    <div class="row">
                        <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ $action }}" enctype="multipart/form-data">
                            @method('PUT')
                            @csrf
                            <div class="col-lg-12">
                                <h3>
                                    {{__('orders.details')}}
                                </h3>
                                <hr>
                            </div>
                            <div class="form-group col-lg-6">
                                <label>{{  __('orders.status') }} </label>
                                <select name="status" class="form-control">
                                    @foreach($statuses as $row)
                                        <option {{$order->status == $row ? 'selected' : ''}} value="{{$row}}">{{__('orders.statuses.'.$row)}}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="form-group col-lg-6">
                                <label>{{  __('orders.id') }} </label>
                                <p class="form-control" style="height: auto">{{$order->id}}</p>
                            </div>
                            <div class="form-group col-lg-6">
                                <label>{{ __('orders.date') }} </label>
                                <p class="form-control" style="height: auto">{{$order->date}}</p>
                            </div>

                            <div class="form-group col-lg-6">
                                <label>{{ __('orders.payment_status') }} </label>
                                <p class="form-control" style="height: auto">{{__('orders.payment_statuses.'.$order->payment_status)}}</p>
                            </div>

                            <div class="form-group col-lg-6">
                                <label>{{  __('orders.note') }} </label>
                                <p class="form-control" style="height: auto">{{$order->note}}</p>
                            </div>

                            <div class="text-center mt-5 col-12">
                            <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
                        </div>
                        </form>
                    </div>

                </div>
                <div class="tab-pane " id="payment_info">
                    <div class="row">
                        <div class="col-lg-12">
                            <h3>
                                {{__('orders.payment_info')}}
                            </h3>
                            <hr>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.total_tax') }} </label>
                            <p class="form-control" style="height: auto">{{$order->total_tax ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.shipping_cost') }} </label>
                            <p class="form-control" style="height: auto">{{$order->shipping_cost ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.on_hand_cost') }} </label>
                            <p class="form-control" style="height: auto">{{$order->on_hand_cost ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.total_products') }} </label>
                            <p class="form-control" style="height: auto">{{$order->total_products ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.discount') }} </label>
                            <p class="form-control" style="height: auto">{{$order->discount ?? ''}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.total') }} </label>
                            <p class="form-control" style="height: auto">{{$order->total ?? ''}}</p>
                        </div>

                    </div>
                </div>
                <div class="tab-pane" id="address">
                    <div class="row">
                        <div class="col-lg-12">
                            <h3>
                                {{__('orders.address_details')}}
                            </h3>
                            <hr>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('web.address_name') }} </label>
                            <p class="form-control" style="height: auto">{{$order->address->name}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.address') }} </label>
                            <p class="form-control" style="height: auto">{{$order->address->address}}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.city') }} </label>
                            <p class="form-control" style="height: auto">{{ $order->address->city->currentDescription->title }}</p>
                        </div>
                        <div class="form-group col-lg-6">
                            <label>{{ __('orders.area') }} </label>
                            <p class="form-control" style="height: auto">{{ $order->address->area->currentDescription->title }}</p>
                        </div>
                        <div class="form-group col-lg-12">
                            <iframe
                                style='width:100%'
                                height="250"
                                frameborder="0"
                                scrolling="no"
                                marginheight="0"
                                marginwidth="0"
                                src="https://maps.google.com/maps?q={{$order->address->latitude.', '.$order->address->longitude}}&z=15&output=embed"
                            >
                            </iframe>
                        </div>


                    </div>
                </div>
                <div class="tab-pane" id="products">
                    <div class="row">
                        <div class="col-lg-12">
                            <h3>
                                {{__('orders.products')}}
                            </h3>
                            <hr>
                        </div>
                        <div class="col-lg-12">
                            @foreach($order->products as $key=>$row)
                                <div class="col-lg-12 pricing-list-item border-item mb-4"  style="background-color: rgba(21,97,203,0.1);height:auto">
                                    <div class="row">
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.product_name') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->product->currentDescription->title }} {{$row->item_id ? (' - '.$row->item->currentDescription->title ) : '' }}</p>
                                        </div>
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.product_main_category') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->product->category->currentDescription->title }}</p>
                                        </div>
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.product_sub_category') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->product->subCategory->currentDescription->title }}</p>
                                        </div>
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.count') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->count}}</p>
                                        </div>
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.product_cost') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->total}}</p>
                                        </div>
                                        @if(count($row->additions))
                                            <div class="col-lg-12 row">
                                                <div class="form-group col-lg-6">
                                                    <h4>{{  __('orders.additions') }} </h4>
                                                </div>
                                                <div class="form-group col-lg-6"></div>
                                                @foreach($row->additions as $add)
                                                    <div class="form-group col-lg-6">
                                                        <p class="form-control" style="height: auto">{{ $add->addition->currentDescription->title}}</p>
                                                    </div>
                                                @endforeach
                                            </div>
                                        @endif

                                    </div>
                                </div>
                            @endforeach
                        </div>

                    </div>
                </div>
                <div class="tab-pane" id="rates">
                    <div class="row">
                        <div class="col-lg-12">
                            <h3>
                                {{__('orders.rates')}}
                            </h3>
                            <hr>
                        </div>
                        <div class="col-lg-12">
                            @foreach($order->rates as $key=>$row)
                                <div class="col-lg-12 pricing-list-item border-item mb-4"  style="background-color: rgba(21,97,203,0.1);height:auto">
                                    <div class="row">
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.rate') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->rate }}</p>
                                        </div>
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.comment') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->comment }}</p>
                                        </div>
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.date') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->date }}</p>
                                        </div>

                                    </div>
                                </div>
                            @endforeach
                        </div>
                        @if(!$order->rateStore && $order->status == \Modules\Order\Enums\OrderStatusEnum::RECEIVED->value)
                            <div class="col-lg-12">
                                <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ route('order.rate',$order->id) }}" enctype="multipart/form-data">
                                    @method('PUT')
                                    @csrf

                                    <div class="form-group col-lg-6">
                                        <label>{{  __('orders.rate') }} </label>
                                        <select name="rate" class="form-control">
                                            @for($i=1;$i<=5;$i++)
                                                <option value="{{$i}}">{{$i}}</option>
                                            @endfor
                                        </select>
                                    </div>
                                    <div class="form-group col-lg-6">
                                        <label>{{  __('orders.comment') }} </label>
                                        <input type="text" name="comment" class="form-control" placeholder="{{  __('orders.comment') }}">
                                    </div>

                                    <div class="text-center mt-5 col-12">
                                        <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
                                    </div>
                                </form>
                            </div>
                        @endif
                    </div>
                </div>
                <div class="tab-pane" id="complaints">
                    <div class="row">
                        <div class="col-lg-12">
                            <h3>
                                {{__('orders.complaints')}}
                            </h3>
                            <hr>
                        </div>
                        <div class="col-lg-12">
                            @foreach($order->complaints as $key=>$row)
                                <div class="col-lg-12 pricing-list-item border-item mb-4"  style="background-color: rgba(21,97,203,0.1);height:auto">
                                    <div class="row">
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.description') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->description }}</p>
                                        </div>
                                        <div class="form-group col-lg-6">
                                            <label>{{  __('orders.reason') }} </label>
                                            <p class="form-control" style="height: auto">{{ $row->reason->currentDescription->title }}</p>
                                        </div>

                                    </div>
                                </div>
                            @endforeach
                            @if(!$order->complaintStore && $order->status == \Modules\Order\Enums\OrderStatusEnum::RECEIVED->value)
                                    <div class="col-lg-12">
                                        <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ route('order.complaint',$order->id) }}" enctype="multipart/form-data">
                                            @method('PUT')
                                            @csrf

                                            <div class="form-group col-lg-6">
                                                <label>{{  __('orders.reason_id') }} </label>
                                                <select name="reason_id" class="form-control">
                                                    @foreach($reasons as $row)
                                                        <option  value="{{$row->id}}">{{$row->title}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                            <div class="form-group col-lg-6">
                                                <label>{{  __('orders.description') }} </label>
                                                <input type="text" name="description" class="form-control" placeholder="{{  __('orders.description') }}">
                                            </div>

                                            <div class="text-center mt-5 col-12">
                                                <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
                                            </div>
                                        </form>
                                    </div>
                                @endif

                        </div>

                    </div>
                </div>



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

@endsection

@section('inner_js')
    <!-- Editor JS orders -->
    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>-
    <script>
        var route_prefix = "{{ url(config('lfm.prefix')) }}";
        var url = "{{url('/')}}/";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>

@endsection
