<?php
session_start();
require 'config.php';
if(!isset($_SESSION["usuario"]) || $_SESSION["rol"] !== "ADMINISTRADOR"){
    header("Location: dashboard.php?vista=ordenes");exit;
}
$id = (int)($_POST['id'] ?? 0);
if($id > 0){
    $pdo->prepare("DELETE FROM refequipo WHERE id_orden_serv=?")->execute([$id]);
    $pdo->prepare("DELETE FROM refaccesorios WHERE id_orden_serv=?")->execute([$id]);
    $pdo->prepare("DELETE FROM anticipo_revision WHERE id_orden_serv_aplicado=?")->execute([$id]);
    $pdo->prepare("DELETE FROM ordenes_de_servicio WHERE id_orden_serv=?")->execute([$id]);
}
header("Location: dashboard.php?vista=ordenes&msg=borrado");
exit;
