;** Rc_0026 *******************************************************************
;*  Relatorio com Clientes sem autorizados                                     *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 23/04/2003 por Anivel Augusto Rodrigues
;Ultima Alteracao: 02/04/2004 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes
;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             

;*******************************************************************************
;* Rotina p/ Selecionar e Order Registros                                      *
;*******************************************************************************
Proc ORDEM()
ClearAll

{Ask} {Destinat} Check
Moveto [Tipo] TypeIn "C"
Moveto [Inativo]
Switch
  Case VSDGSTATUS="1": TypeIn "N"
  Case VSDGSTATUS="2": TypeIn "S"
EndSwitch
Do_It!
ClearAll

{Ask} {Destaut}
Moveto [Codigo] Example "cod"
{Ask} {Answer} TypeIn "Fast Delete"
Moveto [Codigo] Example "cod"
Do_It!
ClearAll

If VSDGOPRELCODALF = "2"
   Then {Modify} {Sort} {Answer} {Same} Down Down Down "1" Do_It!
        DORDEM="Alfabetica"
   Else {Modify} {Sort} {Answer} {Same} "1" Do_It!
        DORDEM="de Codigo"
EndIf

EndProc  ; (Seleciona)

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc SD_Dialog1(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_OPRELCODALF"    : Campo="NO"
            Case Campo="TG_STATUS"         : Campo="TG_OPRELCODALF"
            Case Campo="YES" Or Campo="NO" : Campo="TG_OPRELCODALF"
          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_OPRELCODALF" : Campo="TG_STATUS"
                    Case Campo="TG_STATUS"      : Campo="YES"
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
  Case Campo="":
     MSG_CAMPO=""
Endswitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp
EndProc

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

VSDGOPRELCODALF =""
VSDGSTATUS      =""

While True

  ShowDialog "RelatĒrio de Clientes sem Autorizados" Proc "SD_Dialog1"
  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 72

    Label  @ 00,00 "Ordem" For "TG_OPRELCODALF"
    Accept @ 01,04 Width 04 "A1"  Picture "1,2" Tag "TG_OPRELCODALF" To VSDGOPRELCODALF
    Accept @ 01,09 Width 25 "A12" Picture "!*!" Tag "TG_NOMOPRELCODALF" To VSDGNOMOPRELCODALF

    Label  @ 02,00 "Status do Cliente" For "TG_STATUS"
    Accept @ 03,04 Width 04 "A1"  Picture "1,2,3" Tag "TG_STATUS" To VSDGSTATUS
    Accept @ 03,09 Width 25 "A12" Picture "!*!" Tag "TG_NOMSTATUS" To VSDGNOMSTATUS

    Pushbutton @ 05,22 width 11 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 05,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")
  ORDEM()
  If IsEmpty("Answer")
     Then MENSAGEM("No Existem Registros a Processar")
          Loop
  EndIf

  CopyReport "\\Base\\Sistemas\\Cadastro\\RC_0040"  "3"  "Answer" "R"

  IMPRIREL("Answer","R")

  Delete "Answer"

EndWhile
ClearAll
Release Vars All
Release Procs All

