<?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($answer ?? ''  && $answer->id): ?>
            <?php echo method_field('PUT'); ?>
        <?php endif; ?>
        <?php echo csrf_field(); ?>

       <div class="form-group col-lg-6">
                <label><?php echo e(meta('patients', getCurrentLocale()) ?? __('answers.patients')); ?> </label>
               
                     
                         <select  class="selectpicker form-control"  data-show-subtext="true" data-live-search="true" name="user_id">
                             <option selected disabled><?php echo e(__('answers.select')); ?></option>
                    <?php $__currentLoopData = $patients; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option <?php if($answer ?? ''  && $answer->id): ?> <?php if($row->id == $answer->user_id): ?> selected <?php endif; ?> <?php endif; ?> value="<?php echo e($row->id); ?>"> <?php echo e($row->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
              
              
                </div>
                  <div class="form-group col-lg-6">
            <label><?php echo e(meta('date', getCurrentLocale()) ?? __('answers.date')); ?> </label>
            <input type="date" class="form-control <?php echo e($errors->has('date') ? 'is-invalid' : ''); ?>" name="date" placeholder="<?php echo e(meta('date', getCurrentLocale()) ??__('answers.date')); ?>" value='<?php echo e(old("date", $answer->date ?? "")); ?>' >
        </div>
       <div class="form-group col-lg-6">
                <label><?php echo e(meta('questions', getCurrentLocale()) ?? __('answers.questions')); ?> </label>
               
                     
                         <select onchange="question(this)" class="form-control" name="answer[0][question_id]">
                             <option selected disabled><?php echo e(__('answers.select')); ?></option>
                    <?php $__currentLoopData = $questions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option <?php if($answer ?? ''  && $answer->id): ?> <?php if($row->id==$answer->question_id): ?> selected <?php endif; ?> <?php endif; ?> value="<?php echo e($row->id); ?>"> <?php echo e($row->question); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
              
              
                </div>
                         
       
      
                 <div class="form-group col-lg-6">
                <label><?php echo e(meta('questions', getCurrentLocale()) ?? __('answers.answer')); ?> </label>
               
                     
                         <select  onchange="answered(this)" class="form-control" id="answer" name="answer[0][answer_id]">
                            <?php if($answer ?? ''  && $answer->id): ?>
                            <?php $__currentLoopData = $answers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option <?php if($answer ?? ''  && $answer->id): ?> <?php if($row->id==$answer->answer_id): ?> selected <?php endif; ?> <?php endif; ?> value="<?php echo e($row->id); ?>"><?php echo e($row->answer); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php else: ?>
                             <option selected disabled><?php echo e(__('answers.selectquestion')); ?></option>
                             <?php endif; ?>
                            
                    </select>
              
              
                </div>
          <div class="col-lg-12">
              
                    <div class="row pricing-list-item border-item mb-4 form-group "  <?php if(!($answer ?? ''  && $answer->id)): ?> style="display:none" <?php endif; ?> id="data" >
                        
                        <?php if($answer ?? ''  && $answer->id): ?>
                <?php if(checkquestion($answer->id)): ?>
             <div class="form-group col-lg-6">
                <label> <?php echo e(__('answers.question')); ?> </label>
               
                     
                         <select onchange="answersed(this)" class="form-control " name="answer[1][question_id]">
                            <?php $__currentLoopData = questionsanswer($answer->answer_id); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option <?php if($row->id == questionanswer($answer->id)): ?> selected <?php endif; ?>  value="<?php echo e($row->id); ?>"> <?php echo e($row->question); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
              
                </div>
                 <div class="form-group col-lg-6">
                <label><?php echo e(__('answers.answer')); ?> </label>
               
                                  <select class="form-control" id="answer" name="answer[1][answer_id]">
                         <?php $__currentLoopData = answers(questionanswer($answer->id)); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option  <?php if($row->id == answer($answer->id)): ?> selected <?php endif; ?> value="<?php echo e($row->id); ?>"><?php echo e($row->answer); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </select>
              </div>
               <?php endif; ?>
                   <?php endif; ?>
                
                </div>
            </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'); ?>
<script>
    function question(elem){
       
        var num = $(elem).val();
        
        
        
         $.ajax({
          url : url_question+'/'+num,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
             
            $('#answer').html(data);
              
          }
        })
    }
    function answered(elem){
       
        var num = $(elem).val();
        
         $.ajax({
          url : url_answer+'/'+num,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
               if(data != 'no'){
            $("#data").css("display", "block");
            $('#data').html(data);
               }
               else{
                    $("#data").empty();
               }
          }
        })
    }
     function answersed(elem){
       
        var num = $(elem).val();
        
         $.ajax({
          url : url_question+'/'+num,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
              
            $('#answers').html(data);
          }
        })
    }
    
    </script>
    <!-- Editor JS files -->

            <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('/')); ?>/",
            url_answer = "<?php echo e(url('/')); ?>/admin/answerdata",
            url_question = "<?php echo e(url('/')); ?>/admin/questiondata",
            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/answers/form.blade.php ENDPATH**/ ?>