
<?php $__env->startSection('title', 'لیست کاربران'); ?>

<?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 small">مدیریت و مشاهده تمام کاربران فروشگاه</p>
        </div>
        <span class="badge bg-label-primary fs-6"><?php echo e(number_format($users->total())); ?> کاربر</span>
    </div>

    
    <div class="card mb-4">
        <div class="card-body py-3">
            <form method="GET" action="<?php echo e(route('admin.users.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>
                            <option value="1" <?php echo e(request('status') === '1' ? 'selected' : ''); ?>>فعال</option>
                            <option value="0" <?php echo e(request('status') === '0' ? 'selected' : ''); ?>>غیرفعال</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <select name="verify" class="form-select">
                            <option value="">تأیید موبایل (همه)</option>
                            <option value="1" <?php echo e(request('verify') === '1' ? 'selected' : ''); ?>>تأیید شده</option>
                            <option value="0" <?php echo e(request('verify') === '0' ? 'selected' : ''); ?>>تأیید نشده</option>
                        </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') !== null && request('status') !== '' || request('verify') !== null && request('verify') !== ''): ?>
                        <a href="<?php echo e(route('admin.users.index')); ?>" class="btn btn-outline-secondary">پاک کردن</a>
                        <?php endif; ?>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="card">
        <div class="card-body p-0">
            <?php if($users->isEmpty()): ?>
            <div class="text-center py-5 text-muted">
                <i class="ti ti-users-off ti-lg mb-2 d-block"></i>
                کاربری یافت نشد.
            </div>
            <?php else: ?>
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0">
                    <thead class="table-light">
                        <tr>
                            <th>نام و نام خانوادگی</th>
                            <th>شماره موبایل</th>
                            <th>تعداد سفارش</th>
                            <th>تأیید موبایل</th>
                            <th>وضعیت</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr style="cursor:pointer" onclick="window.location='<?php echo e(route('admin.users.show', $user->mobile)); ?>'">
                            <td>
                                <div class="fw-medium"><?php echo e($user->first_name); ?> <?php echo e($user->last_name); ?></div>
                                <?php if($user->role === 'admin'): ?>
                                <span class="badge bg-label-dark">مدیر</span>
                                <?php endif; ?>
                            </td>
                            <td class="font-monospace small" dir="ltr"><?php echo e($user->mobile); ?></td>
                            <td>
                                <span class="badge bg-label-info"><?php echo e(number_format($user->orders_count)); ?></span>
                            </td>
                            <td>
                                <?php if($user->mobile_verify): ?>
                                <span class="badge bg-label-success"><i class="ti ti-circle-check ti-xs me-1"></i>تأیید شده</span>
                                <?php else: ?>
                                <span class="badge bg-label-warning"><i class="ti ti-clock ti-xs me-1"></i>تأیید نشده</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if($user->status): ?>
                                <span class="badge bg-label-success">فعال</span>
                                <?php else: ?>
                                <span class="badge bg-label-danger">غیرفعال</span>
                                <?php endif; ?>
                            </td>
                            <td onclick="event.stopPropagation()">
                                <a href="<?php echo e(route('admin.users.show', $user->mobile)); ?>" class="btn btn-sm btn-outline-primary">
                                    <i class="ti ti-eye ti-xs me-1"></i>مشاهده
                                </a>
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
            <?php if($users->hasPages()): ?>
            <div class="d-flex justify-content-center py-3">
                <?php echo e($users->links()); ?>

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