<?php
require_once 'includes/config.php';

try {
    $db_auth->exec("USE " . DB_AUTH_NAME);
    
    // Cek data di semua tabel
    $tables = ['superadmin', 'supervisor', 'developer'];
    
    foreach ($tables as $table) {
        echo "<h3>Data di tabel $table:</h3>";
        $stmt = $db_auth->query("SELECT id, username, password, nama_lengkap, active FROM $table");
        $users = $stmt->fetchAll(PDO::FETCH_ASSOC);
        
        echo "<pre>";
        print_r($users);
        echo "</pre>";
        echo "<hr>";
    }
    
    // Buat password baru untuk semua user
    $password = 'admin123';
    $hash = password_hash($password, PASSWORD_DEFAULT);
    
    // Update password di semua tabel
    foreach ($tables as $table) {
        $stmt = $db_auth->prepare("UPDATE $table SET 
            password = ?,
            active = 'active'
        WHERE username = ?");
        
        $stmt->execute([$hash, $table]);
        echo "Password updated for $table<br>";
    }
    
} catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
?> 