;** Rm_0002  *******************************************************************
;*  Rela‡Æo de Cheques liquidados                                              *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 24/01/2020 por Anivel Augusto Rodrigues
;Motivo Alteracao: Inclusao novo processo concetrador RM_0090, RM_0070, RM_0080            

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc SD_Dialog(Disparo,Campo,Evento,Elemento)
private Disparo,Campo,Evento,Elemento, Temp

Temp=True
MSG_CAMPO=""
TECLA=""
If Disparo="OPEN"  
   Then AoCriarShowDialog()
        TiraSombraShowDialog()
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"] = -60: If Campo="TG_EMPRESATE"
;                                     Then ListaRegra_F2() 
;                                  EndIf
     Case Evento["KeyCode"] =  27:
          Temp=False
          Switch
            Case Campo="TG_EMPRESATE"     : Campo="NO"
            Case Campo="TG_NCHT"          : Campo="TG_EMPRESATE"
            Case Campo="TG_NCARREG"       : Campo="TG_NCHT"
            Case Campo="TG_CONTA"         : Campo="TG_NCARREG"
            Case Campo="TG_REPRESEN"      : Campo="TG_CONTA"
            Case Campo="TG_DESTINAT"      : Campo="TG_REPRESEN"
            Case Campo="TG_OPDTCHVLI"     : Campo="TG_DESTINAT"
            Case Campo="TG_DTINI"         : Campo="TG_OPDTCHVLI"
            Case Campo="TG_DTFIM"         : Campo="TG_DTINI"

            Case Campo="TG_CPFCGCTIT"     : Campo="TG_DTFIM"
            Case Campo="TG_NOMETIT"       : Campo="TG_CPFCGCTIT"
            Case Campo="TG_NUMCHEQ"       : Campo="TG_NOMETIT"
            Case Campo="TG_VALOR"         : Campo="TG_NUMCHEQ"

            Case Campo="TG_CODMODELO"     : Campo="TG_VALOR"
            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_NCHT"   
                    Case Campo="TG_NCHT"       : Campo="TG_NCARREG"
                    Case Campo="TG_NCARREG"    : Campo="TG_CONTA"
                    Case Campo="TG_CONTA"      : Campo="TG_REPRESEN"
                    Case Campo="TG_REPRESEN"   : Campo="TG_DESTINAT"
                    Case Campo="TG_DESTINAT"   : Campo="TG_OPDTCHVLI"
                    Case Campo="TG_OPDTCHVLI"  : Campo="TG_DTINI"
                    Case Campo="TG_DTINI"      : Campo="TG_DTFIM"
                    Case Campo="TG_DTFIM"      : Campo="TG_CPFCGCTIT"
                    
                    Case Campo="TG_CPFCGCTIT"  : Campo="TG_NOMETIT"
                    Case Campo="TG_NOMETIT"    : Campo="TG_NUMCHEQ"
                    Case Campo="TG_NUMCHEQ"    : Campo="TG_VALOR"
                    Case Campo="TG_VALOR"      : Campo="TG_CODMODELO"
                      VSDGVALOR=controlvalue("TG_VALOR")
                    
                    Case Campo="TG_CODMODELO"  : Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="":
     MSG_CAMPO=""
  Case Campo="TG_VALOR":
       MSG_CAMPO="Informe se necessario o valor do cheque para filtrar !"
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("10  Por Data Vencimento")
ModeloRelatoriosAdd("08  Por Cliente/Data InclusÆo")
ModeloRelatoriosAdd("09  Por Representante/Data Vencimento")
;ModeloRelatoriosAdd("Separator")
ModeloRelatoriosAdd("Fim")
                           
EndProc ;ModeloRelatoriosCarregaLista


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

VSDGEMPRESA   =""
VSDGNCHT      =BlankNum()
VSDGNCARREG   =""
VSDGCONTA     =""
VSDGREPRESEN  =""
VSDGDESTINAT  =""
VSDGOPDTCHVLI ="1"
VSDGDTINI     = BlankDate()
VSDGDTFIM     = BlankDate()

VSDGCPFCGCTIT =""
VSDGNOMETIT   =""
VSDGNUMCHEQ   =""
VSDGVALOR     =BlankNum()

ModeloRelatoriosCarregaLista()

While True
  ShowDialog "Cheques Liquidados" Proc "SD_Dialog"
  Trigger "OPEN","ARRIVE"
  Key "F1","ENTER","ESC","TAB",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140,-60  
    @ 01,00 Height 22 Width 80

    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 "Lan‡amento" For "TG_NCHT"
    Accept @ 03,01 Width 13 "N"  Picture "#[#####]" Tag "TG_NCHT" To VSDGNCHT
    Accept @ 03,09 Width 25 "A22" Picture "!*!" Tag "TG_NOMNCHT"  To VSDGNOMNCHT

    Label  @ 04,00 "Carregamento" For "TG_NCARREG"
    Accept @ 05,01 Width 9  "A6"  Picture "[&,#][#*#]" Tag "TG_NCARREG"    To VSDGNCARREG
    Accept @ 05,09 Width 25 "A20" Picture "!*!" Tag "TG_NOMNCARREG" To VSDGNOMNCARREG

    Label  @ 06,00 "Conta"  For "TG_CONTA"
    Accept @ 07,01 Width 07 "A4"  Picture "#*#" Tag "TG_CONTA"    To VSDGCONTA
    Accept @ 07,09 Width 25 "A20" Picture "!*!" Tag "TG_NOMCONTA" To VSDGNOMCONTA

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

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

    Label  @ 12,00 "Op‡äes de Datas" For "TG_OPDTCHVLI"
    Accept @ 13,04 Width 04 "A1"  Picture "1,2,3,4" Tag "TG_OPDTCHVLI" To VSDGOPDTCHVLI
    Accept @ 13,09 Width 25 "A22" Picture "!*!" Tag "TG_NOMOPDTCHVLI"  To VSDGNOMOPDTCHVLI

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

    Label  @ 00,35 "CPF/CNPJ do Titular" for "TG_CPFCGCTIT"
    Accept @ 01,36  Width 33 "A18" picture "##[.]###.###/####-##,###.###.###-##" Tag "TG_CPFCGCTIT" to VSDGCPFCGCTIT

    Label  @ 02,35 "Nome do Titular" for "TG_NOMETIT"
    Accept @ 03,36  Width 33 "A40" picture "!*!" Tag "TG_NOMETIT" to VSDGNOMETIT

    Label  @ 04,35 "Numero do Cheque"  For "TG_NUMCHEQ"
    Accept @ 05,36 Width 33 "A15"  Picture "!*!" Tag "TG_NUMCHEQ" To VSDGNUMCHEQ

    Label  @ 06,35 "Valor do Cheque"  For "TG_VALOR"
    Accept @ 07,36 Width 33 "$"                   Tag "TG_VALOR"    To VSDGVALOR

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

    Pushbutton @ 18,54 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 18,66 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 VSDGEMPRESA="0000"
     Then VSDGEMPRESA2=""
     Else VSDGEMPRESA2=VSDGEMPRESA
  EndIf

  DISPOSITIVO()
  If OK="" Then Loop EndIf

  switch
    case VSDGCODMODELO="10" : Play "RM_0002A" 
    case VSDGCODMODELO="08" : Play "RM_0002A" 
    case VSDGCODMODELO="09" : Play "RM_0002A" 

  endswitch

EndWhile
ClearAll
Release Vars All
Release Procs All
