<?php
require_once __DIR__ . '/../config/db.php';

try {
    $pdo = getConnection();
    
    echo "--- AUDITORIA LOG ON 2026-06-05 ---\n";
    $stmt = $pdo->prepare("SELECT * FROM auditoria_log WHERE DATE(fecha) = '2026-06-05' OR DATE(created_at) = '2026-06-05' LIMIT 50");
    $stmt->execute();
    $rows = $stmt->fetchAll();
    print_r($rows);
    
    // If table columns are different, let's catch it and try generic SELECT
    if (empty($rows)) {
        echo "No rows found with specific date filter, trying generic select:\n";
        $stmt2 = $pdo->query("SELECT * FROM auditoria_log ORDER BY id DESC LIMIT 20");
        print_r($stmt2->fetchAll());
    }

} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
    
    // Maybe the columns are different, let's show table columns
    try {
        $stmtCol = $pdo->query("SHOW COLUMNS FROM auditoria_log");
        print_r($stmtCol->fetchAll());
        
        $stmt2 = $pdo->query("SELECT * FROM auditoria_log ORDER BY 1 DESC LIMIT 20");
        print_r($stmt2->fetchAll());
    } catch (Exception $e2) {
        echo "Error fetching columns/records: " . $e2->getMessage() . "\n";
    }
}
