<?php

require_once "db.class.php";


if ($_POST['accion']=='listado'){

    $alumno=$_POST['alumno'];
    $grado=$_POST['grado'];
    $curso=$_POST['curso'];
    $asignatura=$_POST['asignatura'];
    $periodo=$_POST['periodo'];
    $r1=$_POST['r1'];
    $r2=$_POST['r2'];
    
    $obj = new database();
    $obj->conectar(); $obj->consulta("set names 'utf8'");

    $query=$obj->consulta("select codigo, descripcion from logros where grado='".$grado."' and curso='".$curso."' and asignatura='".$asignatura."' and periodo='".$periodo."' and (orden>=".$r1." and orden<=".$r2.") order by orden");

    $obj->disconnect();
  
    $cadena="<table class='hovertable1' border='0' cellspacing='0' cellpadding='0' width='100%'>";
 
    while($row = $obj->fetch_assoc($query)) {
      
      $cadena.="<tr>
                <td align='center'>               
                <input id='".$row['codigo']."' type='checkbox' onClick=\"validar('".$row['codigo']."')\"/> 
                </td>
    
                <td>&ensp;".$row['codigo']."&ensp;</td><td>".($row['descripcion'])."
                </td>
                </tr>";
    
    }
    $cadena.="</table>";

    echo $cadena;

}

if ($_POST['accion']=='listado_logro'){

    $codigo=$_POST['codigo'];
    $cdn="light".$_POST['codigo'];
    $cdn1="fade".$_POST['codigo'];
    
    $id1=$_POST['id1'];
    $grado=$_POST['grado'];
    $curso=$_POST['curso'];
    $asignatura=$_POST['asignatura'];
    $periodo=$_POST['periodo'];
    $r1=$_POST['r1'];

    $obj = new database();
    $obj->conectar(); $obj->consulta("set names 'utf8'");

    $query=$obj->consulta("select codigo, descripcion from logros where grado='".$grado."' and curso='".$curso."' and asignatura='".$asignatura."' and periodo='".$periodo."' and orden=".$r1." order by orden");

    $obj->disconnect();
 
    $cadena="<table class='hovertable' border='0' cellspacing='0' cellpadding='0' width='100%'>";

    $cadena.="<tr><td colspan='3' align='center'><b>COMPETENCIA</b></td></tr>";

    while($row = $obj->fetch_assoc($query)) {
      
      $cadena.="<td align='center'> <img id='elem1'  class='confirmar' src='imagenes/si.png' onClick='mostrar_logro(\"S\",\"".$id1."\");' height='20' width='30' alt='Seleccionar' title='Seleccionar'>";
      $cadena.="<img id='elem1'  class='confirmar' src='imagenes/no.png' onClick='mostrar_logro(\"N\",\"".$id1."\");' height='20' width='30' alt='Seleccionar' title='Seleccionar'></td>";
      $cadena.="<td>".$row['codigo']."</td><td>".($row['descripcion'])."</td></tr>";
    }
    $cadena.="</table>";

    echo $cadena;

}

?>