;** Rm_0120 ********************************************************************
;*  Rela‡ao de Cheques Nao Apresentados                                        *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 16/10/1996 por Anivel Augusto Rodrigues
;Ultima Alteracao: 20/07/2006 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes

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

{Ask} {MovCont} Check
Moveto [Codigo da Conta       ] TypeIn "~VSDGCONTA"
Moveto [Tipo da Conta         ] TypeIn "X"
Moveto [Data                  ] TypeIn "~VSDGDTREF"
Do_It!
ClearAll

EndProc   ; (Seleciona)


;*******************************************************************************
;* Rotina p/ Montar Opcoes p/ Grade                                            *
;*******************************************************************************
Proc Monta_Opcoes_FC(OPCAODIVERSAS, ITEMDESEJADO)
Private OPCAODIVERSAS, ITEMDESEJADO, wcg, icg, icgt, tnovo, nomecampo,opconta

View "Conta"
If IsAssigned(Opcoes)
   Then Release Vars Opcoes
EndIf
DynArray Opcoes[]
wcg=0

While Not EOT()
  If [Codigo da Empresa]=SYS_EMPRESA_DEFAULT And
     [Tipo da Conta             ]="X" And
     Search("FRENTE LOJA",[Descricao da Conta])>0
     Then wcg=wcg+1
          Opcoes[wcg]=Completa([Descricao da Conta],31," ")+[Codigo da Conta]
  EndIf
  Skip
EndWhile
ClearImage
EndProc    ; (Monta_Opcoes)

;*******************************************************************************
;* Rotina p/ Checagem Opcoes p/ Grade                                          *
;*******************************************************************************
Proc Checa_Opcoes_FC(OPCAODIVERSAS, VALORDESEJADO)
Private OPCAODIVERSAS, VALORDESEJADO, icg, resultado

If DynArraySize(Opcoes)=0
   Then Return False
EndIf

resultado=false
For icg From 1 To DynArraySize(Opcoes)
  Switch
    Case OPCAODIVERSAS="Codigo da Conta":
         If RTrim(SubStr(Opcoes[icg],32,4))=VALORDESEJADO
            Then resultado=true
         EndIf
  EndSwitch
  If resultado
     then MontaRegistro_F1_FC(OPCAODIVERSAS,icg)
          QuitLoop
  EndIf
EndFor
return resultado
EndProc         ;  (Checa_Opcoes)

;*******************************************************************************
;* Rotina Montar Registro_F1 p/ Grade                                          *
;*******************************************************************************
Proc MontaRegistro_F1_FC(OPCAODIVERSAS, indice)
private OPCAODIVERSAS, indice

If IsAssigned(Registro_F1)
   Then Release Vars Registro_F1
EndIf
DynArray Registro_F1[]
Switch
  Case OPCAODIVERSAS="Codigo da Conta"       :
       Registro_F1["Codigo da Conta"]         =RTrim(SubStr(Opcoes[indice],32,4))
       Registro_F1["Descricao da Conta"]      =RTrim(SubStr(Opcoes[indice],1,30))
       If IsAssigned(VSDGCONTA)
          Then VSDGCONTA          =Registro_F1["Codigo da Conta"]
               VSDGNOMCONTA       =Registro_F1["Descricao da Conta"]
       EndIf
EndSwitch
EndProc    ;  (Monta_RegistroF1)

;*******************************************************************************
;* Rotina de Selecionar Grade                                                  *
;*******************************************************************************
Proc Seleciona_Opcoes_FC(OPCAODIVERSAS,SEMRETORNO)
Private OPCAODIVERSAS, LJ, AJ, nc, SEMRETORNO

If DynArraySize(Opcoes)=0
   Then Mensagem("Tabela sem Registros !")
        Return False
EndIf

AJ=DynArraySize(Opcoes)
If AJ>15
   Then AJ=15
   Else If AJ<3 Then AJ=3 EndIf
EndIf

Switch
  Case OPCAODIVERSAS="Codigo da Conta"   : LJ=37 nc=1
EndSwitch

ArrayElement=0
Showdialog "Consulta "+OPCAODIVERSAS Proc "Opcoes_Dialog_FC"
   Trigger "OPEN","ARRIVE"
    Key "TAB","ReverseTab","ENTER","ESC"
     @ 02,01 height AJ+2 width LJ+5

   PickDynArray @0,01 Height AJ width LJ
   Columns nc
   Opcoes
   Tag "TG_OPCAO"
   To ArrayElement
EndDialog
If RetVal
   Then Return True
   Else Return False
EndIf
EndProc   ; (Seleciona_Opcoes)

;*******************************************************************************
;* Rotina de Controle p/ ShowDialog Grade                                      *
;*******************************************************************************
Proc Opcoes_Dialog_FC(Disparo,Campo,Evento,Elemento)
Temp=True
TECLA=" Esc=Retornar  Enter=Selecionar  =Mover  "
If Disparo="EVENT" And DynArraySize(Evento)>0 And Evento["Type"]="KEY" Then
   Switch
      Case Evento["KeyCode"] = 9 Or Evento["KeyCode"] = -15: Temp=False
      Case Evento["KeyCode"] = 27:
           Resultado_F1=False
           CancelDialog
      Case Evento["KeyCode"] = 13:
           Temp=False
           MontaRegistro_F1_FC(OPCAODIVERSAS,ArrayElement)
           Resultado_F1=True
           AcceptDialog
   EndSwitch
EndIf

@ 24,0 ?? TECLA+Spaces(80-Len(TECLA))
PaintCanvas Attribute 31 24,0,24,79
Return Temp
EndProc      ; (Opcoes_Dialog)

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc SD_Dialog_FC(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:
          If Campo="TG_CONTA"
             Then Seleciona_Opcoes_FC("Codigo da Conta","")
             Else Dialog_F1()
          EndIf
     Case Evento["KeyCode"] =  27:
          Temp=False
          Switch
            Case Campo="TG_CONTA"         : Campo="NO"
            Case Campo="TG_DTREF"         : Campo="TG_CONTA"
            Case Campo="YES" Or Campo="NO": Campo="TG_CONTA"
          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_CONTA" :
                         RefreshDialog
                         If Not Checa_Opcoes_FC("Codigo da Conta", VSDGCONTA)
                            Then Mensagem("Tipo de Conta Inv lida !")
                            Else Campo="TG_DTREF"
                         EndIf
                    Case Campo="TG_DTREF" : Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="TG_CONTA":
       MSG_CAMPO="Informe somente Conta Cai'X'a"
  Case Campo="":
     MSG_CAMPO=""
Endswitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

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

If Not IsAssigned(SYS_EMPRESA_DEFAULT) Then SYS_EMPRESA_DEFAULT="0001" EndIf

VSDGCONTA  =""
VSDGDTREF  =Today()

While True
  Echo Normal
  Echo Off

  Monta_Opcoes_FC("Codigo da Conta", "")

  ShowDialog "Lan‡amentos Frente de Caixa" Proc "SD_Dialog_FC"
  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 "Conta"  For "TG_CONTA"
    Accept @ 01,01 Width 07 "A4"  Picture "#*#" Tag "TG_CONTA"    To VSDGCONTA
    Accept @ 01,09 Width 23 "A20" Picture "!*!" Tag "TG_NOMCONTA" To VSDGNOMCONTA

    Label  @ 02,00 "Data Referente" For "TG_DTREF"
    Accept @ 03,01 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTREF" To VSDGDTREF

    Pushbutton @ 05,14 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 VSDGDTREF=BlankDate()
     Then Mensagem("Data Invalida !")
          Loop
  EndIf

  AGUARDE("Aguarde, Filtrando Dados")
  Seleciona()
 ;If IsEmpty("Answer")
 ;   Then MENSAGEM("N„o existem registros a processar")
 ;        Loop
 ;EndIf

  CopyForm "MovCont" "F" "Answer" "F"
  CopyForm "MovCont" "4" "Answer" "4"
  Play "AAA1001"

EndWhile
ClearAll
Release Vars All
Release Procs All
