;** Rm_0256 ********************************************************************
;* Resumo das Entradas por Estado                                              *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 27/05/2008 por Anivel Augusto Rodrigues
;Ultima Alteracao: 19/09/2016 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes showdialog                   
;Ultima Alteracao: 23/01/2020 por Anivel Augusto Rodrigues
;Motivo Alteracao: Inclusao novo processo concetrador RM_0256, RM_0760A             

;*******************************************************************************
;* 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_EMPRESATE"     : Campo="NO"
            Case Campo="TG_DTINI"         : Campo="TG_EMPRESATE"
            Case Campo="TG_DTFIM"         : Campo="TG_DTINI"
            Case Campo="TG_CODMODELO"     : Campo="TG_DTFIM"
            Case Campo="YES" Or Campo="NO": Campo="TG_EMPRESATE"
          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_EMPRESATE" : Campo="TG_DTINI"
                    Case Campo="TG_DTINI"     : Campo="TG_DTFIM"
                    Case Campo="TG_DTFIM"     : Campo="TG_CODMODELO"
                    Case Campo="TG_CODMODELO" : Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf

Switch
  Case Campo="": MSG_CAMPO=""
Endswitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

;************************************
;* ROTINA PARA Ler/Gravacao Opcao   *
;************************************
Proc ModeloRelatoriosCarregaLista()

TG_CODMODELO_COMCASASDECIMAIS=false

VSDGCODMODELO     = ""
VSDGMODELO        = ""

;ModeloRelatoriosAdd("XXX XX maximo 70 XX")

ModeloRelatoriosAdd("Criar") ; linha obrigatoria inicial
ModeloRelatoriosAdd("53 - Por Estado")
ModeloRelatoriosAdd("58 - Por Composi‡Æo de Dias")
;ModeloRelatoriosAdd("Separator")

ModeloRelatoriosAdd("Fim")
                           
EndProc ;ModeloRelatoriosCarregaLista

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

sys_Valor()

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

ModeloRelatoriosCarregaLista()

While True

  ShowDialog "Resumo das Entradas" 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 12 Width 72

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

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

    Label  @ 05,00  "Modelo de ~R~elat¢rio"  For "TG_CODMODELO"
    Accept @ 06,01  Width 06 "A3"  Picture "!*!" Tag "TG_CODMODELO" To VSDGCODMODELO
    Accept @ 06,06  Width 63 "A60"  Picture "!*!" Tag "TG_MODELO" To VSDGMODELO        

    Pushbutton @ 08,22 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 08,36 width 11 "~C~ancela" CANCEL                    Tag "NO"  To BottonValue

  EndDialog
  If Not RetVal Then QuitLoop EndIf
  If Not Valida_ShowDialog("") Then Loop EndIf
  if not ValidarModelosRelatorios() then loop endif         

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

  If VSDGEMPRESA="0000"
     Then VSDGEMPRESA2=""
     Else VSDGEMPRESA2=VSDGEMPRESA
  EndIf

  DISPOSITIVO()
  If OK="" Then Loop EndIf

  AGUARDE("Aguarde, Gerando o Relat¢rio")
  switch
    case VSDGCODMODELO="53"  : Play "RM_0256A"
    case VSDGCODMODELO="58"  : Play "RM_0256B"
  endswitch

EndWhile
ClearAll
Release Vars All
Release Procs All
