OUTROARQ SCCRCLI
OUTROARQ SE_PROD SEIP_C PCOD 
variavel zPcod := 0
variavel zQuant := 0
variavel zPrTotal := 0
variavel zPdesc := ''
variavel zPrUnit := 0
variavel pag := 1
variavel sPrtLineLen := 80
variavel zDesenhoDoForm := ""
variavel zFgTemServicos := .f.
variavel zTotMercadoria := 0
variavel zTotServicos   := 0
variavel zTotDevolucoes := 0
variavel zareaOrig := select()
variavel wCrNumPed := ""
VARIAVEL #TEXTO_FONTE
   
   debugalert('0 cupom.lst ')

      oLst:cAlias_DataCols := 'itens'
      oLst:cAliasMaster := 'itens'
      oLst:lPrtRodape := .f.
      oLst:lPortrait := .t.
      OLST:NLinesPorPagina := 50

      TEXT INTO zDesenhoDoForm
         .function DesenhaForm
            oPdf:nLinesPorPagina := oLst:nLinesPorPagina
            oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1-(oPdf:pRow+1 + 6) )
            oPdf:Box( oPdf:pRow+1+ oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6), 0, oPdf:sPrtLineLen, 6)
            oPdf:Box( oPdf:pRow+1+ oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6), 47, oPdf:sPrtLineLen-47, 6, 1, {0.95, 0.95, 0.95}, 3)
            oPdf:Box( oPdf:pRow+1+ oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6), 47, oPdf:sPrtLineLen-47, 6)
         .end_function
      ENDTEXT
      oLst:PrtLine( 'CONFIG', zDesenhoDoForm)

      oLst:AddCol('Prod;zPcod;P;999999;6;;')
      oLst:AddCol('Descricao;zPdesc;P;@S35;35;;')
      oLst:AddCol('Quant;zQuant;P;9999.99;7;;')
      oLst:AddCol('Vl.Unit;zPrUnit;P;@E 99,999.99;9;;')
      oLst:AddCol('Vl.Total;zPrTotal;P;@E 99,999.99;9;;')
      
      if m_fValDev>0
         oLst:Cab1( "RESGATE DE VALE-GAS "+StrZero(m_fnumped,10) )
         oLst:AddCab( '_LINHA_GROSSA_' )
      else
         oLst:Cab1( "ORCAMENTO "+StrZero(m_fnumped,10) )
         oLst:AddCab( '_LINHA_GROSSA_' )
         oLst:AddCab( {"style"=>"font:Helvetica-Bold", "COLS"=>"0,C"}, "NAO E' NOTA FISCAL - NAO E' VALIDO COMO RECIBO E COMO GARANTIA DE" )
         oLst:AddCab( {"style"=>"font:Helvetica-Bold", "COLS"=>"0,C"}, "MERCADORIA - NAO COMPROVA PAGAMENTO" )
      endif
      oLst:AddCab( '_LINHA_GROSSA_' )
      oLst:AddCab( {"COLS"=>"0,C"} ,{"style"=>"font:Helvetica-BoldOblique"}, 'Identificacao do Estabelecimento Emitente' )
      oLst:AddCab( 'Emitente:'+AllTrim(hDadosEmp["EMP_NOME"]), 'CNPJ: '+AllTrim(emp_cgc) )
      oLst:AddCab( 'Vendedor: ('+lTrim(Str(m_fVendedor,6))+') '+AllTrim(m_fnome), 'Em '+Dtoc(m_fDataEmi)+' as '+left(m_fHora,5)+'hs')

      if m_fValDev=0
         oLst:AddCab( '_LINHA_GROSSA_' )
         Abra("0NOIDX",r_siga,"vb_fpag","vb_fpag","vb_fpag","fplanopag")
         if dbseek(m_fplanopag)
            oLst:AddCab( {"COLS"=>"0,C"} ,{"style"=>"font:Helvetica-BoldOblique"}, 'Forma de Pagamento: '+AllTrim(vb_fpag->pdesc) )
         endif
         DbCloseArea()
         wCrNumPed := strzero(m_fnumped,6)
   
         ABRA ("0NOIDX", r_siga, "SCCRDUP", "SCCRDUP", "SCRID_ND", "CR_NUM_PED")
         oLst:AddCab( {"style"=>"font:Helvetica-BoldOblique"}, 'Parcela       Vencto' ,'Valor  Td' )
         if DbSeek(wCrNumPed)
            do while .not. eof() .and. left(cr_num_ped,6) = wCrNumPed
               if (cr_cod_Cli=m_fcli .or. cr_tip_dup="FP" ) 
                  oLst:AddCab( {"style"=>"font:Helvetica-BoldOblique"}, alltrim(cr_num_ped)+' '+Dtoc(if(cr_tip_dup$"CT/CH",cr_dt_doc,cr_dt_venc)) , Transform(cr_valor,"@E 99999,999.99")+' '+cr_tip_dup )
               endif
               skip
            enddo
         endif
         DbCloseArea()
         DbSelectArea(zareaOrig)
      endif
      
      oLst:AddCab( '_LINHA_FINA_' )
      if m_fValDev=0
         oLst:AddCab( {"COLS"=>"0,C"} ,{"style"=>"font:Helvetica-BoldOblique"}, 'Identificacao do Destinatario' )
      else
         oLst:AddCab( {"COLS"=>"0,C"} ,{"style"=>"font:Helvetica-BoldOblique"}, 'Identificacao do Cliente' )
      endif
      if m_fcli>0
         Sccrcli->(DbGoto( m_fcli ))
         oLst:AddCab( 'Nome: '+strzero(m_fcli,6)+'- '+AllTrim (wcCrNome))
         oLst:AddCab( 'Cpf.CNPJ: '+AllTrim(sccrcli->cr_CGC), 'RG.IE: '+AllTrim(sccrcli->cr_INSC_ES), 'Fone:'+AllTrim(sccrcli->cr_fone))
         oLst:AddCab( 'Email: '+AllTrim(sccrcli->cr_email),'Fax/Celular:'+AllTrim(sccrcli->Cr_fax))
         oLst:AddCab( 'Endereco: '+sccrcli->(AllTrim(cr_rua)+' '+AllTrim(cr_bairro)+' '+AllTrim(cr_cep)) )
         if !empty(sccrcli->cr_pontore)
            oLst:AddCab( 'Ponto Ref: '+AllTrim(sccrcli->cr_pontore) )
         endif
      else
         oLst:AddCab( 'Nome: Cliente Avulso', '')
      endif

      oLst:AddCab( {"call_pdf_function"=>"DesenhaForm", "style"=>"font:Helvetica-BoldOblique#size:12#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'ITENS VENDIDOS')
      oLst:AddCab( {"style"=>"font:Courier-Oblique"}, '_CABCOLS_')

      oLst:AddRodape( '_LINHA_FINA_', "", {|| "Pagina "+Str(pag++,4)+" "} )

debugalert('1 imprimira itens vendidos na cupom.lst ')
      nRow := 1
      do while nRow <= len(v_pcod)
         zPcod := v_pcod[nRow]
         zQuant := v_quant[nRow]
         zPrTotal := v_valor[nRow]
         if zQuant > 0 .and. se_prod->(DbSeek(zPcod))
            if m_fValDev > 0
               v_valor[nRow] := zQuant * se_prod->pVluVenda
               zPrTotal := zQuant * se_prod->pVluVenda
            endif
            if se_prod->pServico="S"
               zFgTemServicos := .t.               
            else
               zPdesc := se_prod->pDesc
               zPrUnit := v_valor[nRow]/zQuant
               oLst:PrtD( '_DATACOLS_')
               zTotMercadoria := zTotMercadoria + v_valor[nRow]
            endif
         endif
         nRow := nRow+1
      enddo

debugalert('1 imprimira servicos vendidos na cupom.lst ')
      if zFgTemServicos
         oLst:PrtD( '')
         oLst:PrtD( {"style"=>"font:Helvetica-BoldOblique#size:12#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'SERVICOS EXECUTADOS')
         oLst:PrtD( {"style"=>"font:Courier-Oblique"}, '_CABCOLS_')
         // oLst:PrtD( '_LINHA_GROSSA_')
         nRow := 1
         do while nRow <= len(v_pcod)
            zPcod := v_pcod[nRow]
            zQuant := v_quant[nRow]
            zPrTotal := v_valor[nRow]
            if zQuant > 0 .and. se_prod->(DbSeek(zPcod)) .and. se_prod->pServico="S"
               zPdesc := se_prod->pDesc
               zPrUnit := v_valor[nRow]/zQuant
               oLst:PrtD( '_DATACOLS_')
               zTotServicos := zTotServicos + v_valor[nRow]
            endif
            nRow := nRow+1
         enddo
      endif

      nRow := 0
      oLst:PrtD( {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-6-1)"}, "")
      m_fobs:=AllTrim(m_fobs)
      do while ++nRow <= mlCount(m_fobs, 60)
         oLst:PrtD( {"style"=>"font:Courier-Oblique#size:8#col:0#row:(oPdf:pRow+1)"}, rTrim(MemoLine(m_fObs,60,nRow)) )
      enddo

      oLst:PrtD( zTotMercadoria>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-6)"}, " ","Vl.Produtos: "+   Transform(zTotMercadoria ,"@E 99,999,999,999.99") )
      if m_fValDev = 0
         oLst:PrtD( zTotMercadoria>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-6)"}, " ","Vl.Produtos: "+   Transform(zTotMercadoria ,"@E 99,999,999,999.99") )
         oLst:PrtD( zTotServicos >0,  {"style"=>"font:Helvetica-Oblique#col:30#row:(oPdf:pRow+1)"},            " ","Vl.Servicos: "+   Transform(zTotServicos   ,"@E 99,999,999,999.99") )
         // oLst:PrtD( zTotDevolucoes>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"},            " ","Vl.Devolucoes: "+ Transform(zTotDevolucoes ,"@E 99,999,999,999.99") )
   
         oLst:PrtD( m_fDesconto>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","Descontos: "+ Transform(m_fDesconto,"@E 99,999,999,999.99") )
         oLst:PrtD( m_fValDev>0,   {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","Creditos: "+ Transform(m_fValDev,"@E 99,999,999,999.99") )
         oLst:PrtD( {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-2)"}, " ","VALOR: "+ Transform(m_fVal,"@E 99,999,999,999.99") )
      endif
debugalert('11 vai renderizar cupom.lst ')
#FIM_TEXTO_FONTE

comando antes DbGoBottom()


// oLst:AddCab( {"AplicaFormatacaoDefaultNoCabecalho"=>"nao", "style"=>"font:Helvetica-Bold#size:14#ncolor:99#width:80", "COLS"=>"0,C"}, "ORCAMENTO "+StrZero(m_fnumped,10) )
// Fontes Padroes:
// Courier               
// Courier-Bold          negrito
// Courier-Oblique       italico
// Courier-BoldOblique   negrito italico
// Helvetica             
// Helvetica-Bold        negrito
// Helvetica-Oblique     italico
// Helvetica-BoldOblique negrito italico

// oLst:AddCab( {"AplicaFormatacaoDefaultNoCabecalho"=>"nao","style"=>"font:Helvetica-Bold#size:14#ncolor:99#width:80#bold;", "COLS"=>"0,C"}, "ORCAMENTO "+StrZero(m_fnumped,10) )
// Method Say (nRow, nCol, aCellsDeUmaRowParaModificar, cPict, cFont, nSize, uColor, lBold )
// Method Say ( nRow, nCol, cTxt, oFont, nSize, nColor, lFgRowColEmPixels, lRedefina_Largura_e_Altura_Corrente, cAlinhamento, nTamanhoDaColuna)

// pendencia1: colocar quadrado com dados do emitente no topo da pagina  com fontsize 10
// pendencia1: colocar logomarca .jpg no lado esquerdo, com 1/5 do comprimento da linha 

// oLst:AddCab( {"style"=>"font:Helvetica#size:14#ncolor:99#width:80#bold;", "COLS"=>"0,C"}, "ORCAMENTO "+StrZero(m_fnumped,10) )
// oLst:AddCab( {"eval_pdf"=>"eval(zFormPdf)"}, "ORCAMENTO "+StrZero(m_fnumped,10) )

//oLst:AddCab( {"COLS"=>"0,C"} ,{"style"=>"font:Helvetica-BoldOblique#bgfill:{1,{0.65,0.65,0.65},1}"}, 'Dados do Veiculo' )
// (sombraclara ou sombraclaracomborda)   e sombraclarasemborda
// (sombraescura ou sombraescuracomborda) e sombraescurasemborda
// (borda ou comborda ou bordapreta) bordaclara bordaescura

// dentro da .function DesenhaForm :
//    oPdf:Say( 3.1, 10, "eduardo", "Helvetica-BoldOblique")
//    oPdf:Box( 0, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina )
// oPdf:Box( nRow, nCol, nLarguraDoBox, nAlturaDoBox, nGrossuraLinha, aColor, nTypeBordaXpreenchimento )
//           nTypeBordaXpreenchimento: 1-So_Contorno    2-Preenche_Interior   3-Contorno_e_interior
//           aColor: {0,0,0} Preto...  {1,1,1} Branco     {.50,.50,.50} Cinza ...  quanto mais proximo do 1 mais branco fica
// oPdf:sPrtLineLen = largura maxima da linha mais comprida do relatorio
// oPdf:nLinesPorPagina = quantidade de linhas que vou querer por pagina

// oPdf:Box( 0, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1, 1, {0.95, 0.95, 0.95}, 2)
// oPdf:Box( 0, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1)

// oPdf:Box( 0, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina - 1 )
// oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1)
//debugalert('--> lst_tp: '+str(oPdf:nLinesPorPagina,4) )
//debugalert('--> box: linha_ini:'+str(oPdf:pRow+1,3)+' ate linha: '+str(oPdf:pRow+1+oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6),3) ) 

//  oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen, 14 )
