;** Rm_0015 ********************************************************************
;* Relacao de Formulas                                                         *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 08/08/2008 por Anivel Augusto Rodrigues
;Ultima Alteracao: 14/12/2016 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes showdialog                   
;Ultima Alteracao: 20/05/2020 por Bruno Carvalho
;Motivo Alteracao: Alterado CopyReport "...\\Fundicao\\Formulac" p/ "...\\Fundicao\\RM_0030"

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

{Ask} {\\Sistemas\\Estoque\\Itens}
Moveto [Codigo do Item   ] Example "ITEM"
Moveto [Tipo do Item     ] TypeIn "~VSDGTPITEM.."
Moveto [Codigo da Familia] TypeIn "~VSDGFAMI.."
Moveto [Codigo do Grupo  ] TypeIn "~VSDGGRP.."
Moveto [Inativo          ] TypeIn "Not S"

{Ask} {FormulaC} Check
Moveto [Codigo do Produto] Example "ITEM" TypeIn ", ~VSDGITEM.."
Do_It!
ClearAll

If Not IsEmpty("Answer")
   Then CopyReport "\\Base\\Sistemas\\Fundicao\\RM_0030" "2" "Answer" "R"
EndIf

EndProc

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

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

VSDGTPITEM     = ""
VSDGFAMI    = ""
VSDGGRP     = ""
VSDGPRODUTO = ""

While True

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

    Label  @ 00,00 "Tipo do Item"  For "TG_TPITEM"
    Accept @ 01,04 Width 04 "A1"  Picture "!" Tag "TG_TPITEM"      To VSDGTPITEM
    Accept @ 01,09 Width 25 "A20" Picture "!*!" Tag "TG_NOMTPITEM" To VSDGNOMTPITEM

    Label  @ 02,00 "Familia"  For "TG_FAMI"
    Accept @ 03,02 Width 06 "A3"  Picture "#*#" Tag "TG_FAMI"      To VSDGFAMI
    Accept @ 03,09 Width 25 "A25" Picture "!*!" Tag "TG_NOMFAMI"   To VSDGNOMFAMI

    Label  @ 04,00 "Grupo"  For "TG_GRP"
    Accept @ 05,02 Width 06 "A3"  Picture "#*#" Tag "TG_GRP"       To VSDGGRP
    Accept @ 05,09 Width 25 "A25" Picture "!*!" Tag "TG_NOMGRP"    To VSDGNOMGRP

    Label  @ 06,00 "Item"  For "TG_ITEM"
    Accept @ 07,01 Width 33 "A10" Picture "#*#" Tag "TG_ITEM"     To VSDGITEM
    Accept @ 08,01 Width 33 "A35" Picture "!*!" Tag "TG_NOMITEM" To VSDGNOMITEM

    Pushbutton @ 10,22 width 11 "~O~k"      OK     Default Value "Ok"  Tag "YES" To BottonValue
    Pushbutton @ 10,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 o relat˘rio")

  SELECIONA()

  If IsEmpty("Answer")
     Then MENSAGEM("N„o existem registros a processar")
          Loop
  EndIf

  IMPRIREL("Answer","R")

  Delete "Answer"
EndWhile
ClearAll
Release Vars All
Release Procs All
