@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 }}">
        @if($physcalneed ?? ''  && $physcalneed->id)
            @method('PUT')
            <input type="hidden" name="id" value="{{$physcalneed->id}}">
        @endif
        @CSRF

        <div class="form-group col-lg-6">
            <label>{{ meta('trainner', getCurrentLocale()) ?? __('physcalneeds.trainner') }} </label>
           <select class="form-control {{ $errors->has('trainner_id') ? 'is-invalid' : '' }}" name="trainner_id" id="trainner">
               <option selected disabled>{{__('physcalneeds.select')}}</option>
               @foreach($trainners as $row)
               <option  value="{{$row->id}}">{{$row->name}}</option>
               @endforeach
           </select>
            </div>
             <div class="form-group col-lg-6">
            <label>{{ meta('branch', getCurrentLocale()) ?? __('reservations.branch') }} </label>
           <select class="form-control {{ $errors->has('branch_id') ? 'is-invalid' : '' }}" name="branch_id" id="branch">
               <option selected disabled>{{__('reservations.selectdoctor')}}</option>
               
           </select>
            </div>
              <input type="hidden"  name="patient_id" value="{{$physcalneed->patient_id}}">
            
         <div class="form-group col-lg-6">
            <label>{{ meta('dating', getCurrentLocale()) ?? __('physcalneeds.dating') }} </label>
            <input type="date" class="form-control {{ $errors->has('dating') ? 'is-invalid' : '' }}" name="dating" id="dating" placeholder="{{ meta('dating', getCurrentLocale()) ??__('physcalneeds.dating') }}" value='{{ old("dating") }}'/>
        </div>
         <div class="form-group col-lg-6">
            <label>{{ meta('timing', getCurrentLocale()) ?? __('physcalneeds.timing') }} </label>
            <input type="time" class="form-control {{ $errors->has('timing') ? 'is-invalid' : '' }}" name="timing" placeholder="{{ meta('timing', getCurrentLocale()) ??__('physcalneeds.timing') }}" value='{{ old("timing") }}'/>
        </div>
         @if($physcalneed ?? ''  && $physcalneed->id)
        @if(!is_null($physcalneed->count))
         <div class="form-group col-lg-6">
            <label>{{ meta('count', getCurrentLocale()) ?? __('physcalneeds.count') }} </label>
            <input type="number" min="0" class="form-control {{ $errors->has('count') ? 'is-invalid' : '' }}" name="count" id="count" placeholder="{{ meta('count', getCurrentLocale()) ??__('physcalneeds.count') }}" value='{{ old("count") }}'/>
        </div>
         @endif
         @endif
         
            
         <div id="table" class="text-center mt-4 col-12">
            
         </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>
     $(document).ready(function(){
   
    $(document).on('change','#trainner',function(){
      
      var trainner = $('#trainner').val();
     
          var dates = $('#dating').val();
        var data = trainner + ','+ dates;
       
        
        $.ajax({
          url : urls+data,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
            $('#table').html(data);
            
          }
        })
         $.ajax({
          url : url_branch+trainner,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
            $('#branch').html(data);
            
          }
        })  
      

    });
    $(document).on('change','#dating',function(){
      
      var trainner = $('#trainner').val();
     
          var dates = $('#dating').val();
        var data = trainner + ','+ dates;
        if(trainner != null)
        $.ajax({
          url : urls+data,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
              
            $('#table').html(data);
            
          }
        })
        
      

    });
    
  });

</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/datingtrain')}}/",
            url_branch ="{{url('admin/branch')}}/",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
@endsection
