-- ============================================
-- Query to List All Users with Details
-- ============================================
-- Run this SQL query in phpMyAdmin or your database tool
-- to see all users and their login credentials

SELECT 
    id,
    name,
    email,
    contactNumber,
    role,
    isActive,
    passwordSet,
    isEmailVerified,
    isPhoneVerified,
    createdAt,
    updatedAt
FROM users
ORDER BY 
    CASE role
        WHEN 'admin' THEN 1
        WHEN 'manager' THEN 2
        WHEN 'supplier' THEN 3
        WHEN 'workshop' THEN 4
        WHEN 'customer' THEN 5
        ELSE 6
    END,
    createdAt DESC;

-- ============================================
-- Query to List Only Admin/Manager Users
-- ============================================
SELECT 
    id,
    name,
    email,
    contactNumber,
    role,
    isActive,
    passwordSet,
    createdAt
FROM users
WHERE role IN ('admin', 'manager')
ORDER BY createdAt DESC;

-- ============================================
-- Query to List Only Supplier Users
-- ============================================
SELECT 
    id,
    name,
    email,
    contactNumber,
    role,
    isActive,
    passwordSet,
    createdAt
FROM users
WHERE role = 'supplier'
ORDER BY createdAt DESC;

-- ============================================
-- Query to List Only Customer Users
-- ============================================
SELECT 
    id,
    name,
    email,
    contactNumber,
    role,
    isActive,
    passwordSet,
    createdAt
FROM users
WHERE role = 'customer'
ORDER BY createdAt DESC;

-- ============================================
-- Query to List Only Workshop Users
-- ============================================
SELECT 
    id,
    name,
    email,
    contactNumber,
    role,
    isActive,
    passwordSet,
    createdAt
FROM users
WHERE role = 'workshop'
ORDER BY createdAt DESC;

-- ============================================
-- NOTE: Passwords are hashed (bcrypt) and cannot be displayed
-- To reset a password, you need to:
-- 1. Generate a new bcrypt hash at https://bcrypt-generator.com/
-- 2. Update the password field with the new hash
-- ============================================
