;** Rm_0110  *******************************************************************
;*  Relacao de Cheques Emitidos/NÆo Apresentados/Pre-Datados                   *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 26/04/2018 por Anivel Augusto Rodrigues
;Ultima Alteracao: 26/04/2018 por Anivel Augusto Rodrigues
;Motivo Alteracao: Inclusao novo processo concetrador            

;*******************************************************************************
;* 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_CONTA"         : Campo="TG_EMPRESATE"
            Case Campo="TG_DESTINAT"      : Campo="TG_CONTA"
            Case Campo="TG_CHEQUE"        : Campo="TG_DESTINAT"
            Case Campo="TG_SERIE"         : Campo="TG_CHEQUE"
            Case Campo="TG_CODMODELO"     : Campo="TG_SERIE"
            Case Campo="TG_OPDTEMISCOMP"  : Campo="TG_CODMODELO"
            Case Campo="TG_DTINI"         : Campo="TG_CODMODELO"
            Case Campo="TG_DTFIM"         : Campo="TG_DTINI"
            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_CONTA"
                    Case Campo="TG_CONTA" :
                         If Not IsBlank(VSDGCONTA)
                            Then If VSDGTPCONTA<>"C"
                                    Then Mensagem("Conta Invalida !")
                                         VSDGNOMCONTA=""
                                    Else Campo="TG_DESTINAT"
                                 EndIf
                            Else VSDGTPCONTA =""
                                 VSDGNOMCONTA=""
                                 Campo="TG_DESTINAT"

                         EndIf
                    Case Campo="TG_DESTINAT"     : Campo="TG_CHEQUE"

                    Case Campo="TG_CHEQUE"       : Campo="TG_SERIE"
                         VSDGCHEQUE = ControlValue("TG_CHEQUE")
                    Case Campo="TG_SERIE"        : Campo="TG_CODMODELO"
                         VSDGSERIE = ControlValue("TG_SERIE")
                         
                    Case Campo="TG_CODMODELO"    : 
                      switch
                        case VSDGCODMODELO="28"  : VSDGOPDTEMISCOMP   =""
                                                   VSDGNOMOPDTEMISCOMP="DATA DESCONTADO"
                                                   Campo="TG_DTINI"
                                                   
                        case VSDGCODMODELO="05"  Or
                             VSDGCODMODELO="06"  Or
                             VSDGCODMODELO="26"  : VSDGOPDTEMISCOMP   =""
                                                   VSDGNOMOPDTEMISCOMP="DATA PRE-DATADO"
                                                   Campo="TG_DTINI"
                                                   
                        otherwise                : Campo="TG_OPDTEMISCOMP"                          

                      endswitch
                    
                    Case Campo="TG_OPDTEMISCOMP" : 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_CONTA":
       MSG_CAMPO="Informe somente Conta 'C'orrente"
  OtherWise:
       MSG_CAMPO=""
Endswitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

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

VSDGCODMODELO     = ""
VSDGMODELO        = ""

;ModeloRelatoriosAdd("XXX XX maximo 70 XX")

ModeloRelatoriosAdd("Criar") ; linha obrigatoria inicial
ModeloRelatoriosAdd("03  Emitidos")
ModeloRelatoriosAdd("04  NÆo apresentados")
ModeloRelatoriosAdd("28  Descontados")
ModeloRelatoriosAdd("Separator")
ModeloRelatoriosAdd("05  Pre-Datado nÆo apresentados por pessoa")
ModeloRelatoriosAdd("06  Pre-Datado nÆo apresentados por vencimento")
ModeloRelatoriosAdd("26  Pre-Datado nÆo apresentados por vencimento/conta")
ModeloRelatoriosAdd("Fim")
                           
EndProc ;ModeloRelatoriosCarregaLista

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

VSDGEMPRESA =""
VSDGCONTA   =""
VSDGDESTINAT=""
VSDGCHEQUE   =""
VSDGSERIE   =""
VSDGNOMCONTA=""
VSDGTPCONTA =""
VSDGDTINI   =BlankDate()
VSDGDTFIM   =BlankDate()
VSDGOPDTEMISCOMP   =""
VSDGNOMOPDTEMISCOMP=""

ModeloRelatoriosCarregaLista()

While True
  ShowDialog "Rela‡Æo de cheques emitidos/nÆo apresentados/pre-datados" 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 16 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_NOMEMP" To VSDGNOMEMP
    
    Label  @ 02,00 "Conta"  For "TG_CONTA"
    Accept @ 03,01 Width 07 "A4"  Picture "#*#" Tag "TG_CONTA"    To VSDGCONTA
    Accept @ 03,09 Width 25 "A20" Picture "!*!" Tag "TG_NOMCONTA" To VSDGNOMCONTA

    Label  @ 04,00 "Pessoa"  For "TG_DESTINAT"
    Accept @ 05,01 Width 07 "A4"  Picture "[&,#][#*#]" Tag "TG_DESTINAT" To VSDGDESTINAT
    Accept @ 05,09 Width 25 "A20" Picture "!*!" Tag "TG_NOMDEST"  To VSDGNOMDEST

    Label  @ 06,08 "N§ Cheque     Serie"  For "TG_CHEQUE"
    Accept @ 07,09 Width 12 "A15" Picture "#*#" Tag "TG_CHEQUE"   To VSDGCHEQUE
    Accept @ 07,22 Width 12 "A10" Picture "!*!" Tag "TG_SERIE"    To VSDGSERIE
    
    Label  @ 00,35 "Op‡äes de Datas" For "TG_OPDTEMISCOMP"
    Accept @ 01,39 Width 04 "A1"  Picture "1,2" Tag "TG_OPDTEMISCOMP" To VSDGOPDTEMISCOMP
    Accept @ 01,44 Width 25 "A20"  Picture "!*!" Tag "TG_NOMOPDTEMISCOMP" To VSDGNOMOPDTEMISCOMP

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

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

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

  EndDialog
  If Not RetVal Then QuitLoop EndIf

  If IsBlank(VSDGDTFIM)
     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 Relatorio")
  switch
    case VSDGCODMODELO="03" : Play "RM_0110A"
    case VSDGCODMODELO="28" : Play "RM_0110C"
    case VSDGCODMODELO="04" : Play "RM_0110B"
    case VSDGCODMODELO="05" : Play "RM_0110D"
    case VSDGCODMODELO="06" : Play "RM_0110E"
    case VSDGCODMODELO="26" : Play "RM_0110F"
  endswitch

EndWhile
ClearAll
Release Vars All
Release Procs All
