<?
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">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</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 catedr&aacute;ticos</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_catedraticos_print.php?orden=<?=$orden."&idc=$idc&txtmes=$txtmes&txtyear=$txtyear";?>','chooser','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">
                  <form action="<?=$PHP_SELF;?>" method="post" name="form1" class="lbl_campo">
Seleccione un catedr&aacute;tico:
                    <select name="menu1" class="textbox" onChange="MM_jumpMenu('parent',this,0)">
                      <option value="#" selected>SELECCIONE UNO...</option>
                      <?
                      $qcat=mysql_query("select * from usuarios where catedratico = 'S' and usuario <>'admin' order by apellido");
                      while($icat=mysql_fetch_array($qcat)){
                      if($idc==enc($icat[usuario])){
                       $sel="selected class='selected_option'";
                      }else{$sel="";}
                      ?>
                        <option value="<?=$PHP_SELF."?idc=".enc($icat[usuario]);?>"><?=$icat[apellido]." ".$icat[nombre];?></option>
                      <?
                      }?>
                    </select>
                    <input name="Submit" type="submit" class="boton_guardar" value="Ver reporte">
                  </form>
                </div></td>
              </tr>
              <?if(!$idc){exit();}?>
              <tr>
                <td colspan="3" align="left" valign="top" bgcolor="#FFFFCC"><table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><span class="titulo_pagina">CATEDRATICO</span>: <span class="titulo_pagina"><?="[ ".dec($idc)." ] ".nombre_usuario(dec($idc),"Ca");?> </span></td>
                  </tr>
                </table><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 usuario = '$id_catedratico'
                                       group by mes, year
                                       order by $orden");

                  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="50%"  border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CFDFEF">
                    <tr bgcolor="#CFDFEF">
                      <td width="50%"><div align="center" class="lbl_campo"><a href="<?=$PHP_SELF."?idc=$idc&orden=fecha";?>"><img src="../images/sort_asc.png" alt="Ordenar  [Ascendente]" width="12" height="12" border="0"></a> Fecha <a href="<?=$PHP_SELF."?idc=$idc&orden=fecha desc";?>"><img src="../images/sort_desc.png" alt="Ordenar  [Descendente]" width="12" height="12" border="0"></a></div></td>
                      <td width="50%"><div align="center" class="lbl_campo"><a href="<?=$PHP_SELF."?idc=$idc&orden=ip";?>"><img src="../images/sort_asc.png" alt="Ordernar [Ascendente]" width="12" height="12" border="0"></a> IP <a href="<?=$PHP_SELF."?idc=$idc&orden=ip desc";?>"><img src="../images/sort_desc.png" alt="Ordenar  [Descendente]" width="12" height="12" border="0"></a></div></td>
                    </tr>
                    <?
                  if(!$orden){
                    $orden="fecha";
                  }

                    $id_catedratico=dec($idc);
                    $i=0;
                    $qacc=mysql_query("select fecha, ip
                                       from accesos
                                       where opcion_visitada='Login'
                                       and usuario = '$id_catedratico'
                                       and month(fecha)=$txtmes and year(fecha)=$txtyear
                                       order by $orden");
                  echo mysql_error();
                  while($iacc=mysql_fetch_array($qacc)){
                  $i++;
                  ?>
                    <tr bgcolor="<?=color_fila($i);?>" class="parrafo">
                      <td align="center"><?=fechalarga($iacc[fecha]);?>
                      <div align="center"></div></td>
                      <td align="center"><?=$iacc[ip];?>
                      <div align="center"></div></td>
                    </tr>
                   <?}?>
                </table></td></tr>
            </table>
           </td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>
