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

<div class="border-item">
    <form class="form-row service_form" method="post" action="<?php echo e($action); ?>" enctype="multipart/form-data">
        <?php if($service ?? ''  && $service->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('title', $language->local) ?? __('services.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) ?? __('services.title')); ?>" value='<?php echo e(old("title_{$language->local}", $service[$language->local]->title ?? "")); ?>'/>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

        <div class="description_container col-md-12">
            <?php if(($service ?? null) && count($service->description)): ?>
                <?php $__currentLoopData = $service->descriptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $descriptions): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="form-group col-lg-12 card deleted_description descriptions_card">
                        <label><?php echo e(__('services.descriptions')); ?></label>
                        <div class="row">
                            <?php if($loop->iteration != 1): ?>
                                <div class="form-group col-md-12 d-flex justify-content-end">
                                    <a href="#" class="btn btn-danger delete_description mr-3"><i class="fa fa-times"></i></a>
                                </div>
                            <?php endif; ?>
                            <div class="form-group col-lg-3">
                                <label><?php echo e(__('services.description_icon')); ?> </label>
                                <input id="image_thumbnail_<?php echo e($loop->iteration); ?>" class="image_thumbnail_<?php echo e($loop->iteration); ?>" type="hidden" name="icon[]" value="<?php echo e($descriptions['icon'] ?? ""); ?>"/>
                                <div class="photos main_photo_<?php echo e($loop->iteration); ?> <?php echo e($descriptions['icon'] ?? '' ? ' wow fadeInUp' : 'hide'); ?>">
                                    <div class="col-lg-12">
                                        <div class="items">
                                            <div class="img">
                                                <a href="#" id="lfm" data-input=".image_thumbnail_<?php echo e($loop->iteration); ?>" data-preview=".image_holder_<?php echo e($loop->iteration); ?>" class="lfm" data-hide=".pick_button">
                                                    <img src="<?php echo e(asset($descriptions['icon'] ?? '')); ?> "  id="image_holder_<?php echo e($loop->iteration); ?>" class="image_holder_<?php echo e($loop->iteration); ?>"/>
                                                </a>
                                            </div>
                                            <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail_<?php echo e($loop->iteration); ?>" data-hide=".main_photo_<?php echo e($loop->iteration); ?>" data-show=".pick_button_<?php echo e($loop->iteration); ?>"><i class="fas fa-times"></i></a>
                                        </div>
                                    </div>
                                </div>

                                <div class="clearfix"></div>
                                <span class="input-group-btn pick_button_<?php echo e($loop->iteration); ?> <?php echo e(($descriptions['icon'] ?? "") ? 'hide' : ''); ?> ">
                                    <a id="lfm" data-input=".image_thumbnail_<?php echo e($loop->iteration); ?>" data-preview=".image_holder_<?php echo e($loop->iteration); ?>" data-show=".main_photo_<?php echo e($loop->iteration); ?>" data-hide=".pick_button_<?php echo e($loop->iteration); ?>" class="lfm btn btn-primary text-light">
                                        <i class="fas fa-camera-retro"></i> Choose
                                    </a>
                                </span>
                            </div>
                            <div class="col-md-9">
                                <div class="row">
                                    <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div class="form-group col-md-6">
                                            <input type="text" name="desc_<?php echo e($lang->local); ?>[]" placeholder="<?php echo e(__('services.descriptions') . ' (' . $lang->name . ')'); ?>" class="form-control" value="<?php echo e($descriptions['desc_'.$lang->local]); ?>"/>
                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php else: ?>
                <div class="form-group col-lg-12 card descriptions_card">
                    <label><?php echo e(__('services.descriptions')); ?></label>
                    <div class="row">
                        <div class="form-group col-lg-3">
                            <label><?php echo e(__('services.description_icon')); ?> </label>
                            <input id="image_thumbnail_1" class="image_thumbnail_1" type="hidden" name="icon[]" value=""/>
                            <div class="photos main_photo_1 hide">
                                <div class="col-lg-12">
                                    <div class="items">
                                        <div class="img">
                                            <a href="#" id="lfm" data-input=".image_thumbnail_1" data-preview=".image_holder_1" class="lfm" data-hide=".pick_button_1">
                                                <img src=""  id="image_holder_1" class="image_holder_1"/>
                                            </a>
                                        </div>
                                        <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail_1" data-hide=".main_photo_1" data-show=".pick_button_1"><i class="fas fa-times"></i></a>
                                    </div>
                                </div>
                            </div>

                            <div class="clearfix"></div>
                            <span class="input-group-btn pick_button_1">
                            <a id="lfm" data-input=".image_thumbnail_1" data-preview=".image_holder_1" data-show=".main_photo_1" data-hide=".pick_button_1" class="lfm btn btn-primary text-light">
                                <i class="fas fa-camera-retro"></i> Choose
                            </a>
                         </span>
                        </div>
                        <div class="col-md-9">
                            <div class="row">
                                <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="form-group col-md-6">
                                        <input type="text" name="desc_<?php echo e($lang->local); ?>[]" placeholder="<?php echo e(__('services.descriptions') . ' (' . $lang->name . ')'); ?>" class="form-control" value=""/>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

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

        
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('image', getCurrentLocale()) ?? __('services.image')); ?> </label>
            <input id="image_thumbnail" class="image_thumbnail" type="hidden" name="image" value="<?php echo e(old("image", $service->image ?? "")); ?>"/>

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

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

        <div class="text-center mt-5 col-12">
            <button class="butn service_button"><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>
        var route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>";
        var url = "<?php echo e(url('/')); ?>/",
        currentLanguage = "<?php echo e(getCurrentLocale()); ?>",
        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>
        $('.add_descriptions').click(function (e) {
            e.preventDefault();
            let counter = parseInt(Math.random()*99999)*parseInt(new Date().getSeconds());
            let descriptionDiv = `
                <div class="form-group col-lg-12 card descriptions_card deleted_description">
                    <label><?php echo e(__('services.descriptions')); ?></label>
                    <div class="row">
                        <div class="form-group col-md-12 d-flex justify-content-end">
                            <a href="#" class="btn btn-danger delete_description mr-3"><i class="fa fa-times"></i></a>
                        </div>
                        <div class="form-group col-lg-3">
                        <label><?php echo e(__('services.description_icon')); ?> </label>
                        <input id="image_thumbnail_`+counter+`" class="image_thumbnail_`+counter+`" type="hidden" name="icon[]" value=""/>

                        <div class="photos main_photo_`+counter+` hide">
                            <div class="col-lg-12">
                                <div class="items">
                                    <div class="img">
                                        <a href="#" id="lfm" data-input=".image_thumbnail_`+counter+`" data-preview=".image_holder_`+counter+`" class="lfm" data-hide=".pick_button_`+counter+`">
                                            <img src=""  id="image_holder_`+counter+`" class="image_holder_`+counter+`"/>
                                        </a>
                                    </div>
                                    <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail_`+counter+`" data-hide=".main_photo_`+counter+`" data-show=".pick_button_`+counter+`"><i class="fas fa-times"></i></a>
                                </div>
                            </div>
                        </div>

                        <div class="clearfix"></div>
                        <span class="input-group-btn pick_button_`+counter+`">
                            <a id="lfm" data-input=".image_thumbnail_`+counter+`" data-preview=".image_holder_`+counter+`" data-show=".main_photo_`+counter+`" data-hide=".pick_button_`+counter+`" class="lfm btn btn-primary text-light">
                                <i class="fas fa-camera-retro"></i> Choose
                            </a>
                        </span>
                    </div>
                    <div class="col-md-9">
                    <div class="row">
                        <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="form-group col-md-6">
                                <input type="text" name="desc_<?php echo e($lang->local); ?>[]" placeholder="<?php echo e(__('services.descriptions') . ' (' . $lang->name . ')'); ?>" class="form-control" value=""/>
                            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    </div>
                        </div>
                    </div>
                </div>`;

            $('.description_container').append(descriptionDiv);

        });

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

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



        $('.service_button').click(async function (e) {
            e.preventDefault();

            let form = $('.service_form'),
                data = new FormData(form[0]),
                url = form.attr('action'),
                method = form.attr('method');

            const response=await ajax({
                url,
                data,
                dataType: 'json',
                method
            });

            if (response.url){
                window.location.href = response.url;
            }

            if (response.errors){
                toasterError(response.errors);
            }
        });

    </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\marketzy\resources\views/admin/services/form.blade.php ENDPATH**/ ?>