@extends('admin.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="#main" 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">{{__('products.details')}}</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="#store_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">{{__('products.store_details')}}</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="#section_images" 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">{{__('products.images')}}</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="#section_items" 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">{{__('products.items')}}</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="#section_additions" 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">{{__('products.additions')}}</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="#section_reasons" 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">{{__('products.reasons')}}</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="#section_actions" 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">{{__('products.actions')}}</span>
            </a>
        </li>

    </ul>
    <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ $action }}" enctype="multipart/form-data">
        @if($product ?? ''  && $product->id)
            @method('PUT')
        @endif
        @csrf
        <div class="tab-content row col-12">
            <div class="tab-pane col-lg-12 active" id="main">
                <div class="form-row">



                    @foreach($languages as $language)
                        <div class="form-group col-lg-6">
                            <label>{{ meta('title', $language->local) ?? __('products.title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                            <input type="text" class="form-control" disabled value='{{ $product[$language->local]->title }}'/>
                        </div>
                        <div class="form-group col-lg-12">
                            <label>{{ meta('description', $language->local) ?? __('products.description') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                            <textarea  class="form-control"disabled>{{ old("description_{$language->local}", $product[$language->local]->description ?? "") }}</textarea>
                        </div>
                    @endforeach


                    <div class="form-group col-lg-6" >
                        <label>{{ __('products.count') }} </label>
                        <input type="text" class="form-control" disabled  value='{{ $product->count }}'/>
                    </div>

                    <div class="form-group col-lg-6" >
                        <label>{{ __('products.cost') }} </label>
                        <input type="text" class="form-control" disabled value='{{ $product->cost }}'/>
                    </div>

                    <div class="form-group col-lg-6" >
                        <label>{{ __('products.cost_discount') }} </label>
                        <input type="text" class="form-control" disabled value='{{ $product->cost_discount }}'/>
                    </div>


                </div>

            </div>
            <div class="tab-pane col-lg-12" id="store_details">
                <div class="row">
                    <div class="col-lg-12">
                        <h3> {{__('products.store.details')}} </h3>
                    </div>
                    <div class="row col-lg-12">

                        <div class="form-group col-lg-6" >
                            <label>{{ __('products.store.name') }} </label>
                            <input type="text" class="form-control" disabled  value='{{ $product->store->name }}'/>
                        </div>
                        <div class="form-group col-lg-6" >
                            <label>{{ __('products.store.category') }} </label>
                            <input type="text" class="form-control" disabled  value='{{ $product->store->category->currentDescription->name }}'/>
                        </div>
                        <div class="form-group col-lg-6" >
                            <label>{{ __('products.store.sub_category') }} </label>
                            <input type="text" class="form-control" disabled  value='{{ $product->store->subCategory->currentDescription->name }}'/>
                        </div>
                        <div class="form-group col-lg-6" >
                            <label>{{ __('products.store.created_at') }} </label>
                            <input type="text" class="form-control" disabled  value='{{ $product->store->created_at }}'/>
                        </div>
                        <div class="form-group col-lg-6" >
                            <label>{{ __('products.store.accepted_at') }} </label>
                            <input type="text" class="form-control" disabled  value='{{ $product->store->accepted_at }}'/>
                        </div>
                        <div class="form-group col-lg-6" >
                            <h4>{{ __('products.store.logo') }} </h4>
                            <img style="width: 100%;height: 30pc" src="{{asset($product->store->logo)}}"/>
                        </div>

                    </div>
                </div>
            </div>
            <div class="tab-pane col-lg-12" id="section_images">
                <div class="row">
                    <div class="col-lg-12">
                        <h3> {{__('products.images')}} </h3>
                    </div>
                    <div class="form-group col-lg-6" >
                        <h4>{{ __('products.main_image') }} </h4>
                        <img style="width: 100%;height: 30pc" src="{{asset($product->image)}}"/>
                    </div>
                    <div class="form-group col-lg-6" ></div>

                    @foreach ($product['photos'] as $photo)
                        <div class="form-group col-lg-6" >
                            <h4>{{ __('products.photo') }} </h4>
                            <img style="width: 100%;height: 30pc" src="{{asset($photo->photo)}}"/>
                        </div>
                    @endforeach

                </div>
            </div>
            <div class="tab-pane col-lg-12" id="section_items">
                <div class="row">
                    <div class="col-lg-12">
                        <h3> {{__('products.items')}} </h3>
                    </div>
                    <div class="col-lg-12" >
                        @foreach($items as $row)
                            <div class="row pricing-list-item  mb-4 "  style="background-color: rgba(21,97,203,0.1);height:auto;padding: 20px">
                                @foreach($languages as $language)
                                    <div class="form-group col-lg-6">
                                        <label>{{  __('products.title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                                        <input type="text" class="form-control" disabled value="{{$row->descriptions($language->id)->title}}"/>
                                    </div>
                                @endforeach

                                <div class="pricing-list-item col-lg-12 mb-4 "   style="background-color: white;height:auto;padding: 20px">
                                    @foreach($row->items as $keyItem=>$rowItem)
                                        <div class="row pricing-list-item  mb-4 "  style="background-color: rgba(21,97,203,0.1);height:auto;padding: 20px">

                                            @foreach($languages as $language)
                                                <div class="form-group col-lg-6">
                                                    <label>{{  __('products.title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                                                    <input type="text" class="form-control" disabled value="{{$rowItem->descriptions($language->id)->title}}"/>
                                                </div>
                                            @endforeach
                                            <div class="form-group col-lg-6">
                                                <label>{{  __('products.cost') }} </label>
                                                <input type="text" class="form-control" disabled value="{{$rowItem->cost}}"/>
                                            </div>
                                        </div>
                                    @endforeach
                                </div>
                            </div>
                        @endforeach
                    </div>
                </div>
            </div>

            <div class="tab-pane col-lg-12" id="section_additions">
                <div class="row">
                    <div class="col-lg-12">
                        <h3> {{__('products.additions')}} </h3>
                    </div>
                    <div class="col-lg-12" >
                        @foreach($additions as $row)
                            <div class="row pricing-list-item  mb-4 "  style="background-color: rgba(21,97,203,0.1);height:auto;padding: 20px">
                                @foreach($languages as $language)
                                    <div class="form-group col-lg-6">
                                        <label>{{  __('products.title') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
                                        <input type="text" class="form-control" disabled value="{{$row->descriptions($language->id)->title}}"/>
                                    </div>
                                @endforeach
                                <div class="form-group col-lg-6">
                                    <label>{{  __('products.cost') }} </label>
                                    <input type="text" class="form-control" disabled value="{{$row->cost}}"/>
                                </div>

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

            <div class="tab-pane col-lg-12" id="section_reasons">
                <div class="row">
                    <div class="col-lg-12">
                        <h3> {{__('products.logs')}} </h3>
                    </div>
                    <div class="col-lg-12" >
                        @foreach($logs as $row)
                            <div class="row pricing-list-item  mb-4 "  style="background-color: rgba(21,97,203,0.1);height:auto;padding: 20px">
                                <div class="form-group col-lg-6">
                                    <label>{{  __('products.message') }} </label>
                                    <input type="text" class="form-control" disabled value="{{$row->message}}"/>
                                </div>
                                <div class="form-group col-lg-6">
                                    <label>{{  __('products.reason_id') }} </label>
                                    <input type="text" class="form-control" disabled value="{{$row->reason->currentDescription->title}}"/>
                                </div>
                                <div class="form-group col-lg-6">
                                    <label>{{  __('products.created_at') }} </label>
                                    <input type="text" class="form-control" disabled value="{{date('Y-m-d g:i a',strtotime($row->created_at))}}"/>
                                </div>


                            </div>
                        @endforeach
                    </div>
                </div>
            </div>
            <div class="tab-pane col-lg-12" id="section_actions">
                <div class="row">
                    <div class="col-lg-12">
                        <h3> {{__('products.action')}} </h3>
                    </div>
                    <div class="col-lg-12 row" >
                        <div class="form-group col-lg-6">
                            <label>{{  __('products.status') }} </label>
                            <select onchange="selectStatus()" id="status" name="status" class="form-control">
                                @foreach($statuses as $row)
                                    <option {{$product->status == $row ? 'selected' : ''}} value="{{$row}}">{{__('products.statuses.'.$row)}}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="form-group col-lg-6 refuse">
                            <label>{{  __('products.message') }} </label>
                            <input type="text" name="message" placeholder="{{__('products.message')}}" class="form-control">
                        </div>
                        <div class="form-group col-lg-6 refuse">
                            <label>{{  __('products.reason_id') }} </label>
                            <select name="reason_id" class="form-control">
                                <option value="">{{__('dashboard.select')}}</option>
                                @foreach($reasons as $row)
                                    <option  value="{{$row->id}}">{{$row->title}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="text-center mt-5 col-12">
                        <button class="butn" ><span>{{ __('dashboard.save') }}</span></button>
                    </div>
                </div>
            </div>


        </div>


    </form>
</div>

@endsection

@section('inner_js')
    <!-- Editor JS orders -->
    {{--        <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>--}}
    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>
    <script>
        function selectStatus()
        {
            let status = $('#status').val()
            if(status != 1)
            {
                $('.refuse').show()
            }
            else
            {
                $('.refuse').hide()
            }
        }
        $('#status').trigger('change')
    </script>
    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            currentLanguage = "{{getCurrentLocale()}}",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
@endsection



