<?php
error_reporting(E_ERROR | E_PARSE);
include '../conector.php';

echo "=== Verificar TODOS los registros en planilla_detalle por planilla ===\n";
$sql = "SELECT planilla, COUNT(*) as total FROM planilla_detalle GROUP BY planilla ORDER BY planilla";
$res = mysql_query($sql);
while($row = mysql_fetch_assoc($res)){
    echo "Planilla ID " . $row['planilla'] . ": " . $row['total'] . " registros\n";
}

echo "\n=== Verificar estructura de planilla_consulta ===\n";
$sql2 = "DESCRIBE planilla_consulta";
$res2 = mysql_query($sql2);
while($row2 = mysql_fetch_assoc($res2)){
    echo $row2['Field'] . " - " . $row2['Type'] . "\n";
}

echo "\n=== Revisar query en generador.php que falla ===\n";
// La query usa planilla_consulta.periodo que debe ser el ID de la planilla (9, 10, 11, 15)
// NO el numero de periodo (1, 2, 3, 4)
$per1 = 15; // Este es el ID de la planilla para periodo 4
$cur1 = 12;
$estudiante = 160008;

$query = "SELECT * FROM planilla_consulta WHERE periodo = $per1 AND estudiante = $estudiante LIMIT 1";
echo "Query: $query\n";
$res = mysql_query($query);
echo "Resultados: " . mysql_num_rows($res) . "\n";
?>