;** NP_0239  ********************************************************************
;** Impressao de Nota Promissoria                 ** BRASIL TEXTIL     *
;*******************************************************************************
;Autor: Visao/Vise
;Desenvolvido  em: 18/11/2009 por Nikolas
;Alterado em     : 08/12/2009 por Nikolas
;Motivo Alteracao: Ajustes
;Ultima Alteracao: 03/02/2010 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes NUMCOPIA=1     
;Ultima Alteracao: 04/02/2010 por Cleber Alves          
;Motivo Alteracao: Ajustes Valor Extenso
;Ultima Alteracao: 18/09/2017 por Kamila Gomes          
;Motivo Alteracao: Ajustes Valor Extenso
;*******************************************************************************

;**** Teste da Impressora ****
Moveto "FaturaC"
AGUARDE("Imprimindo Vencimentos")

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

Print File ARQIMP CI_15CPP
Print File ARQIMP CI_6LPP
;********* Imprime Vencimentos*********
Array dia[12]
Array mes[12]
Array mes2[12]
Array ano[12]

For I From 1 To 12
    dtvencto[i]=BlankDate()
    valorven[i]=BlankNum()
    dia[i] =""
    mes[i] =""
    mes2[i] =""
    ano[i] =""
EndFor

Moveto "FaturaV"
Moveto [Numero da OF]
Locate [FaturaC->Numero da OF]
If RetVal
   Then i=0
        While [Numero da OF] = [FaturaC->Numero da OF]
          i=i+1
          dtvencto[i] = [Data ]
          valorven[i] = [Valor]
          dia[i]      = Day([Data])
          mes[i]      = MESEXT(Month([Data]))
          mes2[i]      = Month([Data])
          ano[i]      = Year([Data])
          Skip
          If EOT()
             Then QuitLoop
          Endif
        EndWhile
Endif
Moveto "FaturaC"
i=1

While valorven[i] <> BlankNum()

     
      
      Print File ARQIMP "\n\n"

      Print File ARQIMP "   PROTOCOLO ___/___/_____                "

      If Not IsBlank(dtvencto[2])
         Then Print File ARQIMP Spaces(04)+Format("W12,AR",(NOTAFISC+"/"+CHR(65+i-1)))+Spaces(46)
         Else Print File ARQIMP Spaces(04)+Format("W14,AR",(NOTAFISC+"  "))+Spaces(20)
      EndIf


      Print File ARQIMP Spaces(05)+Format("W03,AR",(dia[i]))+"/"+Format("W03,AL",(mes2[i]))+"/"+Format("W5,AL",(ano[i]))


      Print File ARQIMP Spaces(17)+Format("W15.2,EIC",valorven[i])+"\n\n"

      If Not IsBlank(dtvencto[2])
         Then Print File ARQIMP "   No.NP..: "+Format("W12,AL",(NOTAFISC+"/"+CHR(65+i-1)))+"\n\n"
         Else Print File ARQIMP "   No.NP..: "+Format("W14,AL",(NOTAFISC+"  "))
      EndIf


;***** Extenso p/ Data ********************************************************

      dtextenso=""
      EscExt(NumVal(Dia[i]))
      dtextenso=SubStr(Extenso,1,SearchFrom(" CENT",extenso,1))

      If Dia[i] = 1
        Then dtextenso=dtextenso+"DIA DO MES DE "+Mes[i]
        Else dtextenso=dtextenso+"DIAS DO MES DE "+Mes[i]
      EndIf

      EscExt(NumVal(SubStr(StrVal(NumVal(ano[i])),1,1))*1000000)
      dtextenso=dtextenso+"DO ANO DE"+SubStr(Extenso,1,SearchFrom(" REA",extenso,1))

      If NumVal(SubStr(StrVal(NumVal(ano[i])),2,3))>0
         Then dtextenso=dtextenso+"E"
              EscExt(NumVal(SubStr(StrVal(NumVal(ano[i])),2,3))*1000)
              dtextenso=dtextenso+SubStr(Extenso,1,SearchFrom(" REA",extenso,1))
      EndIf

      Print File ARQIMP "\n"

      Print File ARQIMP Spaces(51)+SubStr(dtextenso,01,60)+"\n"

      Print File ARQIMP Spaces(02)+" Compra..: "+Format("D13",[Data de Emissao])+"\n\n"

      Print File ARQIMP Spaces(02)+" Cliente.: "+Format("W07,AL",[CODIGO])

      Print File ARQIMP Spaces(38)+SubStr(dtextenso,61,22)+"\n\n"

;******************************************************************************

      ESCEXT(valorven[i]) 
      Print File ARQIMP Spaces(50)+SubStr(EXTENSO,001,80)+"\n"

      Print File ARQIMP Spaces(02)+" Vencto..: "+Format("W03,AL",(dia[i]))+"/"+Format("W03,AL",(mes2[i]))+"/"+Format("W5,AL",(ano[i]))


      Print File ARQIMP Spaces(25)+SubStr(EXTENSO,081,80)+"\n\n"



      Print File ARQIMP Spaces(02)+" Valor...: "+Format("W11.2,EIC",valorven[i])


      Print File ARQIMP Spaces(33)+"Divinopolis/MG         Codigo: "+Format("w07,AL",[CODIGO])+"\n"

      Print File ARQIMP Spaces(56)+Format("W40,Al",[Razao Social])

      Print File ARQIMP Spaces(18)+" "+Format("D13",[Data de Emissao])+"\n"




      Print File ARQIMP Spaces(02)+" Receber.: ___/___/____ "

      Print File ARQIMP Spaces(30)+Format("W18,AL",[CGC])

      Print File ARQIMP Spaces(30)+Format("W18,AL",[IE])+"\n"

      Print File ARQIMP Spaces(56)+Format("W40,AL",[Endereco])+"\n"


      Print File ARQIMP Spaces(02)+" ______________________ "
      Print File ARQIMP Spaces(30)+[Bairro]+"\n"


      Print File ARQIMP Spaces(02)+"       Assinatura "


      Print File ARQIMP Spaces(36)+Format("W49,AL",[Cidade])+" "+ [UF]+"      "+ [CEP]+"\n\n"


      Print File ARQIMP Spaces(55)+" Vendedor(a): "+[Nome Fantasia Represent]+"    Forma Pagamento: "+[Descricao CondPagto]+"\n"



      ;Print File ARQIMP "\n"



      ;Moveto [Codigo]
      ;Ativa_Lookup()
      ;Moveto [Codigo]
      ;Locate [Faturac->Codigo]
      ;If RetVal
      ;   Then Print File ARQIMP Spaces(35)+[Codigo da Area   ]+"\n"
      ;   Else Print File ARQIMP "\n"
      ;EndIf
      ;KeyPress "ESC"

      Moveto "FaturaC"

      Print File ARQIMP "\n"

      i=i+1

EndWhile

Print File ARQIMP CI_10CPP
Print File ARQIMP CI_6LPP

UnlockRecord

;---- Imprime Arquivo Impressao ------------------------------------------------
NUMCOPIA=1
ImpriArq(ARQIMP)



LIMPAGUARDE()

