@extends('admin.layouts.container')

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

<div class="border-item">
    <form class="form-row" enctype="multipart/form-data" method="post" action="{{ $action }}">
        @if($category ?? ''  && $category->id)
            @method('PUT')
        @endif
        @CSRF
         
         
        <div class="form-group col-lg-6">
            <label>{{ meta('name', getCurrentLocale()) ?? __('categories.name') }} </label>
            <input type="text" class="form-control {{ $errors->has('name') ? 'is-invalid' : '' }}" name="name" placeholder="{{ meta('name', getCurrentLocale()) ??__('categories.name') }}" value='{{ old("name", $category->name ?? "") }}'/>
        </div>
<div class="form-group col-lg-6"></div>
        

       
       
                
                <div class="row pricing-list-item border-item mb-4 col-12" @if($category ?? ''  && $category->id) @else  style="display:none" @endif id="anatomys">
                    @if($category ?? ''  && $category->id)
                    @foreach($anatomies as $data=>$row)
                    <div class="row pricing-list-item border-item mb-4 col-12">
          <div class="form-group col-lg-6">
            <label>{{ __('anatomies.anatomy')}} </label>
            <input name="anatomy[{{$data}}][name]" class="form-control" value="{{$row->name}}">
        </div>

        
        
        <div class="form-group col-lg-1" style="font-size: 30px;margin-top:35px;">
    	<i class="fas fa-times-circle" onclick="remove(this)"></i></div>
                            </div>
                    @endforeach
                    @endif
                </div>
<div class="col-lg-12">
       <a style="cursor: pointer;" @if($category ?? ''  && $category->id) data-id="{{count($anatomies)}}" @else   data-id="0" @endif onclick="addanatomy(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>{{__("anatomies.add_anatomy")}}</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')
<script>
    function addanatomy(elem){
        $("#anatomys").css("display", "block");
        var num = $(elem).attr('data-id');
        
        var newrow = parseInt(num)+1; 
        $(elem).attr('data-id', newrow);
        
         $.ajax({
          url : urls+'/'+num,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
            $('#anatomys').append(data);
          }
        })
    }
     function remove(elem){
            $(elem).closest('.row').remove();
        }
</script>
    <!-- Editor JS files -->
{{--    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>--}}
            <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            urls = "{{url('/')}}/admin/addanatomytype",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
@endsection
