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 := 132
variavel zDesenhoDoForm := ""
variavel zFgTemServicos := .f.
variavel zTotMercadoria := 0
variavel zTotServicos   := 0
variavel zTotDevolucoes := 0
variavel zPrCusto := 0
variavel zPrCustoEq := 0
variavel zfVal3 := 0
variavel zfValCf := 0
variavel zPercMargem:=''
variavel zPercMarkup:=''
variavel zPercLiquid:=''

VARIAVEL #TEXTO_FONTE
   debugalert('0 entrou no cupom_dav.lst ')
     // 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:nLinesPorPagina := 66
      oLst:lOutPutXML := .f.

      BLOCO_TXT zDesenhoDoForm
         .function DesenhaForm
            oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen+3, oPdf:nLinesPorPagina-1-(oPdf:pRow+1 + 6) )
            oPdf:Box( oPdf:pRow+1+ oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6), 0, oPdf:sPrtLineLen+3, 6)
            oPdf:Box( oPdf:pRow+1+ oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6), 47, oPdf:sPrtLineLen-47+3, 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+3, 6)
         .end_function
         .setmemo NomeTxt
kj hj kj kj hkj hkjh kjh kj hkjh kjh kjkjkjkj kj kj  kj kj kj khkh kjkj kj hkj.
         .end_setmemo
      FIM_BLOCO_TXT
      oLst:PrtLine( 'CONFIG', zDesenhoDoForm)

      // oLst:EvalLineBlocks('DETALHE', {'saymemo'=>'uppp,2,2,80,3'}  //.saymemo=uppp,2,2,80,3
      // oLst:PrtLine( 'CONFIG', '.saymemo=uppp,2,2,80,3')

      oLst:cAlias_DataCols := 'itens'
      oLst:cAliasMaster := 'itens'
      oLst:lPrtRodape := .f.
      
      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;;')
      oLst:AddCol('Pr.Cst;zPrCusto;P;@E 99,999.99;9;;')
      oLst:AddCol('Vl.Marg;zPrTotal-zPrCusto;P;@E 99,999.99;9;;')
      oLst:AddCol('%Marg;100*(zPrTotal-zPrCusto)/zPrTotal;P;@E 999.99%;7;')
      oLst:AddCol('%MkUp;100*(if(zPrCusto>0,(zPrTotal-zPrCusto)/zPrCusto,0));P;@E 999.99%;7;;')
      
      oLst:AddCab( {"AplicaFormatacaoDefaultNoCabecalho"=>"nao", "style"=>"font:Helvetica-Bold#size:14", "COLS"=>"0,C"}, "PEDIDO "+StrZero(m_fnumped,10) )

      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))+') '+m_fnome, 'Emissao: '+Dtoc(m_fDataEmi)+' as '+m_fHora)
      oLst:AddCab( '_LINHA_FINA_' )
      oLst:AddCab( {"COLS"=>"0,C"} ,{"style"=>"font:Helvetica-BoldOblique"}, 'Identificacao do Destinatario' )
      if m_fcli>0
         Sccrcli->(DbGoto( m_fcli ))
         oLst:AddCab( 'Nome: '+strzero(m_fcli,6)+'- '+AllTrim (wcCrNome), 'RG/IE:'+sccrcli->Cr_Insc_Es, 'CNPJ/CPF: '+sccrcli->Cr_Cgc)
         // oLst:AddCab( 'Fantasia: '+sccrcli->cr_fantasi, 'Contato: '+sccrcli->cr_contato, 'Fone:'+sccrcli->cr_fone)
         oLst:AddCab( 'Contato: '+AllTrim(sccrcli->cr_contato), 'Fone:'+AllTrim(sccrcli->cr_fone))
         oLst:AddCab( 'Email: '+sccrcli->cr_email,'Fax/Celular:'+sccrcli->Cr_fax)
         oLst:AddCab( 'Endereco: '+sccrcli->(AllTrim(cr_rua)+' '+AllTrim(cr_numrua)+' '+AllTrim(cr_bairro)+' '+AllTrim(cr_cep)) )
         if !empty(sccrcli->cr_pontore)
            oLst:AddCab( 'Ponto Ref: '+sccrcli->cr_pontore )
         endif
      else
         oLst:AddCab( 'Nome: Cliente Avulso', '')
      endif

      if sys_segmento='osauto'

         //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

         oLst:AddCab( {"COLS"=>"0,C"} ,{"style"=>"font:Helvetica-BoldOblique#bgfill:BordaEscura"}, 'Dados do Veiculo' )
         oLst:AddCab( 'Marca: '+m_VeicMarca , 'Modelo: '+m_VeicModel, 'Ano Fabricacao: '+m_VeicAnoFab)
         oLst:AddCab( 'Placa: '+m_VeicPlaca, 'Renavam/Chassi: '+m_VeicRenav)
      endif

      // oLst:AddCab( "End..: "+alltrim(Sccrcli->cr_rua), '')
      // oLst:AddCab( "P.Ref: "+alltrim(Sccrcli->cr_pontore), '')
      // oLst:AddCab( "Fone.: "+alltrim(Sccrcli->cr_fone)+" Bairro:"+alltrim(Sccrcli->cr_bairro), '')

      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_dav.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))
            zPrCusto := zQuant * se_prod->pvluven3
            zPrCustoEq := zQuant * se_prod->pVluMin
            zfVal3  := zfVal3 + zPrCusto
            zfValCf := zfValCf + zPrCustoEq
            if se_prod->pServico="S"
               zFgTemServicos := .t.               
            else
               zPdesc := se_prod->pDesc
               zPrUnit := v_valor[nRow]/zQuant
               oLst:EvalLineBlocks('DETALHE', '_DATACOLS_')
               zTotMercadoria := zTotMercadoria + v_valor[nRow]
            endif
         endif
         nRow := nRow+1
      enddo

debugalert('1 imprimira servicos vendidos na cupom_dav.lst ')
      if zFgTemServicos
         oLst:EvalLineBlocks('DETALHE', '')
         // oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-BoldOblique#size:12#ncolor:99#width:80#bgfill:{1,{0.75,0.75,0.75},3}", "COLS"=>"0,C"}, 'SERVICOS EXECUTADOS')
         oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-BoldOblique#size:12#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'SERVICOS EXECUTADOS')
         oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Courier-Oblique"}, '_CABCOLS_')
         // oLst:EvalLineBlocks('DETALHE', '_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:EvalLineBlocks('DETALHE', '_DATACOLS_')
               zTotServicos := zTotServicos + v_valor[nRow]
            endif
            nRow := nRow+1
         enddo
      endif

debugalert('1 imprimira DEVOLUCOES na cupom_dav.lst ')
      if m_fValDev > 0
         oLst:EvalLineBlocks('DETALHE', '')
         oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-BoldOblique#size:12#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'PRODUTOS DEVOLVIDOS')
         oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Courier-Oblique"}, '_CABCOLS_')
         nRow := 1
         do while nRow <= len(v_dpcod) 
            zPcod := v_Dpcod[nRow]
            zQuant := v_Dquant[nRow]
            zPrTotal := v_Dvalor[nRow]
            if zQuant > 0 .and. se_prod->(DbSeek(zPcod)) 
               zPdesc := se_prod->pDesc
               zPrUnit := v_Dvalor[nRow]/zQuant
               oLst:EvalLineBlocks('DETALHE', '_DATACOLS_')
               zTotDevolucoes := zTotDevolucoes + v_Dvalor[nRow]
            endif
            nRow := nRow+1
         enddo
      endif

      // oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-Oblique"}, " ","VALOR DOS PRODUTOS E SERVICOS: "+ Transform(m_fValProd,"@E 99,999,999,999.99") )

      // oLst:EvalLineBlocks('DETALHE', '_LINHA_GROSSA_')

      //oLst:EvalLineBlocks('DETALHE', {"call_pdf_function"=>"reposiciona_cursor"}, " ")

      zPercMargem:=Transform(100*(m_fVal-zfVal3)/m_fVal,"@E 999.99%")
      zPercMarkup:=Transform(100*if(zfVal3>0,(m_fVal-zfVal3)/zfVal3,0),"@E 999.99%")
      zPercLiquid:=Transform(100*(m_fVal-zfValCf)/m_fVal,"@E 999.99%")

      oLst:EvalLineBlocks('DETALHE', zTotMercadoria>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-6)"}, " ","VALOR DOS PRODUTOS: "+   Transform(zTotMercadoria ,"@E 99,999,999,999.99") )
      oLst:EvalLineBlocks('DETALHE', zTotServicos >0,  {"style"=>"font:Helvetica-Oblique#col:30#row:(oPdf:pRow+1)"},            " ","VALOR DOS SERVICOS: "+   Transform(zTotServicos   ,"@E 99,999,999,999.99") )
      // oLst:EvalLineBlocks('DETALHE', zTotDevolucoes>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"},            " ","VALOR DAS DEVOLUCOES: "+ Transform(zTotDevolucoes ,"@E 99,999,999,999.99") )
      oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","MARGEM BRUTA EM VALOR : "+ Transform(m_fVal-zfVal3,"@E 99,999,999,999.99") )
      oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","MARGEM APOS CUSTO OPERACIONAL: "+ Transform(m_fVal-zfValCf,"@E 99,999,999,999.99") )
      oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","MARGEM BRUTA:"+ zPercMargem + "  LIQUIDA: "+ zPercLiquid+"  Markup:"+zPercMarkup )

      oLst:EvalLineBlocks('DETALHE', m_fDesconto>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","DESCONTOS CONCEDIDOS: "+ Transform(m_fDesconto,"@E 99,999,999,999.99") )
      oLst:EvalLineBlocks('DETALHE', m_fValDev>0,   {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:pRow+1)"}, " ","CREDITOS DE DEVOLUCOES: "+ Transform(m_fValDev,"@E 99,999,999,999.99") )
      oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-2)"}, " ","VALOR FINAL DA VENDA: "+ Transform(m_fVal,"@E 99,999,999,999.99") )

debugalert('11 entrou no cupom_dav.lst ')
      
      oLst:Run()
      oLst:End()
#FIM_TEXTO_FONTE

comando antes DbGoBottom()

   // oLst:AddCab( {"AplicaFormatacaoDefaultNoCabecalho"=>"nao","style"=>"font:Helvetica-Bold#size:14#ncolor:99#width:80#bold;", "COLS"=>"0,C"}, "DAV-OS "+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) )
