<!--#include file="../_topo.asp" -->

<!--#include virtual="/site/scripts/iProtect/loggedin.asp" -->
<!--#include virtual="/site/scripts/iProtect/dsn.asp" -->


<div id="titulos">
	<div class="botao2"><a href="/site/scripts/iProtect/admin.asp">Listagem</a></div>
	<div class="botao2"><a href="/site/scripts/iProtect/admin-novo.asp">Novo Usu&aacute;rio</a></div>
	<div class="botao2"><a href="/site/scripts/iProtect/logout.asp">Log&nbsp;Out</a></div>
</div>

<div id="corpo">


<h4>Listagem dos Administradores</h4>
<p>Para colocar em ordem, escolha e clique no nome da coluna.</p>
<p>&nbsp;</p> 

<%
Dim orderBy
orderBy = request.querystring("orderby")

If orderBy = "Email" Then
	SQL = "SELECT * FROM tbllogin ORDER BY usuarioEmail"
ElseIf orderBy = "nome" Then
	SQL = "SELECT * FROM tbllogin ORDER BY usuarionome"
ElseIf orderBy = "acesso" Then
	SQL = "SELECT * FROM tbllogin ORDER BY usuarioultimologin"
ElseIf orderBy = "datain" Then
	SQL = "SELECT * FROM tbllogin ORDER BY usuariodatain"
ElseIf orderBy = "login" Then
	SQL = "SELECT * FROM tbllogin ORDER BY usuariologin"
ElseIf orderBy = "ativo" Then
	SQL = "SELECT * FROM tbllogin ORDER BY usuarioativo DESC"
Else
	orderBy = "Email"
	SQL = "SELECT * FROM tbllogin ORDER BY usuarioEmail"
End If

Set RS = Server.CreateObject("ADODB.Recordset")

Dim colorchanger
Dim color1
Dim color2
colorchanger = 0
color1 = "#C5D3E7"
color2 = "#B0C4DE"

dim intPage
dim intPageCount
dim intRecordCount

If Request.QueryString("page") = "" Then
	intPage = 1	
Else
	intPage = Request.QueryString("page")
End If
	
RS.CursorLocation = 3
RS.CursorType = 3
RS.ActiveConnection = Conn
	
RS.Open SQL, Conn, 1, 3
	
RS.PageSize = 20
RS.CacheSize = RS.PageSize
intPageCount = RS.PageCount
intRecordCount = RS.RecordCount

If NOT (RS.BOF AND RS.EOF) Then
%>

<table border="0" cellpadding="5" cellspacing="1" width="100%">
               <tr> 
          <td width="6%" class="td4">&nbsp;</td>
          <td width="22%" class="td4"><a href="/site/scripts/iProtect/?orderby=login&page=<%If NOT (orderby = "login") Then%>1<%Else%><%=intPage%><%End If%>">Usu&aacute;rio</a></td>
          <td width="12%" class="td4"><a href="/site/scripts/iProtect/?orderby=senha&page=<%If NOT (orderby = "senha") Then%>1<%Else%><%=intPage%><%End If%>">Senha</a></td>
          <td width="12%" class="td4"><a href="/site/scripts/iProtect/?orderby=nome&page=<%If NOT (orderby = "nome") Then%>1<%Else%><%=intPage%><%End If%>">Nome</a></td>
          <td width="12%" class="td4"><a href="/site/scripts/iProtect/?orderby=email&page=<%If NOT (orderby = "email") Then%>1<%Else%><%=intPage%><%End If%>">Email</a></td>
          <td width="11%" class="td4"><a href="/site/scripts/iProtect/?orderby=ativo&page=<%If NOT (orderby = "ativo") Then%>1<%Else%><%=intPage%><%End If%>">Ativo</a></td>
          <td width="25%" class="td4"><a href="/site/scripts/iProtect/?orderby=acesso&page=<%If NOT (orderby = "acesso") Then%>1<%Else%><%=intPage%><%End If%>">&Uacute;timo 
            Login</a> </td>
        </tr>
        <%	
If CInt(intPage) > CInt(intPageCount) Then intPage = intPageCount
	If CInt(intPage) <= 0 Then intPage = 1
		If intRecordCount > 0 Then
			RS.AbsolutePage = intPage
			intStart = RS.AbsolutePosition
			If CInt(intPage) = CInt(intPageCount) Then
				intFinish = intRecordCount
			Else
				intFinish = intStart + (RS.PageSize - 1)
			End if
		End If
	If intRecordCount > 0 Then
		For intRecord = 1 to RS.PageSize
%>
        <tr> 
                      <td class="td1"><a href="/site/scripts/iProtect/admin-editar.asp?ID=<%=RS("usuarioID")%>"><img src="../images/icon_alterar.png" width="20" height="20" alt="Alterar"></a>&nbsp;&nbsp;<a href="/site/scripts/iProtect/admin-apagar.asp?ID=<%=RS("usuarioID")%>"><img src="../images/icon_delete.png" width="20" height="20" alt="Delete"></a></td>
          <td class="td1"><%=RS("usuariologin")%></td>
          <td class="td1"><%=RS("usuariosenha")%></td>
          <td class="td1"><%=RS("usuarionome")%></td>
          <td class="td1"><%=RS("usuarioemail")%></td>
          <td class="td1"><%=RS("usuarioativo")%></td>
          <td class="td1"><%=RS("usuarioultimologin")%></td>
        </tr>
        <%
RS.MoveNext
If colorchanger = 1 Then
	colorchanger = 0
	color1 = "#C5D3E7"
	color2 = "#B0C4DE"
Else
	colorchanger = 1
	color1 = "#DAE3F0"
	color2 = "#C5D3E7"
End If

If RS.EOF Then Exit for
	Next
%>
        <tr> 
          <td colspan="7">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
              <tr> 
                <td width="50%" align="left"> 
                  <%If cInt(intPage) > 1 Then%>
                  <a href="/site/scripts/?orderby=<%=orderBy%>&page=<%=intPage - 1%>"><< Anterior</a> 
                  <%End If%>
                  </td>
                <td width="50%" align="right"> 
                  <%If cInt(intPage) < cInt(intPageCount) Then%>
                  <a href="/site/scripts/?orderby=<%=orderBy%>&page=<%=intPage + 1%>">Pr&oacute;ximo 
                  >></a> 
                  <%End If%>
                  </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <br>
      <%End If
Else%>

<p>No momento n&atilde;o existem administradores cadastrados.</p>
<%End If
RS.close
Set RS = Nothing
Conn.close
Set Conn = Nothing%>
</table></tr>
  </table>
  </td>
</tr>
</table>
</div>

<!--#include file="../_botton.asp" -->
