<?php $__env->startSection('content'); ?>
    <section class="breadcrumb-area">
        <div class="container">
            <div class="breadcrumb-area-content">
                <h3 class="breadcrumb-area-title">
                    <?php echo app('translator')->get('Support Tickets History'); ?>
                </h3>
                <p class="breadcrumb-area-desc mt-3">
                    <?php echo app('translator')->get('View your support ticket history and track the status of your inquiries. Our team is always ready to help resolve any issues you may have.'); ?>
                </p>
            </div>
        </div>
    </section>

    <section class="py-60">
        <div class="container">
            <div class="flex-wrap justify-content-end mb-3">
                <a href="<?php echo e(route('user.ticket.department')); ?>" class="btn btn--base btn--sm">
                    <span class="me-1">
                        <?php echo $__env->make('admin.partials.svg.ticket', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    </span>
                    <?php echo app('translator')->get('Create Ticket'); ?>
                </a>
            </div>
            <div class="user-table-wrapper">
                <table class="table ticket-table">
                    <thead>
                        <tr>
                            <th><?php echo app('translator')->get('Ticket'); ?></th>
                            <th><?php echo app('translator')->get('Last Message'); ?></th>
                            <th><?php echo app('translator')->get('Status'); ?></th>
                            <th><?php echo app('translator')->get('Action'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $supportTickets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ticket): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td>
                                    <div class="ticket-board">
                                        <div class="ticket-board-content">
                                            <a href="<?php echo e(route('user.ticket.view', $ticket->ticket_number)); ?>" class="ticket-board-title">
                                                <span class="priorityName"  data-hsl_color="<?php echo e(json_encode($ticket->priority->converted_color)); ?>">
                                                    <span class="animated-circle">
                                                    </span>
                                                </span>
                                                <?php echo e(__($ticket->subject)); ?>

                                            </a>
                                            <div class="ticket-board-list">
                                                <p class="ticket-board-type">
                                                    <?php echo e(__($ticket->department?->name)); ?>

                                                </p>
                                                <a href="<?php echo e(route('user.ticket.view', $ticket->ticket_number)); ?>" class="ticket-board-id fw-bold">
                                                    #<?php echo e($ticket->ticket_number); ?>

                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </td>

                                <td>
                                    <?php
                                        $lastReply = $ticket->replies->last();
                                    ?>

                                    <?php if($lastReply): ?>
                                        <?php echo e(diffForHumans($lastReply->created_at)); ?>

                                    <?php else: ?>
                                        ----
                                    <?php endif; ?>
                                </td>

                                <td>
                                    <span class="badge statusName" data-ticket_number="<?php echo e($ticket->ticket_number); ?>" data-hsl_color="<?php echo e(json_encode($ticket->ticketStatus->converted_color)); ?>"><?php echo e(__($ticket->ticketStatus->name)); ?></span>
                                </td>

                                <td>
                                    <div class="flex-end gap-2">
                                        <a href="<?php echo e(route('user.ticket.view', $ticket->ticket_number)); ?>" class="btn btn--secondary btn--sm me-1"><?php echo app('translator')->get('View'); ?></a>
                                        <?php if($ticket->ticketStatus->slug == 'closed'): ?>
                                            <button class="btn btn--success btn--sm feedbackBtn" data-ticket_number="<?php echo e($ticket->ticket_number); ?>" data-customer_happiness="<?php echo e($ticket->customer_happiness ?? 'great'); ?>" data-feedback="<?php echo e($ticket->feedback); ?>"><?php echo app('translator')->get('Feedback'); ?></button>
                                        <?php else: ?>
                                            <button class="btn btn--danger btn--sm confirmationBtn" data-question="<?php echo app('translator')->get('Are you sure to close the ticket?'); ?>" data-action="<?php echo e(route('user.ticket.close', $ticket->ticket_number)); ?>"><?php echo app('translator')->get('Close'); ?></button>
                                        <?php endif; ?>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="100%">
                                    <?php if (isset($component)) { $__componentOriginal785b8965d65806a202a14875024d2012 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal785b8965d65806a202a14875024d2012 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.empty-message','data' => ['message' => 'No support ticket found']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('empty-message'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['message' => 'No support ticket found']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal785b8965d65806a202a14875024d2012)): ?>
<?php $attributes = $__attributesOriginal785b8965d65806a202a14875024d2012; ?>
<?php unset($__attributesOriginal785b8965d65806a202a14875024d2012); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal785b8965d65806a202a14875024d2012)): ?>
<?php $component = $__componentOriginal785b8965d65806a202a14875024d2012; ?>
<?php unset($__componentOriginal785b8965d65806a202a14875024d2012); ?>
<?php endif; ?>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <?php if($supportTickets->hasPages()): ?>
                <div class="pagination-wrapper border-0">
                    <?php echo e(paginateLinks($supportTickets)); ?>

                </div>
            <?php endif; ?>
        </div>
    </section>

    <div id="feedbackModal" class="modal custom--modal fade" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><?php echo app('translator')->get('How was your experience with us?'); ?></h5>
                    <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
                        <i class="las la-times"></i>
                    </button>
                </div>
                <form method="POST">
                    <?php echo csrf_field(); ?>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="form--label style-two"><?php echo app('translator')->get('Rating'); ?></label>

                            <div class="rating-emoji-wrapper">
                                <label for="smile-emoji" class="rating-emoji">
                                    <input class="form-check-input d-none" name="customer_happiness" type="radio" value="great" id="smile-emoji">
                                    <?php echo $__env->make('admin.partials.svg.great', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    <span class="rating-emoji-check">
                                        <i class="fas fa-check"></i>
                                    </span>
                                </label>

                                <label for="okay" class="rating-emoji">
                                    <input class="form-check-input d-none" name="customer_happiness" type="radio" value="okay" id="okay">
                                    <?php echo $__env->make('admin.partials.svg.okay', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    <span class="rating-emoji-check">
                                        <i class="fas fa-check"></i>
                                    </span>
                                </label>

                                <label for="bad" class="rating-emoji">
                                    <input class="form-check-input d-none" name="customer_happiness" type="radio" value="bad" id="bad">
                                    <?php echo $__env->make('admin.partials.svg.bad', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    <span class="rating-emoji-check">
                                        <i class="fas fa-check"></i>
                                    </span>
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="form--label style-two"><?php echo app('translator')->get('Feedback'); ?></label>
                            <textarea name="feedback" class="form--control md-style"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn--md btn--base w-100"><?php echo app('translator')->get('Submit'); ?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>


    <?php if (isset($component)) { $__componentOriginalbd5922df145d522b37bf664b524be380 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalbd5922df145d522b37bf664b524be380 = $attributes; } ?>
<?php $component = App\View\Components\ConfirmationModal::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('confirmation-modal'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\ConfirmationModal::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalbd5922df145d522b37bf664b524be380)): ?>
<?php $attributes = $__attributesOriginalbd5922df145d522b37bf664b524be380; ?>
<?php unset($__attributesOriginalbd5922df145d522b37bf664b524be380); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalbd5922df145d522b37bf664b524be380)): ?>
<?php $component = $__componentOriginalbd5922df145d522b37bf664b524be380; ?>
<?php unset($__componentOriginalbd5922df145d522b37bf664b524be380); ?>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('style'); ?>
    <style>
        .user-table-wrapper {
            overflow-x: auto;
        }

        .user-table-wrapper .table {
            min-width: 700px;
            border: 1px solid hsl(var(--border-color));
            border-radius: 8px;
            overflow: hidden;
        }

        @media (min-width: 992px) {
            .user-table-wrapper .table thead th {
                font-size: 14px;
                font-weight: 500;
                color: hsl(var(--text-color));
            }

            .user-table-wrapper .table tbody td {
                font-size: 14px;
            }
        }

        .ticket-table tbody tr {
            cursor: unset;
        }
    </style>
<?php $__env->stopPush(); ?>


<?php $__env->startPush('script'); ?>
    <script>
        (function($) {
            "use strict";

            let modal = $('#feedbackModal');
            let action = `<?php echo e(route('user.ticket.feedback', '')); ?>`;
            $('.feedbackBtn').on('click', function() {
                let ticketNumber = $(this).data('ticket_number');
                let rating = $(this).data('customer_happiness');
                let feedback = $(this).data('feedback');
                modal.find('form')[0].reset();
                modal.find(`input[name="customer_happiness"][value="${rating}"]`).prop('checked', true);
                modal.find('textarea[name="feedback"]').val(feedback);
                modal.find('form').attr('action', action + '/' + ticketNumber)
                modal.modal('show');
            });

        })(jQuery);
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make($activeTemplate . 'layouts.frontend', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\projects\custom_viserdesk\Files\core\resources\views/templates/basic/user/ticket/list.blade.php ENDPATH**/ ?>