@extends('admin.layouts.container')

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

<div class="border-item">
    
       
        <div class="form-group col-lg-12">
        <label>{{__('reservations.reservation_details')}}</label>
            @if(count($reservations)>0)
            <div class="row">
             <div class="form-group col-lg-6">
            <a href="{{ route ('doctorreservations.anatomyshow', $reservation->id) }}"  class="butn"><span>{{ __('reservations.anatomyshow') }}</span></a>
        </div>
           <div class="form-group col-lg-6">
              <a style="float:right;" href="{{ route ('doctorreservations.prescriptionshow', $reservation->id) }}"  class="butn"><span>{{ __('reservations.prescriptionshow') }}</span></a>
        </div>
        </div>
            <h3>{{__('reservations.continue_reservation')}}</h3>
            @php $all = $reservation->count + 1;
                 $remain = $all - $reserved;
            @endphp
            <h5>{{__('reservations.remain_reservation') .' : ' }} @if($remain != '0') {{$remain}} @else {{__('reservations.notcontinue')}} @endif</h5>
            <br><br>
            <label>{{__('reservations.compare')}}</label>
            <table id="pricing-list-container" style="width:100%;">
                <thead>
                    <th>#</th>
                    <th>{{__('reservations.height')}}</th>
                    <th>{{__('reservations.width')}}</th>
                    <th>{{__('reservations.wight')}}</th>
                    <th>{{__('reservations.doctor')}}</th>
                    <th>{{__('reservations.day')}}</th>
                </thead>
                <tbody>
                    @foreach($reservations as $key=>$row)
                    <tr>
                    <td>{{$key+1}}</td>
                    <td>{{$row->height}}</td>
                    <td>{{$row->width}}</td>
                    <td>{{$row->weight}}</td>
                    <td>{{$row->doctor->name}}</td>
                    <td>{{date("Y-m-d", strtotime($row->created_at) )}}</td>
                </tr>
                    @endforeach
                </tbody>
            </table> 
            <br><br>
            
            <label>#{{$last->systemfood->name}}</label>
            <table id="pricing-list-container" style="width:100%;word-break:break-all">
                <thead>
                    <th >{{__('reservations.meal_name')}}</th>
                    <th >{{__('reservations.meal_type')}}</th>
                    <th >{{__('reservations.meal_calories')}}</th>
                    <th >{{__('reservations.meal_fats')}}</th>
                    <th >{{__('reservations.meal_carbohydrates')}}</th>
                    <th >{{__('reservations.meal_protein')}}</th>
                    <th >{{__('reservations.meal_glycemic')}}</th>
                </thead>
                <tbody>
                    @foreach($last->systemfood->meals->sortBy('type') as $row)
                    <tr>
                    <td>{{$row->name}}</td>
                    <td>@if($row->type == '1'){{__('reservations.breakfast')}} @elseif($row->type == '2') {{__('reservations.launch')}} @elseif($row->type == '3') {{__('reservations.dinner')}}  @else {{__('reservations.snakes')}} @endif</td>
                    <td>{{$row->calories}}</td>
                    <td>{{$row->fats}}</td>
                    <td>{{$row->Carbohydrates}}</td>
                    <td>{{$row->Protein}}</td>
                    <td>{{$row->glycemic}}</td>
                    </tr>
                    @endforeach
                </tbody>
            </table> 
            <br><br>
            
          
          <label>{{__('reservations.train')}}</label>
            <table id="pricing-list-container" style="width:100%;">
                <thead>
                    <th>#</th>
                    <th >{{__('reservations.physical_name')}}</th>
                    <th >{{__('reservations.physical_description')}}</th>
                    
                </thead>
                <tbody>
                    @foreach($systemphysic as $key=>$row)
                   <tr>
                       <td>{{$key}}</td>
                       <td>{{$row->name}}</td>
                       <td>@foreach($row->physicals as $data){{$data->name}} : {{$data->description}} <br> @endforeach</td>
                   </tr>
                    @endforeach
                </tbody>
            </table> 
            <br><br>
           
            
              
            @else
            <h3>{{__('reservations.new_reservation')}}</h3>
            @endif
       
        </div>
        @if(count($answers) > 0)
        
         <div class="form-group col-lg-12">
              <label>{{__('reservations.compare_questions')}}</label>
            <table id="pricing-list-container" style="width:100%;">
                <thead>
                    <th>#</th>
                    <th>{{__('reservations.question')}}</th>
                    <th>{{__('reservations.answer')}}</th>
                   
                </thead>
                <tbody>
                    @foreach($answers as $key=>$row)
                    <tr>
                    <td>{{$key+1}}</td>
                    <td>{{$row->question->question}}</td>
                    <td>{{$row->answer}}</td>
                    </tr>
                    @endforeach
                </tbody>
            </table> 
            <br><br>
         </div>
         @endif
       
         
        
</div>

@endsection

@section('inner_js')
    <!-- Editor JS files -->
    <script type="text/javascript">
    $(document).ready(function(){
    $(document).on('change','#dating',function(){
      
      var doctor = $('#doctor').val();
     
          var dates = $('#dating').val();
        var data = doctor + ','+ dates;
        if(doctor != null)
        $.ajax({
          url : urldating+data,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
              
            $('#table').html(data);
            
          }
        })
    });
    $(document).on('change','#system_food',function(){
     
      var data = $('#system_food').val();
      
        
        if(doctor != null)
        $.ajax({
          url : urlfood+data,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
              
            $('#tablefood').html(data);
            
          }
        })
    });
       $(document).on('change','#system_physical',function(){
      
      var data = $('#system_physical').val();
    
        
        if(doctor != null)
        $.ajax({
          url : urlphysical+data,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {

            $('#tablephysical').html(data);
            
          }
        })
    });
  });
    function addanatomy(elem) {
    
  
      var datarow =$(elem).attr('counter');
      
      var newdata = parseInt(datarow)+1; 
      
      $(elem).attr('counter', newdata);
        
        $.ajax({
          url : urlanatomy +datarow,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
            $('#anatomy').append(data);
          }
        })
}
</script>
<script type="text/javascript">
    function addprescription(elem) {
    
  
      var datarow =$(elem).attr('counter');
      
      var newdata = parseInt(datarow)+1; 
      
      $(elem).attr('counter', newdata);
        
        $.ajax({
          url : urlprescription +datarow,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
            $('#prescription').append(data);
          }
        })
}
</script>

{{--    <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('/')}}/",
            urlanatomy = "{{url('admin/anatomy')}}/",
            urlprescription = "{{url('admin/prescription')}}/",
            urldating = "{{url('admin/dating')}}/",
            urlfood = "{{url('admin/systemfood')}}/",
            urlphysical = "{{url('admin/systemphysical')}}/",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
@endsection
