Histórico da Página
...
Informações | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Objeto oData Serão feitos tratamentos internos neste objeto. Ele possui apenas dois métodos para uso externo, usado em conjunto com os métodos da nova classe, sendo eles: Método AliasToData() - Método do objeto oData que converte o alias recebido em dados para o Smart View.
Método AppendData() - Método do objeto oData que adiciona um json para o array de dados. Parâmetros:
Exemplos de uso estarão abaixo nos métodos criados para a classe IntegratedProvider.
|
...
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "msobject.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.materiais.produtos.integratedprovider @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGACOM", tables="SB1", name="Materiais", country="ALL", initialRelease="12.1.2210") 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") 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_FILIAL, B1_COD, B1_DESC, B1_TIPO, B1_UM, B1_UREV 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:appendData({"Filial": (cAlias)->B1_FILIAL,; "Codigo": (cAlias)->B1_COD,; "Descricao": (cAlias)->B1_DESC,; "Tipo": (cAlias)->B1_TIPO, ; "Unidade": (cAlias)->B1_UM, ; "Revisao": FwTimeStamp(65, StoD((cAlias)->B1_UREV), "00:00:00") }) //O campo data deverá ser enviado no formato correto (cAlias)->(DBSkip()) enddo (cAlias)->(DBCloseArea()) return self:oData method getSchema() as object class SB1TReportsBusinessObject self:aliasToSchema("SB1", "B1_COD") self:addProperty("Descricao", "Descricao", "string", "Descricao","B1_DESC") self:addProperty("Tipo", "Tipo", "string", "Tipo","B1_TIPO") self:addProperty("Unidade", "Unidade de medida", "string", "Unidade","B1_UM") self:addProperty("Revisao", "Revisao", "date", "Revisao","B1_UREV") return self:oSchema |
...
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "msobject.ch" #include "protheus.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.materiais @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGACOM", tables="SB1", name="Materiais", country="ALL", initialRelease="12.1.2210") 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_FILIAL, B1_COD, B1_DESC, B1_TIPO, B1_UM, B1_UREV, B1_FILIAL, B1_PRV1 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(65, StoD((cAlias)->B1_UREV), "00:00:00") self:appendData({"Filial": (cAlias)->B1_FILIAL,; "Codigo": (cAlias)->B1_COD,; "Descricao": (cAlias)->B1_DESC,; "Tipo": (cAlias)->B1_TIPO, ; "Unidade": (cAlias)->B1_UM, ; "Revisao": cDate ,; "Preco": (cAlias)->B1_PRV1}) (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:addProperty("Filial", "Filial", "string", "Filial", "B1_FILIAL", cComboFil,.F.) self:addProperty("Codigo", "Codigo", "string", "Codigo", "B1_COD") self:addProperty("Descricao", "Descricao", "string", "Descricao","B1_DESC") self:addProperty("Tipo", "Tipo", "string", "Tipo","B1_TIPO") self:addProperty("Unidade", "Unidade de medida", "string", "Unidade","B1_UM") self:addProperty("Revisao", "Revisao", "date", "revisao","B1_UREV") self:addProperty("Data", "Data", "date", "Data","B1_UREV") self:addProperty("Preco", "Preço", "number", "Preço","B1_PRV1") return self:oSchema |
...
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "msobject.ch" #include "protheus.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.materiais.produtos.integratedprovider.lookup @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGACOM", tables="SB1", name="Produtos do Protheus", country="ALL", initialRelease="12.1.2210") 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("Compras") self:setIsLookUp(.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_FILIAL, B1_COD, B1_DESC, B1_TIPO, B1_UM, B1_UREV 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(65, StoD((cAlias)->B1_UREV), "00:00:00") self:appendData({"Filial": (cAlias)->B1_FILIAL,; "Codigo": (cAlias)->B1_COD,; "Descricao": (cAlias)->B1_DESC,; "Tipo": (cAlias)->B1_TIPO, ; "Unidade": (cAlias)->B1_UM, ; "Revisao": cDate}) (cAlias)->(DBSkip()) enddo (cAlias)->(DBCloseArea()) return self:oData method getSchema() as object class SB1TReportsBusinessObject local cField as character local aStruct as array local lIsRequired as logical Local aDescriptor as array Local nFieldReturn as numeric //Seta a descrição da consulta self:setDescriptor("Código","Código do Produto", "Descrição") cComboFil := "D MG 01=Filial BH; D MG 02=Filial Uberaba; D RJ 01 =Filial RJ" self:aliasToSchema("SB1", {"B1_FILIAL", "B1_COD"}) self:addProperty("Descricao", "Descricao", "string", "Descricao","B1_DESC") self:addProperty("Tipo", "Tipo", "string", "Tipo","B1_TIPO") self:addProperty("Unidade", "Unidade de medida", "string", "Unidade","B1_UM") self:addProperty("Revisao", "Revisao", "date", "revisao","B1_UREV") self:addProperty("Camp Log", "Camp Log", "boolean", "Camp Lógico","B1_LOGI") cField := "B1_COD" aStruct := {} aAdd(aStruct, {"ATF0510001", "ATFA036 EMISSAO DE NOTA EM LOT"}) aAdd(aStruct, {"0003","PRODUTO PADRAO"}) aAdd(aStruct, {"EST00000000000000000000001GGGR","'PRODTO ESTOQUE GRADE EAI INTE"}) lIsRequired := .F. aDescriptor := {"Codigo","Descrição"} nFieldReturn := 1 //Seta os valores para o Lookup self:setLookUpVal(cField, aStruct, lIsRequired, aDescriptor, nFieldReturn) return self:oSchema |
...
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "msobject.ch" #include "protheus.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.materiais @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGACOM", tables="SB1", name="Materiais", country="ALL", initialRelease="12.1.2210") 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 - KeyLabel") //Seta o lookup do campo do tipo combobox 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 local nSkip as numeric local nEnd as numeric local nCount as numeric nCount := 0 cQuery := "SELECT B1_FILIAL, B1_COD, B1_DESC, B1_TIPO, B1_UM, B1_UREV, B1_FILIAL, B1_PRV1 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) //Seta a quantidade de itens por página (Default 100) self:setPageSize(15) //Posiciona o conteúdo da query if nPage == 1 (cAlias)->(dbGoTop()) else //Encontra a quantidade de itens que irá pular de acordo com a página atual nSkip := ((nPage - 1) * self:getPageSize()) (cAlias)->(dbSkip(nSkip)) endif while !(cAlias)->(Eof()) cDate := FwTimeStamp(65, StoD((cAlias)->B1_UREV), "00:00:00") 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 ,; "Preco": (cAlias)->B1_PRV1}) (cAlias)->(DBSkip()) nCount++ //Sai do loop quando chegar no tamanho de itens da página if nCount == self:getPageSize() exit endif enddo //Se não for o último registro indica que terá próxima página self:setHasNext(!(cAlias)->(Eof())) (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:addProperty("Filial", "Filial", "string", "Filial", "B1_FILIAL", cComboFil,.F.) self:addProperty("Codigo", "Codigo", "string", "Codigo", "B1_COD") self:addProperty("Descricao", "Descricao", "string", "Descricao","B1_DESC") self:addProperty("Tipo", "Tipo", "string", "Tipo","B1_TIPO") self:addProperty("Unidade", "Unidade de medida", "string", "Unidade","B1_UM") self:addProperty("Revisao", "Revisao", "date", "revisao","B1_UREV") self:addProperty("Data", "Data", "date", "Data","B1_UREV") self:addProperty("Preco", "Preço", "number", "Preço","B1_PRV1") return self:oSchema |
...