query($sql); // Handle delete operation - only for admin role if (isset($_GET['delete_id'])) { if (hasPermission('delete', $userRole)) { $id = $_GET['delete_id']; $sql = "DELETE FROM barang_kasir WHERE kode_barang = '$id'"; if ($conn->query($sql) === TRUE) { header("Location: /ayula-store/views/barang-kasir/?success=1"); exit(); } else { header("Location: /ayula-store/views/barang-kasir/?success=0"); exit(); } } else { // If user tries to delete without permission, redirect with error header("Location: /ayula-store/views/barang-kasir/?error=Anda tidak memiliki izin untuk menghapus barang"); exit(); } } ?>