<?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); ?>" enctype="multipart/form-data">

            <?php if($work ?? ''  && $work->id): ?>
                <?php echo method_field('PUT'); ?>
            <?php endif; ?>
            <?php echo csrf_field(); ?>


            <?php $__currentLoopData = $languages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                <div class="form-group col-lg-6">
                    <label><?php echo e(meta('name', $language->local) ?? __('works.name')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                    <input type="text" class="form-control <?php echo e($errors->has('name_'.$language->local) ? 'is-invalid' : ''); ?>" name="name_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('name', $language->local) ?? __('works.name')); ?>" value='<?php echo e(old("name_{$language->local}", $work[$language->local]->name ?? "")); ?>'/>
                </div>

                <div class="form-group col-lg-12">
                    <label><?php echo e(meta('description', $language->local) ?? __('works.description')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                    <textarea class="form-control <?php echo e($errors->has('description_'.$language->local) ? 'is-invalid' : ''); ?>" name="description_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('description', $language->local) ?? __('works.description')); ?>" ><?php echo e(old("description_{$language->local}", $work[$language->local]->description ?? "")); ?></textarea>
                </div>

            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                <div class="col-12">
                    <div  class="row pricing-list-item border-item mb-4" style="background-color: white;height:auto">
                        <div class="col-lg-12">
                            <h3> <?php echo e(__('works.sections')); ?> </h3>
                            <div class="col-lg-12" style="height:100%;" id="sections">
                                <?php if($work ?? ''  && $work->id): ?>
                                    <?php $__currentLoopData = $sections; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$section): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div class="row pricing-list-item border-item mb-4"  style="background-color: rgba(21,97,203,0.1);height:auto">
                                            <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <div class="form-group col-lg-5" >
                                                    <label><?php echo e(__('works.section')); ?> <?php echo e($lang->local); ?></label>
                                                    <input name="sections[<?php echo e($key); ?>][section_<?php echo e($lang->local); ?>]" class="form-control"  required  placeholder="<?php echo e(__('works.section')); ?>" value="<?php echo e($section->descriptions($lang->id)->name); ?>" >
                                                </div>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <div class="form-group col-lg-2" 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">
                                                <div  class="row pricing-list-item border-item mb-4" style="background-color: white;height:auto">
                                                    <div class="col-lg-12">
                                                        <h3> <?php echo e(__('works.points')); ?> </h3>
                                                    </div>
                                                    <div class="col-lg-12" id="points<?php echo e($key); ?>">
                                                        <?php $__currentLoopData = $section->points; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $keyPoint=>$point): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <div class="row pricing-list-item border-item mb-4"  style="background-color: rgba(21,97,203,0.1);height:auto">
                                                                <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <div class="form-group col-lg-5" >
                                                                        <label><?php echo e(__('works.point')); ?> <?php echo e($lang->local); ?></label>
                                                                        <input name="sections[<?php echo e($key); ?>][point][<?php echo e($keyPoint); ?>][point_<?php echo e($lang->local); ?>]" class="form-control"  required  placeholder="<?php echo e(__('works.point')); ?>" value="<?php echo e($point->descriptions($lang->id)->name); ?>" >
                                                                    </div>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                                <div class="form-group col-lg-2" 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(); ?>
                                                    </div>
                                                </div>
                                                <div class="col-lg-12">
                                                    <a style="cursor: pointer;"  data-id="<?php echo e(count($section->points)); ?>" section-id="<?php echo e($key); ?>"  onclick="addpoint(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("works.addpoint")); ?></a>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-lg-12">
                            <a style="cursor: pointer;" <?php if($work ?? ''  && $work->id): ?> data-id="<?php echo e(count($sections)); ?>" <?php else: ?> data-id="0" <?php endif; ?> onclick="addsection(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("works.addsection")); ?></a>
                        </div>
                    </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'); ?>
    <!-- Editor JS files -->
    <script src="<?php echo e(asset('/assets/admin/js/lib/tinymce.min.js')); ?>"></script>
    <script>

        function addsection(elem){
            var num = $(elem).attr('data-id');
            var newrow = parseInt(num)+1;
            $(elem).attr('data-id', newrow);

            $.ajax({
                url : url_addsection,
                type : 'GET',
                data : 'key='+num,

                success:function(data)
                {
                    $('#sections').append(data);
                }
            })
        }
        function addpoint(elem){
            var num = $(elem).attr('data-id');
            var section_id = $(elem).attr('section-id');

            var newrow = parseInt(num)+1;
            $(elem).attr('data-id', newrow);

            $.ajax({
                url : url_addpoint,
                type : 'GET',
                data : 'keyPoint='+num+'&key='+section_id,

                success:function(data)
                {
                    $('#points'+section_id).append(data);
                }
            })
        }
        function remove(elem){
            $(elem).closest('.row').remove();
        }
    </script>
    <script>
        let route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>/",
            url_addpoint = <?php echo json_encode(url(getCurrentLocale().'/admin/addpoint/')); ?>,
            url_addsection = <?php echo json_encode(url(getCurrentLocale().'/admin/addsection/')); ?>,
            currentLanguage = "<?php echo e(getCurrentLocale()); ?>",
            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>
    <script src="<?php echo e(asset('assets/admin/js/articles.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/cobons.js')); ?>"></script>
<?php $__env->stopSection(); ?>




<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/wjeen/resources/views/admin/works/form.blade.php ENDPATH**/ ?>