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

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['site_id'])) {
    $site_id = intval($_POST['site_id']);

    $stmt = $pdo->prepare("SELECT username, email FROM users WHERE role = 'officer' AND site_id = ?");
    $stmt->execute([$site_id]);
    $officers = $stmt->fetchAll(PDO::FETCH_ASSOC);

    if ($officers) {
        foreach ($officers as $officer) {
            echo "<li class='list-group-item'>
                    <strong>" . htmlspecialchars($officer['username']) . "</strong><br>
                    Email: " . htmlspecialchars($officer['email']) . "
                  </li>";
        }
    } else {
        echo "<li class='list-group-item'>No officers assigned.</li>";
    }
}
?>
