<?php
require_once __DIR__ . '/../adm/config/db.php';
header('Content-Type: text/plain; charset=utf-8');

// Teste 1: ver todas as categorias
echo "=== TODAS AS CATEGORIAS ===\n";
$res = $conn->query("SELECT id, nome, status, parent_id, posicao FROM categorias ORDER BY posicao ASC, id ASC");
if (!$res) { echo "ERRO: " . $conn->error . "\n"; exit; }
while ($r = $res->fetch_assoc()) {
    echo "ID={$r['id']} | NOME={$r['nome']} | STATUS={$r['status']} | PARENT={$r['parent_id']} | POS={$r['posicao']}\n";
}

// Teste 2: filtro que menu usa
echo "\n=== FILTRADAS PELO MENU (status ativo/Ativo) ===\n";
$res2 = $conn->query("SELECT id, nome, status, parent_id, posicao FROM categorias WHERE status = 'ativo' OR status = 'Ativo' ORDER BY posicao ASC, id ASC");
echo "Rows: " . $res2->num_rows . "\n";
while ($r = $res2->fetch_assoc()) {
    echo "ID={$r['id']} | NOME={$r['nome']} | STATUS={$r['status']} | PARENT={$r['parent_id']} | POS={$r['posicao']}\n";
}
