;** Rm_0070 ********************************************************************
;*  Emissao dos Pedidos por Representnate/Data de Entrega                      *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 08/04/97 por Anivel Augusto Rodrigues
;Ultima Alteracao: 16/04/2007 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes Ask

;*******************************************************************************
;* Rotina p/ Selecionar e Order Registros                                      *
;*******************************************************************************
Proc SELECIONA()
ClearAll
{Ask} {\\Sistemas\\Vendas\\PedidoC}
Moveto [Numero do Pedido       ] Example "Pedido"
Moveto [Codigo da Empresa      ] CheckPlus
Moveto [Nome Fantasia Empresa  ] CheckPlus
Moveto [Nome Fantasia EmitDest ] CheckPlus
Moveto [Codigo do Representante] TypeIn "~VSDGREPRESEN.."
Moveto [Data de Entrega        ] CheckPlus TypeIn ">=~VSDGDTINI, <=~VSDGDTFIM"
Moveto [Situacao do Pedido     ] TypeIn "ABERTO"

{Ask} {\\Sistemas\\Vendas\\PedidoI}
Moveto [Numero do Pedido       ] Example "Pedido"
Moveto [Codigo do Item         ] CheckPlus
Moveto [Descricao do Item      ] CheckPlus
Moveto [Codigo da Cor_Tecido   ] CheckPlus
Moveto [Descricao da Cor_Tecido] CheckPlus
Moveto [Tamanho                ] CheckPlus
Moveto [Quantidade             ] CheckPlus TypeIn ">" Example "qf"
Moveto [Quantidade Faturada    ] CheckPlus Example "qf"
Moveto [Unidade Fiscal         ] CheckPlus
Moveto [Preco Unitario         ] CheckPlus

Do_It!
ClearAll

If Not IsEmpty("Answer")
   Then CopyReport "\\Base\\Sistemas\\Producao\\Rm_0030" "3" "Answer" "R"
EndIf
ClearAll
EndProc

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc SD_Dialog(Disparo,Campo,Evento,Elemento)
Temp=True
MSG_CAMPO=""
TECLA=""
If Disparo="OPEN"  Then AoCriarShowDialog() EndIf
If Disparo="EVENT" And Evento["Type"]="KEY" Then
   Switch
     Case Evento["KeyCode"] =   9: Temp=False
     Case Evento["KeyCode"] = -59: Dialog_F1()
     Case Evento["KeyCode"] =  27:
          Temp=False
          Switch
            Case Campo="TG_REPRESEN"       : Campo="NO"
            Case Campo="TG_DTINI"          : Campo="TG_REPRESEN"
            Case Campo="TG_DTFIM"          : Campo="TG_DTINI"
            Case Campo="YES" Or Campo="NO" : Campo="TG_REPRESEN"
          EndSwitch
     Case (Evento["KeyCode"] <= -104 And Evento["KeyCode"] >= -113) Or 
           Evento["KeyCode"]  = -139 Or  Evento["KeyCode"]  = -140:
           SYS_TECLA_ACIONADA=Evento["KeyCode"]
           Seta_Tecla_Acionada()
           CancelDialog
     Case Evento["KeyCode"] = 13:
          Temp=False
          If Checa_TAG()
             Then Switch
                    Case Campo="TG_REPRESEN" : Campo="TG_DTINI"
                    Case Campo="TG_DTINI"    : Campo="TG_DTFIM"
                    Case Campo="TG_DTFIM"    : Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf

Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc
;*******************************************************************************
;* ROTINA PRINCIPAL                                                            *
;*******************************************************************************
AutoLib="\\Sistemas\\Cadastro\\Bib_Show,\\Sistemas\\Cadastro\\Bibliot"
LimpAguarde()

VSDGTPITEM = ""
VSDGDTINI  = BlankDate()
VSDGDTFIM  = BlankDate()
While True

  ShowDialog "Rela‡„o de Pedidos por Representante/Entrega" Proc "SD_Dialog"
  Trigger "OPEN","ARRIVE"
  Key "F1","ENTER","ESC","TAB",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140  
  @ 06,10   Height 09 Width 55

    Label  @ 00,00 "Representante"  For "TG_REPRESEN"
    Accept @ 01,01 Width 07 "A4" Picture "[&,#][#*#]" Tag "TG_REPRESEN" To VSDGREPRESEN
    Accept @ 01,09 Width 33 "A30" Picture "!*!" Tag "TG_NOMREPR" To VSDGNOMREPR

    Label  @ 02,00 "Per¡odo de Entrega" For "TG_DTINI"
    Label  @ 03,00 "de" For "TG_DTINI"
    Accept @ 03,04 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTINI" To VSDGDTINI
    Label  @ 03,17 "at‚" For "TG_DTFIM"
    Accept @ 03,22 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTFIM" To VSDGDTFIM

    Pushbutton @ 05,14 width 11 "~O~k"      OK     Default Value "Ok"  Tag "YES" To BottonValue
    Pushbutton @ 05,28 width 11 "~C~ancela" CANCEL                     Tag "NO"  To BottonValue

  EndDialog
  If Not RetVal Then QuitLoop EndIf
  If Not Usuario_Vendedor() Then Loop EndIf  

  DISPOSITIVO()
  If OK="" Then Loop EndIf

  AGUARDE("Aguarde, Gerando Relat¢rio")
  SELECIONA()

  If IsEmpty("Answer")
     Then MENSAGEM("N„o existem registros a processar!")
          Loop
  EndIf

  IMPRIREL("Answer","R")

  Delete "Answer"

EndWhile
ClearAll
Release Vars All
Release Procs All
