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

<div class="border-item">
    <form class="form-row add_page_form" method="post" action="<?php echo e($action); ?>" enctype="multipart/form-data">
        <?php if($page ?? ''  && $page->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">
            <label><?php echo e(meta('page_title', $language->local) ?? __('pages.page_title')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('page_title_'.$language->local) ? 'is-invalid' : ''); ?>" name="page_title_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('page_title', $language->local) ?? __('pages.page_title')); ?>" value='<?php echo e(old("page_title_{$language->local}", $page[$language->local]->page_title ?? "")); ?>'/>
        </div>

        <?php if($page[$language->local]->title): ?>
            <div class="form-group col">
                <label><?php echo e(meta('title', $language->local) ?? __('pages.title')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                <input type="text" class="form-control <?php echo e($errors->has('title_'.$language->local) ? 'is-invalid' : ''); ?>" name="title_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('title', $language->local) ?? __('pages.title')); ?>" value='<?php echo e(old("title_{$language->local}", $page[$language->local]->title ?? "")); ?>'/>
            </div>
        <?php endif; ?>
        <?php if($page[$language->local]->description): ?>
            <div class="form-group col-lg-12">
                <label><?php echo e(meta('description', $language->local) ?? __('pages.description')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                <textarea rows="10" name="description_<?php echo e($language->local); ?>" class="form-control <?php echo e($errors->has('description_'.$language->local) ? 'is-invalid' : ''); ?>" placeholder="<?php echo e(meta('description', $language->local) ?? __('pages.description')); ?>"><?php echo e(old("description_{$language->local}", $page[$language->local]->description ?? "")); ?></textarea>
            </div>
        <?php endif; ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php if(in_array($page->id, [2,4])): ?>
                <div class="property_container col-md-12">
                    <?php $__currentLoopData = $page->meta['titles']['ar']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $propertyKey => $propertyName): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="form-group col-lg-12 card deleted_property property_card">
                            <label><?php echo e(__('pages.properties')); ?></label>
                            <div class="row">
                                <div class="form-group col-md-12 d-flex justify-content-end">
                                    <a href="#" class="btn btn-danger delete_property mr-3"><i class="fa fa-times"></i></a>
                                </div>
                                <div class="form-group col-md-12">
                                    <input type="text" name="properties_ar[]" placeholder="<?php echo e(__('pages.property_title') . ' (' . languages('ar')->name . ')'); ?>" class="form-control" value="<?php echo e($propertyName); ?>"/>
                                </div>
                                <div class="form-group col-md-12">
                                    <input type="text" name="properties_en[]" placeholder="<?php echo e(__('pages.property_title') . ' (' . languages('en')->name . ')'); ?>" class="form-control" value="<?php echo e($page->meta['titles']['en'][$propertyKey]); ?>"/>
                                </div>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                </div>
                <div class="form-group col-lg-12">
                    <a href="#" class="btn btn-primary btn-block add_properties"><i class="fa fa-plus"></i> <?php echo e(__('pages.add_properties')); ?></a>
                </div>
            <?php endif; ?>

            
            <?php if($page->image): ?>
                <div class="form-group col-lg-12">
                    <label><?php echo e(meta('image', $lang) ?? __('pages.image')); ?> </label>
                    <input id="image_thumbnail" class="image_thumbnail" type="hidden" name="image" value="<?php echo e(old("image", $page->image ?? "")); ?>"/>

                    <div class="photos image_main_photo <?php echo e(old('image', $page->image ?? '') ? ' wow fadeInUp' : 'hide'); ?>">
                        <div class="col-lg-6">
                            <div class="items">
                                <div class="img">
                                    <a href="#" id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" class="lfm" data-hide=".image_pick_button">
                                        <img src="<?php echo e(asset(old('image', $page->image ?? ''))); ?> "  id="image_holder" class="image_holder"/>
                                    </a>
                                </div>
                                <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail" data-hide=".image_main_photo" data-show=".image_pick_button"><i class="fas fa-times"></i></a>
                            </div>
                        </div>
                    </div>

                    <div class="clearfix"></div>
                    <span class="input-group-btn image_pick_button <?php echo e(old('image', $page->image ?? '') ? 'hide' : ''); ?> ">
                <a id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" data-show=".image_main_photo" data-hide=".image_pick_button" class="lfm btn btn-primary text-light">
                    <i class="fas fa-camera-retro"></i> <?php echo e(__('dashboard.choose')); ?>

                </a>
            </span>
                </div>
            <?php endif; ?>
            

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

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

<?php $__env->startSection('inner_js'); ?>
    <script src="<?php echo e(asset('/assets/admin/js/lib/tinymce.min.js')); ?>"></script>
    
    <script>
        let route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>/",
            currentLanguage = "<?php echo e($lang); ?>",
            imageTitle = "<?php echo e(meta('image_title', $lang) ?? null); ?>",
            imagePath = "<?php echo e(asset('')); ?>",
            inputName = null;
    </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/photos.js')); ?>"></script>


    <script>

        sendAjax('.add_page_button', '.add_page_form');

        $('.add_properties').click(function (e) {
            e.preventDefault();
            let counter = (Math.random()*100000).toString(20).replace('.', '_');
            let serviceDiv = `
                <div class="form-group col-lg-12 card deleted_property property_card">
                    <label><?php echo e(__('pages.properties')); ?></label>
                   <div class="row">
                   <div class="form-group col-md-12 d-flex justify-content-end">
                   <a href="#" class="btn btn-danger delete_property mr-3"><i class="fa fa-times"></i></a>
                   </div>
                    <?php $__currentLoopData = $languages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="form-group col-md-12">
                            <input type="text" name="properties_<?php echo e($language->local); ?>[]" placeholder="<?php echo e(__('pages.property_title') . ' ' . "($language->name)"); ?>" class="form-control" value=""/>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                </div>`;

            $('.property_container').append(serviceDiv);

        });

        $(document).on('click', '.delete_property', function (e) {
            e.preventDefault();
            $(this).parents('.deleted_property').remove();
        });


        $('body').on('DOMNodeInserted', '.properties_container', function(e) {
            if ($(e.target).find('.lfm')) {
                $('.lfm').filemanager('image', {prefix: route_prefix});
            }
        });

    </script>

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




<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\wamp64\www\nesma_cnc\resources\views/admin/pages/form.blade.php ENDPATH**/ ?>