Histórico da Página
...
Bloco de código |
---|
#include "msobject.ch" // Referência o .th da classe #include "totvs.framework.treports.integratedprovider.th" // Cria um novo namespace para sua classe namespace custom.financeiro.naturezas.integratedprovider // Caso queira desativar a utilização da classe mudar para active=.F. @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGAFIN", tables="SED", name="Naturezas", country="ALL", releaseactactrelease="12.1.2210") // Cria uma nova classe e herda a classe principal (IntegratedProvider) com o namespace class SEDTReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object endclass |
...
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "msobject.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.financeiro.naturezas.integratedprovider @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGAFIN", tables="SED", name="Naturezas", country="ALL", releaseactactrelease="12.1.2210") class SEDTReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getDisplayName() as character public method getAreas() as array public method getData() as object public method getSchema() as object endclass method new() as object class SEDTReportsBusinessObject _Super:new() self:setDescription("Naturezas financeiras do Protheus") return self method getDisplayName() as character class SEDTReportsBusinessObject return "Naturezas" method getAreas() as array class SEDTReportsBusinessObject return {"Financeiro"} // Os filtros serão setados na interface do novo TReports method getData(nPage as numeric, oFilter as object) as object class SEDTReportsBusinessObject self:aliasToData("SED", oFilter) return self:oData method getSchema() as object class SEDTReportsBusinessObject self:aliasToSchema("SED") return self:oSchema |
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "msobject.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.financeiro.fornecedores.integratedprovider @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGACOM", tables="SA2", name="SA2TReportsBusinessObject", country="ALL", releaseactactrelease="12.1.2210") class SA2TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getAreas() as array public method getDescription() as character public method getData() as object public method getSchema() as object endclass method new() as object class SA2TReportsBusinessObject _Super:new() self:setDisplayName("Fornecedores") return self method getDescription() as character class SA2TReportsBusinessObject return "Fornecedores do Protheus" method getAreas() as array class SA2TReportsBusinessObject return {"Financeiro", "Contas a pagar"} method getData(nPage as numeric, oFilter as object) as object class SA2TReportsBusinessObject local cQuery as character local cAlias as character cQuery := "SELECT A2_NOME, A2_COD FROM " + RetSqlName('SA2') + " 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({"Nome": (cAlias)->A2_NOME, "Codigo": (cAlias)->A2_COD}) (cAlias)->(DBSkip()) enddo (cAlias)->(DBCloseArea()) return self:oData method getSchema() as object class SA2TReportsBusinessObject self:addProperty("Nome", "Nome do Fornecedor", "string", "Fornecedor", "A2_NOME") self:addProperty("Codigo", "Codigo do Fornecedor", "string", "Cod do Fornecedor", "A2_COD") return self:oSchema |
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", releaseactactrelease="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(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: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", releaseactactrelease="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(6, StoD((cAlias)->B1_UREV)) 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.financeiro.naturezas.integratedprovider // Parece que ao fazer o uso da namespace dessa forma, está gerando alguams exceções aleatório quanto as propriedades das classes // using namespace totvs.framework.treports.integratedprovider @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGAFIN", tables="SED", name="Naturezas Financeiras", country="ALL", releaseactactrelease="12.1.2210") class SEDTReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getDisplayName() as character public method getAreas() as array public method getData() as object public method getSchema() as object endclass method new() as object class SEDTReportsBusinessObject _Super:new() self:setDescription("Naturezas financeiras do Protheus") self:setIsCBoxLookup(.T., .F.) return self method getDisplayName() as character class SEDTReportsBusinessObject return "Naturezas" method getAreas() as array class SEDTReportsBusinessObject return {"Financeiro"} method getData(nPage as numeric, oFilter as object) as object class SEDTReportsBusinessObject self:aliasToData("SED", oFilter) return self:oData method getSchema() as object class SEDTReportsBusinessObject self:aliasToSchema("SED") self:setComboValues("ED_FILIAL", "D MG 01=Filial BH; D MG 02=Filial Uberaba", .F.) self:setComboValues("ED_CALCIRF", "Sim=Sim; Não=Não") 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", releaseactactrelease="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(6, StoD((cAlias)->B1_UREV)) 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.financeiro.fornecedores.integratedprovider.lookup @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGAFIN", tables="SA2", name="Fornecedores", country="ALL", releaseactactrelease="12.1.2210") class SA2TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getAreas() as array public method getDescription() as character public method getData() as object public method getSchema() as object endclass method new() as object class SA2TReportsBusinessObject _Super:new() self:setDisplayName("Fornecedores") self:setIsLookUp(.T.) return self method getDescription() as character class SA2TReportsBusinessObject return "Fornecedores do Protheus" method getAreas() as array class SA2TReportsBusinessObject return {"Financeiro", "Contas a pagar"} method getData(nPage as numeric, oFilter as object) as object class SA2TReportsBusinessObject local cQuery as character local cAlias as character cQuery := "SELECT * FROM " + RetSqlName('SA2') + " WHERE D_E_L_E_T_ = ' '" if oFilter:hasFilter() cQuery += " AND " + oFilter:getSQLExpression() endif cAlias := MPSysOpenQuery(cQuery) while !(cAlias)->(Eof()) self:appendData({"Nome": (cAlias)->A2_NOME,; "Codigo": (cAlias)->A2_COD,; "Estado": (cAlias)->A2_EST}) (cAlias)->(DBSkip()) enddo (cAlias)->(DBCloseArea()) return self:oData method getSchema() as object class SA2TReportsBusinessObject self:addProperty("Nome", "Nome do Fornecedor", "string", "Nome","A2_NOME") self:addProperty("Codigo", "Código do Fornecedor", "string", "Código", "A2_COD") self:addProperty("Estado", "Sigla da Federacao", "string", "Estado", "A2_EST") //Seta o lookup a partir de uma tabela da SX5 self:setX5Struct("A2_EST", "12", .F.) return self:oSchema |
Bloco de código | ||||
---|---|---|---|---|
| ||||
#include "msobject.ch" #include "totvs.framework.treports.integratedprovider.th" namespace custom.financeiro.naturezas.integratedprovider.lookup @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGAFIN", tables="SED", name="Naturezas", country="ALL", releaseactactrelease="12.1.2210") class SEDTReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getDisplayName() as character public method getAreas() as array public method getData() as object public method getSchema() as object endclass method new() as object class SEDTReportsBusinessObject _Super:new() self:setDescription("Naturezas financeiras do Protheus") self:setIsLookUp(.T.) return self method getDisplayName() as character class SEDTReportsBusinessObject return "Naturezas" method getAreas() as array class SEDTReportsBusinessObject return {"Financeiro"} method getData(nPage as numeric, oFilter as object) as object class SEDTReportsBusinessObject self:oData:aliasToData("SED", oFilter) return self:oData method getSchema() as object class SEDTReportsBusinessObject local cQuery as character local aFields as array Local aDescriptor as array Local cReturn as character Local cOrder as character self:oSchema:aliasToSchema("SED") cQuery := "SELECT * FROM "+ RetSQLName("SED") +" WHERE D_E_L_E_T_ = ' '" //cQuery := "SELECT ED_CODIGO, ED_DESCRIC FROM "+ RetSQLName("SED") +" WHERE D_E_L_E_T_ = ' '" aFields := {"ED_CODIGO", "ED_DESCRIC"} aDescriptor := {"Codigo", "Descrição"} cReturn := "ED_CODIGO" cOrder := "ED_DESCRIC" //Seta o lookup a partir da query self:oSchema:setLookUpQuery("ED_CODIGO", aFields, cQuery, .F., aDescriptor, cReturn, cOrder) return self:oSchema |
...
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", releaseactactrelease="12.1.2210") class SB1TReportsBusinessObject from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getData() as object public method getSchema() as object endclass method new() class SB1TReportsBusinessObject _Super:new() //Define a Área self:appendArea("Compras") //Define o nome do Objeto de Negócio self:setDisplayName("Produtos") //Define a descrição do Objeto de Negócio self:setDescription("Produtos do Protheus") return self method getData() as object class SB1TReportsBusinessObject local cQuery as character //Define a quantidade máxima por página (Default 100) self:setPageSize(200) //Define a query do Objeto de Negócio cQuery := "SELECT #QueryFields# FROM " + RetSQLName("SB1") + " WHERE #QueryWhere#" self:setQuery(cQuery) //Define o campo de ordenação da query self:setOrder("B1_COD") //Define o where da query self:setWhere("B1_FILIAL = '"+ FWxFilial('SB1') +"' AND D_E_L_E_T_ = ' '") return self:oData method getSchema() as object class SB1TReportsBusinessObject self:addProperty("Filial", "Filial", "string", "Filial", "B1_FILIAL") self:addProperty("Codigo", "Codigo", "string", "Código", "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 "totvs.framework.treports.integratedprovider.th" namespace custom.materiais.produtos.integratedprovider @totvsFrameworkTReportsIntegratedProvider(active=.T., team="SIGACOM", tables="SB1", name="Materiais", country="ALL", releaseactactrelease="12.1.2210") class SB1TReportsBusinessObjectData from totvs.framework.treports.integratedprovider.IntegratedProvider public method new() as object public method getData() as object public method getSchema() as object endclass method new() class SB1TReportsBusinessObjectData _Super:new() //Define a Área self:appendArea("Compras") //Define o nome do Objeto de Negócio self:setDisplayName("Produtos") //Define a descrição do Objeto de Negócio self:setDescription("Produtos do Protheus") return self method getData(nPage as numeric, oFilter as object) as object class SB1TReportsBusinessObjectData //Define a quantidade máxima por página (Default 100) self:setPageSize(500) //Setar antes de fazer o aliasToData() self:aliasToData("SB1", oFilter) return self:oData method getSchema() as object class SB1TReportsBusinessObjectData self:aliasToSchema("SB1") 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", releaseactactrelease="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(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 ,; "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 |
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="SA5", name="Produto X Fornecedor", country="ALL", releaseactactrelease="12.1.2210") //------------------------------------------------------------------- /*{Protheus. doc} MATR190TReportsBusinessObject Classe para criação do Objeto de Negócio de Prod x Forn para o TReports @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- class MATR190TReportsBusinessObject 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 protected data aFields as array protected data aStruct as array endclass //------------------------------------------------------------------- /*{Protheus.doc} new Método de instância da classe @return object: self @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method new() class MATR190TReportsBusinessObject _Super:new() self:appendArea("Compras") self:aFields := {"A5_FILIAL", "A5_FORNECE", "A5_LOJA", "A5_NOMEFOR", "A5_PRODUTO", "A5_NOMPROD", "A5_CODPRF"} self:aStruct := getStruct(self:aFields) return self //------------------------------------------------------------------- /*{Protheus.doc} getDisplayName Retorna o nome de exibição do objeto de negócio @return string @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getDisplayName() as character class MATR190TReportsBusinessObject return "Produtos x Fornecedores" //------------------------------------------------------------------- /*{Protheus.doc} getDescription Retorna a descrição do objeto de negócio @return string @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getDescription() as character class MATR190TReportsBusinessObject return "Produtos x Fornecedores" //------------------------------------------------------------------- /*{Protheus.doc} getData Retorna os dados do objeto de negócio @param nPage, numérico, indica a página atual do relatório @param oFilter, objeto, contém o filtro do TReports @return object: self:oData @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getData(nPage as numeric, oFilter as object) as object class MATR190TReportsBusinessObject local cQuery as character local cAlias as character local nSkip as numeric local nCount as numeric local nX as numeric local jItems as json local aPDFields as array nCount := 0 cQuery := "SELECT A5_FILIAL,A5_PRODUTO,A5_NOMPROD,A5_FORNECE,A5_NOMEFOR,A5_LOJA,A5_CODPRF FROM " + RetSQLName("SA5") + " 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) 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()) //Verifica se precisa fazer o tratamento para LGPD aPDFields := FwProtectedDataUtil():UsrAccessPDField(__cUserID, self:aFields) lObfuscated := len( aPDFields ) != Len(self:aFields) jItems := JsonObject():new() for nX := 1 To Len(self:aStruct) if lObfuscated .and. aScan(aPDFields, self:aStruct[nX][5]) == 0 jItems[self:aStruct[nX][1]] := FwProtectedDataUtil():ValueAsteriskToAnonymize((cAlias)->&(self:aStruct[nX][5])) else jItems[self:aStruct[nX][1]] := (cAlias)->&(self:aStruct[nX][5]) endif next nX self:oData:appendData(jItems) (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 //------------------------------------------------------------------- /*{Protheus.doc} getSchema Retorna a estrutura dos campos @return object: self:oSchema @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- method getSchema() as object class MATR190TReportsBusinessObject Local nX as numeric for nX := 1 To Len(self:aStruct) self:addProperty(self:aStruct[nX][1], self:aStruct[nX][2], self:aStruct[nX][3], self:aStruct[nX][4], self:aStruct[nX][5]) Next nX return self:oSchema //------------------------------------------------------------------- /*{Protheus.doc} getStruct Prepara a estrutura dos campos @param aCpos array: Array com os campos do relatório @return array: Array com a estrutura dos campos @author Vanessa Ruama @since 02/03/2023 @version 1.0 */ //------------------------------------------------------------------- function getStruct(aCpos) Local aDeParaCpo as array Local aCpoTmp as array Local cCampo as character Local cCpoQry as character Local cTipR as character Local nPos as numeric Local nC as numeric aDeParaCpo := {{"C", "string"}, {"D", "date"}, {"N", "number"}, {"L", "boolean"}} aCpoTmp := {} for nC := 1 to Len(aCpos) cCpoQry := aCpos[nC] nPos := AT(".", aCpos[nC]) + 1 if nPos > 0 cCampo := Substr(cCpoQry, nPos) else cCampo := cCpoQry endif cTipo := GetSx3Cache(cCampo, "X3_TIPO") if (nPos := aScan(aDeParaCpo, {|c| c[01] = cTipo})) > 0 cTipR := aDeParaCpo[nPos, 02] else cTipR := "string" endif AAdd(aCpoTmp, {strTran(cCampo, "_", ""), FWSX3Util():GetDescription(cCampo), cTipR, cCampo, cCampo}) next nC return (aCpoTmp) |
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas