

<?php $__env->startSection('content'); ?>
<div class="side-title">
    <h3><?php echo e($head ?? ''); ?></h3>
</div>

<div class="border-item">
    <form class="form-row" method="post" action="<?php echo e($action); ?>">
        <?php if($reservation ?? ''  && $reservation->id): ?>
            <?php echo method_field('PUT'); ?>
        <?php endif; ?>
        <?php echo csrf_field(); ?> 
       <input type="hidden" name="id" value="<?php echo e($reservation->id); ?>">
       <input type="hidden" name="trainner_id" id="trainner" value="<?php echo e(\Auth::user()->id); ?>">
       
        <div class="form-group col-lg-12">
        <label><?php echo e(__('trainreservations.patient_details')); ?></label>
        <br><br>
        <?php $__currentLoopData = $systemfoods; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
          <label>#<?php echo e($data->name); ?></label>
            <table id="pricing-list-container" style="width:100%;word-break:break-all">
                <thead>
                    <th ><?php echo e(__('trainreservations.meal_name')); ?></th>
                    <th ><?php echo e(__('trainreservations.meal_type')); ?></th>
                    <th ><?php echo e(__('trainreservations.meal_calories')); ?></th>
                    <th ><?php echo e(__('trainreservations.meal_fats')); ?></th>
                    <th ><?php echo e(__('trainreservations.meal_carbohydrates')); ?></th>
                    <th ><?php echo e(__('trainreservations.meal_protein')); ?></th>
                    <th ><?php echo e(__('trainreservations.meal_glycemic')); ?></th>
                    
                </thead>
                <tbody>
                      <?php $__currentLoopData = $data->meals->sortBy('type'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                    <td><?php echo e($row->name); ?></td>
                    <td><?php if($row->type == '1'): ?><?php echo e(__('trainreservations.breakfast')); ?> <?php elseif($row->type == '2'): ?> <?php echo e(__('trainreservations.launch')); ?> <?php elseif($row->type == '3'): ?> <?php echo e(__('trainreservations.dinner')); ?>  <?php else: ?> <?php echo e(__('trainreservations.snakes')); ?> <?php endif; ?></td>
                    <td><?php echo e($row->calories); ?></td>
                    <td><?php echo e($row->fats); ?></td>
                    <td><?php echo e($row->Carbohydrates); ?></td>
                    <td><?php echo e($row->Protein); ?></td>
                    <td><?php echo e($row->glycemic); ?></td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table> 
            <br><br>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php if(count($reservations)>0): ?>
          
            <h3><?php echo e(__('trainreservations.continue_reservation')); ?></h3>
            <?php $all = $reservation->count ;
                 $remain = $all - $reserved;
            ?>
            <h5><?php echo e(__('trainreservations.remain_reservation') .' : '); ?> <?php if($remain != '0'): ?> <?php echo e($remain); ?> <?php else: ?> <?php echo e(__('trainreservations.notcontinue')); ?> <?php endif; ?></h5>
            <br><br>
            <label><?php echo e(__('trainreservations.compare')); ?></label>
            <table id="pricing-list-container" style="width:100%;">
                <thead>
                    <th>#</th>
                    <th><?php echo e(__('trainreservations.height')); ?></th>
                    <th><?php echo e(__('trainreservations.width')); ?></th>
                    <th><?php echo e(__('trainreservations.wight')); ?></th>
                    <th><?php echo e(__('trainreservations.train')); ?></th>
                    <th><?php echo e(__('trainreservations.trainner')); ?></th>
                    <th><?php echo e(__('trainreservations.day')); ?></th>
                </thead>
                <tbody>
                    <?php $__currentLoopData = $reservations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                    <td><?php echo e($key+1); ?></td>
                    <td><?php echo e($row->height); ?></td>
                    <td><?php echo e($row->width); ?></td>
                    <td><?php echo e($row->weight); ?></td>
                    <td><?php echo e($row->system_physic['name']); ?></td>
                    <td><?php echo e($row->trainner->name); ?></td>
                    <td><?php echo e(date("Y-m-d", strtotime($row->created_at) )); ?></td>
                </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table> 
            <br><br>
            
          
            <label>#<?php echo e($last->system_physic->name); ?> : <?php echo e($last->code->name); ?></label>
            <table id="pricing-list-container" style="width:100%;word-break:break-all">
                <thead>
                    <th ><?php echo e(__("meals.number")); ?></th>
                    
                </thead>
                <tbody>
                    <?php $__currentLoopData = $allreserved; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$rows): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr><td style="width:20pc"><?php echo e($key+1); ?> </td> <?php $__currentLoopData = $rows->physics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <td><?php echo e($row->physcal->name); ?> (<?php echo e($row->num); ?>)</td> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table> 
            <br><br>
        
            
            
              
            <?php else: ?>
            <h3><?php echo e(__('trainreservations.new_reservation')); ?></h3>
            <?php endif; ?>
       
        </div>
        
        <label><?php echo e(__('trainreservations.patient_details')); ?></label>
         <div class="row">
            
              <div class="form-group col-lg-6">
                   <label><?php echo e(__('trainreservations.patient')); ?> </label>
            <input type="text" disabled class="form-control"  value='<?php echo e($patient->name); ?>'/>
              </div>
               <div class="form-group col-lg-6">
                   <label><?php echo e(__('trainreservations.patient_email')); ?> </label>
            <input type="text" disabled class="form-control"  value='<?php echo e($patient->email); ?>'/>
              </div>
                 <div class="form-group col-lg-6">
                   <label><?php echo e(__('trainreservations.patient_phone')); ?> </label>
            <input type="text" disabled class="form-control"  value='<?php echo e($patient->phone); ?>'/>
              </div>
                 <div class="form-group col-lg-6">
                   <label><?php echo e(__('trainreservations.patient_email')); ?> </label>
            <input type="text" disabled class="form-control"  value='<?php echo e($patient->email); ?>'/>
              </div>
              <?php if(!is_null($patient->details)): ?>
                 <div class="form-group col-lg-6">
                   <label><?php echo e(__('trainreservations.patient_status')); ?> </label>
            <input type="text" disabled class="form-control"  value='<?php echo e($patient->details->status); ?>'/>
              </div>
             
             <div class="form-group col-lg-6">
                   <label><?php echo e(__('trainreservations.patient_job')); ?> </label>
            <input type="text" disabled class="form-control"  value='<?php echo e($patient->details->job); ?>'/>
              </div>
              
             <div class="form-group col-lg-6">
                   <label><?php echo e(__('trainreservations.patient_gender')); ?> </label>
            <input type="text" disabled class="form-control"  value='<?php if($patient->details->gender == "1"): ?> <?php echo e(__("reservations.male")); ?>  <?php else: ?> <?php echo e(__("reservations.female")); ?> <?php endif; ?>'/>
              </div>
            <div class="form-group col-lg-6">
                   <label><?php echo e(__('trainreservations.patient_date_of_birth')); ?> </label>
            <input type="text" disabled class="form-control"  value='<?php echo e($patient->details->date_of_birth); ?>'/>
              </div>
              <?php endif; ?>
         </div>
         
        <?php if(count($reservations)==0): ?>
         <div class="form-group col-lg-6">
            <label><?php echo e(meta('count', getCurrentLocale()) ?? __('trainreservations.count')); ?> </label>
            <input type="number" min="0"  class="form-control <?php echo e($errors->has('count') ? 'is-invalid' : ''); ?>" name="count" placeholder="<?php echo e(meta('count', getCurrentLocale()) ??__('trainreservations.count')); ?>" value='<?php echo e(old("count", $reservation->count ?? "")); ?>'/>
        </div>
        <div class="form-group col-lg-6"></div>
        <?php else: ?>
          <div class="form-group col-lg-12">
            <label><?php echo e(meta('type', getCurrentLocale()) ?? __('trainreservations.type')); ?> </label>
          <select class="form-control <?php echo e($errors->has('type') ? 'is-invalid' : ''); ?>" name="type">
              <option value="1"><?php echo e(__('trainreservations.arrived')); ?></option>
                    <option value="0"><?php echo e(__('trainreservations.notarrived')); ?></option>
                    </select>
           </div>
        <?php endif; ?>
         <div class="form-group col-lg-6">
            <label><?php echo e(meta('dating', getCurrentLocale()) ?? __('trainreservations.dating')); ?> </label>
            <input type="date"  class="form-control <?php echo e($errors->has('dating') ? 'is-invalid' : ''); ?>" name="dating" id="dating" placeholder="<?php echo e(meta('dating', getCurrentLocale()) ??__('trainreservations.dating')); ?>" value='<?php echo e(old("dating")); ?>'/>
        </div>
         <div class="form-group col-lg-6">
            <label><?php echo e(meta('timing', getCurrentLocale()) ?? __('trainreservations.timing')); ?> </label>
            <input type="time"  class="form-control <?php echo e($errors->has('timing') ? 'is-invalid' : ''); ?>" name="timing" placeholder="<?php echo e(meta('timing', getCurrentLocale()) ??__('trainreservations.timing')); ?>" value='<?php echo e(old("timing")); ?>'/>
        </div>
         <div id="table" class="text-center mt-4 col-12">
            
         </div>
         
      
       
           
         <?php if(count($reservations)==0): ?>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('system_physic_id', getCurrentLocale()) ?? __('reservations.system_physic_id')); ?> </label>
          <select onchange="foodcodes(this)" class="form-control <?php echo e($errors->has('system_physic_id') ? 'is-invalid' : ''); ?>" name="system_physic_id" id="system_food">
              <option selected  value=""><?php echo e(__('reservations.select')); ?></option>
                    <?php $__currentLoopData = $systemphysics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($row->id); ?>"><?php echo e($row->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
           </div>
        <?php else: ?>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('system_physic_id', getCurrentLocale()) ?? __('reservations.system_physic_id')); ?> </label>
          <select onchange="foodcodes(this)" class="form-control <?php echo e($errors->has('system_physic_id') ? 'is-invalid' : ''); ?>" name="system_physic_id" id="system_food">
              <option selected  value=""><?php echo e(__('reservations.select')); ?></option>
                    <?php $__currentLoopData = $systemphysics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option <?php if($last->system_physic_id == $row->id): ?> selected <?php endif; ?> value="<?php echo e($row->id); ?>"><?php echo e($row->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
           </div>
        <?php endif; ?>
      
             <div class="form-group col-lg-6" >
                  <label><?php echo e(meta('code_id', getCurrentLocale()) ?? __('reservations.code_id')); ?> </label>
          <select onchange="codemeal(this)" class="form-control <?php echo e($errors->has('system_physic_id') ? 'is-invalid' : ''); ?>" id="tablephysicalcode" name="code_id" >
              <option selected  value=""><?php echo e(__('reservations.selectsystem')); ?></option>
                   <?php if(count($reservations)>0): ?>
                   <?php $__currentLoopData = $codes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                   <option <?php if($last->code_id == $row->id): ?> selected <?php endif; ?> value="<?php echo e($row->id); ?>"><?php echo e($row->name); ?></option>
                   <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                   <?php endif; ?>
                    </select>
           </div>
            
             <div class="form-group col-lg-12" id="tablephysical" >
               <?php if(count($reservations)>0): ?>
               <?php $__currentLoopData = $physcals; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
               <div id="mealrow" class="row">
         <div class="form-group col-lg-6">
            <label>تمرين </label>
            <input type="hidden" class="form-control" name="physcal[<?php echo e($key); ?>][physcal_id]" value="<?php echo e($row->physcal_id); ?>" />
            <input type="text" class="form-control" disabled value="<?php echo e($row->physcal->name); ?>" />
            </div>
          <div class="form-group col-lg-5">
            <label>العدد </label>
            <input type="number" min="0" class="form-control" name="physcal[<?php echo e($key); ?>][num]" value="<?php echo e($row->num); ?>" />
            </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>
               <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
               <?php endif; ?>
             </div>
                 <div class="col-lg-12" >
       <a style="cursor: pointer;" id="removing" <?php if(count($reservations)==0): ?> data-id="0" <?php else: ?>  data-id="<?php echo e(count($physcals)); ?>"  <?php endif; ?> onclick="addmeal(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("physcalneeds.add_physcal")); ?></a>
                   
</div>
            
        
      
             
                

           
             
               

            
      
       

        <div class="text-center mt-5 col-12">
            <button class="butn"><span><?php echo e(__('dashboard.save')); ?></span></button>
        </div>
    </form>
</div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('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;
        
        
        $.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)
          {
              
            $('#tablephyscal').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);
          }
        })
}

    function addmeal(elem){
        $("#meals").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)
          {
            $('#tablephysical').append(data);
          }
        })
    }
    function foodcodes(elem){
        var num = $(elem).val();
        
        
         $.ajax({
          url : urlfoodcode +num,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
              
              $('#tablephysicalcode').html(data);
          }
        })
    }
    function codemeal(elem)
    {
        
        var num = $(elem).val();
        
        
         $.ajax({
          url : urlmealcode +num,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
              $('#removing').attr('data-id',data.counting);
              $('#tablephysical').html(data.outs);
          }
        })
    }
    function remove(elem){
            $(elem).closest('#mealrow').remove();
        }
</script>


            <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
    <script>
        let route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>/",
            urls = "<?php echo e(url('/')); ?>/admin/addphysictypes",
            urlanatomy = "<?php echo e(url('admin/anatomy')); ?>/",
            urlprescription = "<?php echo e(url('admin/prescription')); ?>/",
            urldating = "<?php echo e(url('admin/datingtrain')); ?>/",
            urlfood = "<?php echo e(url('admin/systemphysic')); ?>/",
            urlfoodcode = "<?php echo e(url('admin/physcalcode')); ?>/",
            urlmealcode = "<?php echo e(url('admin/physiccode')); ?>/",
            urlphysical = "<?php echo e(url('admin/systemphysical')); ?>/",
            imagePath = "<?php echo e(asset('')); ?>";
    </script>
    <script src="<?php echo e(asset('assets/admin/js/editor.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/lfm.js')); ?>"></script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/omaralyomhost/public_html/green_apple/resources/views/admin/trainnerreservations/form.blade.php ENDPATH**/ ?>