;** EC_0223 *********************************************************************
;** Impressao de Carnˆ         ** Fatima Designs **
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 05/03/2009 por Anivel Augusto Rodrigues
;Alterado em     : 02/04/2009 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes salto de linhas



Proc Imp_Carne()

Array dtv[36]
Array vrv[36]

For I From 1 To 12
  vrv[i]=BlankNum()
  dtv[i]=""
EndFor

i=0
Moveto "FaturaV"
Moveto [Numero da OF]
Locate [FaturaC->Numero da OF]
If RetVal
   Then While [Numero da OF] = [FaturaC->Numero da OF]
          i=i+1
          vrv[i]=[Valor]
          dtv[i]=[Data]

          Skip
          If EOT()
             Then QuitLoop
          Endif
        EndWhile
EndIf
If i=0
   Then Mensagem("NÆo existe(m) venctimento(s) p/ o carnˆ !")
        Return
EndIf

Moveto "FaturaC"

NPOk=False
cci=0
For wi From 1 to i

  If cci=3
     Then Imp_NP()
          NPOk=True
          cci=0
  EndIf
  cci=cci+1

  Print File ARQIMP CI_10CPP+CI_6LPP+"\n"

  Print File ARQIMP Spaces(02)+Format("W7,AL",[Codigo])+Spaces(1)+Completa(NOTAFISC+" "+StrVal(wi)+"/"+StrVal(i),10," ")+Spaces(3)+Format("W36,AL",[Razao Social])+"\n\n\n"

  Print File ARQIMP Format("D10",dtv[wi])+Format("W10.2,EIC",Vrv[wi])+Spaces(8)+
        Format("W09,AL",[Codigo])+Spaces(1)+Completa(NOTAFISC+" "+StrVal(wi)+"/"+StrVal(i),11," ")+Spaces(3)+Format("D10",dtv[wi])+"\n\n\n"

  Print File ARQIMP Spaces(48)+Format("W10.2,EIC",Vrv[wi])

  Print File ARQIMP CI_10CPP+CI_8LPP+"\n"

  Print File ARQIMP CI_10CPP+CI_6LPP+"\n\n\n\n\n\n\n\n\n\n"

EndFor
Imp_NP()
UnlockRecord

EndProc



Proc Imp_NP()

If cci<3
   Then For nbi From (cci+1) To 3
          Print File ARQIMP CI_10CPP+CI_8LPP+"\n"
          Print File ARQIMP CI_10CPP+CI_6LPP+"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
        EndFor
        If NPOK
           Then Print File ARQIMP "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
                Return
        EndIf
EndIf

Print File ARQIMP Spaces(4)+Format("D10",[Data de Emissao])+Spaces(02)+Format("W10.2,EIC",[Valor Nota Fiscal])+Spaces(6)+
                  Format("W22,AL",[Codigo do Representante])+Spaces(1)+Format("W8,AL",[Codigo])+"\n\n"

Print File ARQIMP CI_15CPP+Spaces(46)+"FATIMA DESIGNS CORTINAS CONF. IND. E COM. LTDA"+"\n"

Print File ARQIMP Spaces(8)+"65.202.863/0001-97"+CI_10CPP+"\n"

ESCEXT([Valor Nota Fiscal])
Print File ARQIMP Spaces(04)+SubStr(EXTENSO,001,55)+"\n"
Print File ARQIMP Spaces(04)+SubStr(EXTENSO,081,55)+"\n\n\n"

Print File ARQIMP Spaces(30)+Format("W29,AL",[Razao Social])+"\n"

Print File ARQIMP Spaces(03)+Completa(Format("D10",dtv[1]),9," ")+Completa(Format("W7.2,EIC",Vrv[1]),14," ")+"\n"
Print File ARQIMP Spaces(03)+Completa(Format("D10",dtv[2]),9," ")+Completa(Format("W7.2,EIC",Vrv[2]),14," ")+"\n"
Print File ARQIMP Spaces(03)+Completa(Format("D10",dtv[3]),9," ")+Completa(Format("W7.2,EIC",Vrv[3]),14," ")+Spaces(4)+[CGC]+"\n"
Print File ARQIMP Spaces(03)+Completa(Format("D10",dtv[4]),9," ")+Completa(Format("W7.2,EIC",Vrv[4]),14," ")+"\n"
Print File ARQIMP Spaces(03)+Completa(Format("D10",dtv[5]),9," ")+Completa(Format("W7.2,EIC",Vrv[5]),14," ")+Spaces(4)+Format("D13",[Data de Emissao])+"\n"

Print File ARQIMP Spaces(7)+Completa([Endereco]+" - "+[Bairro],42," ")+SubStr([Telefone],1,10)+"\n"

Print File ARQIMP CI_10CPP+CI_6LPP+"\n\n\n"

Endproc

;**** Teste da Impressora ****
Moveto "FaturaC"
AGUARDE("Imprimindo Carne "+NOTAFISC)

ArqImp=PrivDir()+"Carne.Txt"
If IsFile(ArqImp)
   Then Deleta_Arquivo(ArqImp)
EndIf

Imp_Carne()
ImpriArq(ARQIMP)

LIMPAGUARDE()
