%
Set Conexao = Server.CreateObject("ADODB.Connection")
Conexao.Open Application("StringConexaoODBC")
%>
<%call verifica_mobile()%>
<%
titulo = ""
descricao = ""
tags = ""
tags_site = ""
if request("codigo_loja") <> "" then
Set tipob = Server.CreateObject("ADODB.Recordset")
StrQuery="select * from lojas where codigo_loja = "& request("codigo_loja")
tipob.Open (StrQuery), conexao
if tipob.EOF then
end if
While Not tipob.EOF
titulo = tipob("nome_loja")
tipob.Movenext
Wend
tipob.Close
Set tipob = Nothing
end if
if request("codigo_categoria") <> "" then
Set tipob = Server.CreateObject("ADODB.Recordset")
StrQuery="select * from categorias where codigo_categoria = "& request("codigo_categoria")
tipob.Open (StrQuery), conexao
if tipob.EOF then
end if
While Not tipob.EOF
titulo = titulo & " "& tipob("nome_categoria")
tipob.Movenext
Wend
tipob.Close
Set tipob = Nothing
end if
%>
FARB - <%=titulo%>
<%
Set lojas = Server.CreateObject("ADODB.Recordset")
lojas.Open "SELECT * FROM lojas where lojavirtual = 0 ORDER BY nome_loja", Conexao
lojas.MoveFirst
While Not lojas.EOF
loja = lojas("codigo_loja")
v = 0
Set Categorias = Server.CreateObject("ADODB.Recordset")
str="SELECT * FROM categorias where codigo_loja = "& lojas("codigo_loja") &" ORDER BY nome_categoria"
Categorias.Open str , Conexao
While Not Categorias.EOF
v = v + 1
Categorias.MoveNext
Wend
Categorias.Close
Set Categorias = Nothing
txt_loja = lojas("nome_loja")
'nn = len(txt_loja) - 3
'txt_loja2 = right(txt_loja,nn)
v=0
if v = 0 then
%>
<%else%>
<%response.write txt_loja%>
<%end if
loja = lojas("codigo_loja")
ccate = 0
Set Categorias = Server.CreateObject("ADODB.Recordset")
str="SELECT * FROM categorias where codigo_loja = "& lojas("codigo_loja") &" ORDER BY nome_categoria"
Categorias.Open str , Conexao
While Not Categorias.EOF
ccate = ccate + 1
if ccate = 1 then
response.write "
"
end if
Set tprodutos = Server.CreateObject("ADODB.Recordset")
tprodutos.Open "SELECT COUNT(*) As totalRegistros FROM subcategorias where codigo_categoria = "& Categorias("codigo_categoria"), Conexao
tprodutos.MoveFirst
While Not tprodutos.EOF
total = tprodutos("totalRegistros")
tprodutos.MoveNext
wend
tprodutos.Close
Set tprodutos = Nothing
if total > 0 then%>
<%= Categorias("nome_categoria") %>
<%else%>
&codigo_loja=<%= loja %>" class="subcategoria"><%= Categorias("nome_categoria") %>
<%end if
'----------------------------------------------
csub = 0
catego = Categorias("codigo_categoria")
Set sCategorias = Server.CreateObject("ADODB.Recordset")
str1 ="SELECT * FROM subcategorias where codigo_categoria="& catego &" ORDER BY nome_subcategoria"
sCategorias.Open str1, Conexao
While Not sCategorias.EOF
csub= csub + 1
if csub=1 then
response.write "
"
end if
'----------------------------------------------
Categorias.MoveNext
Wend
Categorias.Close
Set Categorias = Nothing
if ccate > 0 then
response.write ""
end if
lojas.MoveNext
Wend
lojas.Close
Set lojas = Nothing
%>
<%
Function RemoveAcentos2(ByVal Texto)
Dim ComAcentos
Dim SemAcentos
Dim Resultado
Dim Cont
'Conjunto de Caracteres com acentos
ComAcentos = "ÁÍÓÚÉÄÏÖÜËÀÌÒÙÈÃÕÂÎÔÛÊáíóúéäïöüëàìòùèãõâîôûêÇç"
'Conjunto de Caracteres sem acentos
SemAcentos = "AIOUEAIOUEAIOUEAOAIOUEaioueaioueaioueaoaioueCc"
Cont = 0
Resultado = Texto
Do While Cont < Len(ComAcentos)
Cont = Cont + 1
Resultado = Replace(Resultado, Mid(ComAcentos, Cont, 1), Mid(SemAcentos, Cont, 1))
Loop
RemoveAcentos2 = Resultado
End Function
Call Valida_Request()
session("recibofim") = ""
produto = LimparTexto(Request("procura"))
codigo_categoria = LimparTexto(Request("codigo_categoria"))
codigo_cat = LimparTexto(Request("codigo_cat"))
codigo_categoria = LimparTexto(Request("codigo_categoria"))
codigo_subcategoria = LimparTexto(Request("codigo_subcategoria"))
codigo_loja = LimparTexto(Request("codigo_loja"))
nome_categoria = LimparTexto(Request("nome_categoria"))
marca = LimparTexto(Request("marca"))
if codigo_loja<> "" then%>
<%=titulo%>
<%end if
if request("procura") <> "" then%>
Busca de produtos por palavra-chave: <%=request("procura")%>
<%end if%>
<%
If Request.QueryString("PaginaAtual") = "" then
PaginaAtual = 1 'estamos na primeira pagina
Else
PaginaAtual = Request.QueryString("PaginaAtual")
End If
Set Produtos = Server.CreateObject("ADODB.Recordset")
Produtos.CursorLocation = 3
Produtos.CursorType = 0
Produtos.Locktype = 1
query = "SELECT codigo_produto, nome_produto, preco_unitario, url_imagem, disponivel, lancamentos, promocao,frete_gratis FROM produtos WHERE "
if isnumeric(produto) = true then
query = query & "(codigo_produto = " & produto & ") and"
buscar = "ok"
else
if produto <> "" then
IF UCASE(RIGHT(produto,1)) = "S" THEN
produto = LEFT(produto,LEN(produto)-1)
END IF
query = query & "(nome_produto like '%" & produto & "%' or metatags like '%" & produto & "%') and"
buscar = "ok"
end if
end if
if codigo_loja <> "" then
query = query & " codigo_loja = " & codigo_loja & " AND "
end if
'if codigo_categoria <> "" then
'query = query & " codigo_categoria = " & codigo_categoria & " AND "
'end if
'if codigo_subcategoria <> "" then
'query = query & " codigo_subcategoria = " & codigo_subcategoria & " AND "
'end if
'if codigo_categoria <> "" then
'query = "SELECT * FROM produtos WHERE "
'query = query & " codigo_subcategoria = " & codigo_categoria & " AND "
'buscar = "ok"
'end if
if marca <> "" then
query = query & " marca = " & marca & " AND "
buscar = "ok"
end if
if request("valores") = "1" then
query = query & " preco_unitario <= 50 AND "
end if
if request("valores") = "2" then
query = query & " preco_unitario >= 50 AND preco_unitario <= 100 AND "
end if
if request("valores") = "3" then
query = query & " preco_unitario >= 100 AND preco_unitario <= 200 AND "
end if
if request("valores") = "4" then
query = query & " preco_unitario >= 200 AND preco_unitario <= 300 AND "
end if
if request("valores") = "5" then
query = query & " preco_unitario >= 300 AND preco_unitario <= 500 AND "
end if
if request("valores") = "6" then
query = query & " preco_unitario >= 500 AND preco_unitario <= 1000 AND "
end if
if request("valores") = "7" then
query = query & " preco_unitario >= 1000 AND "
end if
separa = right(query,4)
If separa <> "AND" Then
query = query & " disponivel_venda = 1 and nome_produto Is not Null "
Else
query = query & " AND disponivel_venda = 1 and nome_produto Is not Null "
End If
ordenar = request.querystring("ordenar")
select case ordenar
case "maiorpreco"
query = query & " order by preco_unitario desc"
case "menorpreco"
query = query & " order by preco_unitario"
case "lancamentos"
query = query & " order by lancamentos desc"
case "ofertas"
query = query & " order by preco_antigo desc"
case else
query = query & " order by lancamentos desc"
end select
if request("codigo_cat") <> "" then
query = "SELECT codigo_produto, nome_produto, preco_unitario, url_imagem, disponivel, lancamentos, promocao FROM produtos WHERE "
if request("valores") = "1" then
query = query & " preco_unitario <= 50 AND "
end if
if request("valores") = "2" then
query = query & " preco_unitario >= 50 AND preco_unitario <= 100 AND"
end if
if request("valores") = "3" then
query = query & " preco_unitario >= 100 AND preco_unitario <= 200 AND"
end if
if request("valores") = "4" then
query = query & " preco_unitario >= 200 AND preco_unitario <= 300 AND"
end if
if request("valores") = "5" then
query = query & " preco_unitario >= 300 AND preco_unitario <= 500 AND"
end if
if request("valores") = "6" then
query = query & " preco_unitario >= 500 AND preco_unitario <= 1000 AND"
end if
if request("valores") = "7" then
query = query & " preco_unitario >= 1000 and"
end if
query = query &" disponivel_venda = 1 and codigo_subcategoria IN (SELECT codigo_subcategoria FROM subcategorias WHERE codigo_categoria = " & request("codigo_cat") & ")"
ordenar = request.querystring("ordenar")
select case ordenar
case "maiorpreco"
query = query & " order by preco_unitario desc"
case "menorpreco"
query = query & " order by preco_unitario"
case "lancamentos"
query = query & " order by lancamentos desc"
case "ofertas"
query = query & " order by preco_antigo desc"
case else
query = query & " order by lancamentos desc"
end select
end if
Produtos.Open query, conexao
If Produtos.Eof Then
%>
Nenhum produto foi encontrado.
<%'response.redirect("farb.asp?menu=catalogo")
Else
Produtos.PageSize = 30
TotalPaginas = Produtos.PageCount
Totalprodutos = Produtos.RecordCount
Produtos.AbsolutePage = PaginaAtual
Coluna = 0
Contador = 0
con =0
While Not Produtos.EOF And Contador < Produtos.PageSize
urlacentos = RemoveAcentos2(lcase(Produtos("nome_produto")))
url = replace(urlacentos, "/", "-")
url = replace(url, "*", "")
url = replace(url, " ", "-")
url = replace(url, """", "")
foto = ""
fotos = Produtos("url_imagem")
if fotos <> "" then
fotos_list = Split(fotos, ";")
foto = fotos_list(0)
else
foto = "semfoto.jpg"
end if
%>
" >
<%Contador = Contador + 1
Produtos.MoveNext
wend
end if%>
<%
if TotalPaginas > 1 then
If request("procura") = "ee" Then
'Mostra Proximos / Anteriores
If PaginaAtual > 1 then
'Nao estamos no comeco, mostra o link de Anterior %>
&codigo_cat=<%= codigo_cat %>&valores=<%=request("valores")%>" >
<%
Else
End If
If CInt(PaginaAtual) <> CInt(TotalPaginas) then
'Nao estamos no fim, mostra o link de Proximo. %>
&codigo_cat=<%= codigo_cat %>&valores=<%=request("valores")%>" >
<%
End If
Else
If PaginaAtual > 1 then
'Nao estamos no comeco, mostra o link de Anterior %>
" >
<%
Else
%>
<%
End If
for pag = 1 to TotalPaginas%>
" > <%=pag%>
<%next
if CInt(PaginaAtual) <= CInt(TotalPaginas) then
If CInt(PaginaAtual) <> CInt(TotalPaginas) then
'Nao estamos no fim, mostra o link de Proximo. %>
" >
<%
End If
Else
response.redirect("produtos.asp?PaginaAtual="&TotalPaginas&"&codigo_categoria="&codigo_categoria&"&nome_categoria="&nome_categoria&"&marca="&marca&"&ordenar="&ordenar&"&procura="&produto&"&codigo_cat="&codigo_cat&"&valores="&request("valores"))
end if
%>
<%
End If
End If
Produtos.Close
Set Produtos = Nothing
%>