;** Rm_0367  *******************************************************************
;*  Emissao da Relacao de Notas p/ Banco                                       *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 05/12/1995 por Anivel Augusto Rodrigues
;Ultima Alteracao: 15/05/2007 por Humberto F.Santos
;Motivo Alteracao: Tirado a forma de pagamento DN da linha 19.
;Ultima Alteracao: 19/05/2020 por Bruno Carvalho
;Motivo Alteracao: Ajustes para o Base no CopyReport do "RM_0367" para "\\Base\\Sistemas\\Vendas\\RM_0367"

;*******************************************************************************
;* Rotina p/ Selecionar e Order Registros                                      *
;*******************************************************************************
Proc SELECIONA()
ClearAll
{Ask} {NotaC}
Moveto [Codigo da Empresa      ] Example "ce" TypeIn ", ~VSDGEMPRESA.."
Moveto [Numero do Documento    ] Example "nd"
Moveto [Serie do Documento     ] Example "sd"
Moveto [Data de Emissao        ] TypeIn ">=~VSDGDTINI,<=~VSDGDTFIM"
Moveto [Forma de Pagamento     ] TypeIn "CO or BO"
Moveto [Codigo da Destinacao   ] TypeIn "Not 053, Not 052"
Moveto [Descricao da Destinacao] TypeIn "..VEND.."
Moveto [Situacao               ] TypeIn "Not C"
Moveto [Tipo Movimento Estoque ] TypeIn "S"

{Ask} {NotaV} Check
Moveto [Codigo da Empresa      ] Example "ce"
Moveto [Numero do Documento    ] Example "nd"
Moveto [Serie do Documento     ] Example "sd"

Do_It!
ClearAll

If Not IsEmpty("Answer")
   Then CopyReport "\\Base\\Sistemas\\Vendas\\RM_0367" "R" "Answer" "R"
EndIf
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_EMPRESA"       : Campo="NO"
            Case Campo="TG_DTINI"         : Campo="TG_EMPRESA"
            Case Campo="TG_DTFIM"         : Campo="TG_DTINI"
            Case Campo="YES" Or Campo="NO": Campo="TG_EMPRESA"
          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_EMPRESA" :Campo="TG_DTINI"
                    Case Campo="TG_DTINI"   :Campo="TG_DTFIM"
                    Case Campo="TG_DTFIM"   :Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="TG_DTFIM":
     MSG_CAMPO="Informe a Data Final"
Endswitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

;*******************************************************************************
;* ROTINA PRINCIPAL                                                            *
;*******************************************************************************
AutoLib="\\Sistemas\\Cadastro\\Bib_Show,\\Sistemas\\Cadastro\\Bibliot"
LimpAguarde()

VSDGEMPRESA =""
VSDGDTINI   =BlankDate()
VSDGDTFIM   =BlankDate()

While True

  ShowDialog "Relacao de Notas p/ Banco" Proc "SD_Dialog"
  Trigger "OPEN","ARRIVE"
  Key "F1","ENTER","ESC","TAB",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140  
   @ 05,12   Height 09 Width 56

    Label  @ 00,00 "Empresa"  For "TG_EMPRESA"
    Accept @ 01,01 Width 07 "A4"  Picture "[&,#][#*#]" Tag "TG_EMPRESA"    To VSDGEMPRESA
    Accept @ 01,09 Width 23 "A20" Picture "!*!" Tag "TG_NOMEMPRESA" To VSDGNOMEMP

    Label  @ 02,00 "Per¡odo Referente" 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,15 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 Valida_ShowDialog("") Then Loop EndIf

  If IsBlank(VSDGDTFIM)
     Then Mensagem("Data Final Invalida !")
          Loop
  EndIf

  DISPOSITIVO()
  If OK="" Then Loop EndIf

  AGUARDE("Aguarde, Gerando o 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
