<?php
include 'auth.php';
require_permission('categories_delete');
include '../includes/db.php';
if (isset($_GET['id'])) {
$id = $_GET['id'];
// Note: In a real-world app, you might want to check if any cars are using this category before deleting.
// For simplicity, we are allowing direct deletion here.
$stmt = $conn->prepare("DELETE FROM categories WHERE id = ?");
$stmt->bind_param("i", $id);
if ($stmt->execute()) {
header("Location: categories.php?success=تم حذف الفئة بنجاح");
} else {
header("Location: categories.php?error=حدث خطأ أثناء الحذف");
}
$stmt->close();
$conn->close();
} else {
header("Location: categories.php");
exit();
}
?>