;** Rm_0030 ********************************************************************
;*  Resumo das Ordem de Compras por Item                                       *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 26/09/2001 por Douglas Rodrigues
;Ultima Alteracao: 13/05/2003 por Karen Lauar Nery
;Motivo Alteracao: Mudanca Base
;Ultima Alteracao: 19/09/2016 por Anivel Augusto Rodrigues
;Motivo Alteracao: Ajustes showdialog                   

;*******************************************************************************
;* Rotina p/ Selecionar e Order Registros                                      *
;*******************************************************************************
Proc Seleciona()
ClearAll
{Ask} {OcC}
Moveto [Numero da OC          ] Example "Oc"
Moveto [Codigo da Empresa     ] Check  TypeIn "~VSDGEMPRESA.."
Moveto [Nome Fantasia Empresa ] Check
Moveto [Nome Fantasia EmitDest] Check
Moveto [Data de Entrega       ] Check TypeIn ">=~VSDGDTINI, <=~VSDGDTFIM"
Moveto [Situacao da OC        ] TypeIn "ABERTO"

{Ask} {OcI}
Moveto [Numero da OC           ] Check Example "Oc"
Moveto [Codigo do Item         ] Check TypeIn "~VSDGITEM.."
Moveto [Descricao do Item      ] Check
Moveto [Codigo da Cor_Tecido   ] Check
Moveto [Descricao da Cor_Tecido] Check
Moveto [Tamanho                ] Check
Moveto [Quantidade             ] Check TypeIn ">" Example "qf"
Moveto [Quantidade Entregue    ] Check Example "qf"
Moveto [Unidade Fiscal         ] Check
Moveto [Preco Unitario         ] Check
Do_It!
ClearAll
EndProc  ; (Seleciona)

;*******************************************************************************
;* 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_EMPRESA"        : Campo="NO"
            Case Campo="TG_ITEM"           : Campo="TG_EMPRESA"
            Case Campo="TG_DTINI"          : Campo="TG_ITEM"
            Case Campo="TG_DTFIM"          : Campo="TG_DTINI"
            Case Campo="YES" Or Campo="NO" : Campo="TG_EMPRESA"
          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_EMPRESA" : Campo="TG_ITEM"
                    Case Campo="TG_ITEM"    : Campo="TG_DTINI"
                    Case Campo="TG_DTINI"   : Campo="TG_DTFIM"
                    Case Campo="TG_DTFIM"   : 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()

VSDGEMPRESA     = ""
VSDGDTINI  = BlankDate()
VSDGDTFIM  = BlankDate()
While True

  ShowDialog "Resumo de OC por Item" 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 12 Width 72

    Label  @ 00,00 "Empresa"  For "TG_EMPRESA"
    Accept @ 01,01 Width 07 "A4"  Picture "[&,#][#*#]" Tag "TG_EMPRESA"    To VSDGEMPRESA
    Accept @ 01,09 Width 25 "A20" Picture "!*!" Tag "TG_NOMEMPRESA" To VSDGNOMEMP

    Label  @ 02,00 "Item"  For "TG_ITEM"
    Accept @ 03,01 Width 33 "A10" Picture "#*#" Tag "TG_ITEM"     To VSDGITEM
    Accept @ 04,01 Width 33 "A35" Picture "!*!" Tag "TG_NOMITEM" To VSDGNOMITEM

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

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

  EndDialog
  If Not RetVal Then QuitLoop EndIf
  If Not Valida_ShowDialog("") Then Loop EndIf

  DISPOSITIVO()
  If OK="" Then Loop EndIf

  AGUARDE("Aguarde, Gerando Relat¢rio")
  SELECIONA()

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

  CopyReport "\\Base\\Sistemas\\Compras\\Rm_0010" "2" "Answer" "R"

  IMPRIREL("Answer","R")

  Delete "Answer"

EndWhile
ClearAll
Release Vars All
Release Procs All
