<?php
/**
 * Delete a committee (and cascade its members)
 */

$stmt = $pdo->prepare('SELECT * FROM committees WHERE id = ?');
$stmt->execute([$id]);
$committee = $stmt->fetch();

if (!$committee) {
    header('Location: ' . BASE_PATH . '/committees');
    exit;
}

$stmt = $pdo->prepare('DELETE FROM committees WHERE id = ?');
$stmt->execute([$id]);

header('Location: ' . BASE_PATH . '/committees?toast=' . urlencode('Committee "' . $committee['name'] . '" deleted.'));
exit;
