<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once 'class.admin.php';
$reg_user = new USER();

echo "<h2>Checking Pending Accounts</h2>";

// Check all accounts
echo "<h3>All Accounts:</h3>";
$stmt_all = $reg_user->runQuery("SELECT id, fname, lname, uname, verify, status FROM account ORDER BY id DESC LIMIT 10");
$stmt_all->execute();
echo "<table border='1'>";
echo "<tr><th>ID</th><th>Name</th><th>Username</th><th>Verify</th><th>Status</th></tr>";
while($row = $stmt_all->fetch(PDO::FETCH_ASSOC)){
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['fname'] . " " . $row['lname'] . "</td>";
    echo "<td>" . $row['uname'] . "</td>";
    echo "<td>" . $row['verify'] . "</td>";
    echo "<td>" . $row['status'] . "</td>";
    echo "</tr>";
}
echo "</table>";

// Check pending accounts (verify = 'N')
echo "<h3>Pending Accounts (verify = 'N'):</h3>";
$stmt_pending = $reg_user->runQuery("SELECT id, fname, lname, uname, verify, status FROM account WHERE verify = 'N' ORDER BY id DESC");
$stmt_pending->execute();
$count = 0;
echo "<table border='1'>";
echo "<tr><th>ID</th><th>Name</th><th>Username</th><th>Verify</th><th>Status</th></tr>";
while($row = $stmt_pending->fetch(PDO::FETCH_ASSOC)){
    $count++;
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['fname'] . " " . $row['lname'] . "</td>";
    echo "<td>" . $row['uname'] . "</td>";
    echo "<td>" . $row['verify'] . "</td>";
    echo "<td>" . $row['status'] . "</td>";
    echo "</tr>";
}
echo "</table>";
echo "<p>Total pending accounts: $count</p>";
?>
