;** OR_0093B********************************************************************
;** Imprime a Digitacao do Orcamento/Termica       Cinderela Center Calçados   *
;*******************************************************************************
;Autor: Visao/Vise
;Desenvolvido  em: 17/10/2008 por Anivel Augusto Rodrigues
;Alterado em     : 21/10/2008 por Cleber Alves
;Motivo Alteracao: Altera‡Æo no cabe‡alho para Condicional
;Alterado em     : 22/12/2009 por Bruno Carvalho
;Motivo Alteracao: Adicionado o Campo Localiza‡Æo (Tab. Itens)

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

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

Moveto "OrcaC"

Print File ARQIMP Fill("=",32)+"\n"
if([Descricao da Destinacao] <>"CONDICIONAL")
   then Print File ARQIMP "        OR€AMENTO"+"\n"
Print File ARQIMP Fill("-",32)+"\n"  
else
   Print File ARQIMP "      CONDICIONAL"+"\n"
Print File ARQIMP Fill("-",32)+"\n"  
endif             
Print File ARQIMP CI_INEG
Print File ARQIMP " *  CINDERELA CENTER CALCADOS"
Print File ARQIMP CI_FNEG
Print File ARQIMP "\n"

Print File ARQIMP "NUMERO   : "+Format("W06,AL",ORCA)+"\n"
Print File ARQIMP "EMISSAO  : "+Format("D13",Today())+"-"+Time()+"\n"
Print File ARQIMP "VALIDADE : "+Format("D13",[Data de Validade])+"\n"  
Print File ARQIMP "VENDEDORA: "+[Codigo do Representante]                
Print File ARQIMP " "+[Nome Fantasia Represent]+"\n"+"\n"


Print File ARQIMP Fill("-",32)+"\n"
Print File ARQIMP Format("W40,AL",[Razao Social])+"\n"
Print File ARQIMP Format("W18,AL",[CGC])
Print File ARQIMP "FH: "+Format("W10,AL",[Codigo])+"\n"
Print File ARQIMP Format("W40,AL",[Endereco])+"\n"
Print File ARQIMP Format("W32,AL",[Bairro])+"\n"
Print File ARQIMP Format("W20,AL",[Cidade])
Print File ARQIMP Format("W32,AL",[Telefone])+"\n"

If Not Isblank([Observacao do Orcamento])
   Then Print File ARQIMP "OBS: "+[Observacao do Orcamento]+"\n"
EndIf

;********** PARCELAS/VENCIMENTOS ********************
Print File ARQIMP Fill("-",32)+"\n"
Print File ARQIMP "Condicao Pagamento         Valor"+"\n"
Moveto "Orcacpg"
Scan For [Numero do Orcamento]=ORCA
  Print File ARQIMP Format("W23,AL",[Descricao CondPagto])
  Print File ARQIMP Format("W09.2,EIC",[Orcac->Valor Nota Fiscal]+(([Orcac->Valor Nota Fiscal]*[Taxa Financeira])/100))+"\n"
EndScan

;******************************** IMPRESSAO DOS ITENS ********************************
Print File ARQIMP Fill("=",32)+"\n"
if([ORCAC->Descricao da Destinacao] <>"CONDICIONAL")
   Then Print File ARQIMP "        ITEM OR€ADOS"+"\n" 
else 
   Print File ARQIMP "      ITEM CONDICIONAL"+"\n"
endif  
Print File ARQIMP Fill("-",32)+"\n"

;Item Codigo      Descri‡Æo
;     Qtde     Vl unit rio               Vl Item
;     
;123  1234567890  123456789012345678901234567890
;     9999 PC x 12345678                12345678

Moveto "OrcaI"
QUANT=0
TOT  =0
Loc  ="" 

Scan For [Numero do Orcamento]=ORCA

   Print File ARQIMP Format("W10,AR",[Codigo do Item])+" "
   Print File ARQIMP Format("W18,AL",[Descricao do Item])

   Print File ARQIMP Format("W09,EIC",[Quantidade])+Spaces(01)
   Print File ARQIMP Format("W02,AL",[Unidade Fiscal])+" x "
   Print File ARQIMP Format("W08.2,EIC",[Preco Unitario])+Spaces(1)
   Print File ARQIMP Format("W08.2,EIC",[Preco Total])+"\n"
   Moveto[Codigo do Item]
   If BUSCA_LOOKUP("Codigo do Item",[OrcaI->Codigo do Item],"")
      Then Loc   =REG_BUSCA_LOOKUP["Localizacao"]
   EndIf
   UnlockRecord
   
   Print File ARQIMP "Loc: "+ Format("W07,EIC",Loc)+"\n" 

   QUANT=QUANT+[Quantidade]
   TOT=TOT+[Preco Total]
   Print File ARQIMP Fill("-",32)+"\n"
EndScan

Moveto "OrcaC"
Print File ARQIMP "Valor Total: "
Print File ARQIMP Spaces(8)+Format("W11.2,EIC",[Valor Mercadoria]+[Valor Servico])+"\n"
Print File ARQIMP Fill("-",32)+"\n"
Print File ARQIMP "VR.MERCADORIAS: "+Format("W08.2,EIC",[Valor Mercadoria])+"\n"
Print File ARQIMP "VR.DESCTO: "+Format("W8.2,EIC",[Valor Desconto])+"\n\n"

Print File ARQIMP CI_INEG
Print File ARQIMP Format("W40,AC","VR A PAGAR.: "+ LTrim(Format("W11.2,EIC",[Valor Nota Fiscal])))
Print File ARQIMP CI_FNEG+"\n"

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

Print File ARQIMP Spaces(02)+Fill("_",28)+"\n"


Print File ARQIMP Format("W32,AC",[Razao Social])+"\n"

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

Print File ARQIMP Format("W32,AC","AGRADECEMOS A PREFERENCIA")+"\n"

Print File ARQIMP Fill("=",32)+"\n"

EndProc ; (IMPRO)

;*******************************************************************************
;* Rotina Principal                                                            *
;*****************+*************************************************************
ArqImp=PrivDir()+"OR_0152.Txt"
If IsFile(ArqImp)
   Then Deleta_Arquivo(ARQIMP)
EndIf

AGUARDE("Imprimindo Orcamento -> "+ORCA)
Moveto "OrcaC"
CoEditKey

IMPRO()
Do_IT!
;---- Imprime Arquivo Impressao ------------------------------------------------
ImpriArq(ARQIMP)

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