;** PD_0053s  ******************************************************************
;** Imprime a Digitacao do Pedido s/ Valor                 ** C.S.S.  **       *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 24/04/1998 por Anivel Augusto Rodrigues
;Alterado em     : 18/09/2006 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes
;Alterado em     : 05/09/2012 por Bruno Carvalho
;Motivo Alteracao: Adicionado "Razao Social" antes do "Codigo" ao exibir o cliente

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

{Ask} {PedidoI} Check
Moveto [Numero do Pedido] TypeIn "~CODPED"
Do_It!
Sort "Answer" On "Codigo do Item","Item do Pedido"

View "PedidoC"
View "PedidoV"

Cabecalho()

Moveto "Answer"
ITEMANTIGO=[Codigo do Item]
CONT=0

Scan
   If [Codigo do Item] <> ITEMANTIGO
      Then If CONT > 1
              Then Print File ARQIMP ASP1+"------------------------------------------------------------------------------------------"+ASP2+"\n"
                   Print File ARQIMP ASP1+"                                                                Total... |"+ASP2+"\n"
                   Limite=Limite+2
           Endif
           Print File ARQIMP ASP1+"=========================================================================================="+ASP2+"\n"
           Limite=Limite+1
           If Limite >= 62
              Then Print File ARQIMP ASP1+"\f"+ASP2
                   Cabecalho()
                   Moveto "Answer"
           Endif
           ITEMANTIGO=[Codigo do Item]
           CONT=0
      Else IF CONT > 0
              Then Print File ARQIMP ASP1+"------------------------------------------------------------------------------------------"+ASP2+"\n"
                   Limite=Limite+1
           Endif
   Endif

   Print File ARQIMP ASP1+Format("W03,AL",[Item do Pedido])
   Print File ARQIMP Format("W05,AR",NumVal([Codigo do Item]))+" "
   Print File ARQIMP Format("W35,AL",[Descricao do Item])
   Print File ARQIMP Format("W04,AL",[Codigo da Cor_Tecido])
   Print File ARQIMP Spaces(01)+Format("W12,AL",[Descricao da Cor_Tecido])

   Print File ARQIMP Format("W9.2,EIC",[Quantidade])
   Print File ARQIMP Format("W03,AR",[Unidade Fiscal])+                                         "|"+ASP2+"\n"

   Limite = Limite + 1
   If Limite >= 62
      Then Print File ARQIMP ASP1+"\f"+ASP2
           Cabecalho()
           Moveto "Answer"
   Endif
   CONT=CONT+1

EndScan
If CONT > 1
   Then Print File ARQIMP ASP1+"------------------------------------------------------------------------------------------"+ASP2+"\n"
        Print File ARQIMP ASP1+"                                                                Total... |"+ASP2+"\n"
        Limite=Limite+2
Endif
Print File ARQIMP ASP1+"=========================================================================================="+ASP2+"\n"
Limite=Limite+1

If Limite >= 47
   Then Print File ARQIMP ASP1+"\f"+ASP2
        Cabecalho()
Endif
RodaPe()

EndProc

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

Moveto "PedidoC"
Moveto [Numero do Pedido]
Locate CODPED

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

Print File ARQIMP ASP1+CI_10CPP+ASP2+"\n"
Print File ARQIMP ASP1+"--------------------------------------------------------------------------------"+ASP2+"\n"
Print File ARQIMP ASP1+Format("W38,AL",NOMEMPRESA)+"Pedido  "+Spaces(04)+"Impressao: "+Format("D13",Today())+"-"+Time()+ASP2+"\n"
Print File ARQIMP ASP1+"--------------------------------------------------------------------------------"+ASP2+"\n\n"

pos=SearchFrom("-",[PedidoC->Nome Fantasia Represent],1)
Print File ARQIMP ASP1+CI_IEXP+CI_INEG
Print File ARQIMP Spaces(24)+"N§ : "+Format("W06.3,AL",[Numero do Pedido])+"/"+ SubStr([PedidoC->Nome Fantasia Represent],1,(Pos-1))
Print File ARQIMP CI_FEXP+CI_FNEG+ASP2+"\n"

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

Print File ARQIMP ASP1+Spaces(9)+[CGC]+ASP2+"\n"

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

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

Print File ARQIMP ASP1+CI_12CPP
Print File ARQIMP "Sq Item                                      Cor/Tecido           Qtde Un      Qtde/Medida"+ASP2+"\n"
Print File ARQIMP ASP1+"-- ---------------------------------------- ---------------- --------- -- ----------------"+ASP2+"\n"

Limite = 18

EndProc

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

Moveto "PedidoC"

Print File ARQIMP ASP1+Chr(27)+Chr(80) ;** Matricial ***
Print File ARQIMP ASP2+"\n\n"
Print File ARQIMP ASP1+Spaces(02)+"N§. Volumes:"+"________"
Print File ARQIMP "  Peso.:"+"___________"+ASP2+"\n\n"

Print File ARQIMP ASP1+Spaces(02)+"Observacoes: "+Format("W60,AL",SubStr([Observacao na Nota Fiscal],001,60))+ASP2+"\n"
If Substr([Observacao na Nota Fiscal],61,120)<>""
   Then Print File ARQIMP ASP1+Spaces(15)+Format("W60,AL",SubStr([Observacao na Nota Fiscal],61,120))+ASP2+"\n"
EndIf
If Substr([Observacao na Nota Fiscal],121,180)<>""
   Then Print File ARQIMP ASP1+Spaces(15)+Format("W60,AL",SubStr([Observacao na Nota Fiscal],121,180))+ASP2+"\n"
EndIf

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

Print File ARQIMP ASP1+Spaces(10)+"  /  /   -                               /  /   -                   "+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+"_____________________________          _____________________________"+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+"Data/Assinatura Separador              Data/Assinatura Medidor     "+ASP2+"\n\n"
Print File ARQIMP ASP1+Spaces(10)+"  /  /   -                               /  /   -                   "+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+"_____________________________          _____________________________"+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+"Data/Assinatura Embalador              Data/Assinatura Conferista  "+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+"  /  /   -                     "+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+"_____________________________  "+ASP2+"\n"
Print File ARQIMP ASP1+Spaces(10)+"Data/Assinatura Volumes        "+ASP2+"\n\n"
Print File ARQIMP ASP1+CI_10CPP
Print File ARQIMP "\f"+ASP2

EndProc

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

Seta_FilePrint("PD_5009S")
IMPPED()
Do_It!
Imprime_FilePrint("Imprimindo Pedido -> "+PEDIDO,"1")

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

