;** PD_0167s *******************************************************************
;** Imprime a Digitacao do Pedido s/ Valor  ** FUNDICAO SAO GERALDORIAS **     *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 24/04/1998 por Anivel Augusto Rodrigues
;Alterado em     : 11/04/2007 por Nikolas M. Mateus
;Motivo Alteracao: Ajustes

;*******************************************************************************
;* 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 "PedidoV"
View "PedidoC"

Cabecalho()

Moveto "Answer"

Scan

Print File ARQIMP ASP1+CI_INEG

    Print File ARQIMP ASP1+Format("W04,AL",[Item do Pedido])
    Print File ARQIMP Format("W9.2,EIC",[Quantidade])
    Print File ARQIMP Spaces(01)+Format("W35,AL",[Descricao do Item])
;   Print File ARQIMP Spaces(12)+Format("W05,AR",NumVal([Codigo do Item]))+" "
;   Print File ARQIMP Format("W03,AR",[Unidade Fiscal])
;   Print File ARQIMP Format("W7.2,EIC",[Preco Unitario])
;   Print File ARQIMP Format("W10.2,EIC",[Preco Total])+ASP2+"\n"
   Print File ARQIMP ASP2+"\n"

Print File ARQIMP ASP1+CI_FNEG


   Limite = Limite + 1
   If Limite > 62
      Then Print File ARQIMP ASP1+"\f"+ASP2
           Cabecalho()
           Moveto "Answer"
   Endif
EndScan
OBS="N"
View "\\Sistemas\\Cadastro\\FichaCli"
Moveto [Codigo]
Locate [PedidoC->Codigo]
If RetVal
   Then If [Data da Primeira Compra]=[PedidoC->Data de Emissao]
           Then View "\\Sistemas\\Cadastro\\DestObs"
                Moveto [Codigo]
                Locate [PedidoC->Codigo]
                If RetVal
                   Then OBS="S"
                Endif
        Endif
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+Chr(27)+Chr(80)
Print File ARQIMP CI_10CPP
Print File ARQIMP 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"

Print File ARQIMP ASP1+CI_INEG
;Print File ARQIMP ASP1+CI_IEXP+CI_INEG
pos=SearchFrom("-",[PedidoC->Nome Fantasia Represent],1)

Print File ARQIMP ASP1+"Emissao: "+Format("D10",[Data de Emissao])+Spaces(02)
Print File ARQIMP Spaces(02)+"Data de Entrega: "+Format("D10",[Data de Entrega ])
Print File ARQIMP Spaces(01)+"Placa: "+Format("W08.3,AL",[Placa do Veiculo])
Print File ARQIMP Spaces(02)+"N§ Ped.: "+Format("W06.3,AL",[Numero do Pedido])+ASP2+"\n\n"

;Print File ARQIMP Spaces(24)+"N§ : "+Format("W06.3,AL",[Numero do Pedido])+ASP2+"\n"

Print File ARQIMP ASP1+CI_FNEG
;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 ASP2+"\n\n\n"

;Print File ARQIMP ASP1+"Representante: "+Format("W05,AL",[Codigo do Representante])
;Print File ARQIMP Format("W25,AL",[Nome Fantasia Represent])
;Print File ARQIMP "  Comissao: "+Format("W06.2,EIC",[Comissao do Representante])+ASP2+"% \n"

;Print File ARQIMP ASP1+"Emissao: "+Format("D10",[Data de Emissao])+Spaces(03)
;Print File ARQIMP Tabela])+ASP2+"\n\n"

Print File ARQIMP ASP1+CI_INEG

Print File ARQIMP ASP1+CI_12CPP
Print File ARQIMP      "Sq     Qtde   Item                                     "+ASP2+"\n"
Print File ARQIMP ASP1+" -- --------- ---------------------------------------- "+ASP2+"\n"

Print File ARQIMP ASP1+CI_FNEG

Limite=18

EndProc

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

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

Moveto "PedidoC"

Print File ARQIMP ASP1+Chr(27)+Chr(80) ;** Matricial ***
Print File ARQIMP ASP2+"\n"

;Print File ARQIMP ASP1+"                                                    Total"+ASP2+"\n"
         ;; 999    9.999,99   9.999.999,99888.88%777.777,776.666.666,665.555.555,55

;Print File ARQIMP ASP1+Format("W8.2,EIC",[Numero de Volumes])
;Print File ARQIMP Format("W12.2,EIC",[Peso Bruto])
;Print File ARQIMP Spaces(13)+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 Spaces(47)+"Valor Total: "+Format("W12.2,EIC",[Valor Nota Fiscal])+ASP2+"\n\n"

Print File ARQIMP ASP2+"\n"

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

;********************* IMPRESSAO DOS VENCIMENTOS **************************
;Print File ARQIMP ASP1+Spaces(02)+"Vencimentos: "
;Array DATA[5]
;Array VALOR[5]
;K=0
;KV=0
;Moveto "Pedidov"
;Moveto [Numero do Pedido]
;Locate CODPED
;If RetVal
;   Then While [Numero do Pedido]=CODPED
;          K=K+1
;          DATA[K]  = Format("D10",[Data])
;          VALOR[K] = Format("W11.2,AL,EIC",[Valor])
;          If K=5
;             Then VENC()
;                  K=0
;          EndIf
;          Skip
;          If EOT() Then QuitLoop EndIf
;        EndWhile
;Endif
;If K>0
;   Then VENC()
;EndIf
;Print File ARQIMP ASP2+"\n"

Moveto "PedidoC"
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
If OBS="S"
   Then Print File ARQIMP ASP1+Format("W70,AL",[\Sistemas\Cadastro\DestObs->Observacoes])+ASP2+"\n"
Endif

Print File ARQIMP ASP1+ASP2+"\n\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 Responsavel "+ASP2+"\n\n"
Print File ARQIMP ASP1+CI_10CPP
Print File ARQIMP 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_0035")
IMPPED()
Imprime_FilePrint("Imprimindo Pedido -> "+PEDIDO,"1")

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

