@extends('admin.layouts.container')

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

<div class="border-item">
    <form class="form-row" onsubmit="saveproduct(this)" method="post" action="{{ $action }}" enctype="multipart/form-data">
        
        @if($package ?? ''  && $package->id)
            @method('PUT')
        @endif
        @csrf
       <div id="ajaxErrorResponse" class="col-lg-12">
           <label class=""></label>
       </div>
       <div class="form-group col-lg-6">
            <label>{{ meta('section_id', getCurrentLocale()) ?? __('packages.section') }}</label>
            <select name="section_id" id="section_id" class="form-control my-editor {{ $errors->has('section_id') ? 'is-invalid' : '' }}">
                <option value="">{{meta('section_id', getCurrentLocale()) ?? __('packages.section')}}</option>
                @foreach ($sections as $section)
                    <option {{old("section_id", $package->section_id ?? "") == $section->id ? 'selected': ''}} value="{{$section->id}}">{{sectionname($section->id)}}</option>
                @endforeach
            </select>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('cost_long', getCurrentLocale()) ?? __('packages.cost_long')}}</label>
            <input type="number"  class="form-control  {{ $errors->has('cost_long') ? 'is-invalid' : '' }}" id="cost_long"  name="cost_long" placeholder="{{ meta('cost_long', getCurrentLocale()) ?? __('packages.cost_long') }} " value='{{ old("cost_long", $package->cost_long ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
             <label>{{ meta('cost_long_month', getCurrentLocale()) ?? __('packages.cost_long_month')}}</label>
            <input type="number"  class="form-control  {{ $errors->has('cost_long_month') ? 'is-invalid' : '' }}" id="cost_long_month"  name="cost_long_month" placeholder="{{ meta('cost_long_month', getCurrentLocale()) ?? __('packages.cost_long_month') }} " value='{{ old("cost_long_month", $package->cost_long_month ?? "") }}'/>
        </div>
  <div class="form-group col-lg-6">
            <label>{{ meta('cost', getCurrentLocale()) ?? __('packages.cost')}}</label>
            <input type="number"  class="form-control  {{ $errors->has('cost') ? 'is-invalid' : '' }}" id="cost" name="cost" placeholder="{{ meta('cost', getCurrentLocale()) ?? __('packages.cost') }}" value='{{ old("cost", $package->cost ?? "") }}'/>
        </div> 
        <div class="form-group col-lg-6">
            <label>{{ meta('cost_month', getCurrentLocale()) ?? __('packages.cost_month')}}</label>
            <input type="number"  class="form-control  {{ $errors->has('cost_month') ? 'is-invalid' : '' }}" id="cost_month" name="cost_month" placeholder="{{ meta('cost_month', getCurrentLocale()) ?? __('packages.cost_month') }}" value='{{ old("cost_month", $package->cost_month ?? "") }}'/>
        </div> 
         
  <div class="form-group col-lg-6">
        </div> 
         
          
        @foreach($languages as $language)
        <div class="form-group col-lg-6">
            <label>{{ meta('name', $language->local) ?? __('packages.name') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('name_'.$language->local) ? 'is-invalid' : '' }}" name="name_{{ $language->local }}" id="name_{{$language->local}}" placeholder="{{ meta('name', $language->local) ?? __('packages.name') }}" value='{{ old("name_{$language->local}", $package[$language->local]->name ?? "") }}'/>
        </div>

       <!--<div class="form-group col-lg-12">-->
       <!--     <label>{{ meta('description', $language->local) ?? __('packages.description')}} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>-->
       <!--     <textarea name="description_{{ $language->local }}" class="form-control {{ $errors->has('description_'.$language->local) ? 'is-invalid' : '' }}" id="description_{{$language->local}}" placeholder="{{ meta('description', $language->local) ?? __('packages.description')}}">{{ old("description_{$language->local}", $package[$language->local]->description ?? "") }}</textarea>-->
       <!-- </div>-->


        @endforeach
       
     
        <div class="form-group col-lg-12 image_container">
    
            <label>{{ meta('image', getCurrentLocale()) ?? __('packages.image') }} </label>
            <input id="image_thumbnail" class="image_thumbnail" type="hidden" name="image" value="{{old("image", $package->image ?? "")}}"/>

            <div class="photos main_photo {{ old('image', $package->image ?? '') ? ' wow fadeInUp' : 'hide' }}">
                <div class="col-md-4">
                    <div class="items">
                        <div class="img">
                            <a href="#" id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" class="lfm" data-hide=".pick_button">
                                <img src="{{asset(old('image', $package->image ?? ''))}} "  id="image_holder" class="image_holder"/>
                            </a>
                        </div>
                        <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail" data-hide=".main_photo" data-show=".pick_button"><i class="fas fa-times"></i></a>
                    </div>
                </div>
            </div>

            <div class="clearfix"></div>
            <span class="input-group-btn pick_button {{ old('image', $package->image ?? '') ? 'hide' : '' }} ">
                <a id="lfm"  data-input=".image_thumbnail" data-preview=".image_holder" data-show=".main_photo" data-hide=".pick_button" class="lfm btn btn-primary text-light">
                    <i class="fas fa-camera-retro"></i> Choose
                </a>
             </span>
        </div>
        
         <div class="col-lg-12">
    <div  id="items">
        @if($package ?? ''  && $package->id)
      
        @foreach($items as $key=>$row)
          @if($key%2 == '0' || $key == '0' )
        <div class="row">
            @endif
        
        <div class="form-group col-lg-5">
            <label>{{__('web.value')}} {{$row->language->local}}</label>
             <input type="hidden" class="form-control" id="item_{{$key}}_language_id" name="item[{{$key}}][language_id]" value="{{$row->language_id}}" />
            
            <input type="text" class="form-control" id="item_{{$key}}_value" name="item[{{$key}}][value]" placeholder="Value {{$row->language->local}}" value="{{$row->value}}" />

        </div>
        @if($key%2 != 0)
        <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>
        @endif
        @endforeach
        @endif
    </div>
    </div>
      <div class="col-lg-12">
       <a style="cursor: pointer;" @if($package ?? ''  && $package->id) data-id="{{count($items)}}" @else data-id="0" @endif onclick="additem(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("packages.additem")}}</a>
                   
</div>

<!--         <div class="col-lg-12">-->
<!--             <div class="row pricing-list-item border-item mb-4" style="background-color: rgba(21,97,203,0.1);height:auto">-->
<!--                   <div class="col-lg-12"><h3>{{__('packages.files')}}</h3></div>-->
<!--                  <div class="col-lg-12"id="files" style="height:100%">-->
<!--                      @if($package ?? ''  && $package->id)-->
<!--                      @foreach($files as $num=>$row)-->
                      
          
<!--                       <div class="col-12">-->
<!--                        <div class="row pricing-list-item border-item mb-4">-->
<!--                            <input type="hidden"  name="file[{{$num}}][id]"value="{{$row->id}}">-->
<!--                      <input type="hidden"  name="files[]"value="{{$row->id}}">-->
<!--                                @foreach(languages() as $key=>$language)-->
<!--                            <div class="form-group col-lg-5">-->
<!--                                <label>{{__('packages.file')}} {{$language->local}}</label>-->
<!--                                <input type="text" class="form-control" id="file_{{$num}}_name_{{$language->local}}" name="file[{{$num}}][name_{{$language->local}}]" placeholder="{{__('packages.file')}} {{$language->local}}" value="{{filenamelang($row->id,$language->id)}}" />-->
                                
<!--                            </div>-->
                            
<!--                            @endforeach-->
                           
<!--                            <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>-->
                        	<!--------------- new --------------->
<!--                                <div class="col-lg-12">-->
<!--                                    <div class="form-group">-->
                                       
<!--                                        <div class="box" style="display:block">-->
<!--                                            <div class="js--image-preview"></div>-->
<!--                                            <div class="upload-options">-->
<!--                                                <label>-->
<!--                                                <input type="file" name="file[{{$num}}][image]" class="image-upload" />-->
<!--                                              </label>-->
<!--                                            </div>-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                </div>-->
<!--                        	</div>-->
<!--                    	</div>-->
<!--                        @endforeach-->
<!--                      @endif-->
<!--                  </div>-->
<!--                  <div class="col-lg-12">-->
<!--       <a style="cursor: pointer;" @if($package ?? ''  && $package->id) data-id="{{count($files)}}" @else data-id="0" @endif onclick="addfile(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("packages.addfile")}}</a>-->
                   
<!--</div>-->
<!--             </div>-->
<!--         </div>-->
         
<!--          <div class="col-lg-12">-->
<!--             <div class="row pricing-list-item border-item mb-4" style="background-color: rgba(21,97,203,0.1);height:auto">-->
<!--                   <div class="col-lg-12"><h3>{{__('packages.advices')}}</h3></div>-->
<!--                  <div class="col-lg-12"id="advices" style="height:100%">-->
<!--                      @if($package ?? ''  && $package->id)-->
<!--                      @foreach($advices as $num=>$row)-->
                      
<!--                       <div class="col-12">-->
<!-- <div class="row pricing-list-item border-item mb-4">-->
<!--     <input type="hidden"  name="advice[{{$num}}][id]"value="{{$row->id}}">-->
<!--                      <input type="hidden"  name="advices[]"value="{{$row->id}}">-->
<!--     <div class="form-group col-lg-6">-->
<!--         <label>{{__('packages.link')}}</label>-->
<!--            <input type="text" class="form-control" name="advice[{{$num}}][link]" id="advice_{{$num}}_link" placeholder="{{__('packages.link')}} " value="{{$row->link}}"  />-->
            
<!--     </div>-->
<!--      <div class="form-group col-lg-6" style="font-size: 30px;margin-top:35px;">-->
<!--    	<i class="fas fa-times-circle" onclick="remove(this)"></i>-->
<!--      </div>-->
<!--            @foreach(languages() as $key=>$language)-->
<!--        <div class="form-group col-lg-6">-->
<!--            <label>{{__('packages.advice')}} {{$language->local}}</label>-->
<!--            <input type="text" class="form-control" name="advice[{{$num}}][name_{{$language->local}}]" id="advice_{{$num}}_name_{{$language->local}}" placeholder="{{__('packages.advice')}} {{$language->local}}" value="{{advicenamelang($row->id,$language->id)}}"  />-->
            
<!--        </div>-->
        
<!--        @endforeach-->
       
    	<!--------------- new --------------->
<!--            <div class="col-lg-12">-->
<!--                <div class="form-group">-->
<!--                   <label>{{__('packages.image')}}</label>-->
<!--                    <div class="box" style="display:block">-->
<!--                        <div class="js--image-preview"></div>-->
<!--                        <div class="upload-options">-->
<!--                            <label>-->
<!--                            <input type="file" name="advice[{{$num}}][image]" class="image-upload" />-->
<!--                          </label>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
           
<!--    	</div>-->
<!--    	</div>-->
   
                      
<!--                      @endforeach-->
<!--                      @endif-->
                      
<!--                  </div>-->
<!--                    <div class="col-lg-12">-->
<!--       <a style="cursor: pointer;" @if($package ?? ''  && $package->id) data-id="{{count($advices)}}" @else data-id="0" @endif onclick="addadvice(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("packages.addadvice")}}</a>-->
                   
<!--</div>-->
<!--             </div>-->
<!--         </div>-->
         
<!--          <div class="col-lg-12">-->
<!--             <div class="row pricing-list-item border-item mb-4" style="background-color: rgba(21,97,203,0.1);height:auto">-->
<!--                   <div class="col-lg-12"><h3>{{__('packages.recipes')}}</h3></div>-->
<!--                  <div class="col-lg-12"id="recipes" style="height:100%">-->
<!--                      @if($package ?? ''  && $package->id)-->
<!--                      @foreach($recipes as $keys=>$row)-->
<!--                        <div class="col-12">-->
<!-- <div class="row pricing-list-item border-item mb-4">-->
<!--                      <input type="hidden"  name="recipe[{{$keys}}][id]"value="{{$row->id}}">-->
<!--                      <input type="hidden"  name="recipes[]"value="{{$row->id}}">-->
<!--            @foreach(languages() as $language)-->
<!--        <div class="form-group col-lg-5">-->
<!--            <label>{{__('packages.recipe')}} {{$language->local}}</label>-->
<!--            <input type="text" class="form-control" name="recipe[{{$keys}}][name_{{$language->local}}]" id="recipe_{{$keys}}_name_{{$language->local}}" placeholder="{{__('packages.recipe')}} {{$language->local}}"  value="{{recipenamelang($row->id,$language->id)}}"  />-->
            
<!--        </div>-->
        
<!--        @endforeach-->
       
<!--        <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>-->
    	<!--------------- new --------------->
<!--            <div class="col-lg-6">-->
<!--                <div class="form-group">-->
                   
<!--                    <label>{{__('packages.image')}}</label>-->
<!--                    <div class="box" style="display:block">-->
<!--                        <div class="js--image-preview"></div>-->
<!--                        <div class="upload-options">-->
<!--                            <label>-->
<!--                            <input type="file" name="recipe[{{$num}}][image]" class="image-upload" />-->
<!--                          </label>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--             <div class="col-lg-6">-->
<!--                <div class="form-group">-->
<!--                    <label>{{__('packages.file')}}</label>-->
<!--                    <div class="box" style="display:block">-->
<!--                        <div class="js--image-preview"></div>-->
<!--                        <div class="upload-options">-->
<!--                            <label>-->
<!--                            <input type="file" name="recipe[{{$num}}][file]" class="image-upload" />-->
<!--                          </label>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--    	</div>-->
<!--    	</div>-->
 
                      
<!--                      @endforeach-->
<!--                      @endif-->
                      
<!--                  </div>-->
<!--                    <div class="col-lg-12">-->
<!--       <a style="cursor: pointer;" @if($package ?? ''  && $package->id) data-id="{{count($recipes)}}" @else data-id="0" @endif onclick="addrecipe(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("packages.addrecipe")}}</a>-->
                   
<!--</div>-->
<!--             </div>-->
<!--         </div>-->
         
         
         <hr>
         <div class="col-lg-12">
             <div class="row pricing-list-item border-item mb-4" style="background-color: rgba(21,97,203,0.1);height:auto">
                   <div class="col-lg-12"><h3>
                    <button class="btn btn-link btn-block text-left"  type="button" onclick="collapseDataAll(this)" target-id="four">
                                    {{__('packages.weeksFour')}}
                                </button>
                   </h3></div>
                  <div class="col-lg-12"id="Allfour" style="height:100%;display:none">
                      @if($package ?? ''  && $package->id)
                       @foreach(daysFour($package->id) as $i=>$row)
    <div class="row pricing-list-item border-item mb-4" >
    <div class="col-lg-12">
        <label>
            <button class="btn btn-link btn-block text-left"  type="button" onclick="collapseData(this)" data-id="{{$i}}" target-id="link">
                                    {{__('packages.day')}} : {{$i+1}}
                                </button>
            </label>
    </div>
    
    <div class="col-lg-12" style="height:100%" id="link{{$i}}" >
        @foreach(videos($row->id) as $nums=>$vid)
        
<div class="row pricing-list-item border-item mb-4" style="background-color: rgb(3 5 8 / 10%);">
    
    
    <div class="col-lg-5" >
        <label>{{ __('packages.link')}}</label>
        <input type="text"  class="form-control {{ $errors->has('link') ? 'is-invalid' : '' }}" name="days[{{$i}}][video][{{$nums}}][link]" id="days_{{$i}}_video_{{$nums}}_link" placeholder="{{ meta('link', getCurrentLocale()) ?? __('packages.link') }}" value="{{$vid->link}}"/>
    
    </div>
     <div class="col-lg-5" >
        <label>{{ __('packages.num')}}</label>
        <input type="text"  class="form-control {{ $errors->has('num') ? 'is-invalid' : '' }}" name="days[{{$i}}][video][{{$nums}}][num]" id="days_{{$i}}_video_{{$nums}}_num" placeholder="{{ meta('num', getCurrentLocale()) ?? __('packages.num') }}" value="{{$vid->num}}"/>
    
    </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 class="col-lg-6" >
        <label>{{ __('packages.rows')}}</label>
        <input type="text"  class="form-control {{ $errors->has('rows') ? 'is-invalid' : '' }}" name="days[{{$i}}][video][{{$nums}}][rows]" id="days_{{$i}}_video_{{$nums}}_rows" placeholder="{{ meta('rows', getCurrentLocale()) ?? __('packages.rows') }}" value="{{$vid->rows}}"/>
    
    </div>
    <div class="col-lg-6" ></div>
      @foreach(languages() as $key=>$language)
        <div class="form-group col-lg-6">
            <label>{{__('packages.name')}} {{$language->local}}</label>
            <input type="text" class="form-control" name="days[{{$i}}][video][{{$nums}}][name_{{$language->local}}]" id="days_{{$i}}_video_{{$nums}}_name_{{$language->local}}" placeholder="{{__('packages.name')}} {{$language->local}}" value="{{videonamelang($vid->id,$language->id)}}" />
            
        </div>
        
        @endforeach
       
    </div>
        @endforeach
    </div>
    <br>
     <div class="col-lg-12" id="increase{{$i}}"  @if($row->type == '0') style="display:none;" @endif>
       <a style="cursor: pointer;"  data-id="{{count(videos($row->id))}}" target-id="{{$i}}"  onclick="addvideo(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("packages.addvideo")}}</a>
                   
</div>
    </div>
    @endforeach
    
                  </div>
             </div>
               <div class="row pricing-list-item border-item mb-4 "   style="background-color: rgba(21,97,203,0.1);height:auto">
                   <div class="col-lg-12"><h3>
                   <button class="btn btn-link btn-block text-left"  type="button" onclick="collapseDataAll(this)" target-id="eight">
                                    {{__('packages.weeksEight')}}
                                </button>
                                </h3>
                   </div>
                  <div class="col-lg-12"id="Alleight" style="height:100%;display:none">
                    
     @foreach(daysEight($package->id) as $i=>$row)
    <div class="row pricing-list-item border-item mb-4" >
    <div class="col-lg-12">
        <label>
        <button class="btn btn-link btn-block text-left"  type="button" onclick="collapseData(this)" data-id="{{$i}}" target-id="linkEight">
                                    {{__('packages.day')}} : {{$i+1}}
                                </button>
        </label>
    </div>
    
    <div class="col-lg-12" style="height:100%" id="linkEight{{$i}}" >
        @foreach(videos($row->id) as $nums=>$vid)
        
<div class="row pricing-list-item border-item mb-4" style="background-color: rgb(3 5 8 / 10%);">
    
    
    <div class="col-lg-5" >
        <label>{{ __('packages.link')}}</label>
        <input type="text"  class="form-control {{ $errors->has('link') ? 'is-invalid' : '' }}" name="daysEight[{{$i}}][video][{{$nums}}][link]" id="days_{{$i}}_video_{{$nums}}_link" placeholder="{{ meta('link', getCurrentLocale()) ?? __('packages.link') }}" value="{{$vid->link}}"/>
    
    </div>
     <div class="col-lg-5" >
        <label>{{ __('packages.num')}}</label>
        <input type="text"  class="form-control {{ $errors->has('num') ? 'is-invalid' : '' }}" name="daysEight[{{$i}}][video][{{$nums}}][num]" id="days_{{$i}}_video_{{$nums}}_num" placeholder="{{ meta('num', getCurrentLocale()) ?? __('packages.num') }}" value="{{$vid->num}}"/>
    
    </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 class="col-lg-6" >
        <label>{{ __('packages.rows')}}</label>
        <input type="text"  class="form-control {{ $errors->has('rows') ? 'is-invalid' : '' }}" name="daysEight[{{$i}}][video][{{$nums}}][rows]" id="days_{{$i}}_video_{{$nums}}_rows" placeholder="{{ meta('rows', getCurrentLocale()) ?? __('packages.rows') }}" value="{{$vid->rows}}"/>
    
    </div>
    <div class="col-lg-6" ></div>
      @foreach(languages() as $key=>$language)
        <div class="form-group col-lg-6">
            <label>{{__('packages.name')}} {{$language->local}}</label>
            <input type="text" class="form-control" name="daysEight[{{$i}}][video][{{$nums}}][name_{{$language->local}}]" id="days_{{$i}}_video_{{$nums}}_name_{{$language->local}}" placeholder="{{__('packages.name')}} {{$language->local}}" value="{{videonamelang($vid->id,$language->id)}}" />
            
        </div>
        
        @endforeach
       
    </div>
        @endforeach
    </div>
    <br>
     <div class="col-lg-12" id="increaseEight{{$i}}"  @if($row->type == '0') style="display:none;" @endif>
       <a style="cursor: pointer;"  data-id="{{count(videos($row->id))}}" target-id="{{$i}}"  onclick="addvideoEight(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("packages.addvideo")}}</a>
                   
</div>
    </div>
    @endforeach
    @else
    @for($i=0;$i < 20 ;$i++)
    <div class="row pricing-list-item border-item mb-4" >
    <div class="col-lg-12">
        <button class="btn btn-link btn-block text-left"  type="button" onclick="collapseData(this)" data-id="{{$i}}" target-id="link">
                                    {{__('packages.day')}} : {{$i+1}}
                                </button>
    </div>
  
    
    <div class="col-lg-12" style="height:100%" id="link{{$i}}">
      
    </div>
    <br>
     <div class="col-lg-12" id="increase{{$i}}"  >
       <a style="cursor: pointer;"  data-id="0" target-id="{{$i}}"  onclick="addvideo(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("packages.addvideo")}}</a>
                   
</div>
    </div>
    @endfor
    @endif
                  </div>
             </div>
         </div>
         @if(!($package ?? ''  && $package->id))
         <div class="col-lg-12">
             <div class="row pricing-list-item border-item mb-4" style="background-color: rgba(21,97,203,0.1);height:auto">
                   <div class="col-lg-12">
                       <h3>
                       <button class="btn btn-link btn-block text-left"  type="button" onclick="collapseDataAll(this)" target-id="eight">
                                    {{__('packages.weeksEight')}}
                                </button>
                                </h3></div>
                  <div class="col-lg-12"id="Alleight" style="height:100%;display:none">
                      
                      
    
    @for($i=0;$i < 40 ;$i++)
    <div class="row pricing-list-item border-item mb-4" >
    <div class="col-lg-12">
         <button class="btn btn-link btn-block text-left"  type="button" onclick="collapseData(this)" data-id="{{$i}}" target-id="linkEight">
                                    {{__('packages.day')}} : {{$i+1}}
                                </button>
    </div>
  
    
    <div class="col-lg-12" style="height:100%" id="linkEight{{$i}}" >
      
    </div>
    <br>
     <div class="col-lg-12" id="increaseEight{{$i}}" >
       <a style="cursor: pointer;"  data-id="0" target-id="{{$i}}"  onclick="addvideoEight(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("packages.addvideo")}}</a>
                   
</div>
    </div>
    @endfor
         </div>
             </div>
         </div>
    @endif
             
        
      
      
        <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>
        
function saveproduct(elem){
    
       event.preventDefault();
       $('.ajaxErrorResponse').css("display", "none");
       $('form *').removeClass('is-invalid');
       var action = $(elem).attr('action');
       
       var urls = action;
       var dataform = new FormData( $(elem)[0]);
      
       $.ajax({
          url : urls,
          type : 'POST',
          data : dataform,
          dataType : 'json',
  processData: false,
  contentType: false,
          success:function(data)
          {
              window.location.replace("{{url(getCurrentLocale().'/admin/packages')}}");
          }
          ,error: function (data) {
              
   $('.ajaxErrorResponse').html('<label>'+{!! json_encode(__('packages.fill')) !!}+'</label>');
             
    $('.ajaxErrorResponse').css("display", "block");
   $.each(data.responseJSON.errors, function(key,value) {
     
     var keys = key.replaceAll(".","_");
     console.log(keys);
     $('#'+keys).attr('class','form-control is-invalid');
     
 }); 
 
}
        })
   
}
    </script>
    <script>
        
function remove(elem){
            $(elem).closest('.row').remove();
        }
        
        function addfile(elem){
        var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
        $.ajax({
          url : urls_file+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#files').append(data);
          }
        }) 
    }
    function addadvice(elem){
        var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
        $.ajax({
          url : urls_advice+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#advices').append(data);
          }
        }) 
    }
    function addrecipe(elem){
        var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
        $.ajax({
          url : urls_recipe+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#recipes').append(data);
          }
        }) 
    }
    function addvideo(elem){
        var target = $(elem).attr('target-id');
        var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
        $.ajax({
          url : urls_video+'/'+num+','+target,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#link'+target).append(data);
          }
        }) 
    }
    function addvideoEight(elem){
         var target = $(elem).attr('target-id');
        var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
        $.ajax({
          url : urls_videos+'/'+num+','+target,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#linkEight'+target).append(data);
          }
        }) 
    }
    function additem(elem){
        var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+2; 
        $(elem).attr('data-id', newrow);
        
        $.ajax({
          url : urls+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#items').append(data);
          }
        }) 
    }
    function days(elem){
        var num = parseInt($(elem).val())*30 ;
        
        
        
        $.ajax({
          url : url_day+'/'+num,
          type : 'GET',
          data : 'nothing',
          success:function(data)
          {
            $('#days').html(data);
          }
        }) 
    }
    function restday(elem){
        let data = $(elem).attr('data-id');
        let valuing = $(elem).val();
        
        //alert(valuing);
        if(valuing == '0'){
        $('#link'+data).css('display','none');
        $('#increase'+data).css('display','none');
        }
        else{
            $('#link'+data).css('display','block');
            $('#increase'+data).css('display','block');
        }
        
        
        
    }
    
    </script>
     <script>
        function initImageUpload(box) {
            let uploadField = box.querySelector('.image-upload');

            uploadField.addEventListener('change', getFile);

            function getFile(e) {
                let file = e.currentTarget.files[0];
                checkType(file);
            }

            function previewImage(file) {
                let name = file.name;
                let arr = name.split(".");
                
                let thumb = box.querySelector('.js--image-preview'),
                    reader = new FileReader();
                if(arr[1] == 'pdf'){
                   
                   reader.onload = function() {
                    thumb.style.backgroundImage = 'url(https://nawalgym.omar.alyomhost.net/public/assets/web/pdf.png)';
                   }
                }
                else{
                reader.onload = function() {
                    thumb.style.backgroundImage = 'url(' + reader.result + ')';
                
                }
                }
                reader.readAsDataURL(file);
                thumb.className += ' js--no-default';
            }

            function checkType(file) {
                // let imageType = /image.*/;
                // if (!file.type.match(imageType)) {
                //     throw 'Datei ist kein Bild';
                // } else if (!file) {
                //     throw 'Kein Bild gew채hlt';
                // } else {
                    previewImage(file);
                // }
            }

        }

        // initialize box-scope
        var boxes = document.querySelectorAll('.box');

        for (let i = 0; i < boxes.length; i++) {
            let box = boxes[i];
            initDropEffect(box);
            initImageUpload(box);
        }



        /// drop-effect
        function initDropEffect(box) {
            let area, drop, areaWidth, areaHeight, maxDistance, dropWidth, dropHeight, x, y;
            
            // get clickable area for drop effect
            area = box.querySelector('.js--image-preview');
            area.addEventListener('click', fireRipple);

            function fireRipple(e) {
                area = e.currentTarget
                
                    // create drop
                if (!drop) {
                    drop = document.createElement('span');
                    drop.className = 'drop';
                    this.appendChild(drop);
                }
                // reset animate class
                drop.className = 'drop';

                // calculate dimensions of area (longest side)
                areaWidth = getComputedStyle(this, null).getPropertyValue("width");
                areaHeight = getComputedStyle(this, null).getPropertyValue("height");
                maxDistance = Math.max(parseInt(areaWidth, 10), parseInt(areaHeight, 10));

                // set drop dimensions to fill area
                drop.style.width = maxDistance + 'px';
                drop.style.height = maxDistance + 'px';

                // calculate dimensions of drop
                dropWidth = getComputedStyle(this, null).getPropertyValue("width");
                dropHeight = getComputedStyle(this, null).getPropertyValue("height");

                // calculate relative coordinates of click
                // logic: click coordinates relative to page - parent's position relative to page - half of self height/width to make it controllable from the center
                x = e.pageX - this.offsetLeft - (parseInt(dropWidth, 10) / 2);
                y = e.pageY - this.offsetTop - (parseInt(dropHeight, 10) / 2) - 30;

                // position drop and animate
                drop.style.top = y + 'px';
                drop.style.left = x + 'px';
                drop.className += ' animate';
                e.stopPropagation();

            }
        }
        function collapseDataAll(elem){
            let data = $(elem).attr('target-id');
            $('#All'+data).fadeToggle(500);
        }
        function collapseData(elem){
            let data = $(elem).attr('target-id');
            let dataId = $(elem).attr('data-id');
            $('#'+data+dataId).fadeToggle(500);
        }
    </script>
    	
    <script>
        $(".form-group").delegate( ".edit_btn", "click", function() {
            $(this).parentsUntil(".form-group").siblings(".box").toggleClass("d-block");
        })
    </script>
  <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>
        
    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            urls = "{{url('/')}}/admin/additem",
            url_type = {!! json_encode(url(getCurrentLocale().'/admin/type/')) !!},
            urls_video = {!! json_encode(url(getCurrentLocale().'/admin/addvideo/')) !!},
            urls_videos = {!! json_encode(url(getCurrentLocale().'/admin/addvideos/')) !!},
            urls_file = {!! json_encode(url(getCurrentLocale().'/admin/addfile/')) !!},
            urls_advice = {!! json_encode(url(getCurrentLocale().'/admin/addadvice/')) !!},
            urls_recipe = {!! json_encode(url(getCurrentLocale().'/admin/addrecipe/')) !!},
            url_day = {!! json_encode(url(getCurrentLocale().'/admin/days/')) !!},
            
            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



