@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($patient ?? ''  && $patient->id)
            @method('PUT')
        @endif
        @CSRF
@if($patient ?? ''  && $patient->id)
 <div class="text-center mt-5 col-12">
            <a href="{{url('admin/patients/'.$patient->id)}}" class="butn">عرض التفاصيل</a>
        </div>
@endif

@if($patient ?? ''  && $patient->id)
         @if(count($histories)>0)
          <h3>{{__('reads.readpatient')}}</h3>
          <table class="table table-bordered table-hover" style="word-break: break-word;text-align:center;">
            <thead>
                
                <th>#</th>
                <th>{{__('histories.date')}}</th>
                <th>{{__('histories.weight')}}</th>
                <th>{{__('histories.fat')}}</th>
                <th>{{__('histories.muscle')}}</th>
                <th>{{__('histories.liquid')}}</th>
                <th>{{__('histories.bone')}}</th>
                <th>{{__('histories.trust')}}</th>
                <th>{{__('histories.sport')}}</th>
                <th>{{__('histories.recommend')}}</th>
                <th>{{__('histories.complain')}}</th>
                <th>{{__('histories.system')}}</th>
                <th>{{__('histories.note')}}</th>
            </thead>
            
            <tbody>
                 @foreach($histories as $key=>$row)
                <tr>
                    <td>{{$key+1}}</td>
                    <td>{{$row->date}}</td>
                    <td>{{$row->weight}}</td>
                    <td>{{$row->fat}}</td>
                    <td>{{$row->muscle}}</td>
                    <td>{{$row->liquid}}</td>
                    <td>{{$row->bone}}</td>
                    <td>{{$row->trust}}</td>
                    <td>{{$row->sport}}</td>
                    <td>{{$row->recommend}}</td>
                    <td>{{$row->complain}}</td>
                    <td>{{$row->system}}</td>
                    <td>{{$row->note}}</td>
                    
                </tr>
                @endforeach
               
            </tbody>
        </table>
  
        
        @endif
         @endif
           @if($patient ?? ''  && $patient->id)
         @if(count(reads($patient->id))>0)
         <h3>{{__('reads.readdevice')}}</h3>
          <table class="table table-bordered table-hover" style="text-align:center">
           <thead>
                
                <th>#</th>
                <th>{{__('devices.name')}}</th>
                <th>{{__('reads.number')}}</th>
                <th>{{__('sessions.dating')}}</th>
                
            </thead>
            
            <tbody>
                 @foreach(reads($patient->id) as $key=>$row)
                <tr>
                    <td>{{$key+1}}</td>
                    <td>{{$row->device->name}}</td>
                    <td>{{$row->number}}</td>
                    <td>{{date_format($row->created_at, 'Y-m-d')}}</td>
                </tr>
                @endforeach
               
            </tbody>
  
  
       
  
         </table>
        @endif
         @endif
         @if($patient ?? ''  && $patient->id)
         @if(count($reservation)>0)
          <h3>{{__('reservations.reservations')}}</h3>
          <table class="table table-bordered table-hover" style="text-align:center">
            <thead>
                
                <th>#</th>
                <th>{{__('reservations.branch')}}</th>
                <th>{{__('reservations.doctor')}}</th>
                <th>{{__('reservations.count')}}</th>
                <th>{{__('reservations.remain')}}</th>
                <th>{{__('reservations.expired')}}</th>
            </thead>
            
            <tbody>
                 @foreach($reservation as $key=>$row)
                <tr>
                    <td>{{$key+1}}</td>
                    <td>{{$row->branch->name}}</td>
                    <td>{{$row->doctor->name}}</td>
                    <td>{{$row->count}}</td>
                    <td>{{$row->count - remain($row->id)}}</td>
                    <td>@if($row->expired == '1') {{__('reservations.notcontinue')}} @else {{__('reservations.remain')}} @endif</td>
                </tr>
                @endforeach
               
            </tbody>
        </table>
  
        
        @endif
         @endif
         
       
         
        <div class="form-group col-lg-6">
            <label>{{ meta('name', getCurrentLocale()) ?? __('patients.name') }} </label>
            <input type="text" class="form-control {{ $errors->has('name') ? 'is-invalid' : '' }}" name="name" placeholder="{{ meta('name', getCurrentLocale()) ??__('patients.name') }}" value='{{ old("name", $patient->name ?? "") }}'/>
        </div>
        <div class="form-group col-lg-6">
            <label>{{ meta('email', getCurrentLocale()) ?? __('patients.email') }} </label>
            <input type="email" class="form-control {{ $errors->has('email') ? 'is-invalid' : '' }}" name="email" placeholder="{{ meta('email', getCurrentLocale()) ??__('patients.email') }}" value='{{ old("email", $patient->email ?? "") }}'/>
        </div>
         <div class="form-group col-lg-6">
            <label>{{ meta('password', getCurrentLocale()) ?? __('patients.password') }} </label>
            <input type="password" class="form-control {{ $errors->has('password') ? 'is-invalid' : '' }}" name="password" placeholder="{{ meta('password', getCurrentLocale()) ??__('patients.password') }}" value='{{ old("password") }}'/>
        </div>

        <div class="form-group col-lg-6">
            <label>{{ meta('date_of_birth', getCurrentLocale()) ?? __('patients.date_of_birth') }} </label>
            <input type="date" class="form-control {{ $errors->has('date_of_birth') ? 'is-invalid' : '' }}" name="date_of_birth" placeholder="{{ meta('date_of_birth', getCurrentLocale()) ?? __('patients.date_of_birth') }}" value='{{ old("date_of_birth", $patient->details->date_of_birth ?? "") }}'/>
        </div>
        
           <div class="form-group col-lg-6">
            <label>{{ meta('job', getCurrentLocale()) ?? __('patients.job') }} </label>
            <input type="text" class="form-control {{ $errors->has('job') ? 'is-invalid' : '' }}" name="job" placeholder="{{ meta('job', getCurrentLocale()) ?? __('patients.job') }}" value='{{ old("job", $patient->details->job ?? "") }}'/>
        </div>
        
        
         <div class="form-group col-lg-6">
            <label>{{ meta('appetite', getCurrentLocale()) ?? __('patients.appetite') }} </label>
            <input type="text" class="form-control {{ $errors->has('appetite') ? 'is-invalid' : '' }}" name="appetite" placeholder="{{ meta('appetite', getCurrentLocale()) ?? __('patients.appetite') }}" value='{{ old("appetite", $patient->appetite ?? "") }}'/>
        </div>
        
         <div class="form-group col-lg-6">
            <label>{{ meta('type_food', getCurrentLocale()) ?? __('patients.type_food') }} </label>
            <input type="text" class="form-control {{ $errors->has('type_food') ? 'is-invalid' : '' }}" name="type_food" placeholder="{{ meta('type_food', getCurrentLocale()) ?? __('patients.type_food') }}" value='{{ old("type_food", $patient->type_food ?? "") }}'/>
        </div>
        
         <div class="form-group col-lg-6">
            <label>{{ meta('time_wake', getCurrentLocale()) ?? __('patients.time_wake') }} </label>
            <input type="text" class="form-control {{ $errors->has('time_wake') ? 'is-invalid' : '' }}" name="time_wake" placeholder="{{ meta('time_wake', getCurrentLocale()) ?? __('patients.time_wake') }}" value='{{ old("time_wake", $patient->time_wake ?? "") }}'/>
        </div>
        
         <div class="form-group col-lg-6">
            <label>{{ meta('time_meal', getCurrentLocale()) ?? __('patients.time_meal') }} </label>
            <input type="text" class="form-control {{ $errors->has('time_meal') ? 'is-invalid' : '' }}" name="time_meal" placeholder="{{ meta('time_meal', getCurrentLocale()) ?? __('patients.time_meal') }}" value='{{ old("time_meal", $patient->time_meal ?? "") }}'/>
        </div>
        
         <div class="form-group col-lg-6">
            <label>{{ meta('time_sleep', getCurrentLocale()) ?? __('patients.time_sleep') }} </label>
            <input type="text" class="form-control {{ $errors->has('time_sleep') ? 'is-invalid' : '' }}" name="time_sleep" placeholder="{{ meta('time_sleep', getCurrentLocale()) ?? __('patients.time_sleep') }}" value='{{ old("time_sleep", $patient->time_sleep ?? "") }}'/>
        </div>
        
         <div class="form-group col-lg-6">
            <label>{{ meta('time_work', getCurrentLocale()) ?? __('patients.time_work') }} </label>
            <input type="text" class="form-control {{ $errors->has('time_work') ? 'is-invalid' : '' }}" name="time_work" placeholder="{{ meta('time_work', getCurrentLocale()) ?? __('patients.time_work') }}" value='{{ old("time_work", $patient->time_work ?? "") }}'/>
        </div>
        
           <div class="form-group col-lg-6">
            <label>{{ meta('phone', getCurrentLocale()) ?? __('patients.phone') }} </label>
            <input type="number" class="form-control {{ $errors->has('phone') ? 'is-invalid' : '' }}" name="phone" placeholder="{{ meta('phone', getCurrentLocale()) ?? __('patients.phone') }}" value='{{ old("phone", $patient->phone ?? "") }}'/>
        </div>
          
        
           <div class="form-group col-lg-6">
            <label>{{ meta('status', getCurrentLocale()) ?? __('patients.status') }} </label>
            <input type="text" class="form-control {{ $errors->has('status') ? 'is-invalid' : '' }}" name="status" placeholder="{{ meta('status', getCurrentLocale()) ?? __('patients.status') }}" value='{{ old("status", $patient->details->status ?? "") }}'/>
        </div>
      
        
           <div class="form-group col-lg-6">
            <label>{{ meta('gender', getCurrentLocale()) ?? __('patients.gender') }} </label>
            <select class="form-control {{ $errors->has('gender') ? 'is-invalid' : '' }}" name="gender">
                <option selected disabled>{{__('patients.select')}}</option>
                
                <option @if($patient ?? ''  && $patient->id) @if($patient->details->gender == '1') selected @endif @endif value="1">{{__('patients.male')}}</option>
                <option @if($patient ?? ''  && $patient->id) @if($patient->details->gender == '0') selected @endif @endif value="0">{{__('patients.female')}}</option>
            </select>
        </div>
          <div class="form-group col-lg-6">
            <label>{{ meta('knowledge', getCurrentLocale()) ?? __('patients.knowledge') }} </label>
            <select class="form-control {{ $errors->has('knowledge') ? 'is-invalid' : '' }}" name="knowledge">
                <option selected disabled>{{__('patients.select')}}</option>
                <option @if($patient ?? ''  && $patient->id) @if($patient->details->knowledge == '1') selected @endif @endif value="1">{{__('patients.social')}}</option>
                <option @if($patient ?? ''  && $patient->id) @if($patient->details->knowledge == '2') selected @endif @endif value="2">{{__('patients.friend')}}</option>
                <option @if($patient ?? ''  && $patient->id) @if($patient->details->knowledge == '3') selected @endif @endif value="3">{{__('patients.other')}}</option>
            </select>
        </div>

  <div class="form-group col-lg-6">
            <label>{{ meta('branches', getCurrentLocale()) ?? __('patients.branches') }} </label>
            <select class="form-control {{ $errors->has('branches') ? 'is-invalid' : '' }}" name="branches">
                <option selected disabled>{{__('patients.select')}}</option>
                 @foreach($branches as $row)
                <option @if($patient ?? ''  && $patient->id) @if(branchestrue($row->id,$patient->id,'0')) selected @endif @endif value="{{$row->id}}">{{$row->name}}</option>
               @endforeach
            </select>
        </div>
             <div class="form-group col-lg-6">
            <label>{{ meta('joinned', getCurrentLocale()) ?? __('main.joinned') }} </label>
            <input type="date" class="form-control {{ $errors->has('joinned') ? 'is-invalid' : '' }}" name="joinned" placeholder="{{ meta('joinned', getCurrentLocale()) ?? __('main.joinned') }}" value='{{ old("joinned", $user->details->joinned ?? "") }}'/>
        </div>
          <div class="form-group col-lg-12">
                <label>{{ meta('specialties', getCurrentLocale()) ?? __('meals.specialties') }} </label>
               
                     <div class="row">
                    @foreach($specialties as $row)
                    <div class="col-3"><input type="checkbox"  @if($patient ?? ''  && $patient->id) @if(specialties($row->id,$patient->id)) checked @endif @endif name="specialties[]" value="{{$row->id}}"> {{$row->name}}</div>
                    @endforeach
               </div>
                </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 src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
@endsection
