;** PD_0001  *******************************************************************
;** Imprime a Digitacao do Pedido                          ** Divilack     **  *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 24/04/1998 por Anivel Augusto Rodrigues
;Alterado em     : 17/07/2007 por Anivel Augusto Rodrigues
;Motivo Alteracao: Inclusao nome do usuario
;Alterado em     : 19/10/2010 por Bruno Carvalho
;Motivo Alteracao: Removido [Condicao de Pagamento] conforme ajustes na estrturua "PedidoI"
;Ultima Alteracao: 20/10/2017 por Bruno Carvalho                         
;Motivo Alteracao: Removido [Composicao de Dias] 
;Ultima Alteracao: 31/10/2017 por Bruno Carvalho
;Motivo Alteracao: Removido de IMPPED() -> Empresa Atendimento

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

Moveto "PedidoI"

Scan
   COND_PAGTO = BlankNum()                                                      ;[Condicao de Pagamento]
   Print File ARQIMP ASP1+Format("W03,AL",[Item do Pedido])
   Print File ARQIMP Format("W05,AR",NumVal([Codigo do Item]))+" "
   Print File ARQIMP Format("W32,AL",[Descricao do Item])
   Print File ARQIMP Format("W05,AL","")
   Print File ARQIMP Format("W10.2,EIC",[Quantidade])
   Print File ARQIMP Format("W03,AR",[Unidade Fiscal])
   Print File ARQIMP Format("W8.3,EIC",[Preco Unitario])
   Print File ARQIMP Format("W8.3,EIC",[Preco Unitario Tabela])
   Print File ARQIMP Format("W6.2,EIC",[Taxa Desconto Unitario])
   Print File ARQIMP Format("W5.2,EIC",[Comissao do Item])
   Print File ARQIMP Format("W10.2,EIC",[Preco Total])+" "
   Print File ARQIMP Format("W06",[Codigo da Tabela])
   Print File ARQIMP Format("W03",COND_PAGTO+":")+ASP2+"\n"

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

Rodape()

EndProc

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

Moveto "PedidoC"

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

Print File ARQIMP ASP1+Chr(27)+Chr(67)+Chr(33)
Print File ARQIMP CI_8LPP
Print File ARQIMP CI_10CPP
Print File ARQIMP ASP2+"\n"
Print File ARQIMP ASP1+Format("W40,AL",NOMEMPRESA)+Spaces(04)+"Impressao: "+Format("D10",Today())+"-"+Time()+ASP2+ "\n\n"

Print File ARQIMP ASP1+CI_IEXP+CI_INEG
Print File ARQIMP Spaces(23)+"Pedido N§ "+Format("W06.3,AL",[Numero do Pedido])+ASP2+"\n"
Print File ARQIMP ASP1+CI_FEXP+CI_FNEG

Print File ARQIMP "Cliente: "+Format("W05,AL",[Codigo])+Format("W46,AL",[Razao Social])+ASP2+"\n"

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

Print File ARQIMP ASP1+Spaces(09)+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(09)+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+"Vendedor: "+Format("W05,AL",[Codigo do Representante])
Print File ARQIMP Format("W25,AL",[Nome Fantasia Represent])

Moveto [Codigo_Usuario]
If Busca_Lookup("Chapa",[Codigo_Usuario],"SM")
   Then NOME_USUARIO=Reg_Busca_Lookup["Nome"]
   Else NOME_USUARIO=""
EndIF

Print File ARQIMP "Usuario: "+Format("W05,AL",[Codigo_Usuario])
Print File ARQIMP Format("W15,AL",NOME_USUARIO)
Print File ARQIMP " OP: "+[Origem do Pedido]+ASP2+"\n"

Print File ARQIMP ASP1+"Emissao.: "+Format("D13",[Data de Emissao])+Spaces(20)
Print File ARQIMP "Tab.Preco: "+Format("W06,AL",[Codigo da Tabela])+ASP2+"\n\n"

Print File ARQIMP ASP1+CI_15CPP
Print File ARQIMP      "Sq Item                                  LA         Qtde Un   PrUni   PrTab  %Des   C%   PrTotal Tb.Pr CP "+ASP2+"\n"
Print File ARQIMP ASP1+"-- ------------------------------------- ---- ---------- -- ------- ------- ----- ---- --------- ----- ---"+ASP2+"\n"

Limite=18

EndProc

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

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

Moveto "PedidoC"

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

Print File ARQIMP ASP1+Spaces(25)+"  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(25)+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"
Print File ARQIMP ASP1+"Transport..: "+[Razao Social Transport]+ASP2+"\n"
Print File ARQIMP ASP1+"Observacoes: "

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


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

Moveto "PedidoC"
Print File ARQIMP ASP1+ASP2+"\n"
Print File ARQIMP ASP1+"N§ Volumes.:"+"________"
Print File ARQIMP "  Peso:"+"___________"+ASP2+"\n\n"

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 Almoxarif      Dt/Assinat Emb/Confer     Dt/Assinat Cliente          "+ASP2+"\n\n"
Print File ARQIMP ASP1+CI_6LPP
Print File ARQIMP "\f"+ASP2

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 File ARQIMP VALOR[I]+Spaces(02)
EndFor
Print File ARQIMP ASP2+"\n"

KV=KV+1
EndProc

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

Seta_FilePrint("PD_0001")
CoEditKey
IMPPED()
Do_IT!
Imprime_FilePrint("Imprimindo Pedido -> "+PEDIDO,"1")

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