Ir para conteúdo
Fórum Script Brasil
  • 0

Relatorio


PRWEBMaster

Pergunta

Tudo bem pessoal?

Gostaria de uma ajuda, se for possível.

Preciso desenvolver um relatorio na seguinte maneira:

Tenho várias cobranças, e em cada cobrança a o nome da empresa, etc, só que tem cobranças com nome de empresa repetido, o que preciso ajuntar essas empresas repetiras numa unica cobrança, exemplo:

NOME DA EMPRESA

(em baixo)

Todas as cobranças referente a esse empresa.

Na tabela aonde a as cobranças tenho o id_cliente e no_cob.

Muito Obrigado

Link para o comentário
Compartilhar em outros sites

7 respostass a esta questão

Posts Recomendados

  • 0

O meu código está assim:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Response.Buffer = FALSE
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma","no-cache"
Session.TimeOut = 1440
Server.ScriptTimeOut = 999.999

Session.LCID = 4106 'BRASIL

id_cliente = request.QueryString("id_cliente")
no_cob = request.QueryString("no_cob")
no_os = request.QueryString("no_os")
descricao = request.QueryString("descricao")
data_fechado = request.QueryString("data_fechado")
fechado_por = request.QueryString("fechado_por")
v_status_pagto = Request.QueryString("status_pagto")

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("DRIVER={Firebird/Interbase® driver}; DBNAME=localhost:c:\Inetpub\wwwroot\sistema_interno_hcs_v.1.0\bd\BD_HCS.GDB; UID=SYSDBA;PWD=masterkey")

FUNCTION troca_dia_mes(x)
 dia = ""
 mes = ""
 ano = ""

 barra = ""

 FOR i=1 TO LEN(x)
  IF (MID(x,i,1) = "/") THEN
   barra = barra & "/"
  END IF

  IF (barra = "") AND (MID(x,i,1) <> "/") THEN
   dia = dia & MID(x,i,1)
  ELSE
   IF (barra = "/") AND (MID(x,i,1) <> "/") THEN
    mes = mes & MID(x,i,1) 
   ELSE
    IF (barra = "//") AND (MID(x,i,1) <> "/") THEN
     ano = ano & MID(x,i,1)
    END IF
   END IF   
  END IF

 NEXT

 troca_dia_mes = mes & "/" & dia & "/" & ano

END FUNCTION

Dim teste
Dim teste_numRows

Set teste = Server.CreateObject("ADODB.Recordset")
teste.ActiveConnection = oConn

auxsql = "SELECT * FROM TB_GERAR_COB_CAD_ITENS WHERE "

'NO COB
if (Request.QueryString("no_cob") <> "") then
 auxsql = auxsql & "no_cob = '" & Request.QueryString("no_cob") & "' AND "
end if

'MÊS COB
if (Request.QueryString("mes_cob") <> "") then
 auxsql = auxsql & "mes_cob = '" & Request.QueryString("mes_cob") & "' AND "
end if

'DATA COB
if (Request.QueryString("data_cobranca") <> "") then
 auxsql = auxsql & "data_cobranca = '" & Request.QueryString("data_cobranca") & "' AND "
end if

'SITUAÇÃO COBRANÇA
if (Request.QueryString("situacao_cob") <> "") then
 auxsql = auxsql & "situacao_cob = '" & Request.QueryString("situacao_cob") & "' AND "
end if

'TIPO COBRANÇA
if (Request.QueryString("tipo_cob") <> "") then
 auxsql = auxsql & "tipo_cob = '" & Request.QueryString("tipo_cob") & "' AND "
end if

'DATA COBRANÇA
IF (Request.QueryString("data_inicial") <> "") AND (Request.QueryString("data_final") <> "") THEN
 data_inicial = troca_dia_mes(Request.QueryString("data_inicial"))
 data_final = troca_dia_mes(Request.QueryString("data_final")) 

 if data_final = "" then
  auxsql = auxsql & "cast(data_cobranca as date) >= cast('" & data_inicial & "' as date) AND "
 else
  if data_inicial = "" then
   auxsql = auxsql & "cast(data_cobranca as date) <= cast('" & data_final & "' as date) AND "
  else
   auxsql = auxsql & "cast(data_cobranca as date) >= cast('" & data_inicial & "' as date) AND cast(data_cobranca as date) <= cast('" & data_final & "' as date) AND "
  end if
 end if

end if

'NOME EMPRESA
if (Request.QueryString("nome_empresa") <> "") then
 Set cadastro = Server.CreateObject("ADODB.Recordset")
 cadastro.ActiveConnection = oConn

 cadastro.source = "SELECT id_cliente FROM TB_DADOS_CLIENTES WHERE nome_empresa LIKE '" & Request.QueryString("nome_empresa") & "%' "
 cadastro.open()

 if not(cadastro.eof) then
  auxsql = auxsql & "id_cliente = " & cadastro("id_cliente") & " AND "
 else 
  Response.Redirect("filtros_cobranca.asp?msg=Dados não Encontrados na Base de Dados")
  Response.End
 end if 
'end if

 cadastro.close
end if

'STATUS PAGAMENTO
if (Request.QueryString("status_pagto") <> "") then
 Set info = Server.CreateObject("ADODB.Recordset")
 info.ActiveConnection = oConn

 info.source = "SELECT * FROM TB_INFO_PAGTO WHERE status_pagto = '" & Request.QueryString("status_pagto") & "' AND (data_venc_pagto > '01/01/1990')"
 info.open()

 linha_status = ""

 while not(info.eof)
  linha_status = linha_status & "no_os = " & info("no_os") & " OR "
  info.MoveNext
 wend 

 info.close

 if (linha_status <> "") then 
  linha_status = left(linha_status,len(linha_status)-4)
  auxsql = auxsql & "(" & linha_status & ")" & " AND " 
 else 
  Response.Redirect("filtros_cobranca.asp?msg=Dados não Encontrados na Base de Dados")
  Response.End
 end if 
end if

'FORMA PAGAMENTO
if (Request.QueryString("forma_pagto") <> "") then
 Set info = Server.CreateObject("ADODB.Recordset")
 info.ActiveConnection = oConn

 info.source = "SELECT * FROM TB_INFO_PAGTO WHERE forma_pagto = '" & Request.QueryString("forma_pagto") & "' AND (data_venc_pagto > '01/01/1990')"
 info.open()

 linha_forma = ""

 while not(info.eof)
  linha_forma = linha_forma & "no_os = " & info("no_os") & " OR "
  info.MoveNext
 wend 

 info.close

 if (linha_forma <> "") then 
  linha_forma = left(linha_forma,len(linha_forma)-4)
  auxsql = auxsql & "(" & linha_forma & ")" & " AND " 
 else 
  Response.Redirect("filtros_cobranca.asp?msg=Dados não Encontrados na Base de Dados")
  Response.End
 end if 
end if

'Arrumando SELECT
if (right(auxsql,6) = "WHERE ") then
 auxsql = left(auxsql,len(auxsql) - 6) & "ORDER BY no_cob ASC"
else
 auxsql = left(auxsql,len(auxsql) - 4) & "ORDER BY no_cob ASC"
end if

teste.source = auxsql
teste.CursorType = 0
teste.CursorLocation = 2
teste.LockType = 1
teste.Open()

teste_numRows = 0

Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
teste_numRows = teste_numRows + Repeat1__numRows

'  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim teste_total
Dim teste_first
Dim teste_last

' set the record count
teste_total = teste.RecordCount

' set the number of rows displayed on this page
If (teste_numRows < 0) Then
 teste_numRows = teste_total
Elseif (teste_numRows = 0) Then
  teste_numRows = 1
End If

' set the first and last displayed record
teste_first = 1
teste_last  = teste_first + teste_numRows - 1

' if we have the correct record count, check the other stats
If (teste_total <> -1) Then
  If (teste_first > teste_total) Then
    teste_first = teste_total
  End If
  If (teste_last > teste_total) Then
    teste_last = teste_total
  End If
  If (teste_numRows > teste_total) Then
    teste_numRows = teste_total
  End If
End If
%>
<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (teste_total = -1) Then

  ' count the total records by iterating through the recordset
  teste_total=0
  While (Not teste.EOF)
    teste_total = teste_total + 1
    teste.MoveNext
  Wend

  ' reset the cursor to the beginning
  If (teste.CursorType > 0) Then
    teste.MoveFirst
  Else
    teste.Requery
  End If

  ' set the number of rows displayed on this page
  If (teste_numRows < 0 Or teste_numRows > teste_total) Then
    teste_numRows = teste_total
  End If

  ' set the first and last displayed record
  teste_first = 1
  teste_last = teste_first + teste_numRows - 1
  
  If (teste_first > teste_total) Then
    teste_first = teste_total
  End If
  If (teste_last > teste_total) Then
    teste_last = teste_total
  End If

End If
%>
<%
Dim MM_paramName 
%>
<%
' *** Move To Record and Go To Record: declare variables

Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined

Dim MM_param
Dim MM_index

Set MM_rs    = teste
MM_rsCount   = teste_total
MM_size      = teste_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
  MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

  ' use index parameter if defined, otherwise use offset parameter
  MM_param = Request.QueryString("index")
  If (MM_param = "") Then
    MM_param = Request.QueryString("offset")
  End If
  If (MM_param <> "") Then
    MM_offset = Int(MM_param)
  End If

  ' if we have a record count, check if we are past the end of the recordset
  If (MM_rsCount <> -1) Then
    If (MM_offset >= MM_rsCount Or MM_offset = -1) Then  ' past end or move last
      If ((MM_rsCount Mod MM_size) > 0) Then         ' last page not a full repeat region
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
  If (MM_rs.EOF) Then 
    MM_offset = MM_index  ' set MM_offset to the last possible record
  End If

End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

  ' walk to the end of the display range for this page
  MM_index = MM_offset
  While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend

  ' if we walked off the end of the recordset, set MM_rsCount and MM_size
  If (MM_rs.EOF) Then
    MM_rsCount = MM_index
    If (MM_size < 0 Or MM_size > MM_rsCount) Then
      MM_size = MM_rsCount
    End If
  End If

  ' if we walked off the end, set the offset based on page size
  If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
      If ((MM_rsCount Mod MM_size) > 0) Then
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' reset the cursor to the beginning
  If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
  Else
    MM_rs.Requery
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While (Not MM_rs.EOF And MM_index < MM_offset)
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
End If
%>
<%
' *** Move To Record: update recordset stats

' set the first and last displayed record
teste_first = MM_offset + 1
teste_last  = MM_offset + MM_size

If (MM_rsCount <> -1) Then
  If (teste_first > MM_rsCount) Then
    teste_first = MM_rsCount
  End If
  If (teste_last > MM_rsCount) Then
    teste_last = MM_rsCount
  End If
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
  MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
  End If
Next

' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
  End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then 
  MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "")  Then
  MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
  MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
  If (firstItem <> "") Then
    MM_joinChar = "&"
  Else
    MM_joinChar = ""
  End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links

Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev

Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 1) Then
  MM_moveParam = "offset"
  If (MM_keepMove <> "") Then
    MM_paramList = Split(MM_keepMove, "&")
    MM_keepMove = ""
    For MM_paramIndex = 0 To UBound(MM_paramList)
      MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
      If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
        MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
      End If
    Next
    If (MM_keepMove <> "") Then
      MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
    End If
  End If
End If

' set the strings for the move to links
If (MM_keepMove <> "") Then 
  MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If

MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = MM_urlStr & "0"
MM_moveLast  = MM_urlStr & "-1"
MM_moveNext  = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
  MM_movePrev = MM_urlStr & "0"
Else
  MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>::.Sistema de Cobran&ccedil;a HCS.::</title>

&lt;script type="text/javascript" src="validations.js"></script>
&lt;script type="text/javascript" src="jquery.js"></script>
&lt;script type="text/javascript" src="jquery.mask.js"></script>
&lt;script type="text/javascript">
    $(document).ready(function(){
        //Ativando as mascaras
        $('input:text').setMask();
    });
</script>

&lt;script>
function abrir_filtro() {
window.open("filtros_cobranca.asp","content");
}
</script>

<link href="../css/campo_branco.css" rel="stylesheet" type="text/css">

<style type="text/css">
<!--
@import url("css/campo1.css");
@import url("../css/campo_branco_ng.css");
.style10 {    font-family: Calibri;
    font-size: 12px;
}
.style11 {    color: #000000;
    font-weight: bold;
}
.style14 {font-family: Calibri}
.style15 {font-size: 12px}
.style18 {color: #000000}
body {
    margin-left: 2px;
    margin-top: 2px;
    margin-right: 2px;
    margin-bottom: 2px;
}
.forma_pag1 {    font-family: Calibri;
    font-size: 16px;
    color: #FFFFFF;
    background-color: #0099CC;
    border: 1px solid #0099FF;
}
.forma_pag2 {    font-family: Calibri;
    font-size: 16px;
    color: #000000;
    background-color: #FFCC00;
    border: 1px solid #0099FF;
}
.style70 {
    font-size: 12px
}
.style157 {color: #FFFFFF}
.style160 {font-family: Calibri; font-size: 12px; color: #FFFFFF; }
.style161 {color: #333333}
a:link {
    text-decoration: none;
    color: #000000;
}
a:visited {
    text-decoration: none;
    color: #000000;
}
a:hover {
    text-decoration: none;
    color: #000000;
}
a:active {
    text-decoration: none;
    color: #000000;
}
.style53 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style168 {
    color: #000000;
    font-size: 12px;
    font-weight: bold;
}
.style95 {    color: #000033;
    font-weight: bold;
}
.style43 {font-family: Calibri;
    font-size: 10px;
    color: #000000;
    font-weight: bold;
}
.campo_maior {font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #000000;
    background-color: #FFFFFF;
    border: 1px solid #FFFFFF;
    font-weight: bold;
}
.style180 {
    color: #FF0000;
    font-size: 11px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
}
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
}
.style188 {font-size: 11px}
.style189 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; }
.style190 {font-size: 10px}
.style191 {font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; }
.style194 {font-size: 14px}
.style195 {font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; }
.style196 {color: #FF0000}
.forma_pag12 {font-family: Calibri;
    font-size: 16px;
    color: #FFFFFF;
    background-color: #FF0000;
    border: 1px solid #FF0000;
}
.forma_pag11 {font-family: Calibri;
    font-size: 16px;
    color: #FFFFFF;
    background-color: #0099CC;
    border: 1px solid #0099FF;
}
.forma_pag13 {font-family: Calibri;
    font-size: 16px;
    color: #FFFFFF;
    background-color: #666666;
    border: 1px solid #666666;
}
.style23 {    color: #FF0000;
    font-size: 20px;
    font-weight: bold;
    font-family: Calibri;
}
.style50 {    font-family: Calibri;
    font-size: 12px;
    font-weight: bold;
    color: #000000;
}
-->
</style>

&lt;script>
function abrir(URL) {

  var width = 1440;
  var height = 900;

  var left = 99;
  var top = 99;

  window.open(URL,'janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
</script>

<style type="text/css">
.carregando {
-moz-border-radius-bottomleft:5px;
-moz-border-radius-bottomright:5px;
-moz-border-radius-topleft:5px;
-moz-border-radius-topright:5px;
background:#FFFFFF none repeat scroll 0 0;
border:8px solid #C4DAFF;
left:38%;
padding:10px;
position:fixed;
top:18%;
width:365px;
z-index:100001;
}
.forma_pag111 {font-family: Calibri;
    font-size: 16px;
    color: #FFFFFF;
    background-color: #0099CC;
    border: 1px solid #0099FF;
}
.forma_pag121 {font-family: Calibri;
    font-size: 16px;
    color: #FFFFFF;
    background-color: #FF0000;
    border: 1px solid #FF0000;
}
.forma_pag131 {font-family: Calibri;
    font-size: 16px;
    color: #FFFFFF;
    background-color: #666666;
    border: 1px solid #666666;
}
.style154 {font-size: 14px;
    font-weight: bold;
}
.style171 {color: #000000;
    font-size: 18px;
    font-weight: bold;
}
</style>
</head>

<body >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<%
i = 1
While ((Repeat1__numRows <> 0) AND (NOT teste.EOF))

set cadastro = oConn.execute("select * from TB_DADOS_CLIENTES where id_cliente = " & teste("id_cliente") & " order by nome_empresa ASC")
if not(cadastro.EOF) then
 nome_emp = cadastro("nome_empresa")
else
 nome_emp = ""
end if
%>
<tr>
        <td width="1175" colspan="2" valign="top">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td colspan="11"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFF99">
              <tr>
                <td width="5%"><span class="style18"><span class="style11 style14 style15 style18"><span class="style189 style188 style188">EMPRESA:</span></span></span></td>
                <td width="39%"><span class="style18 style53 style188 style188 style188"><em><strong><%=nome_emp%></strong></em></span></td>
                <td width="8%"><div align="center"><strong><span class="style157 style196"><%=teste("data_cobranca")%></span></strong></div></td>
                <td width="3%"><span class="style18 style53 style188 style188 style188"><em>N.&ordm; COB.:</em></span></td>
                <td width="8%"><span class="style180 style14 style15 style15 style15 style188 style188"><span class="style188 style53">&nbsp;<strong><span class="style194"><a href="#" class="style157" onclick="abrir('gerar_cobranca.asp?id_cliente=<%=teste("id_cliente")%>&amp;no_cob=<%=teste("no_cob")%>&amp;no_os=<%=teste("no_os")%>')"><span class="style196">0<span class="style157 style196">0</span></span><span class="style157 style196"><%=teste("no_cob")%></span></a></span></strong></span></span></td>
                <td width="4%"><span class="style53 style188 style188 style188"><em>Situa&ccedil;&atilde;o Cob.:</em></span></td>
                <td width="7%"><span class="style53 style188 style188 style188"><strong>
                  <%
situacao_cob = teste("situacao_cob")

if situacao_cob = "1" then
   Response.Write ("COBRAN&Ccedil;A")
 else
  if situacao_cob = "2" then
    Response.Write ("CONCLU&Iacute;DA")
else
    if situacao_cob = "0" then
      Response.write("CANCELADA")
  end if
 end if
end if

%>
                </strong></span></td>
                <td width="2%"><em>M&Ecirc;S:</em></td>
                <td width="7%"><div align="left"><strong>
                  <%=teste("mes_cob")%>
                </strong></div></td>
                <td width="2%"><em>ANO:</em></td>
                <td width="6%"><div align="left"><strong><%=teste("ano_cob")%></strong></div></td>
                <td width="3%"><span class="style53 style188 style188 style188"><em>Tipo Cob.:</em></span></td>
                <td width="6%"><span class="style53 style188 style188 style188"><span class="style196"><strong>
                  <%
tipo_cob = teste("tipo_cob")

if tipo_cob = "1" then
   Response.Write ("NORMAL")
else
   if tipo_cob = "2" then
     Response.Write ("MENSAL")
 end if 
end if
%>
                </strong></span></span></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td width="43" bgcolor="#CCCCCC"><div align="center" class="style195">N. &ordm; O.F/M</div></td>
            <td width="54" bgcolor="#CCCCCC"><div align="center"><span class="style190"><strong>TIPO ORDEM</strong></span></div></td>
            <td width="105" bgcolor="#CCCCCC"><div align="center" class="style195">TIPO PAGAMENTO</div></td>
            <td width="103" bgcolor="#CCCCCC"><div align="center" class="style195">NUMERA&Ccedil;&Atilde;O</div></td>
            <td width="95" bgcolor="#CCCCCC"><div align="center" class="style195">              VENCIMENTO</div></td>
            <td width="69" bgcolor="#CCCCCC"><div align="center" class="style195">A PAGAR</div></td>
            <td width="4" bgcolor="#CCCCCC">&nbsp;</td>
            <td width="58" bgcolor="#CCCCCC"><div align="center" class="style195">DATA
            PAGTO</div></td>
            <td width="70" bgcolor="#CCCCCC"><div align="center" class="style195">VALOR
            PAGO</div></td>
            <td width="363" bgcolor="#CCCCCC"><div align="center" class="style195">SITUA&Ccedil;&Atilde;O</div></td>
            <td width="211" bgcolor="#CCCCCC"><div align="center" class="style195">ANOTA&Ccedil;&Atilde;O</div></td>
        </tr>
<%
if (v_status_pagto <> "") then
 set info = oConn.execute("select * from TB_INFO_PAGTO where (no_cob = "& teste("no_cob") &") AND (status_pagto = '" & v_status_pagto & "') AND (data_venc_pagto > '01/01/1990') order by no_os ASC ")
else
 set info = oConn.execute("select * from TB_INFO_PAGTO where no_cob = "& teste("no_cob") &"  order by no_os ASC ")
end if

'Visualizar Campos
set gerar_os_itens = server.CreateObject("adodb.recordset")
set gerar_os_itens = oConn.execute ("select * from TB_GERAR_OF_OM_CAD_ITENS where no_cob = "& teste("no_cob") &" order by id ASC")

i = 1
while (not info.EOF)
%>
          <tr>
            <td bgcolor="#FFFFFF"><div align="center"><span class="style70 style18 style14"><strong><span class="style191">00<%=info("no_os")%></span></strong></span></div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style196 style190"></div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style160 style161 style53 style190"><span class="style160 style161 style14 style70"><span class="style188 style18">
              <%
forma_pagto = info("forma_pagto")

if forma_pagto = "0" then
   Response.Write ("A DEFINIR")
else
   if forma_pagto = "1" then
     Response.Write ("BOLETO")
  else
     if forma_pagto = "2" then
     Response.Write ("BOLETO + NF")
  else
      if forma_pagto = "3" then
        Response.write("CART&Atilde;O BNDES")
     else
         if forma_pagto = "4" then
           Response.write("CHEQUE")
        else
            if forma_pagto = "5" then
              Response.write("COBRAN&Ccedil;A MENSAL")
           else
               if forma_pagto = "6" then
                Response.write("DEP&Oacute;SITO")
           else
               if forma_pagto = "7" then
                 Response.write("DINHEIRO")
                 else
                 if forma_pagto = "8" then
                   Response.write("OUTROS")
                 else
                   if forma_pagto = "9" then
                     Response.write("TRANSFER&Ecirc;NCIA")
end if 
 end if
  end if
   end if
    end if
     end if
      end if 
       end if
        end if
         end if
%>
            </span></span></div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style160 style161 style53 style190"><%=info("numeracao")%> </div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style196 style190 style53 style160"><strong>
<%
if info("data_venc_pagto") = (Cdate("01/01/1990")) then
    response.write ("")
else
    response.write (info("data_venc_pagto"))
end if
%> </strong></div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style160 style161"><span class="style43">
              <input name="valor_pagto_<%=i%>" type="text" class="campo_branco" id="v_total_<%=i%>" value="<%=ROUND(info("valor_pagto"),2)%>" size="10" alt="decimal"/>
            </span></div></td>
            <td bgcolor="#FFFFFF"><div align="center"></div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style160 style161 style53 style190"><%=info("data_pago")%> </div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style160 style161"><span class="style43">
              <input name="valor_pago_<%=i%>" type="text" class="campo_branco" id="valor_pago_<%=i%>" value="<%=ROUND(info("valor_pago"),2)%>" size="10" alt="decimal"/>
            </span></div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style160 style161 style53 style190">
              <%
status_pagto = info("status_pagto")

if status_pagto = "1" then
   Response.Write ("A VENCER")
else
  if status_pagto = "2" then
     Response.Write ("CHEQUES PENDENTES")
  else
    if status_pagto = "3" then
       Response.write("PROTESTADO")
    else
      if status_pagto = "4" then
         Response.write("PAGO")
      else
        if status_pagto = "5" then
           Response.write("VENCIDO")
                 else
        if status_pagto = "6" then
           Response.write("SEM CUSTO")
end if
 end if
  end if
   end if
    end if
     end if
%>
            </div></td>
            <td bgcolor="#FFFFFF"><div align="center" class="style160 style161 style53 style190"><%=info("anotacao1")%> </div></td>
        </tr>
<%
info.MoveNext()
i = i + 1
wend
%>          
<tr>
  <td colspan="5" bgcolor="#E9E9E9"><div align="right" class="style191">TOTAL &Agrave; PAGAR:</div></td>
  <td bgcolor="#E9E9E9"><div align="center"><span class="style168 style14 style70">
    <%
set info = oConn.execute("select * from TB_INFO_PAGTO where no_os = "& teste("no_os") &" order by no_os ASC ")

set TABELA1 = oConn.execute ("SELECT * FROM TB_GERAR_OF_OM_CAD WHERE no_cob =" & info("no_cob") & " order by no_os ASC")

pagto = 0
while not(TABELA1.eof)

if (v_status_pagto <> "") then
 set TABELA2 = oConn.execute ("SELECT * FROM TB_INFO_PAGTO WHERE (no_os =" & TABELA1("no_os") & ") and (no_cob =" & info("no_cob") & ") AND (status_pagto = '" & v_status_pagto & "') order by no_os ASC")
else
 set TABELA2 = oConn.execute ("SELECT * FROM TB_INFO_PAGTO WHERE (no_os =" & TABELA1("no_os") & ") AND (no_cob =" & info("no_cob") & ") order by no_os ASC")
end if

 while not(TABELA2.eof)
  pagto = pagto + Cdbl(TABELA2("valor_pagto"))
 TABELA2.MoveNext()
  wend

 TABELA1.MoveNext() 
wend

%>
    </span><span class="style43">
    <input name="valor_pagto_<%=i%>" type="text" class="campo_branco_ng" id="valor_pagto_<%=i%>" value="<%=ROUND(pagto,2)%>" size="10" alt="decimal"/>
  </span></div></td>
  <td bgcolor="#E9E9E9">&nbsp;</td>
  <td bgcolor="#E9E9E9"><div align="right" class="style191">TOTAL PAGO:</div></td>
  <td bgcolor="#E9E9E9"><div align="center"><span class="style168 style14 style70">
<%
set info = oConn.execute("select * from TB_INFO_PAGTO where no_os = "& teste("no_os") &" order by no_os ASC ")

set TABELA1 = oConn.execute ("SELECT * FROM TB_GERAR_OF_OM_CAD WHERE no_cob =" & info("no_cob") & " order by no_os ASC")

pago = 0
while not(TABELA1.eof)

if (v_status_pagto <> "") then
 set TABELA2 = oConn.execute ("SELECT * FROM TB_INFO_PAGTO WHERE (no_os =" & TABELA1("no_os") & ") and (no_cob =" & info("no_cob") & ") AND (status_pagto = '" & v_status_pagto & "') order by no_os ASC")
else
 set TABELA2 = oConn.execute ("SELECT * FROM TB_INFO_PAGTO WHERE (no_os =" & TABELA1("no_os") & ") AND (no_cob =" & info("no_cob") & ") order by no_os ASC")
end if

 while not(TABELA2.eof)
  pago = pago + Cdbl(TABELA2("valor_pago"))
 TABELA2.MoveNext()
  wend

 TABELA1.MoveNext() 
wend
%>
    </span><span class="style43">
    <input name="valor_pago_<%=i%>" type="text" class="campo_branco_ng" id="valor_pago_<%=i%>" value="<%=ROUND(pago,2)%>" size="10" alt="decimal"/>
  </span></div></td>
  <td bgcolor="#E9E9E9">&nbsp;</td>
  <td rowspan="2" bgcolor="#E9E9E9"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td valign="middle"><div align="left"><span class="style35"><strong>&nbsp;TOTAL COB.: </strong></span></div></td>
      <td valign="middle"><div align="left"><span class="style154">
          <%
soma1 = 0
 set TABELA2 = oConn.execute ("SELECT * FROM TB_GERAR_OF_OM_CAD WHERE no_cob =" & teste("no_cob") & " ")

 while not(TABELA2.eof)
  soma1 = soma1 + Cdbl(TABELA2("total_geral"))
 TABELA2.MoveNext()
  wend
%>
          </span><span class="style171">
          <input name="total_geral" type="text" class="forma_pag111" disabled="disabled" id="total_geral" value="<%=ROUND(soma1,2)%>" size="10" alt="decimal"/>
      </span></div></td>
    </tr>
    <tr>
      <td valign="middle" bgcolor="#990000"><div align="left"><span class="style155 style172 style1 style157"><strong>&nbsp;TOTAL D&Eacute;BITO: </strong></span></div></td>
      <td valign="middle" bgcolor="#990000"><div align="left"><span class="style154">
          <%
soma2 = 0
 set TABELA2 = oConn.execute ("SELECT * FROM TB_DEBITO WHERE  no_cob =" & teste("no_cob") & " ")

 while not(TABELA2.eof)
  soma2 = soma2 + Cdbl(TABELA2("valor_debito"))
 TABELA2.MoveNext()
  wend
%>
          <span class="style171">
          <input name="valor_debito" type="text" class="forma_pag121" disabled="disabled" id="valor_debito" value="<%=ROUND(soma2,2)%>" size="10" alt="decimal"/>
      </span></span></div></td>
    </tr>
    <tr>
      <td valign="middle"><div align="left" class="style35"><strong>&nbsp;TOTAL CR&Eacute;DITO:</strong></div></td>
      <td valign="middle"><div align="left"><span class="style154">
          <%
soma3 = 0
 set TABELA2 = oConn.execute ("SELECT * FROM TB_CREDITO WHERE  no_cob =" & teste("no_cob") & " ")

 while not(TABELA2.eof)
  soma3 = soma3 + Cdbl(TABELA2("valor_credito"))
 TABELA2.MoveNext()
  wend
%>


          </span><span class="style171">
          <input name="valor_credito" type="text" class="forma_pag111" disabled="disabled" id="valor_credito" value="<%=ROUND(soma3,2)%>" size="10" alt="decimal"/>
      </span></div></td>
    </tr>
    <tr>
      <td width="1086" valign="middle"><div align="left" class="style35"><strong>&nbsp;TOTAL A PAGAR:</strong></div>
          <strong>
          <label> </label>
        </strong></td>
      <td width="93" valign="middle"><div align="left"><span class="style154">

<%
pago = 0
 set TABELA2 = oConn.execute ("SELECT * FROM TB_INFO_PAGTO WHERE no_cob =" & teste("no_cob") & " ")

 while not(TABELA2.eof)
  pago = pago + Cdbl(TABELA2("valor_pago"))
 TABELA2.MoveNext()
  wend

var_novo_total = soma1 + soma2 - soma3 - pago

var_novo_total = ROUND(var_novo_total,2)
%>
          </span><span class="style171">
          <input name="v_total_cred_deb" type="text" class="forma_pag131"  id="v_total_cred_deb" value="<%=var_novo_total%>" size="10" alt="decimal" />
      </span></div></td>
    </tr>
  </table></td>
</tr>
<tr>
  <td colspan="10" valign="top" bgcolor="#E9E9E9"><span class="style10"><span class="style191"><strong>OBS COB.: <br />
  </strong><%=teste("informe_cob")%> </span></span></td>
  </tr>

<tr>
  <td height="18" colspan="11" bgcolor="#CCCCCC"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    
    <tr>
      <td height="18" bgcolor="#FFFFCC"><span class="style35 style18 style53 style190">FORMA DE PAGAMENTO:</span></td>
      <td bgcolor="#FFFFCC"><span class="style35 style18 style53 style190">&nbsp;ATO:
        <label></label>
            <strong><strong>
            <%
ato = info("ato")

if ato = "x" then
   Response.Write ("X")
end if
%>
          </strong></strong></span></td>
      <td bgcolor="#FFFFCC"><span class="style35 style18 style53 style190">&nbsp;10:
          <label></label>
          <strong><strong>
          <%
dd10 = info("dd10")

if dd10 = "x" then
   Response.Write ("X")
end if
%>
          </strong></strong></span></td>
      <td bgcolor="#FFFFCC"><span class="style35 style18 style53 style190">&nbsp;30:
        <label></label>
            <strong><strong>
            <%
dd30 = info("dd30")

if dd30 = "x" then
   Response.Write ("X")
end if
%>
          </strong></strong></span></td>
      <td bgcolor="#FFFFCC"><span class="style35 style18 style53 style190"> &nbsp;60:<strong>
        <label></label>
        </strong></span><span class="style190 style53 style18 style163"><strong>
        <%
dd60 = info("dd60")

if dd60 = "x" then
   Response.Write ("X")
end if
%>
          </strong></span></td>
      <td bgcolor="#FFFFCC"><span class="style35 style18 style53 style190">&nbsp;90:
        <label></label>
            <strong><strong>
            <%
dd90 = info("dd90")

if dd90 = "x" then
   Response.Write ("X")
end if
%>
          </strong></strong></span></td>
      <td bgcolor="#FFFFCC"><span class="style35 style18 style53 style190">&nbsp;120:
          <label></label>
          <strong><strong>
          <%
dd120 = info("dd120")

if dd120 = "x" then
   Response.Write ("X")
end if
%>
          </strong></strong> </span></td>
      <td bgcolor="#FFFFCC"><span class="style35 style18 style53 style190">&nbsp;135:
          <label></label>
          <strong><strong>
          <%
dd135 = info("dd135")

if dd135 = "x" then
   Response.Write ("X")
end if
%>
          </strong></strong></span></td>
      <td bgcolor="#FFFFCC"><span class="style35 style18 style53 style190">150:
          <label></label>
          <strong><strong>
          <%
dd150 = info("dd150")

if dd150 = "x" then
   Response.Write ("X")
end if
%>
          DIAS&nbsp;</strong></strong></span></td>
    </tr>
  </table></td>
  </tr>
<tr>
  <td height="2" colspan="11"><hr /></td>
</tr>
    </table></td>
      </tr>
<%
 Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
    teste.MoveNext()
    i = i + 1
    wend
%>     
</table>
<div align="center">
  <div align="center"><span class="style23"><span class="style50">  </span></span><span class="style23"><span class="style50">    </span></span><span class="style23"><span class="style50">TOTAL COBRAN&Ccedil;A(s):</span> <span class="style194"><%=(teste_total)%></span></span>
    <table width="45%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table width="31%" border="0" align="center">
            <tr>
              <td><div align="center">
                  <% If MM_offset <> 0 Then %>
                  <a href="<%=MM_moveFirst%>"><img src="First.gif" width="29" height="27" border="0" /></a>
                  <% End If ' end MM_offset <> 0 %>
              </div></td>
              <td><div align="center">
                  <% If MM_offset <> 0 Then %>
                  <a href="<%=MM_movePrev%>"><img src="Previous.gif" width="29" height="26" border="0" /></a>
                  <% End If ' end MM_offset <> 0 %>
              </div></td>
              <td><div align="center">
                  <% If Not MM_atTotal Then %>
                  <a href="<%=MM_moveNext%>"><img src="Next.gif" width="29" height="26" border="0" /></a>
                  <% End If ' end Not MM_atTotal %>
              </div></td>
              <td><div align="center">
                  <% If Not MM_atTotal Then %>
                  <a href="<%=MM_moveLast%>"><img src="Last.gif" border="0" /></a>
                  <% End If ' end Not MM_atTotal %>
              </div></td>
            </tr>
        </table></td>
      </tr>
   </table>
<%
   'response.redirect("teste.asp?soma1=" & soma1 & "&soma2=" & soma2 & "&soma3=" & soma3 & "&pago=" & pago)
%>
   
  </div>
</div>
</body>
</html>
<%
teste.Close()
Set teste = Nothing
'end if
%>

E preciso pegar o nome da empresa e aparecer todas as cobranças referente a está empresa.

Muito obrigado

Editado por quintelab
Adicionado BBCode Code
Link para o comentário
Compartilhar em outros sites

  • 0

você num espera q a gente olhe um codigo de 1200 linhas ne??

em vez disso explica melhor o q você quer.

1 - você quer q so apareca uma linha para a empresa e a soma do valor de todas as cobrancas??

se for, use um group by com sum() como disse o bareta.

2 - você quer agrupar todas as cobrancas da mesma empresa juntos?? tipo, uma embaxo da otra, mas num mesmo grupo pra cada empresa??

se for, na hora do select você ordena pela empresa. quando chegar na empresa, você faz um while q vai checando o recordset ate mudar de empresa. enquanto não mudar, você vai pondo as cobrancas todas juntas.

veja ai se isso ajuda, qualquer duvida poste.

ou se você quer alguma coisa diferente, tente explicar melhor.

Link para o comentário
Compartilhar em outros sites

  • 0

Bom dia

Eu preciso disto aqui, conforme você me perguntou:

2 - você quer agrupar todas as cobrancas da mesma empresa juntos?? tipo, uma embaxo da otra, mas num mesmo grupo pra cada empresa??

se for, na hora do select você ordena pela empresa. quando chegar na empresa, você faz um while q vai checando o recordset ate mudar de empresa. enquanto não mudar, você vai pondo as cobrancas todas juntas.

É que estou com uma grande dificuldade, tentei fazer conforme você me explicou mas não deu certo.

Muito obrigado pela sua atenção.

Link para o comentário
Compartilhar em outros sites

  • 0

a eu não sei direito qual é o layout q você quer q fique, mas o codigo seria mais o menos assim ó:

<% sql = "Select * From cobranca Order By empresa"
Set rs = cn.Execute(sql)

Dim empresa

empresa = 0 'ponha aqui um codigo q você sabe q não existe.

Do While Not rs.EOF
    If empresa <> rs!empresa Then
        If empresa <> 0 Then
            Response.Write "</div>"
        End If
        empresa = rs!empresa %>
        <div>
            <h2><% = rs!nome_empresa %></h2>
    <% End If

    Response.Write rs!cobranca & "<br />"

    rs.MoveNext
Loop

If empresa <> 0 Then
    Response.Write "</div>"
End If %>[/code]

veja ai se consegue entender, qualquer coisa poste.

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,5k
×
×
  • Criar Novo...