alias sf_fatnf
OUTROARQ sccrcli
OUTROARQ sccpfor
VARIAVEL zCli = 0 
VARIAVEL Z_DE = S_DATUAL 
VARIAVEL Z_ATE = S_DATUAL 
VARIAVEL ztNf = 0 
VARIAVEL ztFval = 0 
VARIAVEL ztTotIcms = 0 
VARIAVEL z_STRFORN = ""
VARIAVEL zCrNome := ""
variavel sPrtLineLen = 132

VARIAVEL #TEXTO_FONTE
   // oLst:lPortrait := .t.
   // oLst:nLinesPorPagina := 96
   oLst:lPortrait := .f.
   oLst:nLinesPorPagina := 56
   oLst:AddCol('Emissao;fdataemi;D;99.99.9999;8;')
   oLst:AddCol('NF/COO;if(Val(fNumCoo)>0,fNumCoo,fnum);P;999999999;9;')
   oLst:AddCol('O;Ind_Oper;C;X;4;')
   oLst:AddCol('E;Ind_Emit;C;X;4;')
   oLst:AddCol('Doc;if(Val(fNumCoo)>0,"COO",if(fnum>0,if(val(fModelo)=65,"NFC","NFE"),"NFS"));C;XXX;3;')
   oLst:AddCol('Mod;Cod_Mod;C;XX;3;')
   oLst:AddCol('Sit;Cod_Sit;C;XX;3;')
   oLst:AddCol('ChaveNFE;fChaveNFE;C;@S44;44;')
   oLst:AddCol('CFOP;Fcodop;C;XXXXX;5;')
   oLst:AddCol('Valor;if(val(cod_sit)=2.or.val(cod_sit)=5,0,Fval);P;@E 999,999.99; 10;;;D;S;')
   oLst:AddCol('Outras;if(val(cod_sit)=2.or.val(cod_sit)=5,Fval,0);P;@E 999,999.99; 10;;;D;S;')
   oLst:AddCol('BaseICM;Fbaseicms;N;@E 999,999.99; 10,2;;;D;S;')
   oLst:AddCol('%TxICM;Ftaxaicms;N;@E 999.99; 6,2 ;')
   oLst:AddCol('ValorICM;Ftoticms;N;@E 999,999.99; 10,2;;;D;S;')
   oLst:AddCol('CodCli;fcli;N;999999;6;')
   oLst:AddCol('Cliente;zCrNome;P;@s24;24;')
   oLst:AddCol('xSituacao;nfe_xMotiv;C;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;10;')
   oLst:AddCol('Pedido;fnumped;N;999999;6;')
   oLst:AddCol('*;FgDev;C;X;1;')
   
   oLst:Cab1( "Relacao de Notas de Saida" )
   oLst:Cab4( {|| "Emissoes de "+Dtoc(z_DE)+" ate "+Dtoc(z_ATE) } )
   oLst:AddCab( '_LINHA_FINA_' )
   oLst:AddCab( '_CABCOLS_' )
   oLst:AddCab( '_LINHA_GROSSA_' )

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

T10,10,18,60,Parametros 
T2,2,Cliente.....:,6,zCli,999999
T4,2,Data Inicial:,10,Z_DE,99.99.9999 
T5,2,Data Final..:,10,Z_ATE,99.99.9999 

comando antes z_STRFORN = IF( zCli=0, "Todos", STR(zCli,6) ) 
  
FILTRO (zCli=0 .OR. zCli=fCli) .AND. (fDataEmi>=Z_DE .AND. fDataEmi<=Z_ATE) 
FILTRO Val(fNumCoo)>0.or.(fNum>0 .and. (val(fmodelo)=55.or.val(fmodelo)=65))

comando durante #TEXTO_FONTE
   if FgDev$'DTE'
      sccpfor->( DbGoto( sf_fatnf->fCli ))
      zCrNome := sccpfor->(if(empty(cp_fantasi),cp_nome,cp_fantasi))
   else
      sccrcli->( DbGoto( sf_fatnf->fCli ))
      zCrNome := sccrcli->(if(empty(cr_fantasi),cr_nome,cr_fantasi))
   endif
   zCrNome := Pad( zCrNome , 35)
   ztNf := ztNf + 1
   oLst:EvalCabDetRod()
#FIM_TEXTO_FONTE

comando depois #TEXTO_FONTE
      oLst:lPrtRodape := .f.
      oLst:EvalLineBlocks('DETALHE', '_PULE_1LINHA_', '_LINHA_GROSSA_', '_SOMACOLS_')
      oLst:EvalLineBlocks('DETALHE', {"ROWCOL" => "oLst:oPdf:pRow,0"}, "Totais Referentes a "+lTrim(Transform(ztNf,"@E 999,999"))+" NFs :")

      oLst:Run()
      oLst:End()
#FIM_TEXTO_FONTE

#C
#CRelacao de Notas Fiscais de Saida $ Emitida em [s_datual] as [time()] Pag [pag 999] 
#C*** Cliente: [Z_STRFORN] $ Emissoes: [z_DE] ate [z_ATE] 
#C[repl("-",132)] 
#CPedido Forn                N.F.         Valor  DtEmis   %Icm   Val_Icm Dp CFO     Icm_Ret  DtEmis   Dv 
#*999999 999-xxxxxYYYYYxxxxx 9999999 999,999.99 99% 99,999.99 99 99,999.99 DD.MM.AA dd.mm.aa 99 
#C[repl("=",132)] 
#
#D[fgdev] [fCli 999999]-[zCrNome] [FNUM 9999999] [FVAL 999,999.99] [fDataEmi] [FTAXAICMS 99]% [FTOTICMS 99,999.99] [fcodop] 
#
#ULTPAG [repl("-",132)] 
#ULTPAG *** Totais com [ztNf 999] lancamentos:[ztFval 99,999,999.99]            [ztTotIcms 99,999,999.99]