<?php $__env->startSection('css'); ?>
    <link href="<?php echo e(asset('assets/web/css/lib/image-uploader.min.css')); ?>" rel="stylesheet" type="text/css">
    <link href="<?php echo e(asset('assets/web/css/lib/other.css')); ?>" rel="stylesheet" type="text/css">
    <link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
    <section class="inner_header">
        <img src="<?php echo e(asset('assets/web/images/icons/inner.svg')); ?>" alt="" class="inner_shap">
        <div class="container">
            <ul class="links">
                <li>
                    <a href="<?php echo e(LaravelLocalization::getLocalizedURL($lang, route('home'), [], true)); ?>"><?php echo e(__('main.home')); ?></a>
                </li>
                <li>
                    <a href="#"> <?php echo e(__('otherRequests.others')); ?> </a>
                </li>
            </ul>
            <h4><?php echo e(__('otherRequests.others')); ?></h4>
        </div>
    </section>

    <section class="consultation-pg section_padding">
        <div class="container">
            <div class="form-container">
                <form method="post" action="<?php echo e(route('other.request')); ?>" class="request_request_form">
                    <div class="row mt-5 pt-3">
                        <div class="col-md-6">
                            <div class="form-group">
                                <h5 class="title text-dark mb-4"><b><?php echo e(__('otherRequests.other_request_topic_id')); ?></b></h5>
                                <select name="other_request_topic_id" class="form-control">
                                    <option value=""><?php echo e(__('otherRequests.other_request_topic_id')); ?></option>
                                    <?php if(count($requestTopics)): ?>
                                        <?php $__currentLoopData = $requestTopics; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $requestTopic): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($requestTopic->id); ?>"><?php echo e($requestTopic->name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <h5 class="title text-dark mb-4"><b><?php echo e(__('otherRequests.request_type')); ?></b></h5>
                            <input name="request_type" class="form-control" placeholder="<?php echo e(__('otherRequests.request_type')); ?>"/>
                        </div>
                    </div>
                    <div class="row mt-5 ">
                        <div class="col-md-6">
                            <h5 class="title text-dark mb-4"><b><?php echo e(__('otherRequests.details')); ?></b></h5>
                            <textarea name="details" class="form-control" rows="12"></textarea>
                        </div>
                        <div class="col-md-6">
                            <section>
                                <h5 class="title text-dark mb-2"><b><?php echo e(__('otherRequests.attachments')); ?></b></h5>
                                <div class="file_upload_content files_container">
                                    <div class="file-upload mt-2">
                                        <input name="files[]" class="form-control up_input" type="file" id="formFile"/>
                                        <button class="butn me-4"><?php echo e(__('otherRequests.attachment_file')); ?></button>
                                        <span class="dlt">
                                            <i class="bi bi-x-lg"></i>
                                        </span>
                                    </div>
                                    <span class="add_new_file main_color mt-3"><?php echo e(__('otherRequests.attachment_more_file')); ?></span>
                                </div>
                            </section>
                        </div>

                    </div>
                    <?php if(auth()->check() && auth()->user()->role == 'user'): ?>
                        <button class="submit-butn butn mt-5 m-auto d-block request_request_button" type="button"><span><b><?php echo e(__('otherRequests.send_request')); ?></b></span></button>
                    <?php else: ?>
                        <a href="<?php echo e(route('user.login')); ?>" class="submit-butn butn mt-5 m-auto d-block login_url" type="button"><span><b><?php echo e(__('otherRequests.send_request')); ?> </b></span></a>
                    <?php endif; ?>
                </form>
            </div>
        </div>
    </section>

    <div class="modal confirmConsult request_confirmation_modal fade" id="confirmConsult" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content">
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                <div class="modal-body">
                    <img src="<?php echo e(asset('assets/web/images/icons/confirm.png')); ?>" alt="" class="icon"/>
                    <div class="content text-center mt-4">
                        <h3 class="title text-dark mb-2"><b><?php echo e(__('otherRequests.request_send_successfully')); ?></b></h3>
                        <h5 class="title text-dark mb-2"><?php echo e(__('otherRequests.request_no')); ?> : <b class="request_no"></b></h5>
                    </div>
                </div>
            </div>
        </div>
    </div>

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

<?php $__env->startSection('inner_js'); ?>
    <script src="<?php echo e(asset('assets/web/js/lib/image-uploader.min.js')); ?>"></script>

    <script>

        let uploadAttachments = "<?php echo e(__('otherRequests.upload_attachments')); ?>",
            attachmentFile = "<?php echo e(__('otherRequests.attachment_file')); ?>";

        $(document).ready(function () {
            let other_request_topic_id = localStorage.getItem('other_request_topic_id'),
                request_type = localStorage.getItem('other_request_type'),
                details = localStorage.getItem('other_details');

            $('select[name="other_request_topic_id"]').val(other_request_topic_id);
            $('input[name="request_type"]').val(request_type);
            $('textarea[name="details"]').val(details);

        });

        $('.login_url').hover(function () {
            localStorage.setItem('other_request_topic_id',  $('select[name="other_request_topic_id"]').val());
            localStorage.setItem('other_request_type',  $('input[name="request_type"]').val());
            localStorage.setItem('other_details',  $('textarea[name="details"]').val());
        });

        $('.request_request_button').click(async function (e) {
            e.preventDefault();
            $(this).prop('disabled', true);
            let form = $('.request_request_form'),
                data = new FormData(form[0]),
                url = form.attr('action'),
                method = form.attr('method');

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

            if (response.errors) {
                $(this).prop('disabled', false);
                toasterError(response.errors);
            }
            if (response.success) {
                localStorage.setItem('other_request_topic_id', '');
                localStorage.setItem('other_request_type', '');
                localStorage.setItem('other_details', '');
                let myModal = new bootstrap.Modal(document.querySelector('.request_confirmation_modal'));
                myModal.show();
                $('.request_no').html(response.request_no);
            }
        });

        $('.request_confirmation_modal').on('hide.bs.modal', function () {
            window.location.reload();
        });

        $(".files_container").delegate(".add_new_file" , "click" ,   function(){
            $(this).parent(".files_container").append(`
            <div class="file-upload mt-4">
                <input class="form-control up_input" name="files[]" type="file" id="formCvtFile"/>
                <button class="butn me-4">${attachmentFile}</button>
                <span class="dlt"> <i class="bi bi-x-lg"></i> </span>
            </div>`);
        });

        $(".file_upload_content").on('click', '.file-upload .dlt',  function(){
            $(this).parent(".file-upload").remove();
        });

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

<?php echo $__env->make('web.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/balyomhost/public_html/legal/resources/views/web/others/index.blade.php ENDPATH**/ ?>