
<?php
require_once '../../../config/database.php';
require_once '../../../config/auth.php';

requireRole('super_admin');

$id = $_GET['id'] ?? 0;
if (!$id) {
    header('Location: index.php');
    exit;
}

$db = getDB();

try {
    $stmt = $db->prepare("DELETE FROM socket_types WHERE id = ?");
    $stmt->execute([$id]);
    
    $_SESSION['success'] = 'Socket type deleted successfully!';
} catch (PDOException $e) {
    $_SESSION['error'] = 'Failed to delete socket type. It might be in use.';
}

header('Location: index.php');
exit;
