<?php
session_start();
require_once('inc/config.inc.php');
require_once('inc/functions.inc.php');

$user = check_user();
if (!is_admin_user()) {
    http_response_code(403);
    echo 'Zugriff verweigert.';
    exit;
}

if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['id'])) {
    http_response_code(400);
    echo 'Ungültige Anfrage.';
    exit;
}

$id = intval($_POST['id']);

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

header('Location: company_holidays.php');
exit;
?>