<?php
// public/admin/dashboard_panchayat.php
session_start();
require_once __DIR__ . '/../../config/admin.php';
require_admin_role('PANCHAYAT_ADMIN');
require_once __DIR__ . '/../../config/db.php';
$panchayat_id = $_SESSION['admin_panchayat_id'];
// Participants in panchayat
$participants = $pdo->prepare('SELECT * FROM participants WHERE gp_id=?');
$participants->execute([$panchayat_id]);
$participants = $participants->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Panchayat Admin Dashboard</title>
    <link rel="stylesheet" href="/school-crm/public/assets/bootstrap.min.css">
</head>
<body>
<div class="container py-4">
    <h2>Panchayat Admin Dashboard</h2>
    <div class="card mb-4">
        <div class="card-header">Participant Registration</div>
        <div class="card-body">
            <a href="/school-crm/public/participant_add.php" class="btn btn-success">Register New Participant</a>
        </div>
    </div>
    <h5>Participants in Panchayat</h5>
    <table class="table table-bordered table-sm">
        <thead><tr><th>Name</th><th>Age</th><th>Gender</th><th>Category</th><th>Action</th></tr></thead>
        <tbody>
        <?php foreach ($participants as $p): ?>
            <tr>
                <td><?= htmlspecialchars($p['full_name']) ?></td>
                <td><?= htmlspecialchars($p['age']) ?></td>
                <td><?= htmlspecialchars($p['gender']) ?></td>
                <td><?= htmlspecialchars($p['category']) ?></td>
                <td>
                    <a href="/school-crm/public/participants_update.php?id=<?= $p['id'] ?>" class="btn btn-primary btn-sm">Edit</a>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
    <a href="/school-crm/public/admin/admin_logout.php" class="btn btn-secondary">Logout</a>
</div>
</body>
</html>
