@extends('admin.layouts.container')

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

<div class="border-item">
    <form class="form-row" method="post" action="{{ $action }}" enctype="multipart/form-data">
        
        @if($product ?? ''  && $product->id)
            @method('PUT')
        @endif
        @csrf
      
      
        <div class="form-group col-lg-6">
             <label>{{ meta('youtube', getCurrentLocale()) ?? __('products.youtube')}}</label>
            <input type="text"  class="form-control  {{ $errors->has('youtube') ? 'is-invalid' : '' }}" id="youtube"  name="youtube" placeholder="{{ meta('youtube', getCurrentLocale()) ?? __('products.youtube') }} " value='{{ old("youtube", $product->youtube ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('youtubeNum', getCurrentLocale()) ?? __('products.youtubeNum')}}</label>
            <input type="number"  class="form-control  {{ $errors->has('youtubeNum') ? 'is-invalid' : '' }}" id="youtubeNum"  name="youtubeNum" placeholder="{{ meta('youtubeNum', getCurrentLocale()) ?? __('products.youtubeNum') }} " value='{{ old("youtubeNum", $product->youtubeNum ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('youtubeT', getCurrentLocale()) ?? __('products.youtubeT')}}</label>
            <input type="text"  class="form-control  {{ $errors->has('youtubeT') ? 'is-invalid' : '' }}" id="youtubeT"  name="youtubeT" placeholder="{{ meta('youtubeT', getCurrentLocale()) ?? __('products.youtubeT') }} " value='{{ old("youtubeT", $product->youtubeT ?? "") }}'/>
        </div>
 
         
        <div class="form-group col-lg-6">
             <label>{{ meta('sanpchat', getCurrentLocale()) ?? __('products.sanpchat')}}</label>
            <input type="text"  class="form-control  {{ $errors->has('sanpchat') ? 'is-invalid' : '' }}" id="sanpchat"  name="sanpchat" placeholder="{{ meta('sanpchat', getCurrentLocale()) ?? __('products.sanpchat') }} " value='{{ old("sanpchat", $product->sanpchat ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('sanpchatNum', getCurrentLocale()) ?? __('products.sanpchatNum')}}</label>
            <input type="number"  class="form-control  {{ $errors->has('sanpchatNum') ? 'is-invalid' : '' }}" id="sanpchatNum"  name="sanpchatNum" placeholder="{{ meta('sanpchatNum', getCurrentLocale()) ?? __('products.sanpchatNum') }} " value='{{ old("sanpchatNum", $product->sanpchatNum ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('sanpchatT', getCurrentLocale()) ?? __('products.sanpchatT')}}</label>
            <input type="text"  class="form-control  {{ $errors->has('sanpchatT') ? 'is-invalid' : '' }}" id="sanpchatT"  name="sanpchatT" placeholder="{{ meta('sanpchatT', getCurrentLocale()) ?? __('products.sanpchatT') }} " value='{{ old("sanpchatT", $product->sanpchatT ?? "") }}'/>
        </div>
 
        <div class="form-group col-lg-6">
             <label>{{ meta('tiktok', getCurrentLocale()) ?? __('products.tiktok')}}</label>
            <input type="text"  class="form-control  {{ $errors->has('tiktok') ? 'is-invalid' : '' }}" id="tiktok"  name="tiktok" placeholder="{{ meta('tiktok', getCurrentLocale()) ?? __('products.tiktok') }} " value='{{ old("tiktok", $product->tiktok ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('tiktokNum', getCurrentLocale()) ?? __('products.tiktokNum')}}</label>
            <input type="number"  class="form-control  {{ $errors->has('tiktokNum') ? 'is-invalid' : '' }}" id="tiktokNum"  name="tiktokNum" placeholder="{{ meta('tiktokNum', getCurrentLocale()) ?? __('products.tiktokNum') }} " value='{{ old("tiktokNum", $product->tiktokNum ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('tiktokT', getCurrentLocale()) ?? __('products.tiktokT')}}</label>
            <input type="text"  class="form-control  {{ $errors->has('tiktokT') ? 'is-invalid' : '' }}" id="tiktokT"  name="tiktokT" placeholder="{{ meta('tiktokT', getCurrentLocale()) ?? __('products.tiktokT') }} " value='{{ old("tiktokT", $product->tiktokT ?? "") }}'/>
        </div>
 
        <div class="form-group col-lg-6">
             <label>{{ meta('instagram', getCurrentLocale()) ?? __('products.instagram')}}</label>
            <input type="text"  class="form-control  {{ $errors->has('instagram') ? 'is-invalid' : '' }}" id="instagram"  name="instagram" placeholder="{{ meta('instagram', getCurrentLocale()) ?? __('products.instagram') }} " value='{{ old("instagram", $product->instagram ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('instagramNum', getCurrentLocale()) ?? __('products.instagramNum')}}</label>
            <input type="number"  class="form-control  {{ $errors->has('instagramNum') ? 'is-invalid' : '' }}" id="instagramNum"  name="instagramNum" placeholder="{{ meta('instagramNum', getCurrentLocale()) ?? __('products.instagramNum') }} " value='{{ old("instagramNum", $product->instagramNum ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('instagramT', getCurrentLocale()) ?? __('products.instagramT')}}</label>
            <input type="text"  class="form-control  {{ $errors->has('instagramT') ? 'is-invalid' : '' }}" id="instagramT"  name="instagramT" placeholder="{{ meta('instagramT', getCurrentLocale()) ?? __('products.instagramT') }} " value='{{ old("instagramT", $product->instagramT ?? "") }}'/>
        </div>
 
 
         
<div class="col-lg-12">
         <div class="row "  id="countries">
                    <div class="col-lg-12"><h3>{{__('products.countries')}}</h3></div>
                    
                    @foreach($items as $key=>$row)
                    <div class="row col-lg-12 pricing-list-item border-item mb-4">
                               
<div class="col-lg-6">
            <label>{{ __('products.country') }} </label>
            
                        <select  class="form-control " required name="countries[{{$key}}][country_id]">
                            @foreach($countries as $country)
                         <option @if($country->id == $row->country_id) selected @endif value="{{$country->id}}">{{countrydescription($country->id,'name')}}</option>
                         @endforeach
                          </select>
                      
        </div>
       <div class="col-lg-6">
            <label>{{ __('products.gender') }} </label>
            
                        <select  class="form-control " required name="countries[{{$key}}][gender]">
                           
                         <option @if($row->gender == 'male') selected @endif  value="male">{{__('products.male')}}</option>
                         <option  @if($row->gender == 'female') selected @endif value="female">{{__('products.female')}}</option>
                         
                          </select>
                      
        </div>
        <div class="form-group col-lg-5">
            <label>{{__('products.num')}} </label>
            <input type="number" class="form-control" name="countries[{{$key}}][num]" required placeholder="{{__('products.num')}}" value="{{$row->num}}" />

        </div>
        <div class="form-group col-lg-5">
            <label>{{__('products.age')}} </label>
            <input type="number" max="50" min="10" class="form-control" name="countries[{{$key}}][age]" required placeholder="{{__('products.age')}}" value="{{$row->age}}"/>

        </div>
        
        <div class="form-group col-lg-2" style="font-size: 30px;margin-top:35px;">
    	<i class="fas fa-times-circle" onclick="remove(this)"></i></div>
    	
    	 
    	</div>
    	@endforeach
    
                </div>
</div>
     <div class="col-lg-12">
       <a style="cursor: pointer;"  data-id="{{count($items)}}" onclick="addcountry(this)"  class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("products.addcountry")}}</a>
                   
</div>       
      
        
  
      
        <div class="text-center mt-5 col-12">
            <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
        </div>
    </form>
</div>

@endsection

@section('inner_js')
    <!-- Editor JS files -->
   
  <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>
        <script>
            
    
    function remove(elem){
            $(elem).closest('.row').remove();
        }
        function addcountry(elem){
            
            var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        $('#countries').css('display','block');
         $.ajax({
          url : url_country+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#countries').append(data);
          }
        })
        }
        </script>
    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            urls = "{{url('/')}}/admin/additem",
            url_country = {!! json_encode(url(getCurrentLocale().'/admin/addcountry/')) !!},
            
            currentLanguage = "{{getCurrentLocale()}}",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
    <script src="{{ asset('assets/admin/js/articles.js') }}"></script>
    <script src="{{ asset('assets/admin/js/cobons.js') }}"></script>
@endsection



