<!DOCTYPE html>
<html>
<head>
    <title>Edit User</title>
</head>
<body>
<h3>Edit User</h3>

<form method="POST" action="<?= base_url('admin/update_user/' . base64_encode($user->id)) ?>">
    <label for="name">Name</label>
    <input type="text" id="name" name="name" value="<?= $user->name ?>" required>
    <br>
    
    <label for="email">Email</label>
    <input type="email" id="email" name="email" value="<?= $user->email ?>" required>
    <br>
    
    <label for="role">Role</label>
    <select id="role" name="role_id" required>
        <?php foreach ($roles as $role): ?>
            <option value="<?= $role->id ?>" <?= $user->role_id == $role->id ? 'selected' : '' ?>>
                <?= $role->name ?>
            </option>
        <?php endforeach; ?>
    </select>
    <br>

    <label for="password">Password (Leave blank to keep current password)</label>
    <input type="password" id="password" name="password">
    <br>
    
    <label for="is_active">Status:</label>
    <select name="is_active" id="is_active">
        <option value="1" <?= $user->is_active ? 'selected' : '' ?>>Active</option>
        <option value="0" <?= !$user->is_active ? 'selected' : '' ?>>Inactive</option>
    </select>
    <br>

    <button type="submit">Save Changes</button>
</form>

<a href="<?= base_url('dashboard') ?>">Back to Dashboard</a>
</body>
</html>