;** OC_0079  *******************************************************************
;** Imprime a Digitacao da Ordem de Compra                 ** Isabela Garcia   *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 08/10/2003 por Anivel Augusto Rodrigues
;Alterado em     : 13/04/2006 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes
;Alterado em     : 11/11/2009 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes funcao de impressao

;*******************************************************************************
;* Rotina para Impressao do Relatorio                                          *
;*******************************************************************************
Proc IMPOC()
Cabecalho()

Moveto "OCI"
Scan
   Print File ARQIMP ASP1+Format("W03,AR",StrVal([Item da OC]))+Spaces(1)
   Print File ARQIMP Format("W11,AL",[Codigo do Item])
   Print File ARQIMP Format("W30,AL",[Descricao do Item])
   Print File ARQIMP Format("W11.3,EIC",[Quantidade])
   Print File ARQIMP Format("W03,AR",[Unidade Fiscal])
   Print File ARQIMP Format("W10.2,EIC",[Preco Unitario])
   Print File ARQIMP Format("W11.2,EIC",[Preco Total])+ASP2+"\n"

   Limite = Limite + 1
   If Limite > 62
      Then Print ASP1+"\f"+ASP2+"\n"
           Cabecalho()
           Moveto "OCI"
   Endif
EndScan
OBS="N"

Rodape()
EndProc

;************************************************************************************
;Impressao do Cabecalho                                                             *
;************************************************************************************
Proc Cabecalho()

If Not IsAssigned(NOMEMPRESA)
   Then NOMEMPRESA=""
EndIf

Moveto "OCC"

Open Printer
Printer On

Print File ARQIMP ASP1+CI_10CPP+ASP2+"\n"
Print File ARQIMP ASP1+Format("W40,AL",NOMEMPRESA)+Spaces(04)+"Impressao: "+Format("D10",Today())+"-"+Time()+ASP2+ "\n\n"
If OK<>"I"
   Then Print File ARQIMP ASP1+Spaces(65)+"OC: "+Format("W06,AL",[Numero da OC])+ASP2+ "\n"
   Else Print File ARQIMP ASP1+Spaces(46)+CI_INEG+CI_IEXP+"OC: "+Format("W06,AL",[Numero da OC])+CI_FEXP+CI_FNEG+ASP2+ "\n"
EndIf
Print File ARQIMP ASP1+"Fornecedor: "+Format("W05,AL",[Codigo])+Format("W46,AL",[Razao Social])+ASP2+"\n"

Print File ARQIMP ASP1+Spaces(17)+Format("W40,AL",[Endereco])
Print File ARQIMP Format("W18,AL",[CGC])+ASP2+"\n"

Print File ARQIMP ASP1+Spaces(17)+Format("W20,AL",[Bairro])
Print File ARQIMP Format("W20,AL",[CEP])
Print File ARQIMP Format("W25,AL",[IE])+ASP2+"\n"

Print File ARQIMP ASP1+Spaces(17)+Format("W20,AL",[Cidade])
Print File ARQIMP Format("W20,AL",[UF])
Print File ARQIMP Format("W25,AL",[Telefone])+ASP2+"\n\n"

Print File ARQIMP ASP1+"Comprador.: "+Format("W05,AL",[Codigo do Comprador])
Print File ARQIMP Format("W25,AL",[Nome do Comprador])+ASP2+"\n"

Print File ARQIMP ASP1+"Emissao...: "+Format("D13",[Data de Emissao])+Spaces(05)
If OK<>"I"
   Then Print File ARQIMP "Entrega: "+Format("D13",[Data de Entrega])+ASP2+"\n"
   Else Print File ARQIMP CI_INEG+"Entrega: "+Format("D13",[Data de Entrega])+CI_FNEG+ASP2+"\n"
EndIf

Print File ARQIMP ASP1+CI_10CPP+ASP2+"\n"
Print File ARQIMP ASP1+"Sq  Item                                      Quantidade Un  PrUnitar    PrTotal"+ASP2+"\n"
Print File ARQIMP ASP1+"--- ---------------------------------------- ----------- -- --------- ----------"+ASP2+"\n"

Limite=18
EndProc

;*******************************************************************************
;* Impressao do RodaP‚                                                         *
;*******************************************************************************
Proc RodaPe()

;********************* IMPRESSAO DOS TOTAIS **************************

Moveto "OCC"

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

Print File ARQIMP ASP1+Spaces(27)+"  Mecadorias         Desconto     Liquido       Total"+ASP2+"\n"
                ;;9.999.999,99888.88%777.777,776.666.666,665.555.555,55

Print File ARQIMP ASP1+Spaces(27)+Format("W12.2,EIC",[Valor Mercadoria])
Print File ARQIMP Format("W06.2,EIC",[Taxa de Desconto])+"%"
Print File ARQIMP Format("W10.2,EIC",[Valor do Desconto])
Print File ARQIMP Format("W12.2,EIC",[Valor Mercadoria Liquido])
Print File ARQIMP Format("W12.2,EIC",[Valor Nota Fiscal])+ASP2+"\n\n"

Print File ARQIMP ASP1+"Cond. Pagto: "+[Descricao CondPagto]
Print File ARQIMP "   NP: "+StrVal([Numero de Parcelas])
Print File ARQIMP "   CD: "+[Composicao de Dias]+"   FP: "+[Forma de Pagamento]+"   FR:"+Format("W10.2,EIC",[Valor do Frete])+ASP2+"\n\n"

Print File ARQIMP ASP1+"Transport..: "+Completa([Razao Social Transport],35," ")
If [Frete por Conta]="1"
   Then Print File ARQIMP "Frete: CIF"
   Else Print File ARQIMP "Frete: FOB"
EndIf
Print File ARQIMP ASP2+"\n\n"

Print File ARQIMP ASP1+"Observacoes: "

Print File ARQIMP Format("W60,AL",SubStr([Observacoes da OC],001,60))+ASP2+"\n"
If Substr([Observacoes da OC],61,120)<>""
   Then Print File ARQIMP ASP1+Spaces(13)+Format("W60,AL",SubStr([Observacoes da OC],61,120))+ASP2+"\n"
EndIf
If Substr([Observacoes da OC],121,180)<>""
   Then Print File ARQIMP ASP1+Spaces(13)+Format("W60,AL",SubStr([Observacoes da OC],121,180))+ASP2+"\n"
EndIf


Moveto "OCC"

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

Print File ARQIMP ASP1+"  /  /   -                               /  /   -                  "+ASP2+"\n"
Print File ARQIMP ASP1+"_________________________              ____________________________"+ASP2+"\n"
Print File ARQIMP ASP1+"Dt/Assinat Comprador                   Dt/Assinat Almoxarif        "+ASP2+"\n\n"
Print File ARQIMP ASP1+"\f"+ASP2+"\n"
Print File ARQIMP ASP1+CI_10CPP+ASP2+"\n"
Print File ARQIMP ASP1+CI_6LPP+ASP2+"\n"
Printer Off
Close Printer

EndProc

;*******************************************************************************
;* Rotina de Impressao dos Vencimentos                                         *
;*******************************************************************************
Proc VENC()

If KV>0
   Then Print File ARQIMP ASP1+Spaces(15)
EndIf
For I From 1 to K
  Print File ARQIMP Spaces(03)+DATA[I]+Spaces(02)
EndFor

Print File ARQIMP ASP2+"\n"
Print File ARQIMP ASP1+ Spaces(19)

For I From 1 to K
  Print VALOR[I]+Spaces(02)
EndFor

Print File ARQIMP ASP2+"\n"
KV=KV+1

EndProc

;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************
Aguarde("Imprimindo OC -> "+OC)
Seta_FilePrint("OC_0079")
IMPOC()
Imprime_FilePrint("","R")

Release Vars VALOR,DATA
Release Procs IMPPED,VENC,Cabecalho,Rodape,
              Seta_FilePrint, Imprime_FilePrint


