<?php $__env->startSection('sub_content'); ?>
    <div class="customer-layout-body">
        <div class="customer-analytic-card-wrapper">
            <div class="customer-analytic-card">
                <p class="title"><?php echo app('translator')->get('All Tickets'); ?></p>
                <h4 class="value"><?php echo e($supportTickets->count()); ?></h4>
            </div>
            <div class="customer-analytic-card">
                <p class="title"><?php echo app('translator')->get('Ongoing Tickets'); ?></p>
                <h4 class="value"><?php echo e($supportTickets->count() - $user->closed_support_tickets_count); ?></h4>
            </div>
            <div class="customer-analytic-card">
                <p class="title"><?php echo app('translator')->get('Closed Tickets'); ?></p>
                <h4 class="value"><?php echo e($user->closed_support_tickets_count); ?></h4>
            </div>
            <div class="customer-analytic-card">
                <p class="title"><?php echo app('translator')->get('Happiness Ratings'); ?></p>
                <h4 class="value"> <?php echo e(showAmount($happinessRating)); ?>%</h4>
            </div>
        </div>

        <?php if($pendingTickets->count()): ?>
            <div class="card mb-10">
                <div class="card-header">
                    <p class="card-title"><?php echo app('translator')->get('Pending Tickets'); ?></p>
                </div>
                <div class="card-body p-0">
                    <div class="table-scroller">
                        <table class="table">
                            <tbody>
                                <?php $__currentLoopData = $pendingTickets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pendingTicket): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr data-ticket="<?php echo e($pendingTicket->ticket_number); ?>" class="ticketDetails">
                                        <td>
                                            <div class="ticket-board">
                                                <span class="ticket-board-icon">
                                                    <i class="fa-regular fa-envelope"></i>
                                                </span>
                                                <div class="ticket-board-content">
                                                    <p class="ticket-board-title">
                                                        # <?php echo e(__($pendingTicket->subject)); ?>

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

                                                        </p>
                                                        <p class="ticket-board-id fw-bold">
                                                            #<?php echo e($pendingTicket->ticket_number); ?>


                                                        </p>
                                                        <?php if($pendingTicket->admin): ?>
                                                            <a href="#" class="ticket-board-assign text--base">
                                                                <i class="fa fa-user-check"></i>
                                                                <?php echo e($pendingTicket->admin->name); ?>

                                                            </a>
                                                        <?php endif; ?>
                                                        <?php if(count($pendingTicket->tags)): ?>
                                                            <div class='ticket-board-tags'>
                                                                <?php $__currentLoopData = $pendingTicket->tags; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tag): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                    <span class='tag-style'><?php echo e(__($tag->name)); ?></span>
                                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                            </div>
                                                        <?php endif; ?>
                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="flex-align gap-2">
                                                <span class="thread-icon">
                                                    <?php echo $__env->make('admin.partials.svg.comment', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                                </span>
                                                <p class="fs-14 text--dark"><?php echo e($pendingTicket->replies_count); ?> <?php echo app('translator')->get('Threads'); ?></p>
                                            </div>
                                        </td>
                                        <td>
                                            <?php echo $pendingTicket->ticketStatus->statusBadge; ?>
                                        </td>
                                        <td>
                                            <p class="fs-14 text--dark"> <?php echo e(showDateTime($pendingTicket->created_at, 'd M Y')); ?></p>
                                            <p class="fs-12"><?php echo e(showDateTime($pendingTicket->created_at, 'h:i A')); ?></p>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        <?php endif; ?>

        <div class="row g-2">
            <div class="col-xl-6">
                <div class="card h-100">
                    <div class="card-header">
                        <p class="card-title"><?php echo app('translator')->get('Traffic Analysis'); ?></p>
                    </div>
                    <div class="card-body p-0">
                        <div id="trafficAnalysisChart" class="chart-container pie-chart"></div>
                    </div>
                </div>
            </div>
            <div class="col-xl-6">
                <div class="card h-100">
                    <div class="card-header">
                        <p class="card-title"><?php echo app('translator')->get('Average Handling Time'); ?></p>
                    </div>
                    <div class="card-body">
                        <div class="mb-60">
                            <div class="flex-between">
                                <p class="fs-12 text--dark"><?php echo app('translator')->get('First Response Time'); ?></p>
                                <p class="fs-12 text--dark"><?php echo e($responseTime['avg_first_response_text']); ?></p>
                            </div>
                            <div class="progress progress-sm mt-1" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
                                <div class="progress-bar bg--success progressBar" data-progress_bar="<?php echo e($responseTime['avg_first_response_ratio']); ?>"></div>
                            </div>
                        </div>
                        <div class="mb-60">
                            <div class="flex-between">
                                <p class="fs-12 text--dark"><?php echo app('translator')->get('Average Response Time'); ?></p>
                                <p class="fs-12 text--dark"><?php echo e($responseTime['avg_response_text']); ?></p>
                            </div>
                            <div class="progress progress-sm mt-1" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
                                <div class="progress-bar bg--warning progressBar" data-progress_bar="<?php echo e($responseTime['avg_response_ratio']); ?>"></div>
                            </div>
                        </div>
                        <div class="mb-60">
                            <div class="flex-between">
                                <p class="fs-12 text--dark"><?php echo app('translator')->get('Average Resolution Time'); ?></p>
                                <p class="fs-12 text--dark"><?php echo e($responseTime['resolution_time_text']); ?></p>
                            </div>
                            <div class="progress progress-sm mt-1" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
                                <div class="progress-bar bg--base progressBar" data-progress_bar="<?php echo e($responseTime['resolution_time_ratio']); ?>"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('style'); ?>
    <style>
        .ticketDetails{
            cursor: pointer;
        }
    </style>
<?php $__env->stopPush(); ?>


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

            let route = `<?php echo e(route('admin.ticket.details', '')); ?>`;

            $('.ticketDetails').on('click', function(e) {
                if ($(e.target).closest('.action-col').length) {
                    return;
                }
                let ticketNumber = $(this).data('ticket');
                window.location.href = route + '/' + ticketNumber;
            });

            $('.progressBar').each(function() {
                let progressBar = $(this).data('progress_bar');
                $(this).css('width', progressBar + '%');
            });

            renderPieChart({
                elementId: 'trafficAnalysisChart',
                data: [{
                        value: `<?php echo e($ticketCount['admin']); ?>`,
                        name: 'Admin Tickets',
                        itemStyle: {
                            color: '#CD375A'
                        }
                    },
                    {
                        value: `<?php echo e($ticketCount['web']); ?>`,
                        name: 'Web Tickets',
                        itemStyle: {
                            color: '#4FCE3B'
                        }
                    },
                    {
                        value: `<?php echo e($ticketCount['email']); ?>`,
                        name: 'Email Tickets',
                        itemStyle: {
                            color: '#3769CD'
                        }
                    }
                ],
            });


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

<?php echo $__env->make('admin.customer.index', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\projects\custom_viserdesk\Files\core\resources\views/admin/customer/overview.blade.php ENDPATH**/ ?>