<?php
require 'db_connection.php';

$query = "SELECT * FROM issues WHERE status = 'Pending' ORDER BY created_at DESC";
$stmt = $pdo->query($query);
$issues = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Dashboard</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="sidebar">
        <ul>
            <li><a href="dashboard.php">Dashboard</a></li>
            <li><a href="view_issues.php">View Issues</a></li>
        </ul>
    </div>
    <div class="content">
        <h1>Welcome, Admin</h1>
        <h2>Pending Issues</h2>
        <table>
            <thead>
                <tr>
                    <th>Issue ID</th>
                    <th>Account ID</th>
                    <th>Issue</th>
                    <th>Status</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($issues as $issue): ?>
                <tr>
                    <td><?php echo $issue['id']; ?></td>
                    <td><?php echo $issue['account_id']; ?></td>
                    <td><?php echo $issue['issue']; ?></td>
                    <td><?php echo $issue['status']; ?></td>
                    <td><a href="view_issue.php?id=<?php echo $issue['id']; ?>">View</a></td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</body>
</html>
