<?php $__env->startSection('title', 'Home : What We Do'); ?>
<?php $__env->startSection('content'); ?>
<style>
    .list-top-header-wrap{
        position: inherit;
    }
    /*.what-we-do-list-wrap{
        height: 100%;
        overflow: inherit;
    }*/
</style>    
    <div class="middle-part-wrap">
        <div class="what-we-do-wrap what-we-do-page-wrap">
            <form>
                <div class="what-we-do-detail">
                    <div class="scroll">
                        <div class="list-top-header-wrap">
                            <div class="what-we-do-top-overview">
                                <h3>What We Do Short Overview</h3>
                                <div class="form-group">
                                    <input type="text" class="form-control" placeholder="Enter tag line here."
                                        id="whatwedo_tagline" name="whatwedo_tagline" value="<?php echo e(@$serviceTagline); ?>">
                                </div>
                            </div>
                            <div class="what-we-do-list-top-header">
                                <h3>What We Do List</h3>
                                <a href="<?php echo e(url('admin/home/addtoservice')); ?>">Add New Service</a>
                            </div>
                        </div>
                        <div class="what-we-do-list-wrap">
                            <?php if(count($serviceDetails) > 0): ?>
                                <ul>
                                    <?php $__currentLoopData = $serviceDetails; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $service): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <li>
                                            <div class="what-we-do-list-details">
                                                <div class="what-we-do-list-details-left">
                                                    <img src="<?php echo e(config('app.AWS_CONFIG.AWS_S3_URL') . $service->filePath); ?>">
                                                </div>
                                                <div class="what-we-do-list-details-middle">
                                                    <h5><?php echo e(@$service->title); ?></h5>
                                                    <h6>Overview</h6>
                                                    <p><?php echo e(@$service->overview); ?></p>
                                                </div>                                            
                                                <div class="what-we-do-list-details-right">
                                                    <div class="what-we-do-edit-btn">
                                                        <a data-id="<?php echo e($service->id); ?>" class="edit-delete-btn hideShowBtn"
                                                            href="javascript:void(0);">
                                                            <?php if($service->isHide == 1): ?>
                                                                Show
                                                            <?php else: ?>
                                                                Hide
                                                            <?php endif; ?>
                                                        </a>
                                                        <a class="edit-delete-btn activeInactiveClient"
                                                            href="javascript:void(0);" data-id="<?php echo e($service->id); ?>">Delete</a>
                                                        <a
                                                            href="<?php echo e(url('admin/home/editservice') . '/' . $service->pageUrl); ?>">Edit</a>
                                                    </div>
                                                    <?php if(!empty($service->capabilities)): ?>                                                
                                                    <?php
                                                    // Split the capabilities string into an array
                                                    $capabilities = explode("\n", $service->capabilities);
                                                    ?>                                                
                                                    <h6>Capabilities</h6>
                                                    <ul>
                                                        <?php $__currentLoopData = $capabilities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $capability): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <li>
                                                                <p><?php echo e($capability); ?></p>
                                                            </li>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </ul>
                                                    <?php endif; ?>
                                                </div>
                                            </div>
                                        </li>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </ul>
                            <?php endif; ?>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    
    <script type="text/javascript" src="<?php echo asset('js/tinymce.min.js'); ?>"></script>
    <script>
        $(document).ready(function() {
            activeLi('home');
            $(document).on('click', '.activeInactiveClient', function(e) {
                e.stopPropagation();
                var $this = $(this);
                var id = $this.attr('data-id');
                $('#confirmActiveInactive').attr('data-id', id);
                $('.activeInactiveModal .modal-body').text(
                    `Are you want to delete this service?`);
                $('.activeInactiveModal').modal('show');
            });

            $(document).on('click', '.close,#cancelActiveInactive', function(e) {
                e.preventDefault();
                $('#confirmActiveInactive').attr('data-id', '');
                $('.activeInactiveModal').modal('hide');
            });

            $(document).on('click', '#confirmActiveInactive', function(e) {
                e.preventDefault();
                $('.activeInactiveModal').modal('hide');
                var $this = $(this);
                var id = $this.attr('data-id');
                var url = "<?php echo e(url('admin/deleteService')); ?>";
                if (id) {
                    $('body').prepend('<div class="loader"></div>');
                    var formData = new FormData();
                    var token = "<?php echo e(csrf_token()); ?>";
                    formData.append('_token', token);
                    formData.append('id', id);
                    $.ajax({
                        url: url,
                        type: "POST",
                        cache: false,
                        contentType: false,
                        processData: false,
                        dataType: "json",
                        data: formData,
                        success: function(response) {
                            $('.loader').remove();
                            $('html, body').animate({
                                scrollTop: $('body').offset().top
                            }, 300);
                            displayMessageModal(response.message, 'success', 'selfReload');
                        },
                        error: function(error) {
                            $('.loader').remove();
                            displayMessageModal(error.responseJSON.message, 'error');
                        }
                    });
                }
            });

            $(document).on('click', '.hideShowBtn', function(e) {
                e.preventDefault();
                var $this = $(this);
                console.log($this.text());
                var id = $this.attr('data-id');
                var url = "<?php echo e(url('admin/hideShowService')); ?>";
                $('body').prepend('<div class="loader"></div>');
                var formData = new FormData();
                var token = "<?php echo e(csrf_token()); ?>";
                formData.append('_token', token);
                formData.append('id', id);
                $.ajax({
                    url: url,
                    type: "POST",
                    cache: false,
                    contentType: false,
                    processData: false,
                    dataType: "json",
                    data: formData,
                    success: function(response) {
                        $('.loader').remove();
                        $('html, body').animate({
                            scrollTop: $('body').offset().top
                        }, 300);
                        if ($.trim($this.text()) == 'Hide') {
                            $this.text('Show');
                        } else {
                            $this.text('Hide');
                        }
                    },
                    error: function(error) {
                        $('.loader').remove();
                    }
                });
            });

        });
        function tinyEditor(selector) {
            $('body').prepend('<div class="loader"></div>');
            tinymce.init({
                selector: `#${selector}`,
                height: 500,
                plugins: [
                    "advlist autolink link image lists charmap print preview hr anchor pagebreak",
                    "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                    "table emoticons template paste help directionality",
                    "charmap quickbars colorpicker textcolor autosave",
                ],
                toolbar: [
                    "undo redo | styleselect | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist | forecolor backcolor",
                    "outdent indent| fontselect fontsizeselect formatselect | link image media emoticons | fullscreen preview",
                    "table | hr pagebreak | code | insertdatetime anchor nonbreaking charmap",
                    "searchreplace visualblocks visualchars | removeformat | directionality ltr rtl | help",
                ].join(" | "),
                menubar: "file edit view insert format tools table help",
                branding: false,
                autosave_ask_before_unload: true,
                toolbar_mode: "sliding",
                visual: true,
                setup: (editor) => {
                    editor.on("init", () => {
                        const value = $(`#${selector}`).data("value");
                        if (value) {
                            editor.setContent(value);
                        }
                        $(".tox-promotion-link").remove();
                        $(".loader").remove();
                    });
                    editor.on("blur", (event) => {
                        var tagline = editor.getContent().trim();
                        var url = "<?php echo e(url('admin/updateTagline')); ?>";
                        var token = "<?php echo e(csrf_token()); ?>";
                        var span = document.createElement('span');
                        span.innerHTML = tagline;
                        if (span.textContent.trim().length) {
                            var formData = new FormData();
                            formData.append('_token', token);
                            formData.append('whatwedo_tagline', tagline);

                            $('body').prepend('<div class="loader"></div>');
                            
                            $.ajax({
                                url: url,
                                type: "POST",
                                cache: false,
                                contentType: false,
                                processData: false,
                                dataType: "json",
                                data: formData,
                                success: function(response) {
                                    $('.loader').remove();
                                    displayMessageModal(response.message, 'success');
                                },
                                error: function(error) {
                                    $('.loader').remove();
                                    displayMessageModal(error.responseJSON.message, 'error');
                                }
                            });
                        } else {
                            displayMessageModal("Please enter tagline.", 'error');
                        }
                    });
                },
            });
        }
        tinyEditor("whatwedo_tagline");
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/anser-backend/resources/views/home/whatwedo.blade.php ENDPATH**/ ?>