<?
include("../fnc.php");
enlinea_a();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>e-Ducativo - Bienvenido</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../estilo1.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
  <tr>
    <td bgcolor="#336699">    <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E5E5E5">
      <tr bgcolor="#FFFFFF">
        <td width="40%"><img src="../images/logo_5.gif" width="300" height="50"></td>
        <td width="60%" background="../images/back_header_admin.gif" bgcolor="#FFFFFF"><div align="right" class="usuario_nombre_enc"><strong><strong><?echo "$unombre $uapellido";?></strong><br>
          </strong>Tiene <?=mensajes($uuser);?> mensaje(s) sin leer</div></td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td height="15" colspan="2" background="../images/barra_encabezado.gif">&nbsp;</td>
        </tr>
    </table>
      <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFCC">
        <tr>
          <td valign="top" bgcolor="#FFFFCC">&nbsp;            <div align="right"></div>            <table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#333333">
              <tr align="center" valign="middle" bgcolor="#FFFFCC">
                <td width="56%" height="20" bgcolor="#FFFFCC"><div align="left"><span class="titulo_pagina">REPORTES<img src="../images/flecha_3.jpg" width="9" height="9"> Accesos al sistema de alumnos </span></div>
                  <div align="center" class="titulo_pagina"></div></td>
                <td width="19%" bgcolor="#FFFFCC"><div align="right">
                <?
                if($txtmes and $txtyear){
                ?>
                <a href="#" onClick="window.open('./rpt_accesos_alumnos_print.php?orden1=<?=$orden1."&idc=$idc&txtmes=$txtmes&txtyear=$txtyear";?>','reporte','width=800, height=600, location=no,menubar=no,resaizable=no,status=no,menubar=no');" class="link_parrafo"><img src="../images/printButton.png" width="16" height="16" border="0"> Versi&oacute;n imprimible</a>
                <?
                }
                ?>
                </div></td>
                <td width="25%" bgcolor="#FFFFCC" class="parrafo"><div align="right"><a href="frm_reportes.php" class="link_parrafo">Regresar al men&uacute; de reportes<img src="../images/ic_home.png" width="21" height="21" border="0"></a> </div></td>
              </tr>
              <tr>
                <td colspan="3" align="left" valign="top" bgcolor="#FFFFCC"><div align="left">
                  </div></td>
              </tr>
              <tr>
                <td colspan="3" align="left" valign="top" bgcolor="#FFFFCC"><br>
                    <table width="50%"  border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CFDFEF">
                      <tr bgcolor="#CFDFEF">
                        <td width="37%"><div align="center" class="lbl_campo"><a href="<?=$PHP_SELF."?idc=$idc&orden=mes";?>"><img src="../images/sort_asc.png" alt="Ordenar  [Ascendente]" width="12" height="12" border="0"></a> Mes <a href="<?=$PHP_SELF."?idc=$idc&orden=mes desc";?>"><img src="../images/sort_desc.png" alt="Ordenar  [Descendente]" width="12" height="12" border="0"></a></div></td>
                        <td width="38%"><div align="center" class="lbl_campo"><a href="<?=$PHP_SELF."?idc=$idc&orden=year";?>"><img src="../images/sort_asc.png" alt="Ordernar [Ascendente]" width="12" height="12" border="0"></a> Cantidad accesos <a href="<?=$PHP_SELF."?idc=$idc&orden=year desc";?>"><img src="../images/sort_desc.png" alt="Ordenar  [Descendente]" width="12" height="12" border="0"></a></div></td>
                        <td width="25%" class="lbl_campo"><div align="center">Opciones</div></td>
                      </tr>
                      <?
                  if(!$orden){
                    $orden="month(fecha)";
                  }

                  $id_catedratico=dec($idc);
                  $i=0;
                  $qacc=mysql_query("select distinct month(fecha) as mes, year(fecha) as year, count(*) as cantidad
                                       from accesos
                                       where opcion_visitada='Login'
                                       and tipo_usr = 'Alumno'
                                       group by mes, year
                                       order by $orden");
//                  echo mysql_error();
                  while($iacc=mysql_fetch_array($qacc)){
                  $i++;
                  ?>
                      <tr bgcolor="<?=color_fila($i);?>" class="parrafo">
                        <td align="center"><?=mes_letras($iacc[mes]);?>
                        <div align="center"></div></td>
                        <td align="center"><?=$iacc[cantidad];?>
                        <div align="center"></div></td>
                        <td align="center"><a href="<?=$PHP_SELF."?idc=$idc&txtyear={$iacc[year]}&txtmes={$iacc[mes]}";?>" class="link_parrafo">Ver detalle</a> </td>
                      </tr>
                     <?}?>
                  </table>
                  <br>
                  <?if(!$txtmes or !$txtyear){exit();}?>
                    <table width="100%"  border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CFDFEF">
                      <tr bgcolor="#CFDFEF">
                        <td width="16%" bgcolor="#CFDFEF"><div align="center" class="lbl_campo"><a href="<?=$PHP_SELF."?idc=$idc&txtmes=$txtmes&txtyear=$txtyear&orden1=fecha";?>"><img src="../images/sort_asc.png" alt="Ordenar  [Ascendente]" width="12" height="12" border="0"></a> Fecha <a href="<?=$PHP_SELF."?idc=$idc&txtmes=$txtmes&txtyear=$txtyear&orden1=fecha desc";?>"><img src="../images/sort_desc.png" alt="Ordenar  [Descendente]" width="12" height="12" border="0"></a></div></td>
                        <td width="9%" bgcolor="#CFDFEF"><div align="center"><span class="lbl_campo"><a href="<?=$PHP_SELF."?txtmes=$txtmes&txtyear=$txtyear&idc=$idc&orden1=usuario";?>"><img src="../images/sort_asc.png" alt="Ordenar  [Ascendente]" width="12" height="12" border="0"></a> Carn&eacute; <a href="<?=$PHP_SELF."?idc=$idc&txtmes=$txtmes&txtyear=$txtyear&orden1=usuario desc";?>"><img src="../images/sort_desc.png" alt="Ordenar  [Descendente]" width="12" height="12" border="0"></a></span></div></td>
                        <td width="56%" bgcolor="#CFDFEF"><div align="center"><span class="lbl_campo"><a href="<?=$PHP_SELF."?idc=$idc&txtmes=$txtmes&txtyear=$txtyear&orden1=apellido";?>"><img src="../images/sort_asc.png" alt="Ordenar  [Ascendente]" width="12" height="12" border="0"></a> Nombre del alumno<a href="<?=$PHP_SELF."?idc=$idc&txtmes=$txtmes&txtyear=$txtyear&orden1=apellido desc";?>"><img src="../images/sort_desc.png" alt="Ordenar  [Descendente]" width="12" height="12" border="0"></a></span></div></td>
                        <td width="19%"><div align="center" class="lbl_campo"><a href="<?=$PHP_SELF."?idc=$idc&txtmes=$txtmes&txtyear=$txtyear&orden1=ip";?>"><img src="../images/sort_asc.png" alt="Ordernar [Ascendente]" width="12" height="12" border="0"></a> IP <a href="<?=$PHP_SELF."?idc=$idc&txtmes=$txtmes&txtyear=$txtyear&orden1=ip desc";?>"><img src="../images/sort_desc.png" alt="Ordenar  [Descendente]" width="12" height="12" border="0"></a></div></td>
                      </tr>
                      <?
                  if(!$orden1){
                    $orden1="fecha";
                  }

                    $id_padre=dec($idp);
                    $i=0;
                    $qacc=mysql_query("select accesos.*, alumnos.apellido, alumnos.nombre
                                       from accesos inner join alumnos on alumnos.carnet = accesos.usuario
                                       where opcion_visitada='Login'
                                       and tipo_usr = 'Alumno'
                                       and month(fecha)=$txtmes and year(fecha)=$txtyear
                                       order by $orden1");
                  echo mysql_error();
                  while($iacc=mysql_fetch_array($qacc)){
                  $i++;
                  ?>
                      <tr bgcolor="<?=color_fila($i);?>" class="parrafo">
                        <td align="center">
                          <div align="center"><?=fechalarga($iacc[fecha]);?></div>
                        </td>
                        <td align="center"><div align="left"><?=$iacc[usuario];?></div></td>
                        <td align="center"><div align="left"><?=$iacc[apellido].", ".$iacc[nombre];?></div></td>
                        <td align="center"><?=$iacc[ip];?>
                        <div align="center"></div></td>
                      </tr>
                     <?}?>
                      <tr bgcolor="#CFDFEF" class="parrafo">
                        <td align="center" bgcolor="#CFDFEF">
                        <div align="center" class="lbl_campo">
                          <div align="right">TOTAL:</div>
                        </div>
                        </td>
                        <td align="right" bgcolor="#CFDFEF" class="lbl_campo"><?=$i;?>&nbsp;
                        <div align="right"></div></td>
                        <td align="center" bgcolor="#CFDFEF"><div align="left"><strong>Acceso(s)</strong></div></td>
                        <td align="center">&nbsp;</td>
                      </tr>
                </table></td></tr>
            </table>
           </td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>