<?php
session_start();
include '../config/conexion.php';

if (isset($_GET['id'])) {
    $db = (new Connection())->open();
    try {
        $sql = "DELETE FROM registro_unidad WHERE id = :id";
        $stmt = $db->prepare($sql);
        $stmt->execute([':id' => $_GET['id']]);
        $_SESSION['message'] = 'Unidad eliminada correctamente.';
    } catch (PDOException $e) {
        $_SESSION['message'] = 'Error al eliminar: ' . $e->getMessage();
    }
    header('Location: ../views/registro');
}
?>
