;** Or_0102 ********************************************************************
;** Imprime o Orcamento               Concretos Vico              *
;*******************************************************************************
;Autor: Visao/Vise
;Desenvolvido  em: 24/04/2008 por Nikolas
;Alterado em     : 29/04/2008 por Anivel Augusto Rodrigues
;Motivo Alteracao: Opcao Video
;Alterado em     : 03/12/2019 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes nome empresa

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

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

Moveto "Orcac"

Print File ARQIMP ASP1+CI_15CPP+CI_8LPP+ASP2+"\n\n"

Print File ARQIMP ASP1+CI_IEXP+CI_INEG
Print File ARQIMP "         VICO (37) 99908-1564   "
Print File ARQIMP CI_FEXP+CI_FNEG+ASP2+"\n"

Print File ARQIMP ASP1+"================================================================================"+ASP2+"\n"

Print File ARQIMP ASP1+CI_IEXP+CI_INEG
Print File ARQIMP "** OR€AMENTO **"
Print File ARQIMP Spaces(10)+ "NUMERO:  "+Format("W06.3,AL",[Numero do Orcamento])
Print File ARQIMP CI_FEXP+CI_FNEG+ASP2+"\n\n"

Print File ARQIMP ASP1+"EMISSAO: "+Format("D13",Today())+"-"+Time()+"  "+
                       "VEND: "+Format("W21,AL",[Nome Fantasia Represent])+ASP2+"\n"

Print File ARQIMP ASP1+"--------------------------------------------------------------------------------"+ASP2+"\n"

Print File ARQIMP ASP1+"CLIENTE.: "
Print File ARQIMP Format("W05,AL",[Codigo])
Print File ARQIMP Format("W35,AL",[Razao Social])+ASP2+"\n"

Print File ARQIMP ASP1+"ENDERE€O: "+ Format("W40,AL",[Endereco])+ASP2+"\n"

Print File ARQIMP ASP1+"BAIRRO..: "+ Format("W20,AL",[Bairro])+
                       "FONE: " + Format("W20,AL",[Telefone])+ASP2+"\n"

Print File ARQIMP ASP1+"CIDADE..: "+Format("W20,AL",[Cidade])+Spaces(2)+ASP2+"\n"

Print File ARQIMP ASP1+"OBS.....: "
Print File ARQIMP SubStr([Observacao do Orcamento],001,68)+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+SubStr([Observacao do Orcamento],069,68)+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+SubStr([Observacao do Orcamento],137,68)+ASP2+"\n"

;********************* IMPRESSAO DOS ITENS ********************************
Moveto "Orcai"
Print File ARQIMP ASP1+"================================================================================"+ASP2+"\n"
Print File ARQIMP ASP1+"PRODUTO                                        UF     QUANT    UNIT.R$     TOTAL"+ASP2+"\n"
QUANT=0
TOT=0
Scan
   Print File ARQIMP ASP1+Format("W11,AL",[Codigo do Item])
   Print File ARQIMP Format("W36,AL",[Descricao do Item])
   Print File ARQIMP Format("W03,AL",[Unidade Fiscal])
   Print File ARQIMP Format("W07,EIC",[Quantidade])+Spaces(01)
   Print File ARQIMP Format("W11.2,EIC",[Preco Unitario])
   Print File ARQIMP Format("W11.2,EIC",[Preco Total])+ASP2+"\n"

   QUANT=QUANT+[Quantidade]
   TOT=TOT+[Preco Total]
EndScan

Moveto "Orcac"

Print File ARQIMP ASP1+Spaces(74)+"------"+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(69)+Format("W11.2,EIC",[Valor Mercadoria])+ASP2+"\n"
Print File ARQIMP ASP1+"--------------------------------------------------------------------------------"+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(02)+"VR.MERCADORIAS: "+Format("W11.2,EIC",[Valor Mercadoria])+
                  Spaces(05)+"VR.DESCTO: "+Format("W8.2,EIC",[Valor do Desconto])+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(02)+"VR.SERVICO....: "+Format("W11.2,EIC",[Valor Servico])+
                  Spaces(05)+"VR.FRETE.: "+Format("W8.2,EIC",[Valor do Frete])+ASP2+"\n\n"
Print File ARQIMP ASP1+Spaces(02)+"VR LIQUIDO: "
Print File ARQIMP CI_IEXP+CI_INEG
Print File ARQIMP Format("W11.2,EIC",([Valor Mercadoria]-[Valor do Desconto]))
Print File ARQIMP CI_FEXP+CI_FNEG+ASP2+"\n\n"

Moveto"OrcaCPG"
Print File ARQIMP ASP1+"CONDICOES  DE  PAGAMENTOS  "+ASP2+"\n"
Scan
  Print File ARQIMP ASP1+Format("W20,AL",[Descricao CondPagto])
  Print File ARQIMP " Vr Total: "+Format("W11.2,EIC",[Orcac->Valor Nota Fiscal]+(([Orcac->Valor Nota Fiscal]*[Taxa Financeira])/100))+ASP2+"\n"
EndScan

Moveto "Orcac"
Print File ARQIMP ASP1+"--------------------------------------------------------------------------------"+ASP2+"\n\n"
Print File ARQIMP ASP1+Spaces(17)+"-----------------------------------------"+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(17)+Format("W40,AC",[OrcaC->Razao Social])+ASP2+"\n\n"
Print File ARQIMP ASP1+Spaces(17)+"         AGRADECEMOS A PREFERENCIA"+ASP2+"\n"
Print File ARQIMP ASP1+"---------------------------------------------------------------------------------"+ASP2+"\n"

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

EndProc

;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************
ASP1=""
ASP2=""
ArqImp=PrivDir()+"OR_0102.Txt"
Switch
  Case OK="A":
       ARQIMP = DIREPORT+ARQUIVO+".TXT"
  Case OK="V": ASP1="\""
               ASP2="\""
EndSwitch

If IsFile(ArqImp)
   Then Deleta_Arquivo(ARQIMP)
EndIf

Seta_FilePrint("OR_0102")
IMPORC()
Imprime_FilePrint("Imprimindo Or‡amento -> "+ORCA,"1")

Release Vars VALOR,DATA,CLIENTE
Release Procs IMPORC
LIMPAGUARDE()

