;** RelCCust *******************************************************************
;*  Relacao de Centro de Custo                                                 *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 05/12/95 por Anivel Augusto Rodrigues
;Ultima Alteracao: 09/09/2016 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes showdialog
;Ultima Alteracao: 23/12/2016 por Rafael Matos
;Motivo Alteracao: Ajustes showdialog                    
;Ultima Alteracao: 20/05/2020 por Bruno Carvalho
;Motivo Alteracao: Alterado CopyReport "...\\Ctacor\\CCusto" p/ "...\\CtaCor\\RM_0032"

;*******************************************************************************
;* Rotina p/ Selecionar e Ordernar Registros                                   *
;*******************************************************************************
Proc Seleciona()

{Ask} {CCusto} Check
Do_It!
ClearAll
EndProc   ; (Seleciona)

;*******************************************************************************
;* 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="YES" : Campo="NO"
            Case Campo="NO" : Campo="YES"
          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
          Checa_TAG()
          RefreshDialog
   EndSwitch
EndIf
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************
AutoLib="\\Sistemas\\Cadastro\\Bib_Show,\\Sistemas\\Cadastro\\Bibliot"
LimpAguarde()

While True

  ShowDialog "Rela‡„o de Centro de Custo" Proc "SD_Dialog"
  Trigger "OPEN","ARRIVE"
  Key "F1","ENTER","ESC","TAB",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140  
   @ 06,12   Height 05 Width 72

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

  EndDialog
  If Not RetVal Then QuitLoop 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

  CopyReport "\\Base\\Sistemas\\Ctacor\\RM_0032" "R" "Answer" "R"

  IMPRIREL("Answer","R")

  Delete "Answer"

EndWhile
ClearAll
Release Vars All
Release Procs All

