

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

<div class="border-item">
    <form class="form-row" enctype="multipart/form-data" method="post" action="<?php echo e($action); ?>">
        <?php if($systemfood ?? ''  && $systemfood->id): ?>
            <?php echo method_field('PUT'); ?>
             
        <?php endif; ?>
        <?php echo csrf_field(); ?>
        
         <div class="col-12"></div>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('name', getCurrentLocale()) ?? __('systemfoods.name')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('name') ? 'is-invalid' : ''); ?>" name="name" placeholder="<?php echo e(meta('name', getCurrentLocale()) ??__('systemfoods.name')); ?>" value='<?php echo e(old("name", $systemfood->name ?? "")); ?>'/>
        </div>

      
       <div class="form-group col-lg-6">
                <label><?php echo e(meta('specialties', getCurrentLocale()) ?? __('systemfoods.specialties')); ?> </label>
               <select class="form-control <?php echo e($errors->has('specialty_id') ? 'is-invalid' : ''); ?>" name="specialty_id">
                   <option selected disabled ><?php echo e(__('systemfoods.select')); ?></option>
                    <?php $__currentLoopData = $specialties; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option  <?php if($systemfood ?? ''  && $systemfood->id): ?> <?php if($systemfood->specialty_id == $row->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="row col-12 pricing-list-item border-item mb-4" <?php if(!($systemfood ?? ''  && $systemfood->id)): ?> style="display:none" <?php endif; ?> id="meals">
                     <?php if($systemfood ?? ''  && $systemfood->id): ?>
                     <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data=>$row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <div class="row  col-12 pricing-list-item border-item mb-4">
          <div class="form-group col-lg-6">
            <label><?php echo e(__('categories.name')); ?> </label>
            <input type="text" class="form-control" name="category[<?php echo e($data); ?>][name]" placeholder="<?php echo e(__('categories.name')); ?>" value="<?php echo e($row->name); ?>" />
        </div>
  <div class="form-group col-lg-6" style="font-size: 30px;margin-top:35px;">
    	<i class="fas fa-times-circle" onclick="remove(this)"></i></div>
       
       
       
       
         <div class="row col-12 pricing-list-item border-item mb-4">
          <div class="form-group col-lg-6">
            <label>الكود </label>
            <input type="text" class="form-control" name="category[<?php echo e($data); ?>][name]" placeholder="الكود" value="<?php echo e($row->name); ?>"/>
        </div>
  <div class="form-group col-lg-6" style="font-size: 30px;margin-top:35px;">
    	<i class="fas fa-times-circle" onclick="remove(this)"></i></div>
       <div class="form-group col-lg-12" style="background-color: rgba(21,97,203,0.1);border-radius:10px" id="calories<?php echo e($data); ?>">
           <?php $__currentLoopData = $row->calories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$rows): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
           
           <div class="row cal">
          <div class="form-group col-lg-6">
            <label>السعرات </label>
            <input type="text" class="form-control" name="category[<?php echo e($data); ?>][calorie][<?php echo e($key); ?>][name]" placeholder="السعرات" value="<?php echo e($rows->name); ?>" />
        </div>
        <div class="form-group col-lg-6" style="font-size: 30px;margin-top:35px;">
    	<i class="fas fa-times-circle" onclick="removing(this)"></i></div>
    	</div>
           
           <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
       </div>
       <div class="col-lg-12">
       <a style="cursor: pointer;"  data-id="<?php echo e($data); ?>" row-id="<?php echo e(count($row->calories)); ?>" onclick="addcalorie(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i>اضافة السعرات </a>
                   
</div>
                            </div>
                            
                            
                            
                            </div>
                     <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                     <?php endif; ?>
                </div>
<div class="col-lg-12">
       <a style="cursor: pointer;" <?php if($systemfood ?? ''  && $systemfood->id): ?> data-id="<?php echo e(count($categories)); ?>" <?php else: ?> data-id="0" <?php endif; ?> onclick="addmeal(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("meals.add_category")); ?></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'); ?>
<script>
    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)
          {
            $('#meals').append(data);
          }
        })
    }
    function addcalorie(elem){
        
        var num = $(elem).attr('data-id');
        var row = $(elem).attr('row-id');
        
        var newrow = parseInt(row)+1; 
        $(elem).attr('row-id', newrow);
        
         $.ajax({
          url : urlscal+'/'+num+','+row,
          type : 'GET',
          data : 'nothing',
          dataType : 'json',
          success:function(data)
          {
            $('#calories'+num).append(data);
          }
        })
    }
     function remove(elem){
            $(elem).closest('.row').remove();
        }
        function removing(elem){
            $(elem).closest('.cal').remove();
        }
</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('/')); ?>/",
            
            urls = "<?php echo e(url('/')); ?>/admin/addcategory",
            urlscal = "<?php echo e(url('/')); ?>/admin/addcalorie",
            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/systemfoods/form.blade.php ENDPATH**/ ?>