#line 1 "loadppo.ch"
#line 3 "PF_R1.PRG"
nr:=0
x_tipo := 0
priva m_quant, m_valor, tg_quant, tg_valor
x_aamm_old:= SUBSTR(DTOS(S_DATUAL),3,4)
x_de:=day(s_datual)

x_ate:=x_de
priva sf_fatf
DevPos( 13, 32 ) ; DevOut( "Ano e Mes...:" ) ; SetPos( Row(), Col()+1 ) ; AAdd( GetList, _GET_( x_aamm_old, "x_aamm_old",,, ):display() ) 
DevPos( 14, 32 ) ; DevOut( "Dia Inicial.:" ) ; SetPos( Row(), Col()+1 ) ; AAdd( GetList, _GET_( x_de, "x_de", "99",, ):display() )
DevPos( 15, 32 ) ; DevOut( "Dia Final...:" ) ; SetPos( Row(), Col()+1 ) ; AAdd( GetList, _GET_( x_ate, "x_ate", "99",, ):display() )
DevPos( 16, 32 ) ; DevOut( "Tipo .......:" ) ; SetPos( Row(), Col()+1 ) ; AAdd( GetList, _GET_( x_tipo, "x_tipo", "9", _createblock( "x_tipo >= 0 .AND. x_tipo <= 2" ), ):display() )
ReadModal(GetList) ; GetList := {}
sf_fatf="fatf"+x_aamm_old
d_de  = ctod( str(x_de,2)+"."+right(x_aamm_old,2)+"."+left(x_aamm_old,2) )
d_ate = ctod( str(x_ate,2)+"."+right(x_aamm_old,2)+"."+left(x_aamm_old,2) )

abra ("2", r_siga, "SCCPFOR", "SCCPFOR")
abra ("1", r_siga, SF_FATF, "SF_FATF")
ll = 61
pag=0
if ! abre_prt ("12", .T.)
   return
endif
Mensagem("")
tg_quant := tg_valor := 0
dbSelectArea( "sf_fatf" )
while ! eof () .AND. continuapr ()
   If PFDataemi >= D_DE .AND. PFDataemi <= D_ATE .AND. ( x_tipo = 0 .OR. iif (x_tipo = 1, pfnum > 0, pfnum <= 0) )
      Cab_Pfr1()
      SccpFor->(DbGoto(Sf_Fatf->PFFOR))
      DevPos( LL, 00 ) ; DevOut( PFNUM )      
      DevPos( LL, 12 ) ; DevOut( PFDATAEMI )
      DevPos( LL, 22 ) ; DevOutPict( PFVAL, "@E 9,999,999.99" )
      DevPos( LL, 36 ) ; DevOutPict( STRZERO(PFFOR,4)+"-"+ALLTRIM(SCCPFOR->CP_NOME), "XXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" )
      Tg_Valor+=PfVal
      Ll++
   EndIf
   nr = nr + 1
   dbSkip( 1 )
   SetPos(24,2);QQout(str(nr, 6) + " / " + str (lastrec (), 6))
enddo
DevPos( prow () + 2, 0 ) ; DevOut( "*** TOTAIS GERAIS" )
DevPos( prow (), 22 ) ; DevOutPict( tg_valor, "@E 999999,999.99" )
__Eject()
return

procedure cab_PFr1(tipo)
if ll >= 60
   pag = pag + 1
   DevPos( 1, 0 ) ; DevOut( &m_enfat + ltrim (empresa) + &m_naoenfat + &m_dozecpi )
   DevPos( 2, 0 ) ; DevOut( ltrim (sistema) )
   DevPos( 2, 70 ) ; DevOut( "PAG: " + strzero (pag, 4) )
   DevPos( 3, 0 ) ; DevOut( "RELACAO DE NOTAS FISCAIS DE ENTRADAS, Emitida em "+dtoc(S_datual) )
   DevPos( 4, 0 ) ; DevOut( replicate ("=", 80) )
   DevPos( 5, 0 ) ; DevOut( "Nota Fiscal     Data         Valor  Fornecedor" )


   DevPos( 6, 0 ) ; DevOut( replicate ("=", 88) )
   ll = 7
endif
return
