;** Pd_0130 ********************************************************************
;** Imprime a Digitacao do Pedido                         ** GW ENTRETELAS **  *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 11/08/1997 por Ricardo Augusto Silva
;Alterado em     : 13/04/2006 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes

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

;************************* IMPRESSAO DO CABECALHO *****************************
If Not IsAssigned(NOMEMPRESA)
   Then NOMEMPRESA=""
EndIf
Print File ARQIMP chr(27)+chr(67)+chr(33) ;Imprime 33 Linhas por pagina
Print File ARQIMP ASP1+CI_15CPP+ASP2
Print File ARQIMP ASP1+ASP2
Print File ARQIMP "NONSKID INDUSTRIA E COMERCIO DE ENTRETELAS"+"\n"
Print File ARQIMP "COLARINHOS  GOLAS  PUNHOS  CARCELAS  COS E VISTAS"+"\n"
Print File ARQIMP "ALAMEDA RIO PARANAIBA, 440 - BAIRRO TIETE"+"\n"
Print File ARQIMP "TEL/FAX: (37)3221-1319 CEP: 35.502-463 DIVINOPOLIS MG"+"\n"
Print File ARQIMP " ---------------------------------------------------------------------------------------------------------------------"+ASP2+"\n"
Print File ARQIMP "\027E"
Print File ARQIMP ASP1+"Cliente: "
Print File ARQIMP Format("W05,AL",[Codigo])
Print File ARQIMP Format("W40,AL",[Razao Social])
Print File ARQIMP "N§ Ped.: "+Format("W06.3,AL",[Numero do Pedido])+ASP2+"\n"
Print File ARQIMP "\027F"
Print File ARQIMP ASP1+Spaces(02)+Format("W40,AL",[Endereco])
Print File ARQIMP Format("W18,AL",[CGC])+Spaces(08)+"Emissao: "
Print File ARQIMP Format("D13",[Data de Emissao])+ASP2+" - "+Time()+ "\n"
Print File ARQIMP ASP1+Spaces(02)+Format("W20,AL",[Bairro])
Print File ARQIMP Format("W12,AL",[CEP])
Print File ARQIMP Format("W20,AL",[IE])

Print File ARQIMP ASP1+Spaces(4)+Format("W20,AL",[Cidade])
Print File ARQIMP Format("W3,AL",[UF])
Print File ARQIMP Format("W25,AL",[Telefone])
Print File ARQIMP "\n"
Print File ARQIMP ASP1+Spaces(02)+"Representante: "+Format("W05,AL",[Codigo do Representante])
Print File ARQIMP Format("W25,AL",[Nome Fantasia Represent])
Print File ARQIMP "Destinacao: "+Format("W04,AL",[Codigo da Destinacao])
Print File ARQIMP Format("W25,AL",[Descricao da Destinacao])

;********************* IMPRESSAO DOS ITENS ********************************
Print File ARQIMP "\n"
Print File ARQIMP " -----------------------------------------------------------------------------------------------"+ASP2+"\n"
Print File ARQIMP " Sq  Codigo     Descricao                                      Quant.   Un  Pr.Unit.   Pr.Total "+ASP2+"\n"
Print File ARQIMP " --- ---------- -------------------------------------------  ---------- --- ---------  ---------"+ASP2+"\n"
Moveto "PedidoI"
Cont=1
Scan
   Print File ARQIMP ASP1+Spaces(02)+Format("W03,AL",[Item do Pedido])
   Print File ARQIMP Format("W11,AL",[Codigo do Item])
   Print File ARQIMP Format("W41,AL",[Descricao do Item])
   Print File ARQIMP Format("W03,AR",[Tamanho])
   Print File ARQIMP Format("W11.3,EIC",[Quantidade])
   Print File ARQIMP Spaces(01)+Format("W03,AR",[Unidade Fiscal])
   Print File ARQIMP Format("W10.4,EIC",[Preco Unitario])
   Print File ARQIMP Format("W11.2,EIC",[Preco Total])+ASP2+"\n"
   Cont=Cont+1
   If Cont=49
     Then
     Print File ARQIMP ASP1+ASP2+"\n"
   EndIf
EndScan

;********************* IMPRESSAO DOS TOTAIS **************************
Moveto "PedidoC"
Print File ARQIMP ASP1+ASP2
Print File ARQIMP ASP1+"  Mecadorias     Desconto        Frete       Total"+ASP2+"\n"

Print File ARQIMP ASP1+ 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("W09.2,EIC",[Valor do Frete])
Print File ARQIMP Format("W012.2,EIC",[Valor Nota Fiscal])
Print File ARQIMP "\n\n"

Print File ARQIMP ASP1+Spaces(02)+"Cond. Pagamento.: "+[Descricao CondPagto]
Print File ARQIMP "   NP: "+StrVal([Numero de Parcelas])
Print File ARQIMP "   CD: "+[Composicao de Dias]

;********************* IMPRESSAO DOS VENCIMENTOS **************************

Print File ARQIMP "\n"
Print File ARQIMP ASP1+Spaces(02)+"Vencimentos.....: "

Array DATA[9]
Array VALOR[9]
K=0
Moveto "PedidoV"
Scan
  K=K+1
  DATA[K]  = Format("D13",[Data])
  VALOR[K] = Format("W11.2,AL,EIC",[Valor])
  If K=9
     Then VENC()
          K=0
  EndIf
EndScan
If K>0
   Then VENC()
EndIf
Print File ARQIMP ASP2+"\n"

;************************* IMPRESSAO DO RODAPE ********************************
Moveto "PedidoC"
Print File ARQIMP ASP1+spaces(02)+"Obs. do Pedido..: "+Format("W110,AL",SubStr([Observacao do Pedido],001,110))+ASP2+"\n"
If Substr([Observacao do Pedido],111,110)<>""
   Then Print File ARQIMP ASP1+ Spaces(20)+Format("W110,AL",SubStr([Observacao do Pedido],111,110))+ASP2+"\n"
EndIf

Print File ARQIMP "\n"

Print File ARQIMP Spaces(40)+"_______________________________________________"+ASP2+"\n"
Print File ARQIMP Spaces(40)+"        Data/Assinatura Responsavel"+ASP2+"\n"
Print File ARQIMP CI_10CPP
Print File ARQIMP "\f"+ASP2
;Print File ARQIMP "\n"
;Print File ARQIMP "\f"
EndProc

;*******************************************************************************
;* Rotina de Impressao dos Vencimentos                                         *
;*******************************************************************************
Proc VENC()
If RecNo()>9
   Then Print File ARQIMP ASP1+ Spaces(20)
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(25)
For I From 1 to K
  Print File ARQIMP VALOR[I]+Spaces(02)
EndFor
Print File ARQIMP ASP2+"\n"
EndProc

;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************

Seta_FilePrint("PD_0130")
IMPPED()
Imprime_FilePrint("Imprimindo Pedido -> "+PEDIDO,"1")

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

