Versões comparadas

Chave

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

...

Bloco de código
titleExemplo 3
collapsetrue
#include "msobject.ch"
#include "totvs.framework.treports.integratedprovider.th"

namespace custom.materiais.produtos.integratedprovider

@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:appendArea("Faturamento")
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 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())
    self:oData:appendData({"Filial": (cAlias)->B1_FILIAL,; 
            "Codigo": (cAlias)->B1_COD,; 
            "Descricao": (cAlias)->B1_DESC,;
            "Tipo": (cAlias)->B1_TIPO, ;
            "Unidade": (cAlias)->B1_UM, ;
            "Revisao": FwTimeStamp(6, StoD((cAlias)->B1_UREV)) }) //O campo data deverá ser enviado no formato correto
    (cAlias)->(DBSkip())
enddo

(cAlias)->(DBCloseArea())

return self:oData

method getSchema() as object class SB1TReportsBusinessObject
self:oSchema:addProperty("Codigo", "Codigo", "string", "Código", "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") 
return self:oSchema

...