Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

Bloco de código
titleExemplo 1 - LookUp Key-Label
collapsetrue
#include "msobject.ch"
#include "protheus.ch"
#include "totvs.framework.treports.integratedprovider.th"
 
namespace custom.materiais
 
@totvsFrameworkTReportsIntegratedProvider(active=.T.)
class SB1TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider
    public method new() as object
    public method getDisplayName() as character
    public method getDescription() as character
    public method getData() as object
    public method getSchema() as object
endclass
 
method new() class SB1TReportsBusinessObject
_Super:new()
self:appendArea("Materiais")
self:setIsCBoxLookup(.T., .T.)
return self
 
method getDisplayName() as character class SB1TReportsBusinessObject
return "Produtos"
 
method getDescription() as character class SB1TReportsBusinessObject
return "Produtos do Protheus"
 
method getData(nPage as numeric, oFilter as object) as object class SB1TReportsBusinessObject
local cQuery as character
local cAlias as character
 
cQuery := "SELECT B1_COD, B1_DESC, B1_TIPO, B1_UM, B1_UREV, B1_FILIAL FROM " + RetSQLName("SB1") + " WHERE D_E_L_E_T_ = ' '"
 
//Os filtros serão setados na interface do novo TReports
if oFilter:hasFilter()
    cQuery += " AND " + oFilter:getSQLExpression()
endif
 
cAlias := MPSysOpenQuery(cQuery)
 
while !(cAlias)->(Eof())
    cDate := FwTimeStamp(6, StoD((cAlias)->B1_UREV))
    self:oData:appendData({"Filial": (cAlias)->B1_FILIAL,; 
            "Codigo": (cAlias)->B1_COD,; 
            "Descricao": (cAlias)->B1_DESC,;
            "Tipo": (cAlias)->B1_TIPO, ;
            "Unidade": (cAlias)->B1_UM, ;
            "Revisao": cDate ,;
            "Data": StoD((cAlias)->B1_UREV)})
    (cAlias)->(DBSkip())
enddo
 
(cAlias)->(DBCloseArea()) 
 
return self:oData
 
method getSchema() as object class SB1TReportsBusinessObject
local cComboFil as character

cComboFil := "D MG 01=Filial BH; D MG 02=Filial Uberaba"

self:oSchema:addProperty("Filial", "Filial", "string", "Filial", "B1_FILIAL", cComboFil,.F.)
self:oSchema:addProperty("Codigo", "Codigo", "string", "Codigo", "B1_COD")
self:oSchema:addProperty("Descricao", "Descricao", "string", "Descricao","B1_DESC")
self:oSchema:addProperty("Tipo", "Tipo", "string", "Tipo","B1_TIPO")
self:oSchema:addProperty("Unidade", "Unidade de medida", "string", "Unidade","B1_UM") 
self:oSchema:addProperty("Revisao", "Revisao", "date", "revisao","B1_UREV") 
self:oSchema:addProperty("Data", "Data", "date", "Data","B1_UREV")
self:oSchema:addProperty("Preço", "Preço", "number", "Preço","B1_PRV1")
return self:oSchema

Exemplo de exibição na interface do TReports:

...