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

// Proteksi
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'kader') { exit; }

$id_periksa = $_GET['id_periksa'];
$id_bumil = $_GET['id_bumil'];

try {
    $stmt = $pdo->prepare("DELETE FROM pemeriksaan_bumil WHERE id_periksa_bumil = ?");
    $stmt->execute([$id_periksa]);
    
    // Kembali ke detail dengan sukses
    header("Location: bumil_detail.php?id=$id_bumil&status=deleted");
    exit;
} catch (PDOException $e) {
    die("Gagal menghapus data: " . $e->getMessage());
}