<?php $__env->startSection('css'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('assets/web/css/case_request_and_updates.css')); ?>">
<?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($title); ?> </a>
                </li>
            </ul>
            <h4><?php echo e($title); ?></h4>
        </div>
    </section>

    <section class="consultation-sec section_padding">
        <div class="container">
            <?php if(count($cases)): ?>
                <?php $__currentLoopData = $cases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $case): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="box issue_order mb-3">
                        <div class="issue_head">
                            <div class="row align-items-center">
                                <div class="col-lg-8">
                                    <div class="issue_title">
                                        <h3> <img src="<?php echo e(asset('assets/web/images/sec_head_sh.svg')); ?>" alt="" class="me-2">  <span><?php echo e($case->case_subject); ?></span> </h3>
                                    </div>
                                </div>
                                <div class="col-lg-4 text-lg-end">
                                    <h5 class="issue_number"><?php echo e(__('caseRequests.case_no') . ': ' . $case->id); ?></h5>
                                </div>
                            </div>
                        </div>
                        <div class="issue_body">
                            <div class="issue_card mb-4">
                                <h5 class="sub_title mb-3"><?php echo e(__('caseRequests.request_type')); ?></h5>
                                <p class="text"><?php echo e(__('caseRequests.'.$case->request_type)); ?></p>
                            </div>
                            <div class="issue_card mb-4">
                                <h5 class="sub_title mb-3"><?php echo e(__('caseRequests.details')); ?></h5>
                                <p class="text"><?php echo e($case->details); ?></p>
                            </div>
                            <div class="issue_card mb-4">
                                <h5 class="sub_title mb-3"><?php echo e(__('caseRequests.requests')); ?></h5>
                                <p class="text"><?php echo e($case->requests); ?></p>
                            </div>
                            <div class="issue_card mt-5">
                                <div class="d-flex mb-3 justify-content-between">
                                    <h5 class="sub_title mb-0"> <?php echo e(__('caseRequests.files')); ?> </h5>
                                    <a data-form=".update_form_<?php echo e($loop->iteration); ?>" class="butn sub_butn btn-sm add_more_files  px-2 py-2" href="#0"><span><?php echo e(__('caseRequests.attachment_more_file')); ?></span></a>
                                </div>


                                

                                <form class="d-none mt-3 uploadFileForm update_form_<?php echo e($loop->iteration); ?>" action="<?php echo e(route('cases.updateCaseRequest', $case->id)); ?>" method="post" enctype="multipart/form-data">
                                    <!--<input multiple type="file" name="files[]">-->
                                    <div class="col-lg-12">
                                        <label class="uploadFile">
                                            <i class="fas fa-file-upload fa-md mr-2"></i>
                                            <span class="filename"><?php echo e(__('caseRequests.attachment')); ?></span>
                                            <input type="file" class="inputfile form-control" name="file" >
                                            <input data-target=".case_file_container_<?php echo e($loop->iteration); ?>" type="submit" class="update_request butn" value="<?php echo e(__('caseRequests.upload_attachments')); ?>">
                                        </label>
                                    </div>
                                </form>
                                

                                <div class="files_sended">
                                    <div class="row case_file_container_<?php echo e($loop->iteration); ?>">
                                        <?php if(is_array($case->request_files) && count($case->request_files)): ?>
                                            <?php $__currentLoopData = $case->request_files; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $requestFile): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php if(strpos($requestFile, '.pdf')): ?>
                                                    <div class="col-lg-3">
                                                        <a download href="<?php echo e(asset($requestFile)); ?>" class="img">
                                                            <i class="bi bi-file-pdf fs-5 me-2"></i>
                                                            <h6> <?php echo e(__('caseRequests.file')); ?> </h6>
                                                        </a>
                                                    </div>
                                                <?php else: ?>
                                                    <div class="col-lg-3">
                                                        <a href="<?php echo e(asset($requestFile)); ?>" class="img" data-fancybox>
                                                            <i class="bi bi-image fs-5 me-2"></i>
                                                            <h6> <?php echo e(__('caseRequests.image')); ?> </h6>
                                                        </a>
                                                    </div>
                                                <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php else: ?>
                                            <div class="alert alert-secondary text-danger text-center"><?php echo e(__('caseRequests.no_data')); ?></div>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                                <div class="issue_card mt-5">
                                    <h5 class="sub_title mb-4"><?php echo e(__('members.case_updates')); ?></h5>
                                    <div class=" issue_updates row">
                                        <?php if(count($case->caseUpdates)): ?>
                                        <?php $__currentLoopData = $case->caseUpdates; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $updatesFile): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <div class="col-lg-3">
                                                <a <?php echo e(!strpos($updatesFile->file, 'pdf') ? 'download' : 'target="_blank"'); ?> href="<?php echo e(asset($updatesFile->file)); ?>" class="issue_card d-block mb-4">
                                                    <div class="img">
                                                        <img src="<?php echo e(asset('assets/web/images/documents.png')); ?>" alt="">
                                                    </div>
                                                    <div class="info">
                                                        <h6><?php echo e($updatesFile->name); ?></h6>
                                                        <div class="time mt-3 small">
                                                            <span class="me-3">
                                                                <i class="bi bi-clock me-1 small"></i>
                                                                <span><?php echo e(date('h:i A', strtotime($updatesFile->created_at))); ?></span>
                                                            </span>
                                                            <span>
                                                                <i class="bi bi-calendar me-1 small"></i>
                                                                <span><?php echo e(date('Y M d', strtotime($updatesFile->created_at))); ?></span>
                                                            </span>
                                                        </div>
                                                    </div>
                                                </a>
                                            </div>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php else: ?>
                                            <div class="alert alert-secondary text-danger text-center"><?php echo e(__('caseRequests.no_data')); ?></div>
                                        <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php else: ?>
                <div class="alert alert-secondary text-danger text-center"><?php echo e(__('caseRequests.no_data')); ?></div>
            <?php endif; ?>
        </div>
    </section>

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

<?php $__env->startSection('inner_js'); ?>

    <script>


        $('.update_request').click(async function (e) {
            e.preventDefault();
            $(this).prop('disabled', true);
            let form = $(this).parents('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.request_files) {
                form.addClass('d-none');
                toasterSuccess(response.message);
                $(this).prop('disabled', false);
                // for(let i = 0; i < response.new_files.type.length; i++){
                    if(response.type === 'pdf'){
                        $($(this).data('target')).append(`
                        <div class="col-lg-3">
                            <a download href="${response.request_files}" class="img">
                                <i class="bi bi-file-pdf fs-5 me-2"></i>
                                <h6> <?php echo e(__('caseRequests.file')); ?> </h6>
                            </a>
                        </div>
                    `)
                    }
                    if(response.type === 'image'){
                        $($(this).data('target')).append(`
                        <div class="col-lg-3">
                            <a href="${response.request_files}" class="img" data-fancybox">
                                <i class="bi bi-image fs-5 me-2"></i>
                                <h6> <?php echo e(__('caseRequests.image')); ?> </h6>
                            </a>
                        </div>
                    `)
                    }

                // }
            }
        });

        $('.add_more_files').click(function (e) {
            e.preventDefault();
            $($(this).data('form')).toggleClass('d-none');

        });

        $("input[type=file]").change(function (e) {
            $(this).parents(".uploadFile").find(".filename").text(e.target.files[0].name);
        });


    </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/users/case_requests_and_updates/index.blade.php ENDPATH**/ ?>