Create another page in a report in advpl

0

Good morning ..

I'm new to advpl, and I've created a budget impression. But I have a problem and I have no idea how to solve it, and a simple thing but as I am new to advpl I do not even know how to start doing it, when the budget is too big it jumps to another page, but I have no idea how to do it that. If anyone can guide me or thank you very much ..

Follow my code generating a pdf budget

#INCLUDE "FWPrintSetup.ch"
#INCLUDE "topconn.ch"
#INCLUDE "Protheus.ch"
#INCLUDE "TBICONN.CH"
#INCLUDE "rwmake.ch

user function RelCotac()

Local cQuery   := ""
Local nTotal   := 0
Local nIpi     := 0
Local nPesoL   := 0
Local nPesoB   := 0
Local nTotalF  := 0
Local dData    := Dtoc(dDatabase)
Local hHora    := Time()
Local _cAqrMsg  := ""
Local cTexto   := ""

Private oPrinter
Private oFont1
Private oFont2
Private oHGRAY := TBrush():New( , CLR_HGRAY)
Private lPreview
Private cLogo := FisxLogo("1")


    /*** FONTES ***/
Private oFont18T    := TFont():New("Courier New",,18,,.T.,,,,,.F.)
Private oFont16T    := TFont():New("Courier New",,16,,.T.,,,,,.F.)
Private oFont14TC   := TFont():New("Courier New",,14,,.T.,,,,,.F.)
Private oFont14T    := TFont():New("Arial"      ,,14,,.T.,,,,,.F.)
Private oFont18TA   := TFont():New("Arial"      ,,18,,.T.,,,,,.F.)
Private oFont14TI   := TFont():New("Arial"      ,,13,,.T.,,,,.T.,.F.)
Private oFont11F    := TFont():New("Arial"      ,,11,,.F.,,,,,.F.)
Private oFont13T    := TFont():New("Arial"      ,,12,,.T.,,,,,.F.)
Private oFont13F    := TFont():New("Arial"      ,,12,,.F.,,,,,.F.)
Private oFont10FA   := TFont():New("Arial"      ,,10,,.F.,,,,,.F.)
Private oFont10F    := TFont():New("Courier New",,10,,.F.,,,,,.F.)
Private oFont11FA   := TFont():New("Arial"      ,,11,,.F.,,,,,.F.)

Private oFont09T    := TFont():New("Courier New",,09,,.T.,,,,,.F.)
Private oFont07F    := TFont():New("Courier New",,07,,.F.,,,,,.F.)
Private oFont09F    := TFont():New("Courier New",,09,,.F.,,,,,.F.)
Private oFont09FA   := TFont():New("Arial",,09,,.F.,,,,,.F.)

Private oFont7TA    := TFont():New("Courier New",,07,,.T.,,,,,.F.)
Private oFont12F    := TFont():New("Courier New",,12,,.F.,,,,,.F.)
Private oFont10T    := TFont():New("Courier New",,10,,.T.,,,,,.F.)
Private oFont09F    := TFont():New("Courier New",,09,,.F.,,,,,.F.)
Private oFont09T    := TFont():New("Courier New",,09,,.T.,,,,,.F.)
Private oFont14N    := TFont():New("Courier New",14,14,,.T.,,,,.T.,.F.)

Private oFont10AT   := TFont():New("Arial"      ,,10,,.T.,,,,,.F.)
Private oFont10AF   := TFont():New("Arial"      ,,10,,.F.,,,,,.F.)



If oPrinter == Nil
lPreview := .T.
oPrinter      := FWMSPrinter():New(SCJ->CJ_NUM ,6,.F.,,.T.)
oPrinter:SetResolution(72) //Tamanho estipulado para a Danfe
oPrinter:SetPortrait()
oPrinter:SetPaperSize(9)
oPrinter:SetMargin(60,60,60,60)
oPrinter:cPathPDF :="C:\TEMP\"    
EndIf


oPrinter:StartPage()
//oPrinter:Box (60, 60, 830, 530)

If cEmpAnt == "01"
oPrinter:SayBitmap( 50, 30, cLogo , 100, 100)
oPrinter:Say(80,180,"PIC-QUÍMICA E FARMACÊUTICA LTDA",                                         oFont14TC)
oPrinter:Say(100,150,"Morada da Estrelas, 65 - Jd. Nova Itapevi - ITAPEVI - SP",               oFont09F)
oPrinter:Say(108,150, "Fone: 11 4151-9000 - CNPJ: 03.421.909/0001-01 - I.E: 373.083.103.117",  oFont09F)
oPrinter:Say(116,150, "www.pic-web.com.br.com.br - [email protected]",                     oFont09F)
oPrinter:Say(140,210, "PROPOSTA DE VENDA Nº:" + ALLTRIM(SCJ->CJ_NUM) ,                         oFont14TC)
Else
oPrinter:SayBitmap( 80, 20, cLogo , 110, 60)
oPrinter:Say(80,80,"PHARMASPECIAL ESTEPCIALIDADES QUIMÍCAS E FARMACEUTICAS LTDA",              oFont14TC)
oPrinter:Say(100, 150,"Morada da Estrelas, 55 - Jd. Nova Itapevi - ITAPEVI - SP",              oFont09F)
oPrinter:Say(108,150, "Fone: 11 4151-9000 - CNPJ: 65.678.617/0001-06 - I.E: 373.083.103.117",  oFont09F)
oPrinter:Say(116,150, "www.pharmaspecial.com.br - [email protected]",                oFont09F)
oPrinter:Say(140,210, "PROPOSTA DE VENDA Nº:" + ALLTRIM(SCJ->CJ_NUM) ,                         oFont14TC)
EndIf


oPrinter:Line(150,05,150,550)
If cEmpAnt == "01"
    cQuery += " SELECT SCJ.CJ_EMISSAO,SCJ.CJ_CLIENT,SB1.B1_PESO,SB1.B1_PESBRU,SB5.B5_QE1, " + CRLF
    cQuery += " SA1.A1_NOME,SA1.A1_END,SA1.A1_BAIRRO,SA1.A1_CEP,SA1.A1_MUN,SA1.A1_EST,SA1.A1_DDD,SA1.A1_TEL,SA1.A1_CONTATO,SA1.A1_CGC,SA1.A1_INSCR,SA1.A1_EMAIL," + CRLF
    cQuery += " SCK.CK_ITEM,SCK.CK_PRODUTO,SCK.CK_UM,SCK.CK_QTDVEN,SCK.CK_PRCVEN,SCK.CK_VALOR,SCK.CK_DESCRI,SCK.CK_XIPI" + CRLF
    cQuery += " FROM " +RetSqlName("SCJ")+ " SCJ(NOLOCK),       " + CRLF
    cQuery += "      " +RetSqlName("SA1")+ " SA1(NOLOCK),       " + CRLF
    cQuery += "      " +RetSqlName("SCK")+ " SCK(NOLOCK),       " + CRLF
    cQuery += "      " +RetSqlName("SB5")+ " SB5(NOLOCK),       " + CRLF
    cQuery += "      " +RetSqlName("SB1")+ " SB1(NOLOCK)        " + CRLF
    cQuery += " WHERE SCJ.CJ_NUM ='" + ALLTRIM(SCJ->CJ_NUM) + "'" + CRLF 
    cQuery += " AND SCJ.CJ_FILIAL = '" + xFilial ("SCJ")  + "'  " + CRLF
    cQuery += " AND SCK.CK_FILIAL = '" + xFilial ("SCK")  + "'  " + CRLF
    cQuery += " AND SA1.A1_COD = SCJ.CJ_CLIENT                  " + CRLF
    cQuery += " AND SA1.A1_LOJA = SCJ.CJ_LOJA                   " + CRLF
    cQuery += " AND SCK.CK_NUM = SCJ.CJ_NUM                     " + CRLF
    cQuery += " AND SCK.CK_PRODUTO = SB5.B5_COD                 " + CRLF
    cQuery += " AND SCK.CK_PRODUTO = SB1.B1_COD                 " + CRLF
    cQuery += " AND SCJ.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " AND SA1.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " AND SCK.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " AND SB5.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " AND SB1.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " ORDER BY SCK.CK_ITEM                            " + CRLF
Else
    cQuery += " SELECT SCJ.CJ_EMISSAO,SCJ.CJ_CLIENT,SB1.B1_PESO,SB1.B1_PESBRU, " + CRLF
    cQuery += " SA1.A1_NOME,SA1.A1_END,SA1.A1_BAIRRO,SA1.A1_CEP,SA1.A1_MUN,SA1.A1_EST,SA1.A1_DDD,SA1.A1_TEL,SA1.A1_CONTATO,SA1.A1_CGC,SA1.A1_INSCR,SA1.A1_EMAIL," + CRLF
    cQuery += " SCK.CK_ITEM,SCK.CK_PRODUTO,SCK.CK_UM,SCK.CK_QTDVEN,SCK.CK_PRCVEN,SCK.CK_VALOR,SCK.CK_DESCRI,SCK.CK_XIPI" + CRLF
    cQuery += " FROM " +RetSqlName("SCJ")+ " SCJ(NOLOCK),       " + CRLF
    cQuery += "      " +RetSqlName("SA1")+ " SA1(NOLOCK),       " + CRLF
    cQuery += "      " +RetSqlName("SCK")+ " SCK(NOLOCK),       " + CRLF
    cQuery += "      " +RetSqlName("SB1")+ " SB1(NOLOCK)        " + CRLF
    cQuery += " WHERE SCJ.CJ_NUM ='" + ALLTRIM(SCJ->CJ_NUM) + "'" + CRLF 
    cQuery += " AND SCJ.CJ_FILIAL = '" + xFilial ("SCJ")  + "'  " + CRLF
    cQuery += " AND SCK.CK_FILIAL = '" + xFilial ("SCK")  + "'  " + CRLF
    cQuery += " AND SA1.A1_COD = SCJ.CJ_CLIENT                  " + CRLF
    cQuery += " AND SA1.A1_LOJA = SCJ.CJ_LOJA                   " + CRLF
    cQuery += " AND SCK.CK_NUM = SCJ.CJ_NUM                     " + CRLF
    cQuery += " AND SCK.CK_PRODUTO = SB1.B1_COD                 " + CRLF
    cQuery += " AND SCJ.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " AND SA1.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " AND SCK.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " AND SB1.D_E_L_E_T_ = ' '                        " + CRLF
    cQuery += " ORDER BY SCK.CK_ITEM                            " + CRLF
EndIf


  If Select("QRP") > 0
    Dbselectarea("QRP")
    QRP->(DbClosearea())
EndIf

TcQuery cQuery New Alias "QRP"

//Tratamento para campo data
TCSetField( 'QRP', "CJ_EMISSAO", "D" )

oPrinter:Say(80,  485, "DATA:",                                                                                                 oFont07F)
oPrinter:Say(80,  505, OemToAnsi(dData),                                                                                        oFont07F)
oPrinter:Say(90,  485, "HORA:",                                                                                                 oFont07F)
oPrinter:Say(90,  505, OemToAnsi(hHora),                                                                                        oFont07F)
oPrinter:Say(130, 435, "EMISSÃO: " +OemToAnsi(Dtoc(QRP->CJ_EMISSAO)),                                                           oFont13T)
oPrinter:Say(160, 200, "DADOS DO CLIENTE",                                                                                      oFont14TC)
oPrinter:Say(170, 10, "CLIENTE: ",                                                                                              oFont10T)
oPrinter:Say(170, 50, +ALLTRIM(QRP->CJ_CLIENT)+ ' - ' +ALLTRIM(QRP->A1_NOME),                                                   oFont10F)
oPrinter:Say(180, 10, "ENDEREÇO: ",                                                                                             oFont10T)
oPrinter:Say(180, 55, +ALLTRIM(QRP->A1_END),                                                                                    oFont10F)
oPrinter:Say(190, 10, "BAIRRO: ",                                                                                               oFont10T)
oPrinter:Say(190, 45, +ALLTRIM(QRP->A1_BAIRRO),                                                                                 oFont10F)
oPrinter:Say(190, 300, "CEP: ",                                                                                                 oFont10T)
oPrinter:Say(190, 320, +ALLTRIM(QRP->A1_CEP),                                                                                   oFont10F)
oPrinter:Say(200, 10, "CIDADE: ",                                                                                               oFont10T)
oPrinter:Say(200, 45, +ALLTRIM(QRP->A1_MUN),                                                                                    oFont10F)
oPrinter:Say(200, 300, "UF: ",                                                                                                  oFont10T)
oPrinter:Say(200, 320, +ALLTRIM(QRP->A1_EST),                                                                                   oFont10F)
oPrinter:Say(190, 400, "INSC. EST.: ",                                                                                          oFont10T)
oPrinter:Say(190, 455, +ALLTRIM(TransForm(QRP->A1_INSCR, '@r 999.999.999-99')),                                                 oFont10F)
oPrinter:Say(200, 425, "CNPJ: ",                                                                                                oFont10T)
oPrinter:Say(200, 455, +ALLTRIM(TransForm(QRP->A1_CGC, '@r 99.999.999/9999-99')),                                               oFont10F)
oPrinter:Say(210, 10, "CONTATO: ",                                                                                              oFont10T)
oPrinter:Say(210, 50, +ALLTRIM(QRP->A1_CONTATO),                                                                                oFont10F)
oPrinter:Say(210, 200, "TEL: ",                                                                                                 oFont10T)
oPrinter:Say(210, 220, '('+ALLTRIM(QRP->A1_DDD)+')'+ALLTRIM(TransForm(QRP->A1_TEL, '@r 9999-9999')),                            oFont10F)
oPrinter:Say(210, 300, "E-MAIL: ",                                                                                              oFont10T)
oPrinter:Say(210, 335, +ALLTRIM(QRP->A1_EMAIL),                                                                                 oFont10F)

oPrinter:Line(215,05,215,550)

oPrinter:Say(225,200, " ITENS DA PROPOSTA ",                                                                                      oFont14TC)

oPrinter:FillRect({230, 05, 230+010, 550}, oHGRAY)
oPrinter:Line( 230      ,05 , 60,     05)
oPrinter:Line( 60       ,05 , 60,     550)
oPrinter:Line( 230      ,550 , 60,    550)
oPrinter:Line( 230      ,05 , 230,    550)
oPrinter:Line( 230+10   ,05 , 230+10, 550)
oPrinter:Line( 230      ,05 , 230+10,  05)
oPrinter:Line( 230      ,05 , 230+10,  05)
// Linhas horizontais
oPrinter:Line( 230      ,40  , 230+10,  40)
oPrinter:Line( 230      ,260 , 230+10,  260)
oPrinter:Line( 230      ,310 , 230+10,  310)
oPrinter:Line( 230      ,340 , 230+10,  340)
oPrinter:Line( 230      ,400 , 230+10,  400)
oPrinter:Line( 230      ,430 , 230+10,  430)
oPrinter:Line( 230      ,480 , 230+10,  480)
oPrinter:Line( 230      ,550 , 230+10,  550)

oPrinter:Say(237, 12, "ITENS",                                                                                                   oFont7TA)
oPrinter:Say(237, 45, "DESCRIÇÃO - PRODUTOS",                                                                                    oFont7TA)
oPrinter:Say(237, 277, "QTDA.",                                                                                                  oFont7TA)
oPrinter:Say(237, 317, "UNID.",                                                                                                  oFont7TA)
oPrinter:Say(237, 353, "VLR. UNIT.",                                                                                             oFont7TA)
oPrinter:Say(237, 409, "% IPI",                                                                                                  oFont7TA)
oPrinter:Say(237, 442, "ICMSRET",                                                                                                oFont7TA)
oPrinter:Say(237, 505, "TOTAL",                                                                                                  oFont7TA)

nLinha1 := 240
nLinha2 := 247    
nLinha  := 250

While !("QRP")->(EOF())


   oPrinter:Line( nLinha  ,05 , nLinha   , 550)

   oPrinter:Line( nLinha1 ,05  , nLinha1+10,  05)
   oPrinter:Line( nLinha1 ,40  , nLinha1+10,  40)
   oPrinter:Line( nLinha1 ,260 , nLinha1+10,  260)
   oPrinter:Line( nLinha1 ,310 , nLinha1+10,  310)
   oPrinter:Line( nLinha1 ,340 , nLinha1+10,  340)
   oPrinter:Line( nLinha1 ,400 , nLinha1+10,  400)
   oPrinter:Line( nLinha1 ,430 , nLinha1+10,  430)
   oPrinter:Line( nLinha1 ,480 , nLinha1+10,  480)
   oPrinter:Line( nLinha1 ,550 , nLinha1+10,  550)   
   oPrinter:Say( nLinha2, 15, +ALLTRIM(("QRP")->CK_ITEM),                                                                            oFont09F )
   oPrinter:Say( nLinha2, 45, +ALLTRIM(("QRP")->CK_DESCRI),                                                                          oFont09F )
   oPrinter:Say( nLinha2, 275, +TRANSFORM(("QRP")->CK_QTDVEN,'@e 999.99'),                                                           oFont09F )
   oPrinter:Say( nLinha2, 320, +ALLTRIM(("QRP")->CK_UM),                                                                             oFont09F )
   oPrinter:Say( nLinha2, 350, +TRANSFORM(("QRP")->CK_PRCVEN,'@E 999,999.999'),                                                      oFont09F )
   oPrinter:Say( nLinha2, 400, +TRANSFORM(("QRP")->CK_XIPI,'@E 999.99'),                                                             oFont09F )
   oPrinter:Say( nLinha2, 490, +TRANSFORM(("QRP")->CK_VALOR,'@E 999,999.999'),                                                       oFont09F )
   nLinha1 += 10 
   nLinha2 += 10      
   nLinha  += 10

   nTotal    += QRP->CK_VALOR
   nIpi      += (QRP->CK_VALOR * QRP->CK_XIPI)/100

 If cEmpAnt == "01"
   nPesoL += (QRP->B1_PESO * QRP->B5_QE1)
   nPesoB += (QRP->B1_PESBRU * QRP->B5_QE1)
 Else
   nPesoL += QRP->B1_PESO
   nPesoB += QRP->B1_PESBRU
 EndIf

   QRP->(DbSkip())

EndDo

nTotalF   += (nTotal + nIpi)

oPrinter:Box(nLinha1,    05, nLinha1+80, 550)
oPrinter:Line( nLinha+55  ,05 , nLinha+55   , 550)
oPrinter:Say(nLinha1+20, 15, "SUBTOTAL: ",                                                                                           oFont14TC)
oPrinter:Say(nLinha1+20, 90, +TRANSFORM(nTotal,'@E 999,999.999'),                                                                    oFont14TC)
oPrinter:Say(nLinha1+35, 15, "TOTAL IPI: ",                                                                                          oFont14TC)
oPrinter:Say(nLinha1+35, 90, +TRANSFORM(nIpi,'@E 999,999.999'),                                                                      oFont14TC)
oPrinter:Say(nLinha1+50, 15, "TOTAL FAT.: ",                                                                                         oFont14TC)
oPrinter:Say(nLinha1+50, 90, +TRANSFORM(nTotalF,'@E 999,999.999'),                                                                   oFont14TC) 
oPrinter:Say(nLinha+65,  45, "PESO LIQUIDO: ",                                                                                       oFont10T)
oPrinter:Say(nLinha+65,  90,  +TRANSFORM(nPesoL,'@E 999,999.999'),                                                                   oFont10F)
oPrinter:Say(nLinha+65,  355, "PESO BRUTO: ",                                                                                        oFont10T)
oPrinter:Say(nLinha+65,  390, +TRANSFORM(nPesoB,'@E 999,999.999'),                                                                   oFont10F)



 _cAqrMsg := 'MSGPROPOST'+cEmpAnt+cValToChar("2")
 cTexto := MemoRead('\system\'+_cAqrMsg+".LOG") 

 oPrinter:Say(nLinha+90, 05, "INFORMATIVOS E PROMOÇÕES:",                                       oFont14TC)                                            
 oPrinter:Say(nLinha+100, 05, MemoLine(cTexto,120,1),                                            oFont10F)
 oPrinter:Say(nLinha+110, 05, MemoLine(cTexto,120,2),                                            oFont10F)
 oPrinter:Say(nLinha+120, 05, MemoLine(cTexto,120,3),                                            oFont10F)
 oPrinter:Say(nLinha+130, 05, MemoLine(cTexto,120,4),                                            oFont10F)
 oPrinter:Say(nLinha+140, 05, MemoLine(cTexto,120,5),                                            oFont10F)
 oPrinter:Say(nLinha+150, 05, MemoLine(cTexto,120,6),                                            oFont10F)
 oPrinter:Say(nLinha+170, 05, MemoLine(cTexto,120,7),                                            oFont10T)
 oPrinter:Say(nLinha+180, 05, MemoLine(cTexto,120,8),                                            oFont10T)  

 oPrinter:Line(nLinha+200,05,nLinha+200,550)

  _cAqrMsg := 'MSGPROPOST'+cEmpAnt+cValToChar("1")
  cTexto := MemoRead('\system\'+_cAqrMsg+".LOG")

 oPrinter:Say(nLinha+210, 05, "FORMAS DE PAGAMENTOS:",                                           oFont14TC)                                            
 oPrinter:Say(nLinha+220, 05, MemoLine(cTexto,120,1),                                            oFont10F)
 oPrinter:Say(nLinha+230, 05, MemoLine(cTexto,120,2),                                            oFont10F)
 oPrinter:Say(nLinha+240, 05, MemoLine(cTexto,120,3),                                            oFont10F)
 oPrinter:Say(nLinha+250, 05, MemoLine(cTexto,120,4),                                            oFont10F)
 oPrinter:Say(nLinha+270, 05, "DADOS BANCARIOS:",                                                oFont14TC)
 oPrinter:Say(nLinha+280, 05, MemoLine(cTexto,120,5),                                            oFont10F)
 oPrinter:Say(nLinha+290, 05, MemoLine(cTexto,120,6),                                            oFont10F) 
 oPrinter:Say(nLinha+310, 05, "VALIDADE DA PROPOSTA:",                                           oFont14TC)
 oPrinter:Say(nLinha+320, 05, MemoLine(cTexto,120,7),                                            oFont10F) 


oPrinter:EndPage()

If lPreview
     oPrinter:Preview()
EndIf                      

FreeObj(oPrinter)
oPrinter := Nil

Return .T.

    
asked by anonymous 29.09.2018 / 17:32

0 answers