;** Ro_0148C********************************************************************
;** Imprime a Digitacao do Romaneio               Zangado Auto Pe‡as           *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 24/04/2009 por Humberto F.Santos.
;Alterado em     : 04/06/2009 por Nikolas
;Motivo Alteracao: Ajustes
;*******************************************************************************
;* Rotina para Impressao do Relatorio                                          *
;*******************************************************************************
Proc IMPRO()

;************************* IMPRESSAO DO CABECALHO *****************************
If Not IsAssigned(NOMEMPRESA)
   Then NOMEMPRESA=""
EndIf

Moveto "FaturaC"

Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
Print File ARQIMP CI_15CPP
Print File ARQIMP Fill("=",57)+"\n"
Print File ARQIMP CI_10CPP
Print File ARQIMP CI_IEXP
Print File ARQIMP CI_INEG

Switch
  Case Search("DEV",[Descricao da Destinacao])>0            : Print File ARQIMP "DEVOLU€ŽO"
  Case Search("SIMPLES REMESSA",[Descricao da Destinacao])>0: Print File ARQIMP "SIMPLES REMESSA"
  Case [Codigo da Destinacao]="005"                         : Print File ARQIMP Format("W30,AL",[Descricao da Destinacao])
  OtherWise                                                 : Print File ARQIMP "OR€AMENTO"
EndSwitch
Print File ARQIMP CI_15CPP

Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
;Print File ARQIMP Spaces(10)+Username()
Print File ARQIMP "\n"

Print File ARQIMP Spaces(01)+"EMISSAO: "+Format("D13",Today())+"-"+Time()+"  "+
                  " NUMERO:  "+Format("W06.3,AL",NOTAFISC)+"\n"
;Print File ARQIMP Spaces(01)+"VEND: "+Format("W21,AL",[Nome Fantasia Represent])+"\n"


Print File ARQIMP Fill("-",57)+"\n"

Print File ARQIMP Spaces(02)+"CLIENTE.: "
Print File ARQIMP Format("W05,AL",[Codigo])
Print File ARQIMP Format("W40,AL",[Razao Social])+"\n"
Print File ARQIMP Spaces(02)+"CPF/CNPJ: "+Format("W27,AL",[CGC])+"\n"
;Print File ARQIMP Spaces(02)+"AUTORIZ.: "+Format("W30,AL",[Nome do Autorizado])+Format("W14,AL",[CPF do Autorizado])+"\n"
CLIENTE=[Razao Social]
Print File ARQIMP Spaces(02)+"ENDERECO.: "+ Format("W40,AL",[Endereco])+"\n"
Print File ARQIMP Spaces(02)+"BAIRRO.: "+ Format("W20,AL",[Bairro])+
"FONE: " + Format("W19,AL",[Telefone])+"\n"
Print File ARQIMP Spaces(02)+"CIDADE.: "+Format("W20,AL",[Cidade])+"\n"

If Not Isblank(SubStr([Observacao na Nota Fiscal],001,48))
   Then Print File ARQIMP Spaces(02)+"OBS...:"
        Moveto "FaturaC"
        Print File ARQIMP Format("W48,AL",SubStr([Observacao na Nota Fiscal],001,48))+"\n"
        If Not IsBlank (SubStr([Observacao na Nota Fiscal],049,48))
           Then Print File ARQIMP Spaces(02)+Format("W48,AL",SubStr([Observacao na Nota Fiscal],049,48))+"\n"
                If Not IsBlank(SubStr([Observacao na Nota Fiscal],97,48))
                   Then Print File ARQIMP Spaces(02)+Format("W48,AL",SubStr([Observacao na Nota Fiscal],97,48))+"\n"
                EndIf
        EndIf
EndIf

;********** PARCELAS/VENCIMENTOS ********************

;Print File ARQIMP Fill("-",57)+"\n"
;Print File ARQIMP Spaces(09)+"PARCELA"+Spaces(05)+"ND"+Spaces(05)+"VENCIMENTO"+Spaces(07)+"VALOR"+Spaces(02)+"FP"+"\n"

;Moveto "FaturaV"
;Moveto [Numero da OF]
;Locate [FaturaC->Numero da OF]
;If RetVal
 ;  Then While ([Numero da OF]=[FaturaC->Numero da OF])
  ;        Print File ARQIMP Spaces(12)+AlinhM([Sequencia],2)+Spaces(05)+Format("W4",[Numero de Dias])+
   ;                         Spaces(05)+ Format("D13",[Data])+Spaces(01)+Format("W11.2,EIC",[Valor])+Spaces(02)+Format("W2",[Forma de Pagamento])+"\n"
   ;       Skip
    ;      If EOT() Then QuitLoop EndIf
     ;   EndWhile
;EndIf

;******************************** IMPRESSAO DOS ITENS ********************************
Print File ARQIMP Fill("=",56)+"\n"
 Print File ARQIMP " PRODUTO                    QTD Vr.Unit  Vr.Total"+"\n"
 ;                  12345612345678901234567890123 123123 123456 23456789
Moveto "FaturaI"
Moveto [Numero da OF]
Locate [FaturaC->Numero da OF]
QUANT=0
TOT  =0

While [Numero da OF]=[FaturaC->Numero da OF]
   Print File ARQIMP Spaces(01)+Format("W06,AL",SubStr([Codigo do Item],6,5))
   Print File ARQIMP Format("W20,AL",[Descricao do Item])+" "
   ;Print File ARQIMP Format("W03,AL",[Unidade Fiscal])
   Print File ARQIMP Format("W03,EIC",[Quantidade])+Spaces(01)
   Print File ARQIMP Format("W06.2,EIC",[Preco Unitario])+"  "
   Print File ARQIMP Format("W08.2,EIC",[Preco Total])+"\n"

   QUANT=QUANT+[Quantidade]
   TOT=TOT+[Preco Total]
   Skip
   If EOT() Then QuitLoop EndIf
EndWhile
Moveto "FaturaC"
Print File ARQIMP Spaces(43)+"------"+"\n"
Print File ARQIMP Spaces(38)+Format("W11.2,EIC",[Valor Mercadoria Liquido]+[Valor Desconto])+"\n"
Print File ARQIMP Fill("-",56)+"\n"

 if MSGDESC="COM"
    Then
      Print File ARQIMP Spaces(02)+"VR.MERCADORIAS: "+Format("W11.2,EIC",[Valor Mercadoria Liquido]+[Valor Desconto])+
      Spaces(01)+"VR.DESCTO: "+Format("W8.2,EIC",[Valor Desconto])+"\n"
      Print File ARQIMP Spaces(02)+"VR A PAGAR.: "
      Print File ARQIMP CI_10CPP
      Print File ARQIMP CI_IEXP
      Print File ARQIMP LTrim(Format("W11.2,EIC",[Valor Nota Fiscal]))+"\n\n"
      Print File ARQIMP CI_FEXP
      Print File ARQIMP CI_15CPP
      Print File ARQIMP Fill("-",56)+"\n\n\n\n\n\n"
 else
      Print File ARQIMP Spaces(02)+"VR.MERCADORIAS: "+Format("W11.2,EIC",[Valor Mercadoria Liquido]+[Valor Desconto])+
      Spaces(01)+"VR.DESCTO:"+"\n"
      Print File ARQIMP Spaces(02)+"VR A PAGAR.: "
      Print File ARQIMP CI_10CPP
      Print File ARQIMP CI_IEXP
      Print File ARQIMP LTrim(Format("W11.2,EIC",[Valor Nota Fiscal]+[Valor desconto]))+"\n\n"
      Print File ARQIMP CI_FEXP
      Print File ARQIMP CI_15CPP
      Print File ARQIMP Fill("-",56)+"\n\n\n\n\n\n"

 endif

EndProc ; (IMPRO)

;*******************************************************************************
;* Rotina Principal                                                            *
;*****************+*************************************************************
ShowPopup " Op‡”es de Desconto " CENTERED
  "~Com Desconto" : " Imprime com Desconto " : "COM",
  "~Sem Desconto" : " Imprime sem Desconto " : "SEM"
EndMenu
To MSGDESC

If Not RetVal
   Then MSGDESC="COM"
EndIf

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

AGUARDE("Imprimindo Orcamento -> "+NOTAFISC)
IMPRO()

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

Release Vars  CLIENTE,END_ENT,BAI_ENT,CID_ENT,CEP_ENT
Release Procs IMPRO
LIMPAGUARDE()

