;** RO_0189 ********************************************************************
;** Imprime a Digitacao do Romaneio                     ** DROG.SAO FRANCISCO  *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 24/10/2007 por Humberto F.Santos.
;Alterado em     :   / /      por
;Motivo Alteracao:


;*******************************************************************************
;* Rotina para Impressao do Relatorio                                          *
;*******************************************************************************
Proc IMPFAT()

;* Nao eh necessario mudar as configura‡”es para impressao de duas vias

;************************** IMPRESSAO DO CABECALHO *****************************
If Not IsAssigned(NOMEMPRESA)
   Then NOMEMPRESA=""
EndIf
Moveto "Faturac"
Print File ARQIMP CI_6LPP
Print File ARQIMP CI_15CPP
Print File ARQIMP "DROGARIA SAO FRANCISCO - TEL:.(37)3221-4204" + Spaces(26)
Print File ARQIMP "DROGARIA SAO FRANCISCO - TEL:.(37)3221-4204" +"\n"
Print File ARQIMP "Orcamento: "+Format("W06.3,AL",NOTAFISC)+" - Data: "+Format("D10",Today())+" - Hora: "+Time()+Spaces(18)
Print File ARQIMP "Orcamento: "+Format("W06.3,AL",NOTAFISC)+" - Data: "+Format("D10",Today())+" - Hora: "+Time()+"\n"

Print File ARQIMP "Cliente  : "
Print File ARQIMP Chr(27)+Chr(71)
Print File ARQIMP Format("W05,AL",[Codigo])+Format("W29,AL",[Razao Social])+Spaces(24)
Print File ARQIMP Chr(27)+Chr(72)
Print File ARQIMP "Cliente  : "
Print File ARQIMP Chr(27)+Chr(71)
Print File ARQIMP Format("W05,AL",[Codigo])+Format("W29,AL",[Razao Social])+"\n"
Print File ARQIMP Chr(27)+Chr(72)

Print File ARQIMP Spaces(09)+Format("W39,AL",[Endereco])
Print File ARQIMP Format("W18,AL",[CGC])+Spaces(03)
Print File ARQIMP Spaces(09)+Format("W39,AL",[Endereco])
Print File ARQIMP Format("W18,AL",[CGC])+"\n"

Print File ARQIMP Spaces(09)+Format("W19,AL",[Bairro])
Print File ARQIMP Format("W20,AL",[CEP])
Print File ARQIMP Format("W18,AL",[IE])+Spaces(03)
Print File ARQIMP Spaces(09)+Format("W19,AL",[Bairro])
Print File ARQIMP Format("W20,AL",[CEP])
Print File ARQIMP Format("W18,AL",[IE])+"\n"

Print File ARQIMP Spaces(09)+Format("W19,AL",[Cidade])
Print File ARQIMP Format("W20,AL",[UF])
Print File ARQIMP Format("W17,AL",[Telefone])+Spaces(04)
Print File ARQIMP Spaces(09)+Format("W19,AL",[Cidade])
Print File ARQIMP Format("W20,AL",[UF])
Print File ARQIMP Format("W17,AL",[Telefone])+"\n"

;Print File ARQIMP "Operacao: "
;Print File ARQIMP Chr(27)+Chr(71)
;Print File ARQIMP ""+[Codigo da Destinacao]+" "+[Descricao da Destinacao]+Spaces(45)
;Print File ARQIMP Chr(27)+Chr(72)
;Print File ARQIMP "Operacao: "
;Print File ARQIMP Chr(27)+Chr(71)
;Print File ARQIMP ""+[Codigo da Destinacao]+" "+[Descricao da Destinacao]+"\n"
;Print File ARQIMP Chr(27)+Chr(72)

Print File ARQIMP "Vendedor: "+Format("W05,AL",[Codigo do Representante])
Print File ARQIMP Format("W18,AL",[Nome Fantasia Represent])+Spaces(04)

NOME_USUARIO=""
Moveto [Codigo_Usuario]
Ativa_Lookup()
Moveto [Chapa]
Locate [FaturaC->Codigo_Usuario]
If RetVal
   Then NOME_USUARIO=[Nome]
EndIf
KeyPress "Esc"

Print File ARQIMP Spaces(33)+ "Vendedor: "+Format("W05,AL",[Codigo do Representante])
Print File ARQIMP Format("W18,AL",[Nome Fantasia Represent])+Spaces(04)+"\n"

;********************* IMPRESSAO DOS ITENS ********************************
Print File ARQIMP "------------------------------------------------------------------"+Spaces(03)
Print File ARQIMP "------------------------------------------------------------------"+"\n"
Print File ARQIMP "Item                               Un   Quant Unitario       Total"+Spaces(03)
Print File ARQIMP "Item                               Un   Quant Unitario       Total"+"\n"
Print File ARQIMP "------------------------------------------------------------------"+Spaces(03)
Print File ARQIMP "------------------------------------------------------------------"+"\n"
Moveto "FaturaI"
Moveto [Numero da OF]
Locate [FaturaC->Numero da OF]
QUANT    = 0
TOT      = 0
CONTADOR = 0

While ([Numero da OF]=[FaturaC->Numero da OF]) And (CONTADOR<>12)
  For CON From 1 to 3
     If CON=3
        Then Print File ARQIMP Spaces(02)
     EndIf
     Print File ARQIMP Format("W10,AL",[Codigo do Item])
     Print File ARQIMP Spaces(01)+Format("W23,AL",[Descricao do Item])
     Print File ARQIMP Spaces(01)+Format("W03,Al",[Unidade Fiscal])
     Print File ARQIMP Format("W07.2,EIC",[Quantidade])
     QUANT=QUANT+[Quantidade]
     Print File ARQIMP Format("W09.2,EIC",[Preco Unitario])
     Print File ARQIMP Format("W12.2,EIC",[Preco Total])+Spaces(01)
     CON=CON+1
  EndFor
     TOT   = TOT + [Preco Total]
     CON=1
  Skip
  If EOT() Then QuitLoop EndIf
  CONTADOR = CONTADOR + 1
  Print File ARQIMP "\n"
EndWhile

For ITEM From CONTADOR To 12
    Print File ARQIMP "\n"
EndFor
Print File ARQIMP "Obs:.PRAZO MAXIMO DE PAGAMENTO 30 DIAS."+Spaces(30)
Print File ARQIMP "Obs:.PRAZO MAXIMO DE PAGAMENTO 30 DIAS."+"\n"

Print File ARQIMP "------------------------------------------------------------------"+Spaces(03)
Print File ARQIMP "-----------------------------------------------------------------"+"\n"

;********************* IMPRESSAO DOS TOTAIS **************************
Moveto "FaturaC"

Print File ARQIMP Spaces(35)+"Total.............."+Format("W12.2,EIC",TOT)+Spaces(02)
Print File ARQIMP Spaces(35)+"Total.............."+Format("W12.2,EIC",TOT)+"\n"

;Print File ARQIMP Spaces(35)+"Desconto"+Format("W06.2,EIC",[Taxa de Desconto]) + "%...."
Print File ARQIMP Spaces(35)+"Desconto............" +Format("W11.2,EIC",[Valor Desconto])
;Print File ARQIMP Spaces(36)+"Desconto"+Format("W06.2,EIC",[Taxa de Desconto]) + "%...."
Print File ARQIMP Spaces(37)+ "Desconto..........."+Format("W12.2,EIC",[Valor Desconto])+"\n"

Print File ARQIMP Spaces(35)+"Total Liquido......"+Format("W12.2,EIC",[Valor Mercadoria Liquido])+Spaces(02)
Print File ARQIMP Spaces(35)+"Total Liquido......"+Format("W12.2,EIC",[Valor Mercadoria Liquido])+"\n\n"

Print File ARQIMP Spaces(15)+"Ass: --------------------------------------------"+Spaces(05)
Print File ARQIMP Spaces(15)+"Ass: --------------------------------------------"+"\n"

Print File ARQIMP "-------------------------------------------------------------------"+Spaces(03)
Print File ARQIMP "------------------------------------------------------------------"+"\n"


;************************* IMPRESSAO DO RODAPE *********************************
Print File ARQIMP CI_6LPP
Print File ARQIMP CI_10CPP
Print File ARQIMP "\f"
Print File ARQIMP chr(27)+chr(67)+chr(66) ;Imprime 66 Linhas por pagina
EndProc
;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************
ArqImp=PrivDir()+"Ro_0059.Txt"
If IsFile(ArqImp)
   Then Deleta_Arquivo(ARQIMP)
EndIf

AGUARDE("Imprimindo Romaneio -> "+NOTAFISC)
IMPFAT()
Print File ARQIMP CI_10CPP
Print File ARQIMP CI_6LPP

;---- Imprime Arquivo Impressao ------------------------------------------------
ImpriArq(ARQIMP)

Release Vars VALOR,DATA
Release Procs IMPFAT,VENC
LIMPAGUARDE()


