<%
if session("autorizado") = "" then response.redirect "default.asp"
%>

<%
Set Conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("../../db/Edificios.mdb")
%>
<html>
<head>
<title>Estadisticas Biblioteca</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../css/form.css" type="text/css">
<link rel="stylesheet" href="../form.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#383838">
<form name="form1" method="post" action="Usuarios-bib.asp">
  <table width="620" border="0">
    <tr>
      <td colspan="4"><font face="Geneva, Arial, Helvetica, san-serif" size="3"><b>Estadísticas Usuarios Log-in</b></font></td>
    </tr>
    <tr>
      <td colspan="4">&nbsp;</td>
    </tr>
    <tr>
      <td width="115" class="textselect"><font size="2">Por Area:</font></td>
      <td colspan="3">
        <input type="text" name="empresa" size="30">
    </td>
    </tr>
    <tr>
      <td width="115" class="textselect"><font size="2">Por Nombre:</font></td>
      <td colspan="3">
        <input type="text" name="nombre" size="30">
    </td>
    </tr>
    <tr>
      <td width="115">&nbsp;</td>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td width="115">&nbsp;</td>
      <td colspan="3">
        <input type="submit" name="Submit" value="Enviar" class="boton">
        <input type="reset" name="Submit2" value="Borrar" class="boton">
       
    </td>
    </tr>
  </table>

</form>
<%
cEmpresa=request.form("empresa")
cNombre=request.form("nombre")


  sSQL="SELECT * FROM Estadistica WHERE nombre LIKE '%"&cNombre&"%' and empresa LIKE '"&cEmpresa&"%' ORDER BY fecha,hora"

  set RS = Conn.Execute(sSQL)
  %>
    
      <%if rs.eof then%>
<p><br>
  <font color="#FF0000"><b>No hay datos que coincidan con su petici&oacute;n, intente de nuevo.</b></font></p>
 <%else%> 
<p>&nbsp;</p><table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr bgcolor="#C0C0C0"> 
    <td width="121" height="20"> 
      <div align="left"><font color="#FFFFFF"><b><font face="Geneva, Arial, Helvetica, san-serif" size="2">Fecha</font></b></font></div>
    </td>
    <td width="120" height="20"> 
      <div align="left"><font face="Geneva, Arial, Helvetica, san-serif" size="2" color="#FFFFFF"><b>Hora</b></font></div>
    </td>
    <td width="196" height="20"> 
      <p align="left"><font color="#FFFFFF"><b><font face="Geneva, Arial, Helvetica, san-serif" size="2"> &nbsp;Nombre</font></b></font></p>
    </td>
    <td width="143" height="20"> 
      <div align="left"><font color="#FFFFFF"><b><font face="Geneva, Arial, Helvetica, san-serif" size="2">Empresa</font></b></font></div>
    </td>
    <td width="120" valign="middle" height="20"> 
      <div align="left"><font color="#FFFFFF"><b><font face="Geneva, Arial, Helvetica, san-serif" size="2">IPAdress</font></b></font></div>
    </td>
  </tr>
     
  <%do while not rs.eof%>
  <tr bordercolor="#333333"> 
 
    <td width="121" class="textselect" height="20" style="border-bottom: 1 solid #999999"> 
      <% =RS("fecha") %>
      </td>
    <td width="120" class="textselect" height="20" style="border-bottom: 1 solid #999999"> 
      <% =RS("hora") %>
      </td>
    <td width="196" class="textselect" height="20" style="border-bottom: 1 solid #999999">  
      <% =RS("nombre") %>
      <br>
      </td>
    <td width="143" class="textselect" height="20" style="border-bottom: 1 solid #999999">
      <div align="left">
        <% =RS("Empresa") %>
         
         
        </div>
    </td>
    <td width="120" class="textselect" height="20" style="border-bottom: 1 solid #999999"> 
      <% =RS("ip") %>
      <% ipaddress = RS("ip") %>
            </td>
  </tr>
 	  
  <%
RS.MoveNext
Loop
end if
%>
   
</table>
 

<table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="121" height="9">&nbsp;</td>
    <td width="110" height="9">&nbsp;</td>
    <td width="206" height="9">&nbsp;</td>
    <td height="9" width="263">&nbsp;</td>
  </tr>
  <tr> 
  <%
  sSQL="SELECT count(nombre)as nombre_total FROM Estadistica WHERE nombre LIKE '%"&cNombre&"%' and empresa LIKE '"&cEmpresa&"%'"
  set RS = Conn.Execute(sSQL)
  Do While Not RS.Eof
  %>
    <td width="121" bgcolor="#C0C0C0" height="9"><font face="Geneva, Arial, Helvetica, san-serif" size="2"><b>&nbsp;</b></font><font face="Geneva, Arial, Helvetica, san-serif" size="3"><b><a name="generales"></a></b></font><font face="Geneva, Arial, Helvetica, san-serif" size="2"><b><font color="#FFFFFF">Total 
      Usuarios :</font></b></font></td>
    <td width="110" bgcolor="#C0C0C0" height="9"><font face="Geneva, Arial, Helvetica, san-serif" size="2"> 
      <b>
      <% =RS("nombre_total") %>
     
      </b> </font> 
      </td>
    <td width="206" height="9">&nbsp;</td>
    <td height="9" width="263">&nbsp;</td>
  </tr>
</table>
   <%
  RS.MoveNext
  Loop
  Conn.Close
  %>
<p>&nbsp;</p>
</BODY>
</HTML>