/var/www/vhosts/m-auto.co/httpdocs/admin
Edit: /var/www/vhosts/m-auto.co/httpdocs/admin/branch_delete.php (1290B)
prepare("SELECT id FROM visit_reservations WHERE branch_id = ? UNION ALL SELECT id FROM maintenance_reservations WHERE branch_id = ?");
$stmt_check->bind_param("ii", $id, $id);
$stmt_check->execute();
$result = $stmt_check->get_result();
if ($result->num_rows > 0) {
// Cannot delete, there are reservations linked to it
header("Location: branches.php?error=لا يمكن حذف هذا الفرع لوجود حجوزات مرتبطة به. يمكنك تعديل بياناته بدلاً من ذلك.");
exit();
}
$stmt_check->close();
// Proceed with deletion
$stmt_delete = $conn->prepare("DELETE FROM branches WHERE id = ?");
$stmt_delete->bind_param("i", $id);
if ($stmt_delete->execute()) {
header("Location: branches.php?success=تم حذف الفرع بنجاح");
} else {
header("Location: branches.php?error=حدث خطأ أثناء الحذف");
}
$stmt_delete->close();
$conn->close();
} else {
header("Location: branches.php");
exit();
}
?>