<?php $__env->startSection('title'); ?>درخواست‌های پشتیبانی<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="container-xxl flex-grow-1 container-p-y">

    <div class="d-flex align-items-center justify-content-between mb-4">
        <div>
            <h4 class="mb-1">درخواست‌های پشتیبانی</h4>
            <p class="text-muted mb-0">لیست تمام تیکت‌های کاربران</p>
        </div>
        <a href="<?php echo e(route('admin.tickets.new')); ?>" class="btn btn-primary">
            <i class="ti ti-plus me-1"></i> تیکت جدید
        </a>
    </div>

    <?php if(session('success')): ?>
        <div class="alert alert-success alert-dismissible mb-4">
            <?php echo e(session('success')); ?>

            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    
    <div class="card mb-4">
        <div class="card-body py-3">
            <form method="GET" action="<?php echo e(route('admin.tickets.index')); ?>">
                <div class="row g-2 align-items-center">
                    <div class="col-md-4">
                        <input type="text" name="q" class="form-control"
                               placeholder="شماره تیکت، موضوع، نام یا موبایل..." value="<?php echo e(request('q')); ?>">
                    </div>
                    <div class="col-md-3">
                        <select name="status" class="form-select">
                            <option value="">همه وضعیت‌ها</option>
                            <?php $__currentLoopData = $statuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $val => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($val); ?>" <?php echo e(request('status') === $val ? 'selected' : ''); ?>><?php echo e($label); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <select name="department_id" class="form-select">
                            <option value="">همه دپارتمان‌ها</option>
                            <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $dept): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($dept->id); ?>" <?php echo e((string) request('department_id') === (string) $dept->id ? 'selected' : ''); ?>><?php echo e($dept->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-auto d-flex gap-2">
                        <button type="submit" class="btn btn-primary"><i class="ti ti-search ti-xs"></i></button>
                        <?php if(request('q') || request('status') || request('department_id')): ?>
                        <a href="<?php echo e(route('admin.tickets.index')); ?>" class="btn btn-outline-secondary">پاک کردن</a>
                        <?php endif; ?>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="card">
        <div class="table-responsive">
            <table class="table border-top align-middle mb-0">
                <thead class="table-light">
                    <tr>
                        <th>شناسه</th>
                        <th>موضوع</th>
                        <th>کاربر</th>
                        <th>موبایل</th>
                        <th>دپارتمان</th>
                        <th>پاسخ‌ها</th>
                        <th>وضعیت</th>
                        <th>آخرین به‌روزرسانی</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $tickets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ticket): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><span class="badge bg-label-secondary font-monospace" dir="ltr"><?php echo e($ticket->name); ?></span></td>
                            <td>
                                <a href="<?php echo e(route('admin.tickets.show', $ticket->name)); ?>" class="fw-medium text-body">
                                    <?php echo e($ticket->subject); ?>

                                </a>
                            </td>
                            <td><?php echo e(optional($ticket->user)->first_name); ?> <?php echo e(optional($ticket->user)->last_name); ?></td>
                            <td><small class="text-muted" dir="ltr"><?php echo e(optional($ticket->user)->mobile); ?></small></td>
                            <td>
                                <?php if($ticket->department): ?>
                                    <span class="text-muted"><?php echo e($ticket->department->name); ?></span>
                                <?php else: ?> <span class="text-muted">—</span> <?php endif; ?>
                            </td>
                            <td><span class="badge bg-label-secondary"><?php echo e($ticket->replies_count); ?></span></td>
                            <td><span class="badge bg-label-<?php echo e($ticket->statusColor()); ?>"><?php echo e($ticket->statusLabel()); ?></span></td>
                            <td><small class="text-muted"><?php echo e($ticket->shamsi_updated ?: $ticket->shamsi_created); ?></small></td>
                            <td>
                                <a href="<?php echo e(route('admin.tickets.show', $ticket->name)); ?>" class="btn btn-sm btn-icon btn-outline-primary">
                                    <i class="ti ti-eye ti-xs"></i>
                                </a>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="9" class="text-center py-5 text-muted">
                                <i class="ti ti-ticket-off fs-3 d-block mb-2"></i>
                                هیچ تیکتی ثبت نشده است.
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <?php if($tickets->hasPages()): ?>
        <div class="card-footer d-flex justify-content-between align-items-center">
            <span class="text-muted small"><?php echo e($tickets->total()); ?> تیکت</span>
            <?php echo e($tickets->links()); ?>

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

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

<?php echo $__env->make('admin.layouts.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/louishop/public_html/engine/resources/views/admin/tickets/index.blade.php ENDPATH**/ ?>