├── Iniciar form ├── README.md ├── controle.js ├── displayFields.js └── index.html ├── Iniciar widget ├── README.md ├── javascript.js └── view.ftl ├── .DS_Store ├── Exportar datatable para excel ├── README.md ├── javascript.js ├── jquery.base64.js ├── jquery.btechco.excelexport.js └── table2excel.js ├── Exemplos de impressão ├── README.md └── imprimir table.js ├── Layouts ├── layout_sem_menu │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ ├── layout_sem_menu_en_US.properties │ │ │ ├── layout_sem_menu_es.properties │ │ │ ├── layout_sem_menu_pt_BR.properties │ │ │ ├── layout_sem_menu.properties │ │ │ ├── application.info │ │ │ └── layout.ftl │ │ │ └── webapp │ │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ │ ├── resources │ │ │ └── images │ │ │ │ └── icon.png │ │ │ └── WEB-INF │ │ │ ├── jboss-web.xml │ │ │ └── web.xml │ └── target │ │ └── layout_sem_menu.war └── layout_sem_titulo │ ├── src │ └── main │ │ ├── resources │ │ ├── layout_sem_titulo_en_US.properties │ │ ├── layout_sem_titulo_es.properties │ │ ├── layout_sem_titulo_pt_BR.properties │ │ ├── layout_sem_titulo.properties │ │ ├── application.info │ │ └── layout.ftl │ │ └── webapp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── resources │ │ └── images │ │ │ └── icon.png │ │ └── WEB-INF │ │ ├── jboss-web.xml │ │ └── web.xml │ └── target │ └── layout_sem_titulo.war ├── Iniciar Processo via Rest ├── README.md ├── oauth │ ├── enc-base64-min.js │ ├── hmac-sha1.js │ ├── hmac-sha256.js │ └── oauth-1.0a.js └── javascript.js ├── Dataset com paginação ├── view.ftl ├── javascript.js └── pagination.css ├── Consumir Dataset Publico ├── javascript.js ├── oauth │ ├── enc-base64-min.js │ ├── hmac-sha1.js │ ├── hmac-sha256.js │ └── oauth-1.0a.js ├── README.md └── dataset.js ├── Datasets customizados ├── activeDocument.js ├── urlDocument.js ├── moveDocumento.js ├── cancelaProcesso.js ├── tokenJWT.js ├── dsk_sinc_table_form.js ├── ds_create_folder.js ├── dsk_processTask.js ├── dsk_compacta_zip.js ├── dsk_table_name.js ├── sendFileToWS.js ├── select.js ├── enviaEmail.js ├── dsk_sinc_cadastros.js ├── selectTable.js ├── selectDataSet.js ├── reabreProcesso.js └── selectPaiFilho.js ├── Ordernar datatable (Widget) └── ordeBy dataTable.js ├── Carrega CNPJ Receita └── javascript.js ├── Cadastro formulário customizado └── javascript.js ├── Utils └── jquery.maskMoney.min.js ├── Publicar arquivo no fluig └── fileUpload.js └── Pesquisa Customizada ├── modalTable.js └── modalZoom2.js /Iniciar form/README.md: -------------------------------------------------------------------------------- 1 | Arquivos para auxiliar na criação de um novo formulário -------------------------------------------------------------------------------- /Iniciar widget/README.md: -------------------------------------------------------------------------------- 1 | Arquivos para auxiliar na criação de uma nova widget -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiagotsukahara/fluig-docs/HEAD/.DS_Store -------------------------------------------------------------------------------- /Exportar datatable para excel/README.md: -------------------------------------------------------------------------------- 1 | Exemplo de como exportar um datatable para Excel -------------------------------------------------------------------------------- /Exemplos de impressão/README.md: -------------------------------------------------------------------------------- 1 | Exemplo de impressão da datatable e de criação de impressão customizada -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/resources/layout_sem_menu_en_US.properties: -------------------------------------------------------------------------------- 1 | wcm.layoutsimples.title=Page heading 2 | -------------------------------------------------------------------------------- /Iniciar Processo via Rest/README.md: -------------------------------------------------------------------------------- 1 | Importar biblioteca Oauth e utilizar a função para iniciar um processo no fluig 2 | -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/resources/layout_sem_titulo_en_US.properties: -------------------------------------------------------------------------------- 1 | wcm.layoutsimples.title=Page heading 2 | -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/resources/layout_sem_menu_es.properties: -------------------------------------------------------------------------------- 1 | wcm.layoutsimples.title=T\u00EDtulo de la p\u00E1gina 2 | -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/resources/layout_sem_menu_pt_BR.properties: -------------------------------------------------------------------------------- 1 | wcm.layoutsimples.title=T\u00EDtulo da p\u00E1gina 2 | -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/resources/layout_sem_titulo_es.properties: -------------------------------------------------------------------------------- 1 | wcm.layoutsimples.title=T\u00EDtulo de la p\u00E1gina 2 | -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/resources/layout_sem_titulo_pt_BR.properties: -------------------------------------------------------------------------------- 1 | wcm.layoutsimples.title=T\u00EDtulo da p\u00E1gina 2 | -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/target/layout_sem_menu.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiagotsukahara/fluig-docs/HEAD/Layouts/layout_sem_menu/target/layout_sem_menu.war -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/target/layout_sem_titulo.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiagotsukahara/fluig-docs/HEAD/Layouts/layout_sem_titulo/target/layout_sem_titulo.war -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: Apache Maven 3 | Built-By: vanei 4 | Build-Jdk: 1.6.0_24 5 | Dependencies: org.slf4j 6 | 7 | -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/webapp/resources/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiagotsukahara/fluig-docs/HEAD/Layouts/layout_sem_menu/src/main/webapp/resources/images/icon.png -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: Apache Maven 3 | Built-By: vanei 4 | Build-Jdk: 1.6.0_24 5 | Dependencies: org.slf4j 6 | 7 | -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/webapp/resources/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiagotsukahara/fluig-docs/HEAD/Layouts/layout_sem_titulo/src/main/webapp/resources/images/icon.png -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/resources/layout_sem_menu.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiagotsukahara/fluig-docs/HEAD/Layouts/layout_sem_menu/src/main/resources/layout_sem_menu.properties -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/resources/layout_sem_titulo.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tiagotsukahara/fluig-docs/HEAD/Layouts/layout_sem_titulo/src/main/resources/layout_sem_titulo.properties -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | /layout_sem_menu 4 | false 5 | 6 | 7 | -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | /layout_sem_titulo 4 | false 5 | 6 | 7 | -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 30 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 30 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Iniciar form/controle.js: -------------------------------------------------------------------------------- 1 | var beforeSendValidate = function(numState,nextState){ 2 | 3 | var task = $('#task').val(); 4 | 5 | if (task == 0 || task == 1){ 6 | if ( !valida('.valida') ){ 7 | toast('Existem campos obrigatórios não preenchidos','danger'); 8 | return false; 9 | } 10 | } 11 | 12 | return true; 13 | 14 | } 15 | 16 | function loadBody(){ 17 | 18 | console.log('loadBody'); 19 | displayFields(); 20 | 21 | } 22 | 23 | function displayFields(){ 24 | console.log('displayFields'); 25 | var task = $('#task').val(); 26 | 27 | } -------------------------------------------------------------------------------- /Iniciar form/displayFields.js: -------------------------------------------------------------------------------- 1 | function displayFields(form,customHTML){ 2 | 3 | form.setShowDisabledFields(true); 4 | form.setHidePrintLink(true); 5 | 6 | var manager = 'N'; 7 | if( getValue('WKManagerMode') ){ 8 | manager = 'S'; 9 | } 10 | form.setValue("isManager", manager ); 11 | 12 | var mobile = 'N'; 13 | if( form.getMobile() ){ 14 | mobile = 'S'; 15 | } 16 | form.setValue("isMobile", mobile ); 17 | 18 | form.setValue("task", getValue('WKNumState') ); 19 | form.setValue("processo", getValue('WKNumProces') ); 20 | form.setValue("cod_user", getValue('WKUser') ); 21 | } -------------------------------------------------------------------------------- /Dataset com paginação/view.ftl: -------------------------------------------------------------------------------- 1 | <#-- table para listar dados --> 2 |
3 |
4 | 9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
-------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/resources/application.info: -------------------------------------------------------------------------------- 1 | application.type=layout 2 | application.code=layout_sem_menu 3 | application.title=Sem Menu 4 | application.description=Sem Menu 5 | application.category=SYSTEM 6 | application.renderer=freemarker 7 | developer.code=FLUIG_WCM_DEV 8 | developer.name=andre.timm 9 | developer.url=http://www.fluig.com 10 | layout.defaultSlot=SlotA 11 | layout.file=layout.ftl 12 | locale.file.base.name=layout_sem_menu 13 | slot.SlotGlobalAlert=alertpopover 14 | slot.SlotInstantSearch=suggestsearch 15 | slot.SlotLogin=sociallogin 16 | slot.SlotMenu=menu 17 | slot.SlotUsePolicy=usepolicy 18 | application.icon=icon.png 19 | 20 | -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/resources/application.info: -------------------------------------------------------------------------------- 1 | application.type=layout 2 | application.code=layout_sem_titulo 3 | application.title=Sem titulo 4 | application.description=Sem titulo 5 | application.category=SYSTEM 6 | application.renderer=freemarker 7 | developer.code=Tsukahara 8 | developer.name=tiago 9 | developer.url=http://www.fluig.com 10 | layout.defaultSlot=SlotA 11 | layout.file=layout.ftl 12 | locale.file.base.name=layout_sem_titulo 13 | slot.SlotGlobalAlert=alertpopover 14 | slot.SlotInstantSearch=suggestsearch 15 | slot.SlotLogin=sociallogin 16 | slot.SlotMenu=menu 17 | slot.SlotUsePolicy=usepolicy 18 | application.icon=icon.png 19 | 20 | -------------------------------------------------------------------------------- /Exportar datatable para excel/javascript.js: -------------------------------------------------------------------------------- 1 | // bind 2 | 'load-excel': ['click_loadExcel'], 3 | 4 | loadExcel: function(el, ev){ 5 | 6 | var idTable = ""; 7 | $("table[id^=fluig-table-]", '#idtable' + '_' + $this.instanceId).each(function(index){ 8 | idTable = $(this).attr("id"); 9 | }); 10 | 11 | //Nome arquivo 12 | var fileName = 'geraInventario_'+WCMAPI.getUserLogin()+'_'+$.now(); 13 | 14 | $("#"+idTable).btechco_excelexport({ 15 | containerid: idTable, 16 | datatype: $datatype.Table, 17 | returnUri: true, 18 | filename: fileName 19 | }); 20 | 21 | }, -------------------------------------------------------------------------------- /Consumir Dataset Publico/javascript.js: -------------------------------------------------------------------------------- 1 | //Chamada de função 2 | 3 | const constraintDS = [ 4 | publicDataset.createConstraint("data_inicio_de", '2020-05-10', '2020-05-10', ConstraintType.MUST), 5 | publicDataset.createConstraint("data_inicio_ate", '2020-05-12', '2020-05-12', ConstraintType.MUST), 6 | publicDataset.createConstraint("data_fim_de", '2020-05-10', '2020-05-10', ConstraintType.MUST), 7 | publicDataset.createConstraint("data_fim_ate", '2020-05-12', '2020-05-12', ConstraintType.MUST), 8 | ]; 9 | 10 | publicDataset.getDataset("dsk_indica_obras", null, constraintDS, null, { 11 | success: data => { 12 | 13 | if (data.hasOwnProperty("values") && data.values.length > 0) { 14 | 15 | console.log(data.values); 16 | 17 | } 18 | } 19 | }); -------------------------------------------------------------------------------- /Consumir Dataset Publico/oauth/enc-base64-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join("")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d< 8 | e;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})(); 9 | -------------------------------------------------------------------------------- /Iniciar Processo via Rest/oauth/enc-base64-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | (function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join("")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d< 8 | e;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})(); 9 | -------------------------------------------------------------------------------- /Datasets customizados/activeDocument.js: -------------------------------------------------------------------------------- 1 | function defineStructure() {} 2 | function onSync(lastSyncDate) {} 3 | 4 | function createDataset(fields, constraints, sortFields) { 5 | 6 | var datasetReturn = DatasetBuilder.newDataset(); 7 | 8 | datasetReturn.addColumn( "result" ); 9 | 10 | try{ 11 | 12 | var numDocum = ''; 13 | 14 | if (constraints != null) { 15 | for (var i = 0; i < constraints.length; i++) { 16 | if ( constraints[i].fieldName == 'documentID' ){ 17 | numDocum = parseInt( constraints[i].initialValue ); 18 | log.info('Entrei documentID........... '+constraints[i].initialValue ); 19 | } 20 | } 21 | } 22 | 23 | datasetReturn.addRow( new Array( fluigAPI.getDocumentService().getActive( numDocum ) ) ); 24 | 25 | }catch( e ){ 26 | log.error( e ); 27 | datasetReturn.addRow( new Array( 'NOK' ) ); 28 | } 29 | return datasetReturn; 30 | 31 | } 32 | 33 | function onMobileSync(user) {} -------------------------------------------------------------------------------- /Datasets customizados/urlDocument.js: -------------------------------------------------------------------------------- 1 | function defineStructure() {} 2 | function onSync(lastSyncDate) {} 3 | 4 | function createDataset(fields, constraints, sortFields) { 5 | 6 | var datasetReturn = DatasetBuilder.newDataset(); 7 | 8 | datasetReturn.addColumn( "result" ); 9 | 10 | try{ 11 | 12 | var numDocum = 10660; 13 | 14 | if (constraints != null) { 15 | for (var i = 0; i < constraints.length; i++) { 16 | if ( constraints[i].fieldName == 'documentID' ){ 17 | numDocum = parseInt( constraints[i].initialValue ); 18 | log.info('Entrei empresa........... '+constraints[i].initialValue ); 19 | } 20 | } 21 | } 22 | 23 | datasetReturn.addRow( new Array( fluigAPI.getDocumentService().getDownloadURL( numDocum ) ) ); 24 | 25 | }catch( e ){ 26 | log.error( e ); 27 | datasetReturn.addRow( new Array( 'NOK' ) ); 28 | } 29 | return datasetReturn; 30 | 31 | } 32 | 33 | function onMobileSync(user) {} -------------------------------------------------------------------------------- /Consumir Dataset Publico/README.md: -------------------------------------------------------------------------------- 1 | No arquivo dataset.js, substituir as chaves abaixo com o usuário de aplicativo criado no fluig e substituir a url 2 | ```javascript 3 | token = { 4 | 'public': '', 5 | 'secret': '' 6 | }; 7 | consumer: { 8 | 'public': '', 9 | 'secret': '' 10 | }, 11 | ``` 12 | 13 | ``` 14 | var url = 'SUA URL' // ou WCMAPI.getServerURL(); para widget fluig 15 | ``` 16 | 17 | No arquivo javascript.js, substituir as constraints e nome do dataset pelo fornecido. 18 | 19 | ```javascript 20 | const constraintDS = [ 21 | publicDataset.createConstraint("NOME_DO_CAMPO", 'VALOR', 'VALOR', ConstraintType.MUST), 22 | ]; 23 | 24 | publicDataset.getDataset("DATASET_FORNECIDO", null, constraintDS, null, { 25 | success: data => { 26 | if (data.hasOwnProperty("values") && data.values.length > 0) { 27 | console.log(data.values); 28 | } 29 | } 30 | }); 31 | ``` 32 | -------------------------------------------------------------------------------- /Ordernar datatable (Widget)/ordeBy dataTable.js: -------------------------------------------------------------------------------- 1 | orderBy: function(htmlElement, event){ 2 | var order = htmlElement.getAttribute('data-order-by'); 3 | 4 | dados = dataTable.getData(); 5 | 6 | if( htmlElement.children[1].classList.contains("dropup") ){ 7 | this.orderAscDesc = "ASC"; 8 | }else{ 9 | this.orderAscDesc = "DESC"; 10 | } 11 | 12 | if( htmlElement.children[1].classList.contains("dropup") ){ 13 | //this.orderAscDesc = "ASC"; 14 | dados.sort(function(a, b){ 15 | var a1= a[order].toLowerCase(), b1= b[order].toLowerCase(); 16 | if(a1== b1) return 0; 17 | return a1 > b1? 1: -1; 18 | }); 19 | }else{ 20 | //this.orderAscDesc = "DESC"; 21 | dados.sort(function(a, b){ 22 | var a1= a[order].toLowerCase(), b1= b[order].toLowerCase(); 23 | if(a1== b1) return 0; 24 | return a1 < b1? 1: -1; 25 | }); 26 | } 27 | 28 | dataTable.reload(dados); 29 | }, -------------------------------------------------------------------------------- /Layouts/layout_sem_menu/src/main/resources/layout.ftl: -------------------------------------------------------------------------------- 1 | <#import "/wcm.ftl" as wcm/> 2 | 3 | <#if pageRender.isEditMode()=true> 4 | <@wcm.header /> 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 |
13 | 14 | 15 | <#if pageRender.isEditMode()=true> 16 |
17 | 18 | 19 |
20 | <#else> 21 |
22 | 23 | 24 |
25 | <@wcm.renderSlot id="SlotA" editableSlot="true"/> 26 |
27 | 28 | 29 |
30 | <@wcm.renderSlot id="SlotB" editableSlot="true"/> 31 | 32 |
33 | 34 |
35 | 36 |
37 | -------------------------------------------------------------------------------- /Iniciar widget/javascript.js: -------------------------------------------------------------------------------- 1 | var $this = null; 2 | var user_code = null; 3 | var loadWindow = null; 4 | 5 | var MyWidget = SuperWidget.extend({ 6 | //variáveis da widget 7 | variavelNumerica: null, 8 | variavelCaracter: null, 9 | 10 | //método iniciado quando a widget é carregada 11 | init: function() { 12 | $this = this; 13 | //Carrega Título da página 14 | $('#page_title').html(WCMAPI.getPageTitle()); 15 | //Carrega usuário logado 16 | user_code = WCMAPI.getUserCode(); 17 | //Load do fluig 18 | loadWindow = FLUIGC.loading(window); 19 | //Mostra o load 20 | // loadWindow.show(); 21 | 22 | // verifica se está em modo de edição 23 | if (!this.isEditMode) { 24 | //PopUp da versão 25 | FLUIGC.popover('.bs-docs-popover-hover',{ trigger: 'hover', placement: 'left', html: true, content: 'Versão: 05/02/2021 15:31
Técnico: Tiago Tsukahara'}); 26 | 27 | } 28 | 29 | }, 30 | 31 | //BIND de eventos 32 | bindings: { 33 | local: { 34 | 'execute': ['click_executeAction'] 35 | }, 36 | global: {} 37 | }, 38 | 39 | executeAction: function(htmlElement, event) { 40 | } 41 | 42 | }); -------------------------------------------------------------------------------- /Layouts/layout_sem_titulo/src/main/resources/layout.ftl: -------------------------------------------------------------------------------- 1 | <#import "/wcm.ftl" as wcm/> 2 | <@wcm.header /> 3 | 4 | 5 |
6 | 7 | <@wcm.menu /> 8 | 9 | 10 |
11 |
12 | 13 | 14 | <#if pageRender.isEditMode()=true> 15 |
16 | 17 | 18 |
19 | <#else> 20 |
21 | 22 | 23 | 24 | <#--
--> 25 | <#-- ${i18n.getTranslation('wcm.layoutsimples.title')} --> 26 | <#--

${pageTitle}

--> 27 | <#--
--> 28 | 29 | 30 |
31 | <@wcm.renderSlot id="SlotA" editableSlot="true"/> 32 |
33 | 34 | 35 |
36 | <@wcm.renderSlot id="SlotB" editableSlot="true"/> 37 | 38 |
39 | <@wcm.footer layoutuserlabel="wcm.layoutsimples.user" /> 40 | 41 |
42 |
43 |
44 | -------------------------------------------------------------------------------- /Datasets customizados/moveDocumento.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | function createDataset(fields, constraints, sortFields) { 8 | 9 | log.info('## Move Documentos ##'); 10 | 11 | var dsRetorno = DatasetBuilder.newDataset(); 12 | dsRetorno.addColumn("status"); 13 | 14 | var listaConstraits = {}; 15 | 16 | var usuario = ""; 17 | var senha = ""; 18 | var matricula = ""; 19 | 20 | listaConstraits['documentos'] = ''; 21 | listaConstraits['pasta'] = ''; 22 | 23 | if (constraints != null) { 24 | for (var i = 0; i < constraints.length; i++) { 25 | listaConstraits[ constraints[i].fieldName.trim() ] = constraints[i].initialValue; 26 | log.info('fieldName.....'+constraints[i].fieldName+'...value....'+constraints[i].initialValue); 27 | } 28 | } 29 | 30 | try { 31 | 32 | var stub = ServiceManager.getServiceInstance("ECMDocumentService"); 33 | var helper = stub.getBean(); 34 | var service = helper.instantiate("com.totvs.technology.ecm.dm.ws.ECMDocumentServiceService"); 35 | var servico = service.getDocumentServicePort(); 36 | var documentosArray = helper.instantiate("net.java.dev.jaxb.array.IntArray"); 37 | 38 | var docArray = listaConstraits['documentos'].split(','); 39 | 40 | for (var i = 0; i < docArray.length; i++) { 41 | var idDocumento = new java.lang.Integer( docArray[i] ); 42 | documentosArray.getItem().add(idDocumento); 43 | } 44 | 45 | var retorno = servico.moveDocument(usuario, senha, getValue("WKCompany"), documentosArray, matricula, listaConstraits['pasta']); 46 | 47 | dsRetorno.addRow(new Array('OK')); 48 | 49 | } catch(e){ 50 | log.info(e); 51 | dsRetorno.addRow(new Array(e)); 52 | } 53 | 54 | return dsRetorno; 55 | } 56 | function onMobileSync(user) { 57 | 58 | } -------------------------------------------------------------------------------- /Carrega CNPJ Receita/javascript.js: -------------------------------------------------------------------------------- 1 | function carrega_cnpj(cnpj){ 2 | var wcnpj = cnpj.replace(/\D/g, ''); 3 | // console.log(cnpj); 4 | if (wcnpj != "") { 5 | var validacnpj = /([0-9]{2}[\.]?[0-9]{3}[\.]?[0-9]{3}[\/]?[0-9]{4}[-]?[0-9]{2})|([0-9]{3}[\.]?[0-9]{3}[\.]?[0-9]{3}[-]?[0-9]{2})/g; 6 | if(validacnpj.test(wcnpj)) { 7 | 8 | var url = "https://www.receitaws.com.br/v1/cnpj/"+ wcnpj 9 | console.log("teste "+url); 10 | $.ajax({ 11 | type: "GET", 12 | dataType: "jsonp", 13 | url: url, 14 | crossDomain: true, 15 | data: "", 16 | timeout: 3000, 17 | error: function(XMLHttpRequest, textStatus, errorThrown) { 18 | FLUIGC.toast({ title: '',message: 'CNPJ pesquisado não foi encontrado na receita' , type: 'warning' }); 19 | }, 20 | success: function (data, status, xhr) { 21 | console.log(data); 22 | $("#nome").val(data.nome); 23 | $('#atividade').val(data.atividade_principal[0]['text']); 24 | $("#cep").val(data.cep.replace(".","")); 25 | $("#numero").val(data.numero); 26 | $("#bairro").val(data.bairro); 27 | $("#site").val(data.complemento); 28 | $("#endereco").val(data.logradouro); 29 | } 30 | }); 31 | }else{ 32 | //cnpj é inválido. 33 | // limpa_formulario_cnpj(); 34 | console.log("teste "+validacnpj) 35 | FLUIGC.toast({ title: '',message: 'Formato de CNPJ inválido.' , type: 'warning' }); 36 | } 37 | } else { 38 | // limpa_formulario_cnpj(); 39 | } 40 | } -------------------------------------------------------------------------------- /Datasets customizados/cancelaProcesso.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | function createDataset(fields, constraints, sortFields) { 8 | 9 | log.info('Start cancelaProcesso '); 10 | var dataset = DatasetBuilder.newDataset(); 11 | dataset.addColumn( "status" ); 12 | 13 | try { 14 | var workflowEngineServiceProvider = ServiceManager.getServiceInstance("WorkflowEngineService"); 15 | var workflowServiceLocator = workflowEngineServiceProvider.instantiate("com.totvs.technology.ecm.workflow.ws.ECMWorkflowEngineServiceService"); 16 | var workflowService = workflowServiceLocator.getWorkflowEngineServicePort(); 17 | 18 | var userAdm = ""; 19 | var passAdm = "" 20 | var companyId = '1'; 21 | var processId = ''; 22 | var cancelText = ''; 23 | 24 | if (constraints != null) { 25 | for (var i = 0; i < constraints.length; i++) { 26 | if ( constraints[i].fieldName == 'processId' ){ 27 | processId = constraints[i].initialValue; 28 | log.info('Entrei processId........... '+constraints[i].initialValue ); 29 | } 30 | if ( constraints[i].fieldName == 'cancelText' ){ 31 | cancelText = constraints[i].initialValue; 32 | log.info('Entrei cancelText........... '+constraints[i].initialValue ); 33 | } 34 | } 35 | } 36 | 37 | var cancelamentoProcesso = workflowService.cancelInstance(userAdm, passAdm, companyId, processId, userAdm, cancelText); 38 | 39 | if (cancelamentoProcesso.equals("OK")) { 40 | dataset.addRow(new Array( 'OK' ) ); 41 | } 42 | 43 | }catch( e ){ 44 | log.error( e.toString() ); 45 | dataset.addRow(new Array( 'Erro ' + e.toString() ) ); 46 | } 47 | 48 | return dataset; 49 | } 50 | 51 | function onMobileSync(user) { 52 | 53 | } -------------------------------------------------------------------------------- /Datasets customizados/tokenJWT.js: -------------------------------------------------------------------------------- 1 | function defineStructure() {} 2 | function onSync(lastSyncDate) {} 3 | function onMobileSync(user) {} 4 | function createDataset(fields, constraints, sortFields) { 5 | 6 | var newDataset = DatasetBuilder.newDataset(); 7 | newDataset.addColumn( 'token' ); 8 | 9 | try{ 10 | 11 | var header = { 12 | "alg" : String( "HS256" ), 13 | "typ" : String( "JWT" ), 14 | } 15 | 16 | var str_header = new java.lang.String( JSON.stringify( header ) ); 17 | b64_header = new java.util.Base64.getUrlEncoder().withoutPadding().encodeToString( str_header.getBytes() ); 18 | var sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 19 | var now = new Date(); 20 | var payload = { 21 | "iat" : String( sdf.format( now ) ), 22 | "exp" : String( sdf.format( now.setHours( now.getHours() + 2 )) ), 23 | "nome" : String( "Tiago" ), 24 | "email" : String( "tiago.tsukahara@gmail.com" ), 25 | }; 26 | var str_payload = new java.lang.String( JSON.stringify(payload) ); 27 | b64_payload = new java.util.Base64.getUrlEncoder().withoutPadding().encodeToString( str_payload.getBytes() ); 28 | 29 | var key = new java.lang.String( "kobit" ).getBytes(); 30 | var sha256 = new javax.crypto.Mac.getInstance("HmacSHA256"); 31 | var keySpec = new javax.crypto.spec.SecretKeySpec(key, "HmacSHA256"); 32 | sha256.init( keySpec ); 33 | var str_signature = new java.lang.String( b64_header + "." + b64_payload ); 34 | var sha256_signature = sha256.doFinal( str_signature.getBytes() ); 35 | b64_signature = new java.util.Base64.getUrlEncoder().withoutPadding().encodeToString( sha256_signature ); 36 | 37 | var jwt_token = b64_header + "." + b64_payload + "." + b64_signature; 38 | 39 | newDataset.addRow([ jwt_token ]); 40 | 41 | } catch(erro) { 42 | newDataset.addRow( [ erro.toString() ] ); 43 | } finally { 44 | return newDataset; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /Iniciar form/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 17 | 18 | 19 | 20 |
21 |
22 |
23 |
24 | Parâmetros SBA 25 |
26 |
27 |
28 | 29 |
30 |
31 |
32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | -------------------------------------------------------------------------------- /Datasets customizados/dsk_sinc_table_form.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | function createDataset(fields, constraints, sortFields) { 8 | 9 | log.info( "### Importa INFRAÇÕES ###"); 10 | 11 | var dataset = DatasetBuilder.newDataset(); 12 | 13 | dataset.addColumn( "registros" ); 14 | 15 | var qtdReg = 0; 16 | 17 | var SQL = 'select * from sba_infracao'; 18 | 19 | var constraints = new Array(); 20 | constraints.push(DatasetFactory.createConstraint("SQL", SQL ,SQL, ConstraintType.MUST)); 21 | var dataSet = DatasetFactory.getDataset("select", null, constraints, null); 22 | 23 | for (var i = 0; i < dataSet.rowsCount; i++) { 24 | 25 | var ct = new Array(); 26 | ct.push(DatasetFactory.createConstraint("infracao", dataSet.getValue(i, "infracao") ,'field', ConstraintType.MUST)); 27 | ct.push(DatasetFactory.createConstraint("descricao_infracao", dataSet.getValue(i, "descricao_infracao") ,'field', ConstraintType.MUST)); 28 | ct.push(DatasetFactory.createConstraint("amparo_legal", dataSet.getValue(i, "amparo_legal") ,'field', ConstraintType.MUST)); 29 | ct.push(DatasetFactory.createConstraint("infrator", dataSet.getValue(i, "infrator") ,'field', ConstraintType.MUST)); 30 | ct.push(DatasetFactory.createConstraint("gravidade", dataSet.getValue(i, "gravidade") ,'field', ConstraintType.MUST)); 31 | ct.push(DatasetFactory.createConstraint("orgao_competente", dataSet.getValue(i, "orgao_competente") ,'field', ConstraintType.MUST)); 32 | ct.push(DatasetFactory.createConstraint("valor", dataSet.getValue(i, "valor") ,'field', ConstraintType.MUST)); 33 | ct.push(DatasetFactory.createConstraint("descritor", dataSet.getValue(i, "infracao") + ' - ' + dataSet.getValue(i, "descricao_infracao") ,'field', ConstraintType.MUST)); 34 | 35 | ct.push(DatasetFactory.createConstraint("parentDocumentId", "337527" ,null, ConstraintType.MUST)); 36 | var ds = DatasetFactory.getDataset("processo_movimento", null, ct, null); 37 | 38 | qtdReg++ 39 | 40 | } 41 | 42 | dataset.addRow( new Array( String(qtdReg) ) ); 43 | 44 | return dataset; 45 | 46 | } 47 | 48 | function onMobileSync(user) { 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Iniciar Processo via Rest/javascript.js: -------------------------------------------------------------------------------- 1 | function startProcess() { 2 | var token = { 3 | 'public': '', 4 | 'secret': '' 5 | }; 6 | var oauth = OAuth({ 7 | consumer: { 8 | 'public': '', 9 | 'secret': '' 10 | }, 11 | signature_method: 'HMAC-SHA1' 12 | }); 13 | 14 | var request_data = { 15 | url: 'https://sua_url.com.br:8080/process-management/api/v2/processes/comunicacao_clientes/start', 16 | method: 'POST', 17 | ajaxData: JSON.stringify({ 18 | 'targetState': '102', 19 | 'comment': "", 20 | 'formFields': { 21 | "empresa" : "01", //Opções = '01' (TANAC S.A.),'06' (TANAC S.A. RIO GRANDE); 22 | "cnpj_cliente": "xx.xxx.xxx/xxxx-xx", 23 | "nom_cliente": "Nome Cliente", 24 | "cidade": "cidade", 25 | "cod_cidade": "cod_cidade", 26 | "den_cidade": "den_cidade", 27 | "uf": "uf", 28 | "pais": "pais", 29 | "cod_pais": "cod_pais", 30 | "cod_mercado": "cod_mercado", 31 | "contato": "contato", 32 | "telefone": "telefone", 33 | "email": "email", 34 | "cod_tipo": "cod_tipo", //Opções = '001' (Informações Sobre Produto),'002' (Consultas / Solicitações),'003' (Reclamações),'004' (Sugestões); 35 | "resumo": "resumo", 36 | "descricao": "descricao", 37 | } 38 | }), 39 | data: {} 40 | }; 41 | 42 | $.ajax({ 43 | url: request_data.url, 44 | type: request_data.method, 45 | data: request_data.ajaxData, 46 | contentType: "application/json", 47 | headers: oauth.toHeader(oauth.authorize(request_data, token)), 48 | success: function(data) { 49 | console.log(data); 50 | console.log(data.processInstanceId); //processo Fluig 51 | }, 52 | error: function(xhr, status, error) { 53 | console.log(xhr, status, error); 54 | } 55 | }); 56 | }; 57 | -------------------------------------------------------------------------------- /Datasets customizados/ds_create_folder.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | 8 | function createDataset(fields, constraints, sortFields) { 9 | 10 | var newDataset = DatasetBuilder.newDataset(); 11 | newDataset.addColumn('FOLDER'); 12 | 13 | var listaConstraits = {}; 14 | if (constraints != null) { 15 | for (var i = 0; i < constraints.length; i++) { 16 | listaConstraits[constraints[i].fieldName] = constraints[i].initialValue; 17 | } 18 | } 19 | 20 | try{ 21 | 22 | //Instancia um novo documento e define as propriedades básicas 23 | var dto = docAPI.newDocumentDto(); 24 | dto.setDocumentDescription( listaConstraits['FOLDER_NAME'] ); 25 | dto.setAdditionalComments(''); 26 | dto.setDocumentType(1); 27 | dto.setParentDocumentId(parseInt( listaConstraits['PARENT_FOLDER_CODE'] )); 28 | dto.setInheritSecurity( true ); 29 | dto.setDownloadEnabled( true ); 30 | 31 | var dtosSecurity = new Array(); 32 | 33 | if( listaConstraits['GROUP_HIDDEN'] != undefined 34 | && listaConstraits['GROUP_HIDDEN'] != null 35 | && listaConstraits['GROUP_HIDDEN'] != '' ){ 36 | 37 | var dtoGroupRestrictionSecurity = docAPI.newDocumentSecurityConfigDto(); 38 | dtoGroupRestrictionSecurity.setAttributionType(2); 39 | dtoGroupRestrictionSecurity.setAttributionValue('comercial_hydrowheel_externo'); 40 | dtoGroupRestrictionSecurity.setPermission(false); 41 | dtoGroupRestrictionSecurity.setShowContent(true); 42 | dtoGroupRestrictionSecurity.setDownloadEnabled(true); 43 | dtoGroupRestrictionSecurity.setSecurityLevel(0); 44 | 45 | dtosSecurity.push(dtoGroupRestrictionSecurity); 46 | } 47 | 48 | var FOLDER = docAPI.createFolder(dto, dtosSecurity, null); 49 | log.info("Folder successfully createad: ID :" + FOLDER.getDocumentId()); 50 | 51 | newDataset.addRow( new Array( FOLDER.getDocumentId() ) ); 52 | 53 | } catch (e){ 54 | log.info( "ERROOOOOO"+ e.getMessage() ); 55 | newDataset.addRow( new Array( ( new Date() ).toString(), 'ERRO', e.getMessage() ) ); 56 | } finally { 57 | 58 | } 59 | 60 | return newDataset; 61 | 62 | } 63 | 64 | function onMobileSync(user) { 65 | 66 | } -------------------------------------------------------------------------------- /Consumir Dataset Publico/dataset.js: -------------------------------------------------------------------------------- 1 | const publicDataset = { 2 | 3 | retornaToken: function(){ 4 | var token = { 5 | 'public': '', 6 | 'secret': '' 7 | }; 8 | return token; 9 | }, 10 | retornaOauth: function() { 11 | var oauth = OAuth({ 12 | consumer: { 13 | 'public': '', 14 | 'secret': '' 15 | }, 16 | signature_method: 'HMAC-SHA1' 17 | }); 18 | return oauth; 19 | }, 20 | createConstraint: function(field, initialValue, finalValue, type, likeSearch) { 21 | return { 22 | "_field": field, 23 | "_initialValue": initialValue, 24 | "_finalValue": finalValue, 25 | "_type": type || 1, 26 | "_likeSearch" : likeSearch || false 27 | }; 28 | }, 29 | getDataset: function(datasetName, fields, constratins, order, cb) { 30 | console.log(datasetName, fields, constratins, order); 31 | var self = this; 32 | var url = 'SUA URL' // ou WCMAPI.getServerURL(); para widget fluig 33 | var d = $.Deferred(); 34 | var token = this.retornaToken(); 35 | var oauth = this.retornaOauth(); 36 | var request_data = { 37 | url: url+'/api/public/ecm/dataset/datasets', 38 | method: 'POST', 39 | ajaxData: JSON.stringify({ 40 | "name":datasetName, 41 | "fields": fields || [], 42 | "constraints":constratins || [], 43 | "order": order || [] 44 | }), 45 | data: {} 46 | }; 47 | 48 | $.ajax({ 49 | url: request_data.url, 50 | type: request_data.method, 51 | data: request_data.ajaxData, 52 | contentType: "application/json", 53 | headers: oauth.toHeader(oauth.authorize(request_data, token)) 54 | }).pipe(function(p){ 55 | return p.content; 56 | }).done(function(result){ 57 | d.resolve(result); 58 | cb.success(result); 59 | }).fail(function(data){ 60 | console.log(data) 61 | d.reject 62 | cb.error(data); 63 | }); 64 | 65 | return d; 66 | }, 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /Datasets customizados/dsk_processTask.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | function createDataset(fields, constraints, sortFields) { 8 | 9 | var listaConstraits = {}; 10 | 11 | listaConstraits['cod_processo'] = 'cadastro_item'; 12 | if (constraints != null) { 13 | for (var i = 0; i < constraints.length; i++) { 14 | listaConstraits[ constraints[i].fieldName.trim() ] = constraints[i].initialValue; 15 | log.info('fieldName.....'+constraints[i].fieldName+'...value....'+constraints[i].initialValue); 16 | } 17 | } 18 | log.info( 'Start dataset ' ); 19 | 20 | var newDataset = DatasetBuilder.newDataset(); 21 | newDataset.addColumn( 'cod_atividade' ); 22 | newDataset.addColumn( 'den_atividade' ); 23 | // newDataset.addColumn( 'idi_tip_estado' ); 24 | 25 | 26 | var processId = listaConstraits['cod_processo']; 27 | 28 | var constraints = new Array(); 29 | constraints.push(DatasetFactory.createConstraint("processId", processId , processId, ConstraintType.MUST)); 30 | constraints.push(DatasetFactory.createConstraint("active", 'true' ,'true', ConstraintType.MUST)); 31 | var dataSet = DatasetFactory.getDataset("workflowProcess", null, constraints, ["workflowProcessPK.processInstanceId"]); 32 | 33 | if ( dataSet != null && dataSet != undefined ){ 34 | if ( dataSet.rowsCount > 0){ 35 | var versao = dataSet.getValue(dataSet.rowsCount -1, "version"); 36 | 37 | var SQL = " select NUM_SEQ , DES_ESTADO from estado_proces where COD_DEF_PROCES = '"+processId+"' and NUM_VERS = "+versao+" and COD_MECAN_ATRIBUIC != '' " 38 | var ct = new Array(); 39 | ct.push(DatasetFactory.createConstraint("SQL", SQL , null, ConstraintType.MUST)); 40 | ct.push(DatasetFactory.createConstraint("DATABASE", 'java:/jdbc/FluigDS' , null, ConstraintType.MUST)); 41 | 42 | var ds = DatasetFactory.getDataset("select", null, ct, null); 43 | 44 | if ( ds != null && ds != undefined){ 45 | if ( ds.rowsCount > 0){ 46 | for (var i=0; i < ds.rowsCount; i++){ 47 | var arr = new Array(); 48 | arr.push( ds.getValue(i, 'num_seq' ) ); 49 | arr.push( ds.getValue(i, 'des_estado') ); 50 | // arr.push( ds.getValue(i, 'idi_tip_estado') ); 51 | newDataset.addRow(arr); 52 | } 53 | } 54 | } 55 | 56 | } 57 | } 58 | 59 | return newDataset; 60 | 61 | 62 | 63 | } 64 | function onMobileSync(user) { 65 | 66 | } -------------------------------------------------------------------------------- /Datasets customizados/dsk_compacta_zip.js: -------------------------------------------------------------------------------- 1 | function defineStructure() {} 2 | function onSync(lastSyncDate) {} 3 | function onMobileSync(user) {} 4 | function createDataset(fields, constraints, sortFields) { 5 | 6 | // 422760 7 | // 422752 8 | 9 | var newDataset = DatasetBuilder.newDataset(); 10 | newDataset.addColumn( 'retorno' ); 11 | 12 | try{ 13 | 14 | var filePaths = []; 15 | filePaths.push( getFile('422760') ); //Passar Document ID 16 | filePaths.push( getFile('422752') ); 17 | 18 | f = new java.io.File("/tmp/teste.zip"); // Caminho onde arquivo será gerado 19 | 20 | var out = new java.util.zip.ZipOutputStream(new java.io.FileOutputStream(f)); 21 | 22 | for (var i = 0; i < filePaths.length; i++){ 23 | 24 | newDataset.addRow( new Array( filePaths[i] ) ); 25 | var e = new java.util.zip.ZipEntry(filePaths[i].getName()); 26 | out.putNextEntry(e); 27 | 28 | var data = new java.nio.file.Files.readAllBytes( new java.nio.file.Paths.get( filePaths[i] )); 29 | 30 | // var data = sb.toString().getBytes(); 31 | out.write(data, 0, data.length); 32 | out.closeEntry(); 33 | 34 | } 35 | 36 | 37 | 38 | out.close(); 39 | 40 | 41 | 42 | } catch(e){ 43 | 44 | newDataset.addRow( new Array( erro.toString() ) ); 45 | 46 | } finally{ 47 | 48 | return newDataset; 49 | 50 | } 51 | 52 | 53 | } 54 | 55 | function getFile(anexo) { 56 | var sql = " select sit.storage, doc.nr_documento, doc.nr_versao, doc.nm_arquivo_fisico, doc.ds_principal_documento "+ 57 | " from documento doc "+ 58 | " join fdn_volume vol on (vol.TENANT_ID = doc.COD_EMPRESA "+ 59 | " and vol.VOLUME_CODE = doc.COD_VOL_FISIC) "+ 60 | " left join fdn_volumesite sit on (sit.volume_id = vol.volume_id) "+ 61 | " where doc.cod_empresa = '1' "+ 62 | " and doc.NR_DOCUMENTO = "+ anexo +" "+ 63 | " and doc.VERSAO_ATIVA = 1 "; 64 | 65 | var ct = new Array(); 66 | ct.push(DatasetFactory.createConstraint('DATABASE', 'java:/jdbc/FluigDS', null, ConstraintType.MUST) ); 67 | ct.push(DatasetFactory.createConstraint('SQL', sql, null, ConstraintType.MUST) ); 68 | dsPath = DatasetFactory.getDataset("select", null, ct, null); 69 | if( dsPath.rowsCount > 0 ){ 70 | 71 | var filePath = dsPath.getValue(0,'storage')+'public/'+dsPath.getValue(0,'nr_documento')+'/'+dsPath.getValue(0,'nr_versao')+'/'+dsPath.getValue(0,'nm_arquivo_fisico'); 72 | // log.info( 'filePath......'+filePath ); 73 | 74 | var file = new java.io.File(filePath); 75 | // log.info(file); 76 | 77 | return file; 78 | } 79 | } -------------------------------------------------------------------------------- /Exemplos de impressão/imprimir table.js: -------------------------------------------------------------------------------- 1 | // bind 2 | 'load-imprimir': ['click_imprimir'], 3 | 4 | imprimir: function(el, ev){ 5 | //Declarar variáveis globais rContent e rHeader e dataTable da table 6 | var selected = tbl_Oms.getRow(tbl_Oms.selectedRows()[0]); 7 | var rContent = rcOms; 8 | var rHeader = rhOms; 9 | var data = tbl_Oms.getData(); 10 | 11 | var html = " "+ 12 | " "+ 13 | " "+ 14 | " "+ 23 | " "+ 24 | " "; 25 | 26 | var htmlColumn = ""; 27 | 28 | for( var j = 0; j < rContent.length; j++ ){ 29 | console.log('header......', rContent[j], rHeader[j]['title'], rHeader[j]['width'] ); 30 | if( rHeader[j]['width'] != '0' 31 | && rHeader[j]['width'] != '0%' 32 | && rHeader[j]['width'] != undefined ){ 33 | htmlColumn += " "+ rHeader[j]['title'] +" " 34 | } 35 | } 36 | 37 | html += "" + 38 | " " + 39 | " " + 42 | " " + 43 | "
" + 40 | " Resumo Viagem: "+ selected.viagem +"" + 41 | "
" + 44 | "
" + 45 | "" + 46 | " " + 47 | " "+ htmlColumn + 48 | " "; 49 | 50 | for(var i = 0; i < data.length; i++ ){ 51 | // console.log('entrou...... print '); 52 | 53 | html += ""; 54 | 55 | for( var j = 0; j < rContent.length; j++ ){ 56 | if( rHeader[j]['width'] != '0' 57 | && rHeader[j]['width'] != '0%' 58 | && rHeader[j]['width'] != undefined ){ 59 | if( rContent[j] != 'matricula' && rContent[j] != 'usuario' ){ 60 | html += " "; 61 | } 62 | } 63 | } 64 | html += " "; 65 | } 66 | 67 | html += "
"+ data[i][rContent[j]] +"
"+ 68 | " "+ 69 | " "; 70 | 71 | // console.log('html.....',html); 72 | 73 | var WindowObject = window.open('', "PrintWindow", "width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes"); 74 | //WindowObject.document.writeln(DocumentContainer.innerHTML); 75 | WindowObject.document.writeln(html); 76 | WindowObject.document.close(); 77 | WindowObject.focus(); 78 | WindowObject.print(); 79 | WindowObject.close(); 80 | // modalOM.remove(); 81 | 82 | }, -------------------------------------------------------------------------------- /Iniciar widget/view.ftl: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 | <#-- Título --> 6 | 16 | 17 | <#-- Painel --> 18 |
19 | <#-- Header --> 20 |
21 |

22 | Filtros 23 |

24 |
25 | <#-- Body --> 26 |
27 |
28 |
29 | 30 |
31 | 32 | 33 |
34 | 35 |
36 | 37 | 42 |
43 | 44 |
45 | 46 |
47 | 48 |
49 |
50 | 51 |
52 | 53 |
54 |
55 | 56 | 60 | 66 |
67 |
68 |
69 |
70 | 71 |
72 |
73 |
74 | 75 | <#-- table para listar dados --> 76 |
77 |
78 |
79 |
80 |
81 |
82 |
-------------------------------------------------------------------------------- /Datasets customizados/dsk_table_name.js: -------------------------------------------------------------------------------- 1 | function defineStructure() {} 2 | function onSync(lastSyncDate) {} 3 | 4 | function createDataset(fields, constraints, sortFields) { 5 | 6 | var listaConstraits = {}; 7 | 8 | // listaConstraits['dataSet'] = 'veiculo'; 9 | // listaConstraits['table'] = 'rateio'; 10 | 11 | 12 | var newDataset = DatasetBuilder.newDataset(); 13 | newDataset.addColumn( 'table' ); 14 | newDataset.addColumn( 'tableFilha' ); 15 | 16 | if (constraints != null) { 17 | for (var i = 0; i < constraints.length; i++) { 18 | listaConstraits[ constraints[i].fieldName.trim() ] = constraints[i].initialValue; 19 | log.info('fieldName...'+ constraints[i].fieldName.trim() + ' value...' + constraints[i].initialValue); 20 | } 21 | } 22 | 23 | log.info( 'Start dataset ' ); 24 | 25 | try{ 26 | 27 | log.info( '$001... ' ); 28 | var contextWD = new javax.naming.InitialContext(); 29 | log.info( '$002... ' ); 30 | var dataSourceWD = contextWD.lookup( "java:/jdbc/FluigDS" ); 31 | log.info( '$003... ' ); 32 | var connectionWD = dataSourceWD.getConnection(); 33 | log.info( '$004... ' ); 34 | 35 | // ITEM 36 | 37 | var sql = ""; 38 | if( listaConstraits['table'] != "" 39 | && listaConstraits['table'] != null 40 | && listaConstraits['table'] != undefined ){ 41 | sql = " select doc.COD_LISTA, " + 42 | " ml.COD_LISTA_FILHO as COD_FILHO "+ 43 | " from documento doc "+ 44 | " join META_LISTA_REL ml on (ml.COD_EMPRESA = doc.COD_EMPRESA "+ 45 | " and ml.COD_LISTA_PAI = doc.COD_LISTA "+ 46 | " and ml.COD_TABELA = '"+ listaConstraits['table'] +"' ) "+ 47 | " where doc.COD_EMPRESA = "+ getValue("WKCompany") + 48 | " and doc.NM_DATASET = '"+ listaConstraits['dataSet'] +"' "+ 49 | " and doc.VERSAO_ATIVA = 1 "; 50 | }else{ 51 | sql = " select doc.COD_LISTA "+ 52 | " from documento doc "+ 53 | " where doc.COD_EMPRESA = "+ getValue("WKCompany") + 54 | " and doc.NM_DATASET = '"+ listaConstraits['dataSet'] +"' "+ 55 | " and doc.VERSAO_ATIVA = 1 "; 56 | } 57 | 58 | log.info( '$005 documento... '+sql ); 59 | statementWD = connectionWD.prepareStatement(sql); 60 | rsWD = statementWD.executeQuery(); 61 | 62 | if( rsWD.next() ){ 63 | log.info('table...' + rsWD.getString( 'COD_LISTA' )); 64 | var arr = new Array(); 65 | arr.push( "ML"+ getLPad( getValue("WKCompany"), '000' ) + getLPad( rsWD.getString( 'COD_LISTA' ), '000' ) ); 66 | if( listaConstraits['table'] != "" 67 | && listaConstraits['table'] != null 68 | && listaConstraits['table'] != undefined ){ 69 | arr.push( "ML"+ getLPad( getValue("WKCompany"), '000' ) + getLPad( rsWD.getString( 'COD_FILHO' ), '000' ) ); 70 | }else{ 71 | arr.push( "" ); 72 | } 73 | newDataset.addRow( arr ); 74 | 75 | }else{ 76 | 77 | sql = " SELECT a.COD_LISTA "+ 78 | " FROM serv_dataset a "+ 79 | " WHERE a.COD_EMPRESA = "+ getValue("WKCompany") + 80 | " AND a.IS_ACTIVE = 1 "+ 81 | " and a.COD_DATASET = '"+ listaConstraits['dataSet'] +"' "; 82 | 83 | log.info( '$005 serv_dataset... '+sql ); 84 | statementWD = connectionWD.prepareStatement(sql); 85 | rsWD = statementWD.executeQuery(); 86 | if( rsWD.next() ){ 87 | var arr = new Array(); 88 | arr.push( "MD"+ getLPad( getValue("WKCompany"), '000' ) + getLPad( rsWD.getString( 'COD_LISTA' ), '000' ) ); 89 | arr.push( "" ); 90 | newDataset.addRow( arr ); 91 | } 92 | } 93 | 94 | } catch (e){ 95 | log.info( "ERROOOOOO"+ e.toString() ); 96 | } 97 | finally { 98 | log.info('##### 6 #####'); 99 | if(statementWD != null) statementWD.close(); 100 | if(connectionWD != null) connectionWD.close(); 101 | } 102 | return newDataset; 103 | 104 | 105 | } 106 | 107 | function onMobileSync(user) { 108 | 109 | } 110 | 111 | function getLPad( valor, pad){ 112 | var str = "" + valor; 113 | var ans = pad.substring(0, pad.length - str.length) + str; 114 | return ans; 115 | } -------------------------------------------------------------------------------- /Datasets customizados/sendFileToWS.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | function createDataset(fields, constraints, sortFields) { 8 | 9 | var newDataset = DatasetBuilder.newDataset(); 10 | newDataset.addColumn( 'retorno' ); 11 | 12 | var params = {}; 13 | if (constraints != null) { 14 | for (var i = 0; i < constraints.length; i++) { 15 | if( constraints[i].fieldName.trim() == "file" ){ 16 | params[ constraints[i].fieldName.trim() ] = new org.apache.http.entity.mime.content.FileBody( getFile(constraints[i].initialValue ) ); 17 | }else { 18 | params[ constraints[i].fieldName.trim() ] = new org.apache.http.entity.mime.content.StringBody( constraints[i].initialValue ); 19 | log.info('fieldName.....'+constraints[i].fieldName+'...value....'+constraints[i].initialValue); 20 | } 21 | } 22 | } 23 | 24 | try{ 25 | // log.info("COMEÇOU"); 26 | 27 | var client = org.apache.http.impl.client.HttpClients.createDefault(); 28 | // log.info( client ); 29 | 30 | var url = "SUA URL AQUI"; 31 | var post = new org.apache.http.client.methods.HttpPost(url); 32 | // log.info(post); 33 | // var par = new org.apache.http.entity.mime.content.StringBody('91'); 34 | var reqEntity = new org.apache.http.entity.mime.MultipartEntityBuilder.create(); 35 | 36 | for ( var key in params ){ 37 | // log.info( key + " - " + params[key] ); 38 | reqEntity.addPart(key, params[key]); 39 | } 40 | 41 | // log.info( reqEntity ); 42 | 43 | var builEntity = reqEntity.build(); 44 | // log.info( builEntity ); 45 | 46 | post.setEntity(builEntity); 47 | // log.info(post); 48 | var response = client.execute(post); 49 | var responseJson = org.apache.http.util.EntityUtils.toString(response.getEntity()); 50 | // log.info (responseJson); 51 | 52 | if ( responseJson == "" || responseJson.isEmpty()) { 53 | throw "Retorno esta vazio"; 54 | } else { 55 | var jr = JSON.parse(responseJson); 56 | // printLog( 'info', "## success ## " + jr.success); 57 | 58 | if( !jr.success ){ 59 | throw 'Erro na integração'; 60 | } 61 | 62 | if( jr.data != null ){ 63 | newDataset.addRow( new Array( JSON.stringify( jr.data) ) ); 64 | } 65 | } 66 | 67 | } catch(erro) { 68 | printLog( 'erro', "ERROOOOOO" + erro.toString() ); 69 | newDataset.addRow( new Array( erro.toString() ) ); 70 | // throw erro.toString(); 71 | } 72 | 73 | return newDataset; 74 | 75 | } 76 | function onMobileSync(user) { 77 | 78 | } 79 | 80 | 81 | var debug = true; 82 | 83 | function printLog( tipo, msg ){ 84 | 85 | if( debug ){ 86 | var msgs = getValue("WKDef")+" - "+getValue("WKNumProces")+" - "+msg 87 | if( tipo == 'info'){ 88 | log.info( msgs ); 89 | }else if( tipo == 'error' ){ 90 | log.error( msgs ); 91 | }else if( tipo == 'fatal' ){ 92 | log.fatal( msgs ); 93 | }else{ 94 | log.warn( msgs ); 95 | } 96 | } 97 | } 98 | 99 | function getFile(anexo) { 100 | var sql = " select sit.storage, doc.nr_documento, doc.nr_versao, doc.nm_arquivo_fisico, doc.ds_principal_documento "+ 101 | " from documento doc "+ 102 | " join fdn_volume vol on (vol.TENANT_ID = doc.COD_EMPRESA "+ 103 | " and vol.VOLUME_CODE = doc.COD_VOL_FISIC) "+ 104 | " left join fdn_volumesite sit on (sit.volume_id = vol.volume_id) "+ 105 | " where doc.cod_empresa = '1' "+ 106 | " and doc.NR_DOCUMENTO = "+ anexo +" "+ 107 | " and doc.VERSAO_ATIVA = 1 "; 108 | 109 | var ct = new Array(); 110 | ct.push(DatasetFactory.createConstraint('DATABASE', 'java:/jdbc/FluigDS', null, ConstraintType.MUST) ); 111 | ct.push(DatasetFactory.createConstraint('SQL', sql, null, ConstraintType.MUST) ); 112 | dsPath = DatasetFactory.getDataset("select", null, ct, null); 113 | if( dsPath.rowsCount > 0 ){ 114 | 115 | var filePath = dsPath.getValue(0,'storage')+'public/'+dsPath.getValue(0,'nr_documento')+'/'+dsPath.getValue(0,'nr_versao')+'/'+dsPath.getValue(0,'nm_arquivo_fisico'); 116 | // log.info( 'filePath......'+filePath ); 117 | 118 | var file = new java.io.File(filePath); 119 | // log.info(file); 120 | 121 | return file; 122 | } 123 | } -------------------------------------------------------------------------------- /Dataset com paginação/javascript.js: -------------------------------------------------------------------------------- 1 | var dataTable = null; 2 | var dadosDatatable = []; 3 | var rContent = []; 4 | var rHeader = []; 5 | 6 | function loadDataTable(){ 7 | // console.log('loadReceitas'); 8 | rContent = ['nom_funcionario','cod_usuario','cod_usuario_rm','cod_usuario_fluig']; 9 | 10 | rHeader = [ {'title': 'Nome','dataorder': 'nom_funcionario','width':'10%' }, 11 | {'title': 'Logix','dataorder': 'cod_usuario','width':'10%' }, 12 | {'title': 'RM','dataorder': 'cod_usuario_rm','width':'10%' }, 13 | {'title': 'Fluig','dataorder': 'cod_usuario_fluig','width':'10%' }, 14 | ]; 15 | 16 | dataTable = FLUIGC.datatable('#idtable_' + $this.instanceId, { 17 | dataRequest: dadosDatatable, 18 | renderContent: rContent, 19 | limit:10, 20 | responsive: true, 21 | tableStyle:'table table-striped table-responsive table-bordered table-condensed', 22 | emptyMessage: '
Nenhum dado encontrado!
', 23 | header: rHeader, 24 | search: { 25 | enabled: false, 26 | onSearch: function(res) { 27 | console.log( res ); 28 | var data = dadosDatatable; 29 | var search = data.filter(function(el) { 30 | return (el.data_receita.toUpperCase().indexOf(res.toUpperCase()) >= 0 || 31 | el.tipo_receita.toUpperCase().indexOf(res.toUpperCase()) >= 0 || 32 | el.valor_receita.toUpperCase().indexOf(res.toUpperCase()) >= 0 || 33 | el.valor_ajuda_custo.toUpperCase().indexOf(res.toUpperCase()) >= 0 ) 34 | }); 35 | dataTable.reload(search); 36 | }, 37 | onlyEnterkey: false, 38 | searchAreaStyle: 'col-md-3' 39 | }, 40 | scroll: { 41 | target: '#idtable_'+$this.instanceId, 42 | enabled: false 43 | }, 44 | navButtons: { 45 | enabled: false, 46 | }, 47 | draggable: { 48 | enabled: false 49 | }, 50 | 51 | }, function(err, data) { 52 | if (err) { 53 | FLUIGC.toast({ 54 | message: err, 55 | type: 'danger' 56 | }); 57 | }else{ 58 | loadWindow.hide(); 59 | } 60 | }); 61 | 62 | loadDadosDataTable(); 63 | 64 | } 65 | 66 | function loadDadosDataTable(){ 67 | loadWindow.show(); 68 | var SQL = "select * "+ 69 | " from usuarios p "+ 70 | "where (select count(*) from log_usu_bloq "+ 71 | " where usuario = p.cod_usuario "+ 72 | " and today between nvl(dat_ini_bloqueio,today) "+ 73 | " and nvl(dat_fim_bloqueio,today) ) = 0 "; 74 | 75 | var constraints = new Array(); 76 | constraints.push(DatasetFactory.createConstraint("SQL", SQL ,SQL, ConstraintType.MUST)); 77 | constraints.push(DatasetFactory.createConstraint("DATABASE", 'java:/jdbc/LogixDS' ,null, ConstraintType.MUST)); 78 | 79 | var callback = { 80 | success: function(dataSet) { 81 | console.log(dataSet.values); 82 | if( dataSet != null && dataSet != undefined ){ 83 | 84 | $("#paginationTable").pagination({ 85 | dataSource: regs, 86 | pageSize: $('#pagesize').val(), 87 | showGoInput: true, 88 | showGoButton: true, 89 | goButtonText: 'Ir', 90 | className: 'paginationjs-big', 91 | // autoHidePrevious: true, 92 | // autoHideNext: true, 93 | formatResult: function(data) { 94 | var regs = new Array(); 95 | for (var i = 0; i < data.length; i++) { 96 | var datatableRow = { cod_usuario: data[i]['cod_usuario'], 97 | nom_funcionario: data[i]['nom_funcionario'] 98 | } 99 | regs.push(datatableRow); 100 | } 101 | return regs; 102 | }, 103 | callback: function(paginatedData, pagination){ 104 | console.log(paginatedData, pagination); 105 | dataTable.reload(paginatedData); 106 | loadWindow.hide(); 107 | } 108 | }); 109 | 110 | } else { 111 | toast('Nenhum dado encontrado', 'warning'); 112 | } 113 | 114 | }, 115 | error: function(jqXHR, textStatus, errorThrown) { 116 | console.log(jqXHR, textStatus, errorThrown); 117 | } 118 | }; 119 | 120 | var dataSet = DatasetFactory.getDataset("select", null, constraints, null, callback); 121 | 122 | } -------------------------------------------------------------------------------- /Datasets customizados/select.js: -------------------------------------------------------------------------------- 1 | function defineStructure() {} 2 | function onSync(lastSyncDate) {} 3 | 4 | function createDataset(fields, constraints, sortFields) { 5 | 6 | log.info( 'Start dataset ' ); 7 | var dataset = DatasetBuilder.newDataset(); 8 | 9 | var connectionWD; 10 | var statementWD; 11 | try{ 12 | 13 | var dataBase = 'java:/jdbc/FluigDS'; 14 | var SQLconstrat = " SELECT u.COD_DEF_PROCES, def.DES_DEF_PROCES, u.num_proces, v.num_seq, t.NUM_SEQ_MOVTO, case when v.des_estado is not null then v.des_estado when u.status = 0 then 'Aberto' when u.status = 1 then 'Cancelado' else '' end as des_estado, x.num_seq_estado, u.status, case u.STATUS when 0 then 'Aberto' when 2 then 'Finalizado' when 1 then 'Cancelado' else '' end as den_status, case when u.STATUS = 0 and t.deadline < NOW() then 'Atrasado' when u.STATUS = 0 then v.DES_ESTADO when u.STATUS = 2 then 'Finalizado' when u.STATUS = 1 then 'Cancelado' else '' end as den_status_processo, ifnull( t.deadline, '' ) as prazo_tarefa, t.deadline as deadline, u.COD_MATR_REQUISIT, na.LOGIN as LOGIN_REQUISIT, " + 15 | " t.CD_MATRICULA, n.LOGIN, n.USER_STATE, r.FULL_NAME as full_name, ra.FULL_NAME as 'full_name_requisit', u.END_DATE, u.START_DATE from proces_workflow u join histor_proces x on (x.COD_EMPRESA = u.COD_EMPRESA and x.NUM_PROCES = u.NUM_PROCES ) join tar_proces t on (x.COD_EMPRESA = t.COD_EMPRESA and x.NUM_PROCES = t.NUM_PROCES and case when u.STATUS = 1 then x.NUM_SEQ_MOVTO else x.NUM_SEQ_MOVTO_ANT end = t.NUM_SEQ_MOVTO ) join estado_proces v on (v.COD_EMPRESA = t.COD_EMPRESA and v.COD_DEF_PROCES = u.COD_DEF_PROCES and v.NUM_SEQ = x.NUM_SEQ_ESTADO and v.NUM_VERS = u.NUM_VERS) left join fdn_usertenant n on (n.USER_CODE = t.CD_MATRICULA ) left join fdn_user r on ( r.USER_ID = n.USER_ID ) join fdn_usertenant na on (na.USER_CODE = u.COD_MATR_REQUISIT ) join fdn_user ra on ( ra.USER_ID = na.USER_ID ) join def_proces def on (def.cod_empresa = u.cod_empresa and def.cod_def_proces = u.cod_def_proces ) WHERE u.STATUS in (1) and x.NUM_SEQ_MOVTO = ( select max( y.NUM_SEQ_MOVTO ) from histor_proces y where y.COD_EMPRESA = x.COD_EMPRESA and y.NUM_PROCES = x.NUM_PROCES ) and u.COD_DEF_PROCES = 'acertoViagem' " ; 16 | var created = false; 17 | 18 | if (constraints != null) { 19 | for (var i = 0; i < constraints.length; i++) { 20 | log.info( 'Constrait '+i ); 21 | log.info( constraints[i] ); 22 | if ( constraints[i].fieldName.toUpperCase() == 'SQL' ){ 23 | SQLconstrat = constraints[i].initialValue; 24 | }else if( constraints[i].fieldName.toUpperCase() == 'DATABASE' ) { 25 | dataBase = constraints[i].initialValue; 26 | } 27 | } 28 | } 29 | 30 | log.info( '$001... ' ); 31 | var contextWD = new javax.naming.InitialContext(); 32 | log.info( '$002... ' ); 33 | var dataSourceWD = contextWD.lookup( dataBase ); 34 | log.info( '$003... ' ); 35 | connectionWD = dataSourceWD.getConnection(); 36 | log.info( '$004... ' ); 37 | 38 | 39 | // var SQL = "ALTER SESSION set NLS_DATE_FORMAT = 'DD/MM/YYYY'"; 40 | // var statementWD = connectionWD.prepareStatement(SQL); 41 | // var rsWD = statementWD.executeUpdate(); 42 | 43 | log.info( '$005... ' ); 44 | statementWD = connectionWD.prepareStatement(SQLconstrat); 45 | rsWD = statementWD.executeQuery(); 46 | var columnCount = rsWD.getMetaData().getColumnCount(); 47 | 48 | for(var i=1;i<=columnCount; i++) { 49 | log.info('$0088.....'+ rsWD.getMetaData().getColumnName(i)+' '+rsWD.getMetaData().getColumnName(i).toLowerCase() ); 50 | dataset.addColumn(rsWD.getMetaData().getColumnLabel(i).toLowerCase()); 51 | } 52 | created = true; 53 | 54 | while(rsWD.next()) { 55 | 56 | var Arr = new Array(); 57 | 58 | for(var i=1;i<=columnCount; i++) { 59 | var obj = rsWD.getObject( rsWD.getMetaData().getColumnLabel(i) ); 60 | if(null!=obj){ 61 | Arr[i-1] = rsWD.getObject( rsWD.getMetaData().getColumnLabel(i) ).toString(); 62 | }else{ 63 | Arr[i-1] = "null"; 64 | } 65 | } 66 | dataset.addRow(Arr); 67 | } 68 | 69 | rsWD.close(); 70 | statementWD.close(); 71 | connectionWD.close(); 72 | } catch (e){ 73 | log.info( "ERRO"+ e.getMessage() ); 74 | dataset.addColumn('status'); 75 | dataset.addRow( new Array('Erro: '+e.getMessage()) ); 76 | } 77 | finally { 78 | log.info('##### 6 #####'); 79 | if(statementWD != null) statementWD.close(); 80 | if(connectionWD != null) connectionWD.close(); 81 | } 82 | 83 | 84 | return dataset; 85 | } 86 | 87 | function onMobileSync(user) { } -------------------------------------------------------------------------------- /Consumir Dataset Publico/oauth/hmac-sha1.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | var CryptoJS=CryptoJS||function(g,l){var e={},d=e.lib={},m=function(){},k=d.Base={extend:function(a){m.prototype=this;var c=new m;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, 8 | p=d.WordArray=k.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=l?c:4*a.length},toString:function(a){return(a||n).stringify(this)},concat:function(a){var c=this.words,q=a.words,f=this.sigBytes;a=a.sigBytes;this.clamp();if(f%4)for(var b=0;b>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((f+b)%4);else if(65535>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 9 | 32-8*(c%4);a.length=g.ceil(c/4)},clone:function(){var a=k.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b>>2]>>>24-8*(f%4)&255;b.push((d>>>4).toString(16));b.push((d&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],f=0;f>>3]|=parseInt(a.substr(f, 10 | 2),16)<<24-4*(f%8);return new p.init(b,c/2)}},j=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],f=0;f>>2]>>>24-8*(f%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],f=0;f>>2]|=(a.charCodeAt(f)&255)<<24-8*(f%4);return new p.init(b,c)}},h=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}}, 11 | r=d.BufferedBlockAlgorithm=k.extend({reset:function(){this._data=new p.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=h.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,f=c.sigBytes,d=this.blockSize,e=f/(4*d),e=a?g.ceil(e):g.max((e|0)-this._minBufferSize,0);a=e*d;f=g.min(4*a,f);if(a){for(var k=0;ka;a++){if(16>a)m[a]=d[e+a]|0;else{var c=m[a-3]^m[a-8]^m[a-14]^m[a-16];m[a]=c<<1|c>>>31}c=(n<<5|n>>>27)+l+m[a];c=20>a?c+((j&h|~j&g)+1518500249):40>a?c+((j^h^g)+1859775393):60>a?c+((j&h|j&g|h&g)-1894007588):c+((j^h^ 15 | g)-899497514);l=g;g=h;h=j<<30|j>>>2;j=n;n=c}b[0]=b[0]+n|0;b[1]=b[1]+j|0;b[2]=b[2]+h|0;b[3]=b[3]+g|0;b[4]=b[4]+l|0},_doFinalize:function(){var d=this._data,e=d.words,b=8*this._nDataBytes,g=8*d.sigBytes;e[g>>>5]|=128<<24-g%32;e[(g+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(g+64>>>9<<4)+15]=b;d.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=d.clone.call(this);e._hash=this._hash.clone();return e}});g.SHA1=d._createHelper(l);g.HmacSHA1=d._createHmacHelper(l)})(); 16 | (function(){var g=CryptoJS,l=g.enc.Utf8;g.algo.HMAC=g.lib.Base.extend({init:function(e,d){e=this._hasher=new e.init;"string"==typeof d&&(d=l.parse(d));var g=e.blockSize,k=4*g;d.sigBytes>k&&(d=e.finalize(d));d.clamp();for(var p=this._oKey=d.clone(),b=this._iKey=d.clone(),n=p.words,j=b.words,h=0;h>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((f+b)%4);else if(65535>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 9 | 32-8*(c%4);a.length=g.ceil(c/4)},clone:function(){var a=k.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b>>2]>>>24-8*(f%4)&255;b.push((d>>>4).toString(16));b.push((d&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],f=0;f>>3]|=parseInt(a.substr(f, 10 | 2),16)<<24-4*(f%8);return new p.init(b,c/2)}},j=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],f=0;f>>2]>>>24-8*(f%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],f=0;f>>2]|=(a.charCodeAt(f)&255)<<24-8*(f%4);return new p.init(b,c)}},h=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}}, 11 | r=d.BufferedBlockAlgorithm=k.extend({reset:function(){this._data=new p.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=h.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,f=c.sigBytes,d=this.blockSize,e=f/(4*d),e=a?g.ceil(e):g.max((e|0)-this._minBufferSize,0);a=e*d;f=g.min(4*a,f);if(a){for(var k=0;ka;a++){if(16>a)m[a]=d[e+a]|0;else{var c=m[a-3]^m[a-8]^m[a-14]^m[a-16];m[a]=c<<1|c>>>31}c=(n<<5|n>>>27)+l+m[a];c=20>a?c+((j&h|~j&g)+1518500249):40>a?c+((j^h^g)+1859775393):60>a?c+((j&h|j&g|h&g)-1894007588):c+((j^h^ 15 | g)-899497514);l=g;g=h;h=j<<30|j>>>2;j=n;n=c}b[0]=b[0]+n|0;b[1]=b[1]+j|0;b[2]=b[2]+h|0;b[3]=b[3]+g|0;b[4]=b[4]+l|0},_doFinalize:function(){var d=this._data,e=d.words,b=8*this._nDataBytes,g=8*d.sigBytes;e[g>>>5]|=128<<24-g%32;e[(g+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(g+64>>>9<<4)+15]=b;d.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=d.clone.call(this);e._hash=this._hash.clone();return e}});g.SHA1=d._createHelper(l);g.HmacSHA1=d._createHmacHelper(l)})(); 16 | (function(){var g=CryptoJS,l=g.enc.Utf8;g.algo.HMAC=g.lib.Base.extend({init:function(e,d){e=this._hasher=new e.init;"string"==typeof d&&(d=l.parse(d));var g=e.blockSize,k=4*g;d.sigBytes>k&&(d=e.finalize(d));d.clamp();for(var p=this._oKey=d.clone(),b=this._iKey=d.clone(),n=p.words,j=b.words,h=0;h 0 ){ 16 | retorno = dataset.values[0]; 17 | 18 | // var formLink = WCMAPI.getServerURL() + '/webdesk/streamcontrol/'+ retorno['parentDocumentId'] +'/'+ selected.documentid +'/' +retorno['version']+ '/'; editar 19 | WCMAPI = parent.WCMAPI; 20 | 21 | var formLink = WCMAPI.getServerURL() + '/webdesk/streamcontrol/'+ retorno['documentPK.documentId'] +'/0/0/'; 22 | var html = ' '; 23 | 24 | console.log('HTML......',html); 25 | 26 | var modalDocumentEdit = FLUIGC.modal({ 27 | title: 'Novo Registro', 28 | content: html, 29 | id: 'documentEdit', 30 | size : 'full', 31 | actions: [{ 32 | 'label' : 'Confirmar', 33 | 'bind' : 'data-open-modal', 34 | 'classType' : 'btn-success confirmar' 35 | },{ 36 | 'label': 'Fechar', 37 | 'autoClose': true 38 | }] 39 | }, function(err, data) { 40 | if(err) { 41 | 42 | } else { 43 | 44 | } 45 | }); 46 | 47 | $('#iFrameDoc').on('load', function() { 48 | 49 | // Enquadramento de tela 50 | var modalWidth = $('#documentEdit .modal-body').width(); 51 | $('#iFrameDoc').css("width", modalWidth + "px"); 52 | modalWidth = $('#iFrameDoc').contents().find('html').width() - 8; 53 | $('#iFrameDoc').contents().find('html').css('width', modalWidth + "px"); 54 | var screenHeight = $('#iFrameDoc').contents().find('form').height(); 55 | if (screenHeight < 300){ 56 | screenHeight = 300; 57 | } 58 | $('#iFrameDoc').css("height", screenHeight + "px"); 59 | $('#iFrameDoc').contents().find('#printBt').hide(); 60 | 61 | $('.confirmar').click(function() { 62 | console.log('confirmar'); 63 | 64 | var constraintsEntrada = new Array(); 65 | 66 | $('#iFrameDoc').contents().find("input,select,textarea").each(function () { 67 | // if ( $(this).val() != '' ){ 68 | // console.log('looop ',$(this).attr( 'name' ), $(this).val(), $(this).attr( 'type' ) ); 69 | if ( $(this).attr( 'type' ) == 'radio' && $(this).is(':checked')){ 70 | constraintsEntrada.push( DatasetFactory.createConstraint( $(this).attr( 'name' ), $(this).val(), 'field', ConstraintType.MUST ) ); 71 | } 72 | if ( $(this).attr( 'type' ) != 'radio'){ 73 | constraintsEntrada.push( DatasetFactory.createConstraint( $(this).attr( 'name' ), $(this).val(), 'field', ConstraintType.MUST ) ); 74 | } 75 | // } 76 | }); 77 | 78 | // Editar Documento 79 | // constraintsEntrada.push( DatasetFactory.createConstraint( 'documentId', selected.documentid, null, ConstraintType.MUST) ); 80 | 81 | // Se for Iniciar Processo 82 | // constraintsEntrada.push( DatasetFactory.createConstraint( 'processo', 'Chamado', null, ConstraintType.MUST) ); 83 | // constraintsEntrada.push( DatasetFactory.createConstraint( 'atividade', '9', null, ConstraintType.MUST) ); 84 | // constraintsEntrada.push( DatasetFactory.createConstraint( 'iniciarProcesso', 'S', null, ConstraintType.MUST) ); 85 | 86 | // Se for criar um documento 87 | constraintsEntrada.push( DatasetFactory.createConstraint( 'parentDocumentId', retorno['documentPK.documentId'], null, ConstraintType.MUST) ); 88 | 89 | var dataset = DatasetFactory.getDataset( 'processo_movimento', null, constraintsEntrada, null); 90 | 91 | console.log(dataset); 92 | 93 | if (dataset != undefined && dataset != null) { 94 | if (dataset.values.length > 0 ){ 95 | // console.log(dataset); 96 | if (dataset.values[0]["status"] == 'ok') { 97 | toast('Formulário :' + dataset.values[0]['documentId'] +' criado com sucesso!', 'success'); 98 | // Exemplo atribuição de campo 99 | // $('#cod_infracao').val( $('#iFrameDoc').contents().find("#cod_infracao") ); 100 | modalDocumentEdit.remove(); 101 | } else { 102 | toast('Erro ao salvar formulário: ' + dataset.values[0]["status"], 'danger'); 103 | } 104 | 105 | } 106 | } 107 | 108 | }); 109 | 110 | }); 111 | } 112 | 113 | } 114 | 115 | } -------------------------------------------------------------------------------- /Utils/jquery.maskMoney.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jquery-maskmoney - v3.0.2 3 | * jQuery plugin to mask data entry in the input text in the form of money (currency) 4 | * https://github.com/plentz/jquery-maskmoney 5 | * 6 | * Made by Diego Plentz 7 | * Under MIT License (https://raw.github.com/plentz/jquery-maskmoney/master/LICENSE) 8 | */ 9 | !function($){"use strict";$.browser||($.browser={},$.browser.mozilla=/mozilla/.test(navigator.userAgent.toLowerCase())&&!/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.webkit=/webkit/.test(navigator.userAgent.toLowerCase()),$.browser.opera=/opera/.test(navigator.userAgent.toLowerCase()),$.browser.msie=/msie/.test(navigator.userAgent.toLowerCase()));var a={destroy:function(){return $(this).unbind(".maskMoney"),$.browser.msie&&(this.onpaste=null),this},mask:function(a){return this.each(function(){var b,c=$(this);return"number"==typeof a&&(c.trigger("mask"),b=$(c.val().split(/\D/)).last()[0].length,a=a.toFixed(b),c.val(a)),c.trigger("mask")})},unmasked:function(){return this.map(function(){var a,b=$(this).val()||"0",c=-1!==b.indexOf("-");return $(b.split(/\D/).reverse()).each(function(b,c){return c?(a=c,!1):void 0}),b=b.replace(/\D/g,""),b=b.replace(new RegExp(a+"$"),"."+a),c&&(b="-"+b),parseFloat(b)})},init:function(a){return a=$.extend({prefix:"",suffix:"",affixesStay:!0,thousands:",",decimal:".",precision:2,allowZero:!1,allowNegative:!1},a),this.each(function(){function b(){var a,b,c,d,e,f=s.get(0),g=0,h=0;return"number"==typeof f.selectionStart&&"number"==typeof f.selectionEnd?(g=f.selectionStart,h=f.selectionEnd):(b=document.selection.createRange(),b&&b.parentElement()===f&&(d=f.value.length,a=f.value.replace(/\r\n/g,"\n"),c=f.createTextRange(),c.moveToBookmark(b.getBookmark()),e=f.createTextRange(),e.collapse(!1),c.compareEndPoints("StartToEnd",e)>-1?g=h=d:(g=-c.moveStart("character",-d),g+=a.slice(0,g).split("\n").length-1,c.compareEndPoints("EndToEnd",e)>-1?h=d:(h=-c.moveEnd("character",-d),h+=a.slice(0,h).split("\n").length-1)))),{start:g,end:h}}function c(){var a=!(s.val().length>=s.attr("maxlength")&&s.attr("maxlength")>=0),c=b(),d=c.start,e=c.end,f=c.start!==c.end&&s.val().substring(d,e).match(/\d/)?!0:!1,g="0"===s.val().substring(0,1);return a||f||g}function d(a){s.each(function(b,c){if(c.setSelectionRange)c.focus(),c.setSelectionRange(a,a);else if(c.createTextRange){var d=c.createTextRange();d.collapse(!0),d.moveEnd("character",a),d.moveStart("character",a),d.select()}})}function e(b){var c="";return b.indexOf("-")>-1&&(b=b.replace("-",""),c="-"),c+a.prefix+b+a.suffix}function f(b){var c,d,f,g=b.indexOf("-")>-1&&a.allowNegative?"-":"",h=b.replace(/[^0-9]/g,""),i=h.slice(0,h.length-a.precision);return i=i.replace(/^0*/g,""),i=i.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousands),""===i&&(i="0"),c=g+i,a.precision>0&&(d=h.slice(h.length-a.precision),f=new Array(a.precision+1-d.length).join(0),c+=a.decimal+f+d),e(c)}function g(a){var b,c=s.val().length;s.val(f(s.val())),b=s.val().length,a-=c-b,d(a)}function h(){var a=s.val();s.val(f(a))}function i(){var b=s.val();return a.allowNegative?""!==b&&"-"===b.charAt(0)?b.replace("-",""):"-"+b:b}function j(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function k(a){a=a||window.event;var d,e,f,h,k,l=a.which||a.charCode||a.keyCode;return void 0===l?!1:48>l||l>57?45===l?(s.val(i()),!1):43===l?(s.val(s.val().replace("-","")),!1):13===l||9===l?!0:!$.browser.mozilla||37!==l&&39!==l||0!==a.charCode?(j(a),!0):!0:c()?(j(a),d=String.fromCharCode(l),e=b(),f=e.start,h=e.end,k=s.val(),s.val(k.substring(0,f)+d+k.substring(h,k.length)),g(f+1),!1):!1}function l(c){c=c||window.event;var d,e,f,h,i,k=c.which||c.charCode||c.keyCode;return void 0===k?!1:(d=b(),e=d.start,f=d.end,8===k||46===k||63272===k?(j(c),h=s.val(),e===f&&(8===k?""===a.suffix?e-=1:(i=h.split("").reverse().join("").search(/\d/),e=h.length-i-1,f=e+1):f+=1),s.val(h.substring(0,e)+h.substring(f,h.length)),g(e),!1):9===k?!0:!0)}function m(){r=s.val(),h();var a,b=s.get(0);b.createTextRange&&(a=b.createTextRange(),a.collapse(!1),a.select())}function n(){setTimeout(function(){h()},0)}function o(){var b=parseFloat("0")/Math.pow(10,a.precision);return b.toFixed(a.precision).replace(new RegExp("\\.","g"),a.decimal)}function p(b){if($.browser.msie&&k(b),""===s.val()||s.val()===e(o()))a.allowZero?a.affixesStay?s.val(e(o())):s.val(o()):s.val("");else if(!a.affixesStay){var c=s.val().replace(a.prefix,"").replace(a.suffix,"");s.val(c)}s.val()!==r&&s.change()}function q(){var a,b=s.get(0);b.setSelectionRange?(a=s.val().length,b.setSelectionRange(a,a)):s.val(s.val())}var r,s=$(this);a=$.extend(a,s.data()),s.unbind(".maskMoney"),s.bind("keypress.maskMoney",k),s.bind("keydown.maskMoney",l),s.bind("blur.maskMoney",p),s.bind("focus.maskMoney",m),s.bind("click.maskMoney",q),s.bind("cut.maskMoney",n),s.bind("paste.maskMoney",n),s.bind("mask.maskMoney",h)})}};$.fn.maskMoney=function(b){return a[b]?a[b].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof b&&b?($.error("Method "+b+" does not exist on jQuery.maskMoney"),void 0):a.init.apply(this,arguments)}}(window.jQuery||window.Zepto); -------------------------------------------------------------------------------- /Datasets customizados/enviaEmail.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | function createDataset(fields, constraints, sortFields) { 8 | 9 | log.info( 'Dataset enviaEmail' ); 10 | 11 | var newDataset = DatasetBuilder.newDataset(); 12 | newDataset.addColumn("Email"); 13 | newDataset.addColumn("Conteudo"); 14 | 15 | // var remetente = 'fluig@pormade.com.br'; 16 | var remetente = 'admlog'; 17 | var destinatario = new Array('tiago@kobit.com.br'); 18 | var conteudo = 'TESTE CONTEUDO 3'; 19 | var assunto = 'TESTE ASSUNTO 3'; 20 | var tipo = 'simples'; 21 | 22 | 23 | if (constraints != null) { 24 | for (var i = 0; i < constraints.length; i++) { 25 | log.info( constraints[i] ); 26 | 27 | if (constraints[i].fieldName == "EMAILS") { 28 | remetente = constraints[i].initialValue; 29 | destinatario = constraints[i].finalValue.split(','); 30 | } 31 | 32 | if (constraints[i].fieldName == "CONTEUDO") { 33 | conteudo = constraints[i].initialValue; 34 | assunto = constraints[i].finalValue; 35 | } 36 | 37 | if (constraints[i].fieldName == "TIPO") { 38 | tipo = constraints[i].initialValue; 39 | } 40 | 41 | } 42 | } 43 | 44 | if (!conteudo){ 45 | return newDataset; 46 | } 47 | 48 | 49 | try{ 50 | 51 | if ( tipo == 'simples'){ 52 | log.info('## SIMPLES'); 53 | var obj = new com.fluig.foundation.mail.service.EMailServiceBean(); 54 | 55 | for (var i in destinatario){ 56 | obj.simpleEmail(1 , assunto, remetente, destinatario[i], conteudo, "text/html"); 57 | newDataset.addRow(new Array(destinatario[i], 'enviado com sucesso!')); 58 | } 59 | } 60 | 61 | if ( tipo == 'notify') { 62 | log.info('## NOTIFY'); 63 | //Monta mapa com parâmetros do template 64 | var parametros = new java.util.HashMap(); 65 | parametros.put("CONTEUDO", conteudo); 66 | 67 | //Este parâmetro é obrigatório e representa o assunto do e-mail 68 | parametros.put("subject", assunto); 69 | 70 | //Monta lista de destinatários 71 | var destinatarios = new java.util.ArrayList(); 72 | for (var i in destinatario){ 73 | destinatarios.add( destinatario[i] ); 74 | } 75 | notifier.notify(remetente, "TPL_NEW_BLANK", parametros, destinatarios, "text/html"); 76 | 77 | newDataset.addRow(new Array(destinatario.join(), 'enviado com sucesso!')); 78 | } 79 | 80 | if ( tipo == 'java'){ 81 | log.info('## JAVA'); 82 | // ##### ENVIO DE E-MAIL 83 | var contextWD = new javax.naming.InitialContext(); 84 | var mailSession = contextWD.lookup("java:jboss/mail/Default"); 85 | 86 | var to = new Array(); 87 | for (var i in destinatario){ 88 | to.push(new javax.mail.internet.InternetAddress( destinatario[i] )); 89 | } 90 | 91 | // ### CRIA MENSSAGEM 92 | var menssagem = javax.mail.internet.MimeMessage(mailSession); 93 | var from = new javax.mail.internet.InternetAddress( remetente ); 94 | menssagem.setFrom(from); 95 | menssagem.setRecipients(javax.mail.Message.RecipientType.TO, to); 96 | menssagem.setSubject( assunto ); 97 | // ### Cria corpo do e-mail 98 | var textPart = new javax.mail.internet.MimeBodyPart(); 99 | textPart.setText( conteudo , "utf-8"); 100 | var htmlPart = new javax.mail.internet.MimeBodyPart(); 101 | htmlPart.setContent( conteudo , "text/html; charset=utf-8"); 102 | var multipart = new javax.mail.internet.MimeMultipart(); 103 | multipart.addBodyPart(htmlPart); 104 | menssagem.setContent(multipart); 105 | 106 | // Cria anexo do e-mail 107 | // var messageBodyPart = new javax.mail.internet.MimeBodyPart(); 108 | //messageBodyPart.setDataHandler(new javax.activation.DataHandler(new javax.mail.util.ByteArrayDataSource(HTML,"text/html; charset=utf-8"))); 109 | //messageBodyPart.setDataHandler( new javax.activation.DataHandler( file ) ); 110 | // var source = new javax.activation.FileDataSource('\\tmp\\'+filename); 111 | // messageBodyPart.setDataHandler(new javax.activation.DataHandler( source )); 112 | 113 | // messageBodyPart.setFileName( filename ); 114 | // multipart.addBodyPart(messageBodyPart); 115 | // menssagem.setContent(multipart); 116 | javax.mail.Transport.send(menssagem); 117 | // mailSession.close() 118 | newDataset.addRow(new Array(destinatario.join(), 'enviado com sucesso!')); 119 | } 120 | 121 | }catch(err){ 122 | newDataset.addRow(new Array(destinatario, "erro: " + err.toString())); 123 | } 124 | 125 | return newDataset; 126 | } 127 | 128 | function onMobileSync(user) { 129 | 130 | } -------------------------------------------------------------------------------- /Datasets customizados/dsk_sinc_cadastros.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | function createDataset(fields, constraints, sortFields) { 8 | 9 | log.info( "### REPLICA CADASTROS ###"); 10 | 11 | var dataset = DatasetBuilder.newDataset(); 12 | 13 | dataset.addColumn( "registros" ); 14 | 15 | var qtdReg = 0; 16 | 17 | var datasetDe = 'equipamento'; 18 | var tablesFilhos = ['tipo_teste']; 19 | var parentDocumentId = '5293'; 20 | 21 | var empresaId = "1"; 22 | var user = ""; 23 | var senha = ""; 24 | var comments = "Documento criado via dataset."; 25 | 26 | var dataset = DatasetBuilder.newDataset(); 27 | 28 | var ECMCardServiceProvider = ServiceManager.getServiceInstance("ECMCardServicePRD"); 29 | var ECMCardServiceServiceLocator = ECMCardServiceProvider.instantiate("com.totvs.technology.ecm.dm.ws.ECMCardServiceServiceLocator"); 30 | var ECMCardServiceService = ECMCardServiceServiceLocator.getCardServicePort(); 31 | var cardDtoArray = ECMCardServiceProvider.instantiate("com.totvs.technology.ecm.dm.ws.CardDtoArray"); 32 | var cardDto = ECMCardServiceProvider.instantiate("com.totvs.technology.ecm.dm.ws.CardDto"); 33 | 34 | cardDto.setParentDocumentId( parseInt(parentDocumentId) ); 35 | cardDto.setAdditionalComments( comments ); 36 | 37 | var dsDe = DatasetFactory.getDataset(datasetDe, null, null, null); 38 | 39 | console.log('### QUANTIDADE REGISTROS...' + dsDe.rowsCount); 40 | 41 | for (var x = 0; x < dsDe.rowsCount; x++) { 42 | 43 | var vetCardFields = new Array(); 44 | 45 | var documentId = dsDe.getValue(x, "metadata#id"); 46 | var documentVersion = dsDe.getValue(x, "metadata#version"); 47 | log.info('documentId...' + documentId); 48 | log.info('documentVersion...' + documentVersion); 49 | 50 | for (var i = 0; i < dsDe.getColumnsCount(); i++) { 51 | log.info('linha...' + dsDe.getColumnName(i) + ' | ' + dsDe.getValue(x, dsDe.getColumnName(i))); 52 | var CardFieldDto = ECMCardServiceProvider.instantiate("com.totvs.technology.ecm.dm.ws.CardFieldDto"); 53 | CardFieldDto.setField( dsDe.getColumnName(i) ); 54 | CardFieldDto.setValue( dsDe.getValue(x, dsDe.getColumnName(i)) ); 55 | vetCardFields.push( CardFieldDto ); 56 | 57 | } 58 | 59 | //BUSCAR TABLES FILHOS DO BANCO 60 | log.info('tablesFilhos...' + tablesFilhos.length); 61 | if (tablesFilhos.length > 0){ 62 | 63 | for (var j = 0; j < tablesFilhos.length; j++) { 64 | 65 | log.info('Tables filho...' + tablesFilhos[j]); 66 | 67 | var constraintsFilhos = new Array(); 68 | constraintsFilhos.push(DatasetFactory.createConstraint("tablename", tablesFilhos[j] ,tablesFilhos[j], ConstraintType.MUST)); 69 | constraintsFilhos.push(DatasetFactory.createConstraint("metadata#id", documentId, documentId, ConstraintType.MUST)); 70 | constraintsFilhos.push(DatasetFactory.createConstraint("metadata#version", documentVersion, documentVersion, ConstraintType.MUST)); 71 | 72 | var dsDeFilhos = DatasetFactory.getDataset(datasetDe, null, constraintsFilhos, null); 73 | 74 | for (var k = 0; k < dsDeFilhos.rowsCount; k++) { 75 | // log.info('entrou rows filho') 76 | var seq = k + 1; 77 | for (var l = 0; l < dsDeFilhos.getColumnsCount(); l++) { 78 | log.info('linha...' + dsDeFilhos.getColumnName(l) + '___' + seq + ' | ' + dsDeFilhos.getValue(k, dsDeFilhos.getColumnName(l))); 79 | var CardFieldDto = ECMCardServiceProvider.instantiate("com.totvs.technology.ecm.dm.ws.CardFieldDto"); 80 | CardFieldDto.setField( dsDeFilhos.getColumnName(l) + '___' + seq ); 81 | CardFieldDto.setValue( dsDeFilhos.getValue(k, dsDeFilhos.getColumnName(l)) ); 82 | vetCardFields.push( CardFieldDto ); 83 | } 84 | 85 | } 86 | 87 | } 88 | 89 | } 90 | 91 | log.info('### Publicou ###'); 92 | 93 | cardDto.setCardData( vetCardFields ); 94 | var vetCardDto = new Array(); 95 | vetCardDto.push( cardDto ); 96 | cardDtoArray.setItem( vetCardDto ); 97 | 98 | try{ 99 | 100 | log.info('empresa...'+parseInt(empresaId)); 101 | log.info('user...'+ user); 102 | log.info('senha...'+ senha); 103 | 104 | var Retorno = ECMCardServiceService.create( parseInt(empresaId), 105 | user, 106 | senha, 107 | cardDtoArray ); 108 | var result = new Array(); 109 | 110 | result.push(Retorno.getItem(0).getDocumentId()); 111 | result.push(Retorno.getItem(0).getDocumentDescription()); 112 | result.push(Retorno.getItem(0).getWebServiceMessage()); 113 | 114 | dataset.addColumn( "documentId" ); 115 | dataset.addColumn( "documentDescription" ); 116 | dataset.addColumn( "status" ); 117 | 118 | dataset.addRow( result ); 119 | // qtdReg++ 120 | 121 | }catch( e ){ 122 | log.info( e.toString() ); 123 | 124 | } 125 | 126 | } 127 | 128 | dataset.addRow( new Array( String(qtdReg) ) ); 129 | 130 | return dataset; 131 | 132 | } 133 | 134 | function onMobileSync(user) { 135 | 136 | } 137 | -------------------------------------------------------------------------------- /Consumir Dataset Publico/oauth/hmac-sha256.js: -------------------------------------------------------------------------------- 1 | /* 2 | CryptoJS v3.1.2 3 | code.google.com/p/crypto-js 4 | (c) 2009-2013 by Jeff Mott. All rights reserved. 5 | code.google.com/p/crypto-js/wiki/License 6 | */ 7 | var CryptoJS=CryptoJS||function(h,s){var f={},g=f.lib={},q=function(){},m=g.Base={extend:function(a){q.prototype=this;var c=new q;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, 8 | r=g.WordArray=m.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||k).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 9 | 32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, 10 | 2),16)<<24-4*(b%8);return new r.init(d,c/2)}},n=l.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new r.init(d,c)}},j=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}}, 11 | u=g.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var g=0;gn;){var j;a:{j=k;for(var u=h.sqrt(j),t=2;t<=u;t++)if(!(j%t)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=l(h.pow(k,0.5))),r[n]=l(h.pow(k,1/3)),n++);k++}var a=[],f=f.SHA256=q.extend({_doReset:function(){this._hash=new g.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],j=b[3],h=b[4],m=b[5],n=b[6],q=b[7],p=0;64>p;p++){if(16>p)a[p]= 15 | c[d+p]|0;else{var k=a[p-15],l=a[p-2];a[p]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[p-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[p-16]}k=q+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&m^~h&n)+r[p]+a[p];l=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);q=n;n=m;m=h;h=j+k|0;j=g;g=f;f=e;e=k+l|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+j|0;b[4]=b[4]+h|0;b[5]=b[5]+m|0;b[6]=b[6]+n|0;b[7]=b[7]+q|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; 16 | d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=q.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=q._createHelper(f);s.HmacSHA256=q._createHmacHelper(f)})(Math); 17 | (function(){var h=CryptoJS,s=h.enc.Utf8;h.algo.HMAC=h.lib.Base.extend({init:function(f,g){f=this._hasher=new f.init;"string"==typeof g&&(g=s.parse(g));var h=f.blockSize,m=4*h;g.sigBytes>m&&(g=f.finalize(g));g.clamp();for(var r=this._oKey=g.clone(),l=this._iKey=g.clone(),k=r.words,n=l.words,j=0;j>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 9 | 32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, 10 | 2),16)<<24-4*(b%8);return new r.init(d,c/2)}},n=l.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new r.init(d,c)}},j=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}}, 11 | u=g.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var g=0;gn;){var j;a:{j=k;for(var u=h.sqrt(j),t=2;t<=u;t++)if(!(j%t)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=l(h.pow(k,0.5))),r[n]=l(h.pow(k,1/3)),n++);k++}var a=[],f=f.SHA256=q.extend({_doReset:function(){this._hash=new g.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],j=b[3],h=b[4],m=b[5],n=b[6],q=b[7],p=0;64>p;p++){if(16>p)a[p]= 15 | c[d+p]|0;else{var k=a[p-15],l=a[p-2];a[p]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[p-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[p-16]}k=q+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&m^~h&n)+r[p]+a[p];l=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);q=n;n=m;m=h;h=j+k|0;j=g;g=f;f=e;e=k+l|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+j|0;b[4]=b[4]+h|0;b[5]=b[5]+m|0;b[6]=b[6]+n|0;b[7]=b[7]+q|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; 16 | d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=q.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=q._createHelper(f);s.HmacSHA256=q._createHmacHelper(f)})(Math); 17 | (function(){var h=CryptoJS,s=h.enc.Utf8;h.algo.HMAC=h.lib.Base.extend({init:function(f,g){f=this._hasher=new f.init;"string"==typeof g&&(g=s.parse(g));var h=f.blockSize,m=4*h;g.sigBytes>m&&(g=f.finalize(g));g.clamp();for(var r=this._oKey=g.clone(),l=this._iKey=g.clone(),k=r.words,n=l.words,j=0;j= 0 ){ 53 | not = 'not'; 54 | campo = campo.replace('___not___',''); 55 | } 56 | var upper_lower = "upper"; 57 | if ( campo.indexOf('___lower___') >= 0 ){ 58 | upper_lower = "lower"; 59 | campo = campo.replace('___lower___',''); 60 | } 61 | 62 | if( constraints[i].initialValue == 'true' 63 | || constraints[i].initialValue == 'false' ){ 64 | upper_lower = ''; 65 | } 66 | if ( campo.indexOf('___in___') >= 0 ){ 67 | where += " and "+ campo.replace('___in___','') +" "+ 68 | " "+not+" in ( '"+ constraints[i].initialValue.replaceAll( '\\|', '\',\'' ) +"' ) "; 69 | }else if ( constraints[i].likeSearch || constraints[i].constraintType == 'SHOULD' ){ 70 | where += " and "+campo +" "+ 71 | " "+not+" like "+ upper_lower +"( '%"+ constraints[i].initialValue +"%' ) "; 72 | }else{ 73 | where += " and "+ campo +" "+ 74 | " "+not+" between "+ upper_lower +"( '"+ constraints[i].initialValue +"' ) and "+ upper_lower +"( '"+ constraints[i].finalValue +"' )"; 75 | } 76 | } 77 | } 78 | } 79 | 80 | log.info("Passo 03"); 81 | 82 | if (sortFields != null) { 83 | for (var i = 0; i < sortFields.length; i++) { 84 | order += ', '+sortFields[i]; 85 | } 86 | } 87 | 88 | 89 | log.info( '$$$$$$$$$$$ '+ campos ); 90 | log.info( '$$$$$$$$$$$ '+ where ); 91 | log.info( '$$$$$$$$$$$ '+ order ); 92 | log.info( '$$$$$$$$$$$ '+ limit ); 93 | log.info( '$$$$$$$$$$$ '+ table ); 94 | log.info( '$$$$$$$$$$$ '+ dataBase ); 95 | 96 | 97 | var contextWD = new javax.naming.InitialContext(); 98 | var dataSourceWD = contextWD.lookup( dataBase ); 99 | var connectionWD = dataSourceWD.getConnection(); 100 | 101 | if( banco == 'informix' ){ 102 | var SQL = "set isolation to dirty read"; 103 | var statementWD = connectionWD.prepareStatement(SQL); 104 | var rsWD = statementWD.executeUpdate(); 105 | } 106 | 107 | SQL = " select " ; 108 | if( banco == 'informix' ) 109 | SQL += " first "+ limit ; 110 | 111 | SQL += " "+ distinct +" "+ campos + 112 | " from "+ table + 113 | " where 1=1 "+ where ; 114 | if ( order != '' ) 115 | SQL += " order by "+ order ; 116 | if( banco == 'postgresql' ) 117 | SQL += " limit "+ limit ; 118 | 119 | log.info( SQL ); 120 | 121 | statementWD = connectionWD.prepareStatement(SQL); 122 | rsWD = statementWD.executeQuery(); 123 | 124 | while(rsWD.next()){ 125 | 126 | var dados = new Array(); 127 | if (fields != null) { 128 | for (var i = 0; i < fields.length; i++) { 129 | log.info( 'Field.....'+i ); 130 | log.info( 'Field.....'+fields[i] ); 131 | if ( fields[i] != 'distinct' ){ 132 | dados.push( rsWD.getString( fields[i] ) ); 133 | } 134 | } 135 | } 136 | 137 | dataset.addRow( dados ); 138 | 139 | } 140 | 141 | rsWD.close(); 142 | statementWD.close(); 143 | connectionWD.close(); 144 | 145 | } catch (e){ 146 | log.info( "ERROOOOOO"+ e.toString() ); 147 | }finally { 148 | log.info('##### 6 #####'); 149 | if(statementWD != null) statementWD.close(); 150 | if(connectionWD != null) connectionWD.close(); 151 | } 152 | 153 | 154 | return dataset; 155 | 156 | } 157 | 158 | function isNumeric( obj ) { 159 | return !isNaN( parseFloat(obj) ) && isFinite( obj ); 160 | } 161 | 162 | function onMobileSync(user) { } -------------------------------------------------------------------------------- /Datasets customizados/selectDataSet.js: -------------------------------------------------------------------------------- 1 | function defineStructure() {} 2 | function onSync(lastSyncDate) {} 3 | function createDataset(fields, constraints, sortFields) { 4 | 5 | var dataset = DatasetBuilder.newDataset(); 6 | 7 | var where = ''; 8 | var order = '1 '; 9 | var limit = 300; 10 | var distinct = ''; 11 | var dsName = 'usuario_comercial'; 12 | var campos = new Array(); 13 | var order = '1 '; 14 | 15 | 16 | if (fields != null) { 17 | for (var i = 0; i < fields.length; i++) { 18 | if ( fields[i] != 'distinct' ){ 19 | campos.push( fields[i] ); 20 | //dataset.addColumn( fields[i] ); 21 | }else{ 22 | distinct = 'distinct'; 23 | } 24 | } 25 | } 26 | 27 | if (constraints != null) { 28 | for (var i = 0; i < constraints.length; i++) { 29 | log.info( 'Constrait '+i ); 30 | log.info( constraints[i] ); 31 | if ( constraints[i].fieldName == 'sqlLimit' ){ 32 | limit = constraints[i].initialValue; 33 | }else if( constraints[i].fieldName == 'dataset' ) { 34 | dsName = constraints[i].initialValue; 35 | }else{ 36 | var not = ''; 37 | var campo = constraints[i].getFieldName().toString(); 38 | var iniVal = constraints[i].initialValue; 39 | var finVal = constraints[i].finalValue; 40 | var tmpWhere = ''; 41 | if ( constraints[i].constraintType == 'MUST_NOT' ) 42 | not = 'not'; 43 | if ( campo.indexOf('___not___') >= 0 ){ 44 | not = 'not'; 45 | campo = campo.replace('___not___',''); 46 | } 47 | 48 | if( constraints[i].initialValue == constraints[i].finalValue 49 | && constraints[i].initialValue.split('\\|').length >= 2 ){ 50 | iniVal = constraints[i].initialValue.split('\\|')[0]; 51 | finVal = constraints[i].initialValue.split('\\|')[1]; 52 | } 53 | if ( campo.indexOf('=') >= 0 ){ 54 | tmpWhere = ' and ' + campo; 55 | } else { 56 | if ( campo.indexOf('___in___') >= 0 ){ 57 | if( constraints[i].initialValue.split('\\|').length > 0 ){ 58 | where += " and "+ campo.replace('___in___','') + 59 | " "+not+" in ( '"+ constraints[i].initialValue.split('\\|').join("','") +"' ) "; 60 | } 61 | }else if ( constraints[i].likeSearch || constraints[i].constraintType == 'SHOULD' ){ 62 | where += " and "+ campo + 63 | " "+not+" like upper( '%"+ constraints[i].initialValue +"%' ) "; 64 | }else{ 65 | where += " and "+ campo + 66 | " "+not+" between upper( '"+ iniVal +"' ) and upper( '"+ finVal +"' )"; 67 | } 68 | } 69 | } 70 | } 71 | } 72 | 73 | if (sortFields != null) { 74 | for (var i = 0; i < sortFields.length; i++) { 75 | log.info( 'Order '+i ); 76 | order += ', '+sortFields[i]; 77 | } 78 | } 79 | 80 | try{ 81 | 82 | log.info( '$001... ' ); 83 | var contextWD = new javax.naming.InitialContext(); 84 | log.info( '$002... ' ); 85 | var dataSourceWD = contextWD.lookup( "java:/jdbc/FluigDS" ); 86 | log.info( '$003... ' ); 87 | var connectionWD = dataSourceWD.getConnection(); 88 | log.info( '$004... ' ); 89 | 90 | var sql = " select doc.COD_LISTA " + 91 | " from documento doc "+ 92 | " where doc.COD_EMPRESA = 1 "+ 93 | " and doc.NM_DATASET = '"+ dsName +"' "+ 94 | " and doc.VERSAO_ATIVA = 1 "; 95 | 96 | log.info( '$005... '+sql ); 97 | statementWD = connectionWD.prepareStatement(sql); 98 | rsWD = statementWD.executeQuery(); 99 | 100 | var mlPai = ''; 101 | 102 | while(rsWD.next()) { 103 | mlPai = rsWD.getString( 'COD_LISTA' ); 104 | } 105 | 106 | log.info( '$005 campos...|'+campos+'|...' ); 107 | var sql = " select "; 108 | if( campos.length == 0 ){ 109 | sql += " "+distinct+" p.* " ; 110 | }else{ 111 | sql += " "+distinct+" "+ campos.join(',') +" " ; 112 | } 113 | 114 | 115 | sql += " from ML001"+ getLPad( mlPai, '000' ) +" p "+ 116 | " join DOCUMENTO d on (d.COD_EMPRESA = p.companyid "+ 117 | " and d.NR_DOCUMENTO = p.documentid "+ 118 | " and d.NR_VERSAO = p.version) "+ 119 | " where p.companyid = 1 "+ 120 | " and d.VERSAO_ATIVA = 1 "; 121 | sql += where; 122 | 123 | if ( order != '' ) 124 | sql += " order by "+ order ; 125 | 126 | log.info( '$005... '+sql ); 127 | statementWD = connectionWD.prepareStatement(sql); 128 | rsWD = statementWD.executeQuery(); 129 | var columnCount = rsWD.getMetaData().getColumnCount(); 130 | var created = false; 131 | while(rsWD.next()) { 132 | log.info( '$009... ' ); 133 | if(!created) { 134 | for(var i=1;i<=columnCount; i++) { 135 | dataset.addColumn(rsWD.getMetaData().getColumnName(i).toLowerCase()); 136 | } 137 | created = true; 138 | } 139 | var Arr = new Array(); 140 | 141 | for(var i=1;i<=columnCount; i++) { 142 | var obj = rsWD.getObject(rsWD.getMetaData().getColumnName(i)); 143 | if(null!=obj){ 144 | Arr[i-1] = rsWD.getObject(rsWD.getMetaData().getColumnName(i)).toString(); 145 | }else{ 146 | Arr[i-1] = "null"; 147 | } 148 | } 149 | dataset.addRow(Arr); 150 | } 151 | rsWD.close(); 152 | 153 | } catch (e){ 154 | log.info( "ERROOOOOO"+ e.toString() ); 155 | } 156 | finally { 157 | log.info('##### 6 #####'); 158 | if(statementWD != null) statementWD.close(); 159 | if(connectionWD != null) connectionWD.close(); 160 | } 161 | return dataset; 162 | 163 | } 164 | function onMobileSync(user) {} 165 | 166 | function getLPad( valor, pad){ 167 | var str = "" + valor; 168 | if( pad.length < str.length ) 169 | return str; 170 | return pad.substring(0, pad.length - str.length) + str; 171 | 172 | } -------------------------------------------------------------------------------- /Datasets customizados/reabreProcesso.js: -------------------------------------------------------------------------------- 1 | function defineStructure() { 2 | 3 | } 4 | function onSync(lastSyncDate) { 5 | 6 | } 7 | function createDataset(fields, constraints, sortFields) { 8 | 9 | var choosedState = ""; 10 | var numProcesso = ""; 11 | var usuario = ""; 12 | 13 | log.info( "passo 0001 "); 14 | 15 | if (constraints != null) { 16 | for (var i = 0; i < constraints.length; i++) { 17 | if ( constraints[i].fieldName == 'atividade' ){ 18 | choosedState = constraints[i].initialValue; 19 | log.info('Entrei atividade........... '+constraints[i].initialValue ); 20 | } 21 | if ( constraints[i].fieldName == 'processo' ){ 22 | numProcesso = constraints[i].initialValue; 23 | log.info('Entrei processo........... '+constraints[i].initialValue ); 24 | } 25 | if ( constraints[i].fieldName == 'usuario' ){ 26 | usuario = constraints[i].initialValue; 27 | log.info('Entrei usuario........... '+constraints[i].initialValue ); 28 | } 29 | } 30 | } 31 | 32 | log.info( "passo 0002 "); 33 | var dataset = DatasetBuilder.newDataset(); 34 | dataset.addColumn( "num_seq_movto" ); 35 | 36 | if( choosedState == "" && numProcesso == "" ){ 37 | return dataset; 38 | } 39 | 40 | var contextWD = null; 41 | var dataSourceWD = null; 42 | var connectionWD = null; 43 | var statementWD = null; 44 | 45 | try{ 46 | contextWD = new javax.naming.InitialContext(); 47 | dataSourceWD = contextWD.lookup( "java:/jdbc/FluigDS" ); 48 | connectionWD = dataSourceWD.getConnection(); 49 | //connectionWD.setAutoCommit(false); 50 | 51 | 52 | var sql = " INSERT INTO histor_proces( "+ 53 | " COD_EMPRESA, NUM_SEQ_MOVTO, NUM_PROCES, log_ativ, LOG_FLUXO_AUTOM, NUM_SEQ_CONVER, LOG_FLUXO_PADRAO, "+ 54 | " DAT_MOVTO, HRA_MOVTO, num_seq_movto_ant, LOG_FLUXO_RET, num_seq_estado, NUM_SUB_PROCES, NUM_SEQ_THREAD, MOVTO_DATE_TIME "+ 55 | ") "+ 56 | "SELECT COD_EMPRESA, NUM_SEQ_MOVTO + 1, NUM_PROCES, 1, LOG_FLUXO_AUTOM, NUM_SEQ_CONVER, LOG_FLUXO_PADRAO, "+ 57 | " DAT_MOVTO, HRA_MOVTO, NUM_SEQ_MOVTO, LOG_FLUXO_RET, "+ choosedState +", NUM_SUB_PROCES, NUM_SEQ_THREAD, MOVTO_DATE_TIME "+ 58 | " FROM histor_proces "+ 59 | " WHERE num_proces = "+ numProcesso +" "+ 60 | " AND num_seq_movto = ( SELECT max(num_seq_movto) "+ 61 | " FROM histor_proces "+ 62 | " WHERE num_proces = "+ numProcesso +" ) "; 63 | 64 | log.info( "sql.......... "+sql); 65 | statementWD = connectionWD.prepareStatement(sql); 66 | statementWD.executeUpdate(); 67 | 68 | var sql = " UPDATE proces_workflow "+ 69 | " SET log_ativ = 1, end_date = NULL, STATUS = 0, total_runtime = NULL "+ 70 | " WHERE num_proces = "+ numProcesso +" "; 71 | 72 | log.info( "sql.......... "+sql); 73 | statementWD = connectionWD.prepareStatement(sql); 74 | statementWD.executeUpdate(); 75 | 76 | var sql = " INSERT INTO tar_proces( "+ 77 | " CD_MATRICULA, COD_EMPRESA, NUM_SEQ_MOVTO, "+ 78 | " NUM_PROCES, NUM_SEQ_TRANSF, log_ativ, ASSIGN_START_DATE, assign_end_date, DAT_MSG_ATRASO_RESPONS, "+ 79 | " NUM_HORA_MSG_ATRASO_RESPONS, COD_MATR_ESCOLHID, NUM_SEQ_ESCOLHID, CLOSURE_STATUS, CD_MATRICULA_CONCLUS, IDI_TIP_CONCLUS, DEADLINE, deadlineDate, "+ 80 | " deadlineHour, END_DATE, initialTermDate, initialTermHour, DAT_MSG_ATRASO_GESTOR, NUM_HORA_MSG_ATRASO_GESTOR, DAT_MSG_EXPIRAC_RESPONS, "+ 81 | " NUM_HORA_MSG_EXPIRAC_RESPONS, DAT_MSG_EXPIRAC_GESTOR, NUM_HORA_MSG_EXPIRAC_GESTOR, DAT_MSG_EXPIRAC_REQUISIT, NUM_HORA_MSG_EXPIRAC_REQUISIT, "+ 82 | " DAT_MSG_ATRASO_REQUISIT, NUM_HORA_MSG_ATRASO_REQUISIT, START_DATE, IDI_STATUS, taskCompletionDate, taskCompletionHour, DSL_OBS_TAR, "+ 83 | " LOG_ASSINADO, DS_ARQUIVO_HASH, DS_NOME_ARQUIVO_ASS, WARNING_DATE, TOTAL_RUNTIME "+ 84 | ") "+ 85 | " SELECT case when cd_matricula LIKE 'Pool:%' then CD_MATRICULA ELSE " + 86 | " case when '"+ usuario +"' <> '' then '"+ usuario +"' else cd_matricula end end, COD_EMPRESA, (SELECT MAX(num_seq_movto) FROM histor_proces WHERE histor_proces.num_proces = tar_proces.num_proces ) as NUM_SEQ_MOVTO, "+ 87 | " NUM_PROCES, NUM_SEQ_TRANSF, case when cd_matricula NOT LIKE 'Pool:%' then 1 ELSE 0 end, ASSIGN_START_DATE, case when cd_matricula NOT LIKE 'Pool:%' then null ELSE assign_end_date end, DAT_MSG_ATRASO_RESPONS, "+ 88 | " NUM_HORA_MSG_ATRASO_RESPONS, '' as COD_MATR_ESCOLHID, 0 as NUM_SEQ_ESCOLHID, 0 as CLOSURE_STATUS, CD_MATRICULA_CONCLUS, IDI_TIP_CONCLUS, DEADLINE, deadlineDate, "+ 89 | " deadlineHour, null as END_DATE, initialTermDate, initialTermHour, DAT_MSG_ATRASO_GESTOR, NUM_HORA_MSG_ATRASO_GESTOR, DAT_MSG_EXPIRAC_RESPONS, "+ 90 | " NUM_HORA_MSG_EXPIRAC_RESPONS, DAT_MSG_EXPIRAC_GESTOR, NUM_HORA_MSG_EXPIRAC_GESTOR, DAT_MSG_EXPIRAC_REQUISIT, NUM_HORA_MSG_EXPIRAC_REQUISIT, "+ 91 | " DAT_MSG_ATRASO_REQUISIT, NUM_HORA_MSG_ATRASO_REQUISIT, START_DATE, case when cd_matricula NOT LIKE 'Pool:%' then 0 ELSE 3 end as IDI_STATUS, taskCompletionDate, taskCompletionHour, DSL_OBS_TAR, "+ 92 | " LOG_ASSINADO, DS_ARQUIVO_HASH, DS_NOME_ARQUIVO_ASS, WARNING_DATE, null as TOTAL_RUNTIME "+ 93 | " FROM tar_proces "+ 94 | " WHERE num_proces = "+ numProcesso +" "+ 95 | " AND num_seq_movto = ( select max(num_seq_movto) FROM tar_proces WHERE num_proces = "+ numProcesso +" AND cd_matricula NOT IN ('System:Auto') AND cd_matricula NOT LIKE 'Pool:%' ) "; 96 | 97 | log.info( "sql.......... "+sql); 98 | statementWD = connectionWD.prepareStatement(sql); 99 | statementWD.executeUpdate(); 100 | 101 | var sql = " SELECT max(num_seq_movto) as num_seq_movto"+ 102 | " FROM histor_proces "+ 103 | " WHERE num_proces = "+ numProcesso ; 104 | 105 | statementWD = connectionWD.prepareStatement(sql); 106 | rsWD = statementWD.executeQuery(); 107 | 108 | if(rsWD.next()){ 109 | var dados = new Array(); 110 | dados.push( rsWD.getString( 'num_seq_movto' ) ); 111 | dataset.addRow( dados ); 112 | } 113 | 114 | 115 | //connectionWD.commit( ); 116 | 117 | } catch (e){ 118 | log.erro( "ERRO reabreProcesso.js...."+ e.toString() ); 119 | //connectionWD.rollback(); 120 | } 121 | finally { 122 | log.info('##### 6 #####'); 123 | if(statementWD != null) statementWD.close(); 124 | if(connectionWD != null) connectionWD.close(); 125 | } 126 | return dataset; 127 | } 128 | 129 | function onMobileSync(user) { 130 | 131 | } -------------------------------------------------------------------------------- /Exportar datatable para excel/jquery.base64.js: -------------------------------------------------------------------------------- 1 | /*jslint adsafe: false, bitwise: true, browser: true, cap: false, css: false, 2 | debug: false, devel: true, eqeqeq: true, es5: false, evil: false, 3 | forin: false, fragment: false, immed: true, laxbreak: false, newcap: true, 4 | nomen: false, on: false, onevar: true, passfail: false, plusplus: true, 5 | regexp: false, rhino: true, safe: false, strict: false, sub: false, 6 | undef: true, white: false, widget: false, windows: false */ 7 | /*global jQuery: false, window: false */ 8 | "use strict"; 9 | 10 | /* 11 | * Original code (c) 2010 Nick Galbreath 12 | * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript 13 | * 14 | * jQuery port (c) 2010 Carlo Zottmann 15 | * http://github.com/carlo/jquery-base64 16 | * 17 | * Permission is hereby granted, free of charge, to any person 18 | * obtaining a copy of this software and associated documentation 19 | * files (the "Software"), to deal in the Software without 20 | * restriction, including without limitation the rights to use, 21 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | * copies of the Software, and to permit persons to whom the 23 | * Software is furnished to do so, subject to the following 24 | * conditions: 25 | * 26 | * The above copyright notice and this permission notice shall be 27 | * included in all copies or substantial portions of the Software. 28 | * 29 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 30 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 31 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 32 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 33 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 34 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 35 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 36 | * OTHER DEALINGS IN THE SOFTWARE. 37 | */ 38 | 39 | /* base64 encode/decode compatible with window.btoa/atob 40 | * 41 | * window.atob/btoa is a Firefox extension to convert binary data (the "b") 42 | * to base64 (ascii, the "a"). 43 | * 44 | * It is also found in Safari and Chrome. It is not available in IE. 45 | * 46 | * if (!window.btoa) window.btoa = $.base64.encode 47 | * if (!window.atob) window.atob = $.base64.decode 48 | * 49 | * The original spec's for atob/btoa are a bit lacking 50 | * https://developer.mozilla.org/en/DOM/window.atob 51 | * https://developer.mozilla.org/en/DOM/window.btoa 52 | * 53 | * window.btoa and $.base64.encode takes a string where charCodeAt is [0,255] 54 | * If any character is not [0,255], then an exception is thrown. 55 | * 56 | * window.atob and $.base64.decode take a base64-encoded string 57 | * If the input length is not a multiple of 4, or contains invalid characters 58 | * then an exception is thrown. 59 | */ 60 | 61 | jQuery.base64 = ( function( $ ) { 62 | 63 | var _PADCHAR = "=", 64 | _ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 65 | _VERSION = "1.0"; 66 | 67 | 68 | function _getbyte64( s, i ) { 69 | // This is oddly fast, except on Chrome/V8. 70 | // Minimal or no improvement in performance by using a 71 | // object with properties mapping chars to value (eg. 'A': 0) 72 | 73 | var idx = _ALPHA.indexOf( s.charAt( i ) ); 74 | 75 | if ( idx === -1 ) { 76 | throw "Cannot decode base64"; 77 | } 78 | 79 | return idx; 80 | } 81 | 82 | 83 | function _decode( s ) { 84 | var pads = 0, 85 | i, 86 | b10, 87 | imax = s.length, 88 | x = []; 89 | 90 | s = String( s ); 91 | 92 | if ( imax === 0 ) { 93 | return s; 94 | } 95 | 96 | if ( imax % 4 !== 0 ) { 97 | throw "Cannot decode base64"; 98 | } 99 | 100 | if ( s.charAt( imax - 1 ) === _PADCHAR ) { 101 | pads = 1; 102 | 103 | if ( s.charAt( imax - 2 ) === _PADCHAR ) { 104 | pads = 2; 105 | } 106 | 107 | // either way, we want to ignore this last block 108 | imax -= 4; 109 | } 110 | 111 | for ( i = 0; i < imax; i += 4 ) { 112 | b10 = ( _getbyte64( s, i ) << 18 ) | ( _getbyte64( s, i + 1 ) << 12 ) | ( _getbyte64( s, i + 2 ) << 6 ) | _getbyte64( s, i + 3 ); 113 | x.push( String.fromCharCode( b10 >> 16, ( b10 >> 8 ) & 0xff, b10 & 0xff ) ); 114 | } 115 | 116 | switch ( pads ) { 117 | case 1: 118 | b10 = ( _getbyte64( s, i ) << 18 ) | ( _getbyte64( s, i + 1 ) << 12 ) | ( _getbyte64( s, i + 2 ) << 6 ); 119 | x.push( String.fromCharCode( b10 >> 16, ( b10 >> 8 ) & 0xff ) ); 120 | break; 121 | 122 | case 2: 123 | b10 = ( _getbyte64( s, i ) << 18) | ( _getbyte64( s, i + 1 ) << 12 ); 124 | x.push( String.fromCharCode( b10 >> 16 ) ); 125 | break; 126 | } 127 | 128 | return x.join( "" ); 129 | } 130 | 131 | 132 | function _getbyte( s, i ) { 133 | var x = s.charCodeAt( i ); 134 | 135 | if ( x > 255 ) { 136 | console.log("INVALID_CHARACTER_ERR: DOM Exception 5", s, i, x ); 137 | //throw "INVALID_CHARACTER_ERR: DOM Exception 5"; 138 | } 139 | 140 | return x; 141 | } 142 | 143 | 144 | function _encode( s ) { 145 | if ( arguments.length !== 1 ) { 146 | throw "SyntaxError: exactly one argument required"; 147 | } 148 | 149 | s = String( s ); 150 | 151 | var i, 152 | b10, 153 | x = [], 154 | imax = s.length - s.length % 3; 155 | 156 | if ( s.length === 0 ) { 157 | return s; 158 | } 159 | 160 | for ( i = 0; i < imax; i += 3 ) { 161 | b10 = ( _getbyte( s, i ) << 16 ) | ( _getbyte( s, i + 1 ) << 8 ) | _getbyte( s, i + 2 ); 162 | x.push( _ALPHA.charAt( b10 >> 18 ) ); 163 | x.push( _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) ); 164 | x.push( _ALPHA.charAt( ( b10 >> 6 ) & 0x3f ) ); 165 | x.push( _ALPHA.charAt( b10 & 0x3f ) ); 166 | } 167 | 168 | switch ( s.length - imax ) { 169 | case 1: 170 | b10 = _getbyte( s, i ) << 16; 171 | x.push( _ALPHA.charAt( b10 >> 18 ) + _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) + _PADCHAR + _PADCHAR ); 172 | break; 173 | 174 | case 2: 175 | b10 = ( _getbyte( s, i ) << 16 ) | ( _getbyte( s, i + 1 ) << 8 ); 176 | x.push( _ALPHA.charAt( b10 >> 18 ) + _ALPHA.charAt( ( b10 >> 12 ) & 0x3F ) + _ALPHA.charAt( ( b10 >> 6 ) & 0x3f ) + _PADCHAR ); 177 | break; 178 | } 179 | 180 | return x.join( "" ); 181 | } 182 | 183 | 184 | return { 185 | decode: _decode, 186 | encode: _encode, 187 | VERSION: _VERSION 188 | }; 189 | 190 | }( jQuery ) ); 191 | 192 | -------------------------------------------------------------------------------- /Datasets customizados/selectPaiFilho.js: -------------------------------------------------------------------------------- 1 | function defineStructure() {} 2 | function onSync(lastSyncDate) {} 3 | function createDataset(fields, constraints, sortFields) { 4 | 5 | var dataset = DatasetBuilder.newDataset(); 6 | 7 | var where = ''; 8 | var order = '1 '; 9 | var limit = 300; 10 | var distinct = ''; 11 | var table = ''; 12 | var dsName = ''; 13 | var campos = new Array(); 14 | var order = '1 '; 15 | 16 | 17 | if (fields != null) { 18 | for (var i = 0; i < fields.length; i++) { 19 | if ( fields[i] != 'distinct' ){ 20 | campos.push( fields[i] ); 21 | //dataset.addColumn( fields[i] ); 22 | }else{ 23 | distinct = 'distinct'; 24 | } 25 | } 26 | } 27 | 28 | if (constraints != null) { 29 | for (var i = 0; i < constraints.length; i++) { 30 | log.info( 'Constrait '+i ); 31 | log.info( constraints[i] ); 32 | if ( constraints[i].fieldName == 'sqlLimit' ){ 33 | limit = constraints[i].initialValue; 34 | }else if( constraints[i].fieldName == 'table' ) { 35 | table = constraints[i].initialValue; 36 | }else if( constraints[i].fieldName == 'dataset' ) { 37 | dsName = constraints[i].initialValue; 38 | }else{ 39 | var not = ''; 40 | var campo = constraints[i].getFieldName().toString(); 41 | var iniVal = constraints[i].initialValue; 42 | var finVal = constraints[i].finalValue; 43 | var tmpWhere = ''; 44 | if ( constraints[i].constraintType == 'MUST_NOT' ) 45 | not = 'not'; 46 | if ( campo.indexOf('___not___') >= 0 ){ 47 | not = 'not'; 48 | campo = campo.replace('___not___',''); 49 | } 50 | 51 | if( constraints[i].initialValue == constraints[i].finalValue 52 | && constraints[i].initialValue.split('\\|').length >= 2 ){ 53 | iniVal = constraints[i].initialValue.split('\\|')[0]; 54 | finVal = constraints[i].initialValue.split('\\|')[1]; 55 | } 56 | if ( campo.indexOf('=') >= 0 ){ 57 | tmpWhere = ' and ' + campo; 58 | } else { 59 | if ( campo.indexOf('___in___') >= 0 ){ 60 | if( constraints[i].initialValue.split('\\|').length > 0 ){ 61 | where += " and "+ campo.replace('___in___','') + 62 | " "+not+" in ( '"+ constraints[i].initialValue.split('\\|').join("','") +"' ) "; 63 | } 64 | }else if ( constraints[i].likeSearch || constraints[i].constraintType == 'SHOULD' ){ 65 | where += " and "+ campo + 66 | " "+not+" like upper( '%"+ constraints[i].initialValue +"%' ) "; 67 | }else{ 68 | where += " and "+ campo + 69 | " "+not+" between upper( '"+ iniVal +"' ) and upper( '"+ finVal +"' )"; 70 | } 71 | } 72 | } 73 | } 74 | } 75 | 76 | if (sortFields != null) { 77 | for (var i = 0; i < sortFields.length; i++) { 78 | log.info( 'Order '+i ); 79 | order += ', '+sortFields[i]; 80 | } 81 | } 82 | 83 | try{ 84 | 85 | log.info( '$001... ' ); 86 | var contextWD = new javax.naming.InitialContext(); 87 | log.info( '$002... ' ); 88 | var dataSourceWD = contextWD.lookup( "java:/jdbc/FluigDS" ); 89 | log.info( '$003... ' ); 90 | var connectionWD = dataSourceWD.getConnection(); 91 | log.info( '$004... ' ); 92 | 93 | var sql = " select doc.COD_LISTA, " + 94 | " ml.COD_LISTA_FILHO as COD_FILHO " + 95 | " from documento doc "+ 96 | " join META_LISTA_REL ml on (ml.COD_EMPRESA = doc.COD_EMPRESA "+ 97 | " and ml.COD_LISTA_PAI = doc.COD_LISTA "+ 98 | " and ml.COD_TABELA = '"+ table +"' ) "+ 99 | " where doc.COD_EMPRESA = 1 "+ 100 | " and doc.NM_DATASET = '"+ dsName +"' "+ 101 | " and doc.VERSAO_ATIVA = 1 "; 102 | 103 | log.info( '$005... '+sql ); 104 | statementWD = connectionWD.prepareStatement(sql); 105 | rsWD = statementWD.executeQuery(); 106 | 107 | var mlPai = ''; 108 | var mlFilho = ''; 109 | 110 | while(rsWD.next()) { 111 | mlPai = rsWD.getString( 'COD_LISTA' ); 112 | mlFilho = rsWD.getString( 'COD_FILHO' ); 113 | } 114 | 115 | log.info( '$005 campos...|'+campos+'|...' ); 116 | var sql = " select "; 117 | if( campos.length == 0 ){ 118 | sql += " "+distinct+" f.* " ; 119 | }else{ 120 | sql += " "+distinct+" "+ campos.join(',') +" " ; 121 | } 122 | 123 | 124 | sql += " from ML001"+ getLPad( mlPai, '000' ) +" p "+ 125 | " join ML001"+ getLPad( mlFilho, '000' ) +" f on (p.companyid = f.companyid "+ 126 | " and p.documentid = f.documentid "+ 127 | " and p.version = f.version) "+ 128 | " join DOCUMENTO d on (d.COD_EMPRESA = p.companyid "+ 129 | " and d.NR_DOCUMENTO = p.documentid "+ 130 | " and d.NR_VERSAO = p.version) "+ 131 | " where p.companyid = 1 "+ 132 | " and d.VERSAO_ATIVA = 1 "; 133 | sql += where; 134 | 135 | if ( order != '' ) 136 | sql += " order by "+ order ; 137 | 138 | log.info( '$005... '+sql ); 139 | statementWD = connectionWD.prepareStatement(sql); 140 | rsWD = statementWD.executeQuery(); 141 | var columnCount = rsWD.getMetaData().getColumnCount(); 142 | var created = false; 143 | while(rsWD.next()) { 144 | log.info( '$009... ' ); 145 | if(!created) { 146 | for(var i=1;i<=columnCount; i++) { 147 | dataset.addColumn(rsWD.getMetaData().getColumnName(i).toLowerCase()); 148 | } 149 | created = true; 150 | } 151 | var Arr = new Array(); 152 | 153 | for(var i=1;i<=columnCount; i++) { 154 | var obj = rsWD.getObject(rsWD.getMetaData().getColumnName(i)); 155 | if(null!=obj){ 156 | Arr[i-1] = rsWD.getObject(rsWD.getMetaData().getColumnName(i)).toString(); 157 | }else{ 158 | Arr[i-1] = "null"; 159 | } 160 | } 161 | dataset.addRow(Arr); 162 | } 163 | rsWD.close(); 164 | 165 | } catch (e){ 166 | log.info( "ERROOOOOO"+ e.toString() ); 167 | } 168 | finally { 169 | log.info('##### 6 #####'); 170 | if(statementWD != null) statementWD.close(); 171 | if(connectionWD != null) connectionWD.close(); 172 | } 173 | return dataset; 174 | 175 | } 176 | function onMobileSync(user) {} 177 | 178 | function getLPad( valor, pad){ 179 | var str = "" + valor; 180 | if( pad.length < str.length ) 181 | return str; 182 | return pad.substring(0, pad.length - str.length) + str; 183 | 184 | } -------------------------------------------------------------------------------- /Publicar arquivo no fluig/fileUpload.js: -------------------------------------------------------------------------------- 1 | 2 | var descFile = ""; 3 | var idDocProc = ""; 4 | var folder = ""; 5 | 6 | function openFile( obj ){ 7 | 8 | var parentOBJ; 9 | 10 | if (window.opener) { 11 | parentOBJ = window.opener.parent; 12 | } else { 13 | parentOBJ = parent; 14 | } 15 | 16 | var cfg = { 17 | url : "/ecm_documentview/documentView.ftl", 18 | maximized : true, 19 | title : "Anexo", 20 | callBack : function() { 21 | parentOBJ.ECM.documentView.getDocument( $($(obj).parent().children()[0]).val() ); //, 1000 ); 22 | }, 23 | customButtons : [] 24 | }; 25 | parentOBJ.ECM.documentView.panel = parentOBJ.WCMC.panel(cfg); 26 | 27 | } 28 | 29 | 30 | function openFolder( folder ){ 31 | 32 | var documentUrl = window.parent.WCMAPI.getProtectedContextPath() + "/" + window.parent.WCMAPI.getTenantCode() + "/ecmnavigation?app_ecm_navigation_doc=" + folder; 33 | window.open(documentUrl) 34 | 35 | } 36 | 37 | function loadFile( id ){ 38 | 39 | if( $( '#pasta_chamado' ).val() == "" ){ 40 | if( !confirm("Será criado uma para armazenar os anexos do chamado!") ){ 41 | return false; 42 | }else{ 43 | criaEstrPastas( id ); 44 | } 45 | }else{ 46 | defNomeFile( id ); 47 | } 48 | 49 | } 50 | 51 | function defNomeFile( id ){ 52 | 53 | console.log('id......'+ id); 54 | 55 | var modalLabel = null; 56 | 57 | descFile = "DAP | Documento de Aposentadoria"; 58 | idDocProc = "doc_dap"; 59 | 60 | console.log('descFile...', descFile, 'idDocProc', idDocProc); 61 | // console.log(modalLabel); 62 | // $('#load_file').click(); 63 | // complemento(modalLabel, function(){ 64 | $('#load_file').click(); 65 | // }) 66 | 67 | // 68 | 69 | 70 | } 71 | 72 | var myLoading = FLUIGC.loading(window, { 73 | textMessage: 'Aguarde, realizando upload.' 74 | }); 75 | 76 | function selectFile( files ){ 77 | console.log('selectFile', files); 78 | 79 | if( files.length == 0 ){ 80 | return false; 81 | } 82 | 83 | var file = files[0]; 84 | myLoading.show(); 85 | var blob = new Blob([file],{type: 'application/octet-stream'}); 86 | //enviar o arquivo selecionado para o diretório de upload do usuário logado 87 | $.ajax({ 88 | url: '/api/public/2.0/contentfiles/upload/?fileName=' + encodeURIComponent(file.name), 89 | type: 'POST', 90 | //data: formData, 91 | data: blob, 92 | cache: false, 93 | contentType: 'application/octet-stream', 94 | processData: false, 95 | success: function(data) { 96 | //seta nome do arquivo em um input text para correta visualizacao no dataset do form 97 | $('#file_name').val(file.name); 98 | //funcao que controle o checked que indica se o arquivo foi selecionado 99 | //checkDocumento(file.name, $(input).data("checkbox-name")); 100 | myLoading.hide(); 101 | 102 | publicaFile( file ); 103 | }, 104 | error: function(xhr, status, error) { 105 | //erro 106 | if (status == "error"){ 107 | $(input).val(""); 108 | checkDocumento("", $(input).data("checkbox-name")); 109 | } 110 | myLoading.hide(); 111 | console.log("STATUS: " + status); 112 | console.log("ERROR: " + error); 113 | console.log(xhr); 114 | var err = eval("(" + xhr.responseText + ")"); 115 | //exibe erro no form 116 | FLUIGC.toast({ 117 | title: 'Erro ao realizar upload do arquivo selecionado. ', 118 | message: err.message.message + " " + error, 119 | type: 'danger' 120 | }); 121 | } 122 | }); 123 | } 124 | 125 | function publicaFile( file ){ 126 | 127 | console.log('publicaFile'); 128 | 129 | myLoading.show(); 130 | $.ajax({ 131 | async : true, 132 | type : "POST", 133 | contentType: "application/json", 134 | url : '/api/public/ecm/document/createDocument', 135 | 136 | data: JSON.stringify({ 137 | "description": descFile+' - '+file.name, 138 | "parentId": $('#num_pasta_motorista').val(), 139 | "downloadEnabled": true, 140 | "attachments": [{ 141 | "fileName": file.name 142 | }], 143 | }), 144 | error: function() { 145 | FLUIGC.toast({ 146 | title: '', 147 | message: "Falha ao enviar", 148 | type: 'danger' 149 | }); 150 | myLoading.hide(); 151 | }, 152 | success: function(data) { 153 | console.log('data.....',data.content.id); 154 | $( '#'+idDocProc ).val( data.content.id ); 155 | FLUIGC.toast({ 156 | title: '', 157 | message: "Documento publicado - " + file.name, 158 | type: 'info' 159 | }); 160 | myLoading.hide(); 161 | 162 | // complemento(); 163 | }, 164 | }); 165 | } 166 | 167 | function criaEstrPastas( id ){ 168 | console.log('criaEstrPastas', id); 169 | var fdm = createFolder( $("#num_chamado").val(), '7306', false ); 170 | $( '#pasta_chamado' ).val( fdm ); 171 | 172 | defNomeFile(id); 173 | } 174 | 175 | function createFolder( description, parentId, bloqExt ){ 176 | 177 | console.log('description', description, 'parentId', parentId, 'bloqExt', bloqExt); 178 | 179 | var idFolder = 0; 180 | var grupo = ''; 181 | if( bloqExt ){ 182 | grupo = ''; 183 | } 184 | var cons = new Array(); 185 | cons.push( DatasetFactory.createConstraint( 'FOLDER_NAME', description, null, ConstraintType.MUST) ); 186 | cons.push( DatasetFactory.createConstraint( 'PARENT_FOLDER_CODE', parentId, null, ConstraintType.MUST) ); 187 | cons.push( DatasetFactory.createConstraint( 'GROUP_HIDDEN', grupo, null, ConstraintType.MUST) ); 188 | 189 | var dataset = DatasetFactory.getDataset( 'ds_create_folder', null, cons, null); 190 | 191 | if( dataset.values.length > 0 ){ 192 | idFolder = dataset.values[0]['FOLDER']; 193 | 194 | FLUIGC.toast({ 195 | title: '', 196 | message: "Pasta Criada - " + idFolder+" "+description , 197 | type: 'info' 198 | }); 199 | 200 | } 201 | 202 | return idFolder; 203 | } 204 | 205 | function complemento(modalLabel, callback){ 206 | 207 | console.log(modalLabel); 208 | 209 | if (modalLabel == null) { 210 | console.log('1'); 211 | // $('#load_file').click(); 212 | callback(); 213 | } else { 214 | var html = ' '+ 215 | ''; 216 | 217 | var myModal = FLUIGC.modal({ 218 | content: html, 219 | id: 'fluig-modal', 220 | actions: [{ 221 | 'label': 'Save', 222 | 'classType': 'btn-success save', 223 | 'bind': 'data-save-modal', 224 | }] 225 | }, function(err, data) { 226 | if(err) { 227 | // do error handling 228 | } else { 229 | // do something with data 230 | setMask(); 231 | $('.save').click( function() { 232 | 233 | if ($('#valor_modal').val() == "") { 234 | alert('Obrigatório preenchimento do campo'); 235 | return false; 236 | } 237 | 238 | $('#' + modalLabel[2]).val( $('#valor_modal').val() ); 239 | 240 | myModal.remove(); 241 | 242 | console.log('2'); 243 | callback(); 244 | // $('#load_file').click(); 245 | 246 | }); 247 | } 248 | }); 249 | } 250 | } -------------------------------------------------------------------------------- /Exportar datatable para excel/jquery.btechco.excelexport.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery Excel Export Plugin Library 3 | * http://tarunbatta.blogspot.com/ 4 | * 5 | * Copyright (c) 2013 Tarun Batta 6 | * Licensed under BTechCo licenses. 7 | * https://github.com/btechco/btechco_excelexport/wiki 8 | * 9 | */ 10 | 11 | (function ($) { 12 | 13 | $datatype = { 14 | Table: 1 15 | , Json: 2 16 | , Xml: 3 17 | , JqGrid: 4 18 | } 19 | 20 | var $defaults = { 21 | containerid: null 22 | , datatype: $datatype.Table 23 | , dataset: null 24 | , columns: null 25 | , filename: null 26 | }; 27 | 28 | var $settings = $defaults; 29 | 30 | $.fn.btechco_excelexport = function (options) { 31 | $settings = $.extend({}, $defaults, options); 32 | 33 | switch ($settings.datatype) { 34 | case 1: 35 | Export($("#" + $settings.containerid).parent().html()); 36 | break; 37 | case 2: 38 | Export(ConvertJsonToTable()); 39 | break; 40 | case 3: 41 | Export(ConvertXmlToTable()); 42 | break; 43 | case 4: 44 | Export(ConvertJqGridDataToTable()); 45 | break; 46 | } 47 | 48 | function ConvertJsonToTable() { 49 | var result = ""; 50 | 51 | result += ""; 52 | $($settings.columns).each(function (key, value) { 53 | if (this.ishidden != true) { 54 | result += " row").each(function (key, value) { 149 | result += ""; 150 | $($settings.columns).each(function (k, v) { 151 | if ($(value).find(this.datafield)) { 152 | if (this.ishidden != true) { 153 | result += "a { 41 | min-width: 30px; 42 | height: 28px; 43 | line-height: 28px; 44 | display: block; 45 | background: #fff; 46 | font-size: 14px; 47 | color: #333; 48 | text-decoration: none; 49 | text-align: center 50 | } 51 | 52 | .paginationjs .paginationjs-pages li>a:hover { 53 | background: #eee 54 | } 55 | 56 | .paginationjs .paginationjs-pages li.active { 57 | border: none 58 | } 59 | 60 | .paginationjs .paginationjs-pages li.active>a { 61 | height: 30px; 62 | line-height: 30px; 63 | background: #aaa; 64 | color: #fff 65 | } 66 | 67 | .paginationjs .paginationjs-pages li.disabled>a { 68 | opacity: .3 69 | } 70 | 71 | .paginationjs .paginationjs-pages li.disabled>a:hover { 72 | background: 0 0 73 | } 74 | 75 | .paginationjs .paginationjs-pages li:first-child, 76 | .paginationjs .paginationjs-pages li:first-child>a { 77 | border-radius: 3px 0 0 3px 78 | } 79 | 80 | .paginationjs .paginationjs-pages li:last-child { 81 | border-right: 1px solid #aaa; 82 | border-radius: 0 3px 3px 0 83 | } 84 | 85 | .paginationjs .paginationjs-pages li:last-child>a { 86 | border-radius: 0 3px 3px 0 87 | } 88 | 89 | .paginationjs .paginationjs-go-input>input[type=text] { 90 | width: 30px; 91 | height: 28px; 92 | background: #fff; 93 | border-radius: 3px; 94 | border: 1px solid #aaa; 95 | padding: 0; 96 | font-size: 14px; 97 | text-align: center; 98 | vertical-align: baseline; 99 | outline: 0; 100 | box-shadow: none; 101 | box-sizing: initial 102 | } 103 | 104 | .paginationjs .paginationjs-go-button>input[type=button] { 105 | min-width: 40px; 106 | height: 30px; 107 | line-height: 28px; 108 | background: #fff; 109 | border-radius: 3px; 110 | border: 1px solid #aaa; 111 | text-align: center; 112 | padding: 0 8px; 113 | font-size: 14px; 114 | vertical-align: baseline; 115 | outline: 0; 116 | box-shadow: none; 117 | color: #333; 118 | cursor: pointer; 119 | vertical-align: middle\9 120 | } 121 | 122 | .paginationjs.paginationjs-theme-blue .paginationjs-go-input>input[type=text], 123 | .paginationjs.paginationjs-theme-blue .paginationjs-pages li { 124 | border-color: #289de9 125 | } 126 | 127 | .paginationjs .paginationjs-go-button>input[type=button]:hover { 128 | background-color: #f8f8f8 129 | } 130 | 131 | .paginationjs .paginationjs-nav { 132 | height: 30px; 133 | line-height: 30px 134 | } 135 | 136 | .paginationjs .paginationjs-go-button, 137 | .paginationjs .paginationjs-go-input { 138 | margin-left: 5px\9 139 | } 140 | 141 | .paginationjs.paginationjs-small { 142 | font-size: 12px 143 | } 144 | 145 | .paginationjs.paginationjs-small .paginationjs-pages li>a { 146 | min-width: 26px; 147 | height: 24px; 148 | line-height: 24px; 149 | font-size: 12px 150 | } 151 | 152 | .paginationjs.paginationjs-small .paginationjs-pages li.active>a { 153 | height: 26px; 154 | line-height: 26px 155 | } 156 | 157 | .paginationjs.paginationjs-small .paginationjs-go-input { 158 | font-size: 12px 159 | } 160 | 161 | .paginationjs.paginationjs-small .paginationjs-go-input>input[type=text] { 162 | width: 26px; 163 | height: 24px; 164 | font-size: 12px 165 | } 166 | 167 | .paginationjs.paginationjs-small .paginationjs-go-button { 168 | font-size: 12px 169 | } 170 | 171 | .paginationjs.paginationjs-small .paginationjs-go-button>input[type=button] { 172 | min-width: 30px; 173 | height: 26px; 174 | line-height: 24px; 175 | padding: 0 6px; 176 | font-size: 12px 177 | } 178 | 179 | .paginationjs.paginationjs-small .paginationjs-nav { 180 | height: 26px; 181 | line-height: 26px; 182 | font-size: 12px 183 | } 184 | 185 | .paginationjs.paginationjs-big { 186 | font-size: 16px 187 | } 188 | 189 | .paginationjs.paginationjs-big .paginationjs-pages li>a { 190 | min-width: 36px; 191 | height: 34px; 192 | line-height: 34px; 193 | font-size: 16px 194 | } 195 | 196 | .paginationjs.paginationjs-big .paginationjs-pages li.active>a { 197 | height: 36px; 198 | line-height: 36px 199 | } 200 | 201 | .paginationjs.paginationjs-big .paginationjs-go-input { 202 | font-size: 16px 203 | } 204 | 205 | .paginationjs.paginationjs-big .paginationjs-go-input>input[type=text] { 206 | width: 36px; 207 | height: 34px; 208 | font-size: 16px 209 | } 210 | 211 | .paginationjs.paginationjs-big .paginationjs-go-button { 212 | font-size: 16px 213 | } 214 | 215 | .paginationjs.paginationjs-big .paginationjs-go-button>input[type=button] { 216 | min-width: 50px; 217 | height: 36px; 218 | line-height: 34px; 219 | padding: 0 12px; 220 | font-size: 16px 221 | } 222 | 223 | .paginationjs.paginationjs-big .paginationjs-nav { 224 | height: 36px; 225 | line-height: 36px; 226 | font-size: 16px 227 | } 228 | 229 | .paginationjs.paginationjs-theme-blue .paginationjs-pages li>a { 230 | color: #289de9 231 | } 232 | 233 | .paginationjs.paginationjs-theme-blue .paginationjs-pages li>a:hover { 234 | background: #e9f4fc 235 | } 236 | 237 | .paginationjs.paginationjs-theme-blue .paginationjs-pages li.active>a { 238 | background: #289de9; 239 | color: #fff 240 | } 241 | 242 | .paginationjs.paginationjs-theme-blue .paginationjs-pages li.disabled>a:hover { 243 | background: 0 0 244 | } 245 | 246 | .paginationjs.paginationjs-theme-blue .paginationjs-go-button>input[type=button] { 247 | background: #289de9; 248 | border-color: #289de9; 249 | color: #fff 250 | } 251 | 252 | .paginationjs.paginationjs-theme-green .paginationjs-go-input>input[type=text], 253 | .paginationjs.paginationjs-theme-green .paginationjs-pages li { 254 | border-color: #449d44 255 | } 256 | 257 | .paginationjs.paginationjs-theme-blue .paginationjs-go-button>input[type=button]:hover { 258 | background-color: #3ca5ea 259 | } 260 | 261 | .paginationjs.paginationjs-theme-green .paginationjs-pages li>a { 262 | color: #449d44 263 | } 264 | 265 | .paginationjs.paginationjs-theme-green .paginationjs-pages li>a:hover { 266 | background: #ebf4eb 267 | } 268 | 269 | .paginationjs.paginationjs-theme-green .paginationjs-pages li.active>a { 270 | background: #449d44; 271 | color: #fff 272 | } 273 | 274 | .paginationjs.paginationjs-theme-green .paginationjs-pages li.disabled>a:hover { 275 | background: 0 0 276 | } 277 | 278 | .paginationjs.paginationjs-theme-green .paginationjs-go-button>input[type=button] { 279 | background: #449d44; 280 | border-color: #449d44; 281 | color: #fff 282 | } 283 | 284 | .paginationjs.paginationjs-theme-yellow .paginationjs-go-input>input[type=text], 285 | .paginationjs.paginationjs-theme-yellow .paginationjs-pages li { 286 | border-color: #ec971f 287 | } 288 | 289 | .paginationjs.paginationjs-theme-green .paginationjs-go-button>input[type=button]:hover { 290 | background-color: #55a555 291 | } 292 | 293 | .paginationjs.paginationjs-theme-yellow .paginationjs-pages li>a { 294 | color: #ec971f 295 | } 296 | 297 | .paginationjs.paginationjs-theme-yellow .paginationjs-pages li>a:hover { 298 | background: #fdf5e9 299 | } 300 | 301 | .paginationjs.paginationjs-theme-yellow .paginationjs-pages li.active>a { 302 | background: #ec971f; 303 | color: #fff 304 | } 305 | 306 | .paginationjs.paginationjs-theme-yellow .paginationjs-pages li.disabled>a:hover { 307 | background: 0 0 308 | } 309 | 310 | .paginationjs.paginationjs-theme-yellow .paginationjs-go-button>input[type=button] { 311 | background: #ec971f; 312 | border-color: #ec971f; 313 | color: #fff 314 | } 315 | 316 | .paginationjs.paginationjs-theme-red .paginationjs-go-input>input[type=text], 317 | .paginationjs.paginationjs-theme-red .paginationjs-pages li { 318 | border-color: #c9302c 319 | } 320 | 321 | .paginationjs.paginationjs-theme-yellow .paginationjs-go-button>input[type=button]:hover { 322 | background-color: #eea135 323 | } 324 | 325 | .paginationjs.paginationjs-theme-red .paginationjs-pages li>a { 326 | color: #c9302c 327 | } 328 | 329 | .paginationjs.paginationjs-theme-red .paginationjs-pages li>a:hover { 330 | background: #faeaea 331 | } 332 | 333 | .paginationjs.paginationjs-theme-red .paginationjs-pages li.active>a { 334 | background: #c9302c; 335 | color: #fff 336 | } 337 | 338 | .paginationjs.paginationjs-theme-red .paginationjs-pages li.disabled>a:hover { 339 | background: 0 0 340 | } 341 | 342 | .paginationjs.paginationjs-theme-red .paginationjs-go-button>input[type=button] { 343 | background: #c9302c; 344 | border-color: #c9302c; 345 | color: #fff 346 | } 347 | 348 | .paginationjs.paginationjs-theme-red .paginationjs-go-button>input[type=button]:hover { 349 | background-color: #ce4541 350 | } 351 | 352 | .paginationjs .paginationjs-pages li.paginationjs-next { 353 | border-right: 1px solid #aaa\9 354 | } 355 | 356 | .paginationjs .paginationjs-go-input>input[type=text] { 357 | line-height: 28px\9; 358 | vertical-align: middle\9 359 | } 360 | 361 | .paginationjs.paginationjs-big .paginationjs-pages li>a { 362 | line-height: 36px\9 363 | } 364 | 365 | .paginationjs.paginationjs-big .paginationjs-go-input>input[type=text] { 366 | height: 36px\9; 367 | line-height: 36px\9 368 | } -------------------------------------------------------------------------------- /Exportar datatable para excel/table2excel.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery table2excel - v1.1.1 3 | * jQuery plugin to export an .xls file in browser from an HTML table 4 | * https://github.com/rainabba/jquery-table2excel 5 | * 6 | * Made by rainabba 7 | * Under MIT License 8 | */ 9 | //table2excel.js 10 | ; (function ($, window, document, undefined) { 11 | var pluginName = "table2excel", 12 | 13 | defaults = { 14 | exclude: ".noExl", 15 | name: "Table2Excel", 16 | filename: "table2excel", 17 | fileext: ".xls", 18 | exclude_img: true, 19 | exclude_links: true, 20 | exclude_inputs: true 21 | }; 22 | 23 | // The actual plugin constructor 24 | function Plugin(element, options) { 25 | this.element = element; 26 | // jQuery has an extend method which merges the contents of two or 27 | // more objects, storing the result in the first object. The first object 28 | // is generally empty as we don't want to alter the default options for 29 | // future instances of the plugin 30 | // 31 | this.settings = $.extend({}, defaults, options); 32 | this._defaults = defaults; 33 | this._name = pluginName; 34 | this.init(); 35 | } 36 | 37 | Plugin.prototype = { 38 | init: function () { 39 | var e = this; 40 | 41 | var utf8Heading = ""; 42 | e.template = { 43 | head: "" + utf8Heading + "", 49 | table: { 50 | head: "
", 51 | tail: "
" 52 | }, 53 | foot: "" 54 | }; 55 | 56 | e.tableRows = []; 57 | 58 | // get contents of table except for exclude 59 | $(e.element).each(function (i, o) { 60 | var tempRows = ""; 61 | $(o).find("tr").not(e.settings.exclude).each(function (i, p) { 62 | 63 | tempRows += ""; 64 | $(p).find("td,th").not(e.settings.exclude).each(function (i, q) { // p did not exist, I corrected 65 | 66 | var rc = { 67 | rows: $(this).attr("rowspan"), 68 | cols: $(this).attr("colspan"), 69 | flag: $(q).find(e.settings.exclude) 70 | }; 71 | 72 | if (rc.flag.length > 0) { 73 | tempRows += " "; // exclude it!! 74 | } else { 75 | if (rc.rows & rc.cols) { 76 | tempRows += "" + $(q).html() + ""; 77 | } else { 78 | tempRows += " 0) { 80 | tempRows += " rowspan=\'" + rc.rows + "\' "; 81 | } 82 | if (rc.cols > 0) { 83 | tempRows += " colspan=\'" + rc.cols + "\' "; 84 | } 85 | tempRows += "/>" + $(q).html() + ""; 86 | } 87 | } 88 | }); 89 | 90 | tempRows += ""; 91 | console.log(tempRows); 92 | 93 | }); 94 | // exclude img tags 95 | if (e.settings.exclude_img) { 96 | tempRows = exclude_img(tempRows); 97 | } 98 | 99 | // exclude link tags 100 | if (e.settings.exclude_links) { 101 | tempRows = exclude_links(tempRows); 102 | } 103 | 104 | // exclude input tags 105 | if (e.settings.exclude_inputs) { 106 | tempRows = exclude_inputs(tempRows); 107 | } 108 | e.tableRows.push(tempRows); 109 | }); 110 | 111 | e.tableToExcel(e.tableRows, e.settings.name, e.settings.sheetName); 112 | }, 113 | 114 | tableToExcel: function (table, name, sheetName) { 115 | var e = this, fullTemplate = "", i, link, a; 116 | 117 | e.format = function (s, c) { 118 | return s.replace(/{(\w+)}/g, function (m, p) { 119 | return c[p]; 120 | }); 121 | }; 122 | 123 | sheetName = typeof sheetName === "undefined" ? "Sheet" : sheetName; 124 | 125 | e.ctx = { 126 | worksheet: name || "Worksheet", 127 | table: table, 128 | sheetName: sheetName 129 | }; 130 | 131 | fullTemplate = e.template.head; 132 | 133 | if ($.isArray(table)) { 134 | for (i in table) { 135 | //fullTemplate += e.template.sheet.head + "{worksheet" + i + "}" + e.template.sheet.tail; 136 | fullTemplate += e.template.sheet.head + sheetName + i + e.template.sheet.tail; 137 | } 138 | } 139 | 140 | fullTemplate += e.template.mid; 141 | 142 | if ($.isArray(table)) { 143 | for (i in table) { 144 | fullTemplate += e.template.table.head + "{table" + i + "}" + e.template.table.tail; 145 | } 146 | } 147 | 148 | fullTemplate += e.template.foot; 149 | 150 | for (i in table) { 151 | e.ctx["table" + i] = table[i]; 152 | } 153 | delete e.ctx.table; 154 | 155 | var isIE = /*@cc_on!@*/false || !!document.documentMode; // this works with IE10 and IE11 both :) 156 | //if (typeof msie !== "undefined" && msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // this works ONLY with IE 11!!! 157 | if (isIE) { 158 | if (typeof Blob !== "undefined") { 159 | //use blobs if we can 160 | fullTemplate = e.format(fullTemplate, e.ctx); // with this, works with IE 161 | fullTemplate = [fullTemplate]; 162 | //convert to array 163 | var blob1 = new Blob(fullTemplate, { type: "text/html" }); 164 | window.navigator.msSaveBlob(blob1, getFileName(e.settings)); 165 | } else { 166 | //otherwise use the iframe and save 167 | //requires a blank iframe on page called txtArea1 168 | txtArea1.document.open("text/html", "replace"); 169 | txtArea1.document.write(e.format(fullTemplate, e.ctx)); 170 | txtArea1.document.close(); 171 | txtArea1.focus(); 172 | sa = txtArea1.document.execCommand("SaveAs", true, getFileName(e.settings)); 173 | } 174 | 175 | } else { 176 | var blob = new Blob([e.format(fullTemplate, e.ctx)], { type: "application/vnd.ms-excel" }); 177 | window.URL = window.URL || window.webkitURL; 178 | link = window.URL.createObjectURL(blob); 179 | a = document.createElement("a"); 180 | a.download = getFileName(e.settings); 181 | a.href = link; 182 | 183 | document.body.appendChild(a); 184 | 185 | a.click(); 186 | 187 | document.body.removeChild(a); 188 | } 189 | 190 | return true; 191 | } 192 | }; 193 | 194 | function getFileName(settings) { 195 | return (settings.filename ? settings.filename : "table2excel"); 196 | } 197 | 198 | // Removes all img tags 199 | function exclude_img(string) { 200 | var _patt = /(\s+alt\s*=\s*"([^"]*)"|\s+alt\s*=\s*'([^']*)')/i; 201 | return string.replace(/]*>/gi, function myFunction(x) { 202 | var res = _patt.exec(x); 203 | if (res !== null && res.length >= 2) { 204 | return res[2]; 205 | } else { 206 | return ""; 207 | } 208 | }); 209 | } 210 | 211 | // Removes all link tags 212 | function exclude_links(string) { 213 | return string.replace(/]*>|<\/a>/gi, ""); 214 | } 215 | 216 | // Removes input params 217 | function exclude_inputs(string) { 218 | var _patt = /(\s+value\s*=\s*"([^"]*)"|\s+value\s*=\s*'([^']*)')/i; 219 | return string.replace(/]*>|<\/input>/gi, function myFunction(x) { 220 | var res = _patt.exec(x); 221 | if (res !== null && res.length >= 2) { 222 | return res[2]; 223 | } else { 224 | return ""; 225 | } 226 | }); 227 | } 228 | 229 | $.fn[pluginName] = function (options) { 230 | var e = this; 231 | e.each(function () { 232 | if (!$.data(e, "plugin_" + pluginName)) { 233 | $.data(e, "plugin_" + pluginName, new Plugin(this, options)); 234 | } 235 | }); 236 | 237 | // chain jQuery functions 238 | return e; 239 | }; 240 | 241 | })(jQuery, window, document); 242 | -------------------------------------------------------------------------------- /Consumir Dataset Publico/oauth/oauth-1.0a.js: -------------------------------------------------------------------------------- 1 | if (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { 2 | module.exports = OAuth; 3 | var CryptoJS = require("crypto-js"); 4 | } 5 | 6 | /** 7 | * Constructor 8 | * @param {Object} opts consumer key and secret 9 | */ 10 | function OAuth(opts) { 11 | if(!(this instanceof OAuth)) { 12 | return new OAuth(opts); 13 | } 14 | 15 | if(!opts) { 16 | opts = {}; 17 | } 18 | 19 | if(!opts.consumer) { 20 | throw new Error('consumer option is required'); 21 | } 22 | 23 | this.consumer = opts.consumer; 24 | this.signature_method = opts.signature_method || 'HMAC-SHA1'; 25 | this.nonce_length = opts.nonce_length || 32; 26 | this.version = opts.version || '1.0'; 27 | this.parameter_seperator = opts.parameter_seperator || ', '; 28 | 29 | if(typeof opts.last_ampersand === 'undefined') { 30 | this.last_ampersand = true; 31 | } else { 32 | this.last_ampersand = opts.last_ampersand; 33 | } 34 | 35 | switch (this.signature_method) { 36 | case 'HMAC-SHA1': 37 | this.hash = function(base_string, key) { 38 | return CryptoJS.HmacSHA1(base_string, key).toString(CryptoJS.enc.Base64); 39 | }; 40 | break; 41 | 42 | case 'HMAC-SHA256': 43 | this.hash = function(base_string, key) { 44 | return CryptoJS.HmacSHA256(base_string, key).toString(CryptoJS.enc.Base64); 45 | }; 46 | break; 47 | 48 | case 'PLAINTEXT': 49 | this.hash = function(base_string, key) { 50 | return key; 51 | }; 52 | break; 53 | 54 | case 'RSA-SHA1': 55 | throw new Error('oauth-1.0a does not support this signature method right now. Coming Soon...'); 56 | default: 57 | throw new Error('The OAuth 1.0a protocol defines three signature methods: HMAC-SHA1, RSA-SHA1, and PLAINTEXT only'); 58 | } 59 | } 60 | 61 | /** 62 | * OAuth request authorize 63 | * @param {Object} request data 64 | * { 65 | * method, 66 | * url, 67 | * data 68 | * } 69 | * @param {Object} public and secret token 70 | * @return {Object} OAuth Authorized data 71 | */ 72 | OAuth.prototype.authorize = function(request, token) { 73 | var oauth_data = { 74 | oauth_consumer_key: this.consumer.public, 75 | oauth_nonce: this.getNonce(), 76 | oauth_signature_method: this.signature_method, 77 | oauth_timestamp: this.getTimeStamp(), 78 | oauth_version: this.version 79 | }; 80 | 81 | if(!token) { 82 | token = {}; 83 | } 84 | 85 | if(token.public) { 86 | oauth_data.oauth_token = token.public; 87 | } 88 | 89 | if(!request.data) { 90 | request.data = {}; 91 | } 92 | 93 | oauth_data.oauth_signature = this.getSignature(request, token.secret, oauth_data); 94 | 95 | return oauth_data; 96 | }; 97 | 98 | /** 99 | * Create a OAuth Signature 100 | * @param {Object} request data 101 | * @param {Object} token_secret public and secret token 102 | * @param {Object} oauth_data OAuth data 103 | * @return {String} Signature 104 | */ 105 | OAuth.prototype.getSignature = function(request, token_secret, oauth_data) { 106 | return this.hash(this.getBaseString(request, oauth_data), this.getSigningKey(token_secret)); 107 | }; 108 | 109 | /** 110 | * Base String = Method + Base Url + ParameterString 111 | * @param {Object} request data 112 | * @param {Object} OAuth data 113 | * @return {String} Base String 114 | */ 115 | OAuth.prototype.getBaseString = function(request, oauth_data) { 116 | return request.method.toUpperCase() + '&' + this.percentEncode(this.getBaseUrl(request.url)) + '&' + this.percentEncode(this.getParameterString(request, oauth_data)); 117 | }; 118 | 119 | /** 120 | * Get data from url 121 | * -> merge with oauth data 122 | * -> percent encode key & value 123 | * -> sort 124 | * 125 | * @param {Object} request data 126 | * @param {Object} OAuth data 127 | * @return {Object} Parameter string data 128 | */ 129 | OAuth.prototype.getParameterString = function(request, oauth_data) { 130 | var base_string_data = this.sortObject(this.percentEncodeData(this.mergeObject(oauth_data, this.mergeObject(request.data, this.deParamUrl(request.url))))); 131 | 132 | var data_str = ''; 133 | 134 | //base_string_data to string 135 | for(var key in base_string_data) { 136 | var value = base_string_data[key]; 137 | // check if the value is an array 138 | // this means that this key has multiple values 139 | if (value && Array.isArray(value)){ 140 | // sort the array first 141 | value.sort(); 142 | 143 | var valString = ""; 144 | // serialize all values for this key: e.g. formkey=formvalue1&formkey=formvalue2 145 | value.forEach((function(item, i){ 146 | valString += key + '=' + item; 147 | if (i < value.length){ 148 | valString += "&"; 149 | } 150 | }).bind(this)); 151 | data_str += valString; 152 | } else { 153 | data_str += key + '=' + value + '&'; 154 | } 155 | } 156 | 157 | //remove the last character 158 | data_str = data_str.substr(0, data_str.length - 1); 159 | return data_str; 160 | }; 161 | 162 | /** 163 | * Create a Signing Key 164 | * @param {String} token_secret Secret Token 165 | * @return {String} Signing Key 166 | */ 167 | OAuth.prototype.getSigningKey = function(token_secret) { 168 | token_secret = token_secret || ''; 169 | 170 | if(!this.last_ampersand && !token_secret) { 171 | return this.percentEncode(this.consumer.secret); 172 | } 173 | 174 | return this.percentEncode(this.consumer.secret) + '&' + this.percentEncode(token_secret); 175 | }; 176 | 177 | /** 178 | * Get base url 179 | * @param {String} url 180 | * @return {String} 181 | */ 182 | OAuth.prototype.getBaseUrl = function(url) { 183 | return url.split('?')[0]; 184 | }; 185 | 186 | /** 187 | * Get data from String 188 | * @param {String} string 189 | * @return {Object} 190 | */ 191 | OAuth.prototype.deParam = function(string) { 192 | var arr = string.split('&'); 193 | var data = {}; 194 | 195 | for(var i = 0; i < arr.length; i++) { 196 | var item = arr[i].split('='); 197 | data[item[0]] = decodeURIComponent(item[1]); 198 | } 199 | return data; 200 | }; 201 | 202 | /** 203 | * Get data from url 204 | * @param {String} url 205 | * @return {Object} 206 | */ 207 | OAuth.prototype.deParamUrl = function(url) { 208 | var tmp = url.split('?'); 209 | 210 | if (tmp.length === 1) 211 | return {}; 212 | 213 | return this.deParam(tmp[1]); 214 | }; 215 | 216 | /** 217 | * Percent Encode 218 | * @param {String} str 219 | * @return {String} percent encoded string 220 | */ 221 | OAuth.prototype.percentEncode = function(str) { 222 | return encodeURIComponent(str) 223 | .replace(/\!/g, "%21") 224 | .replace(/\*/g, "%2A") 225 | .replace(/\'/g, "%27") 226 | .replace(/\(/g, "%28") 227 | .replace(/\)/g, "%29"); 228 | }; 229 | 230 | /** 231 | * Percent Encode Object 232 | * @param {Object} data 233 | * @return {Object} percent encoded data 234 | */ 235 | OAuth.prototype.percentEncodeData = function(data) { 236 | var result = {}; 237 | 238 | for(var key in data) { 239 | var value = data[key]; 240 | // check if the value is an array 241 | if (value && Array.isArray(value)){ 242 | var newValue = []; 243 | // percentEncode every value 244 | value.forEach((function(val){ 245 | newValue.push(this.percentEncode(val)); 246 | }).bind(this)); 247 | value = newValue; 248 | } else { 249 | value = this.percentEncode(value); 250 | } 251 | result[this.percentEncode(key)] = value; 252 | } 253 | 254 | return result; 255 | }; 256 | 257 | /** 258 | * Get OAuth data as Header 259 | * @param {Object} oauth_data 260 | * @return {String} Header data key - value 261 | */ 262 | OAuth.prototype.toHeader = function(oauth_data) { 263 | oauth_data = this.sortObject(oauth_data); 264 | 265 | var header_value = 'OAuth '; 266 | 267 | for(var key in oauth_data) { 268 | if (key.indexOf('oauth_') === -1) 269 | continue; 270 | header_value += this.percentEncode(key) + '="' + this.percentEncode(oauth_data[key]) + '"' + this.parameter_seperator; 271 | } 272 | 273 | return { 274 | Authorization: header_value.substr(0, header_value.length - this.parameter_seperator.length) //cut the last chars 275 | }; 276 | }; 277 | 278 | /** 279 | * Create a random word characters string with input length 280 | * @return {String} a random word characters string 281 | */ 282 | OAuth.prototype.getNonce = function() { 283 | var word_characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; 284 | var result = ''; 285 | 286 | for(var i = 0; i < this.nonce_length; i++) { 287 | result += word_characters[parseInt(Math.random() * word_characters.length, 10)]; 288 | } 289 | 290 | return result; 291 | }; 292 | 293 | /** 294 | * Get Current Unix TimeStamp 295 | * @return {Int} current unix timestamp 296 | */ 297 | OAuth.prototype.getTimeStamp = function() { 298 | return parseInt(new Date().getTime()/1000, 10); 299 | }; 300 | 301 | ////////////////////// HELPER FUNCTIONS ////////////////////// 302 | 303 | /** 304 | * Merge object 305 | * @param {Object} obj1 306 | * @param {Object} obj2 307 | * @return {Object} 308 | */ 309 | OAuth.prototype.mergeObject = function(obj1, obj2) { 310 | var merged_obj = obj1; 311 | for(var key in obj2) { 312 | merged_obj[key] = obj2[key]; 313 | } 314 | return merged_obj; 315 | }; 316 | 317 | /** 318 | * Sort object by key 319 | * @param {Object} data 320 | * @return {Object} sorted object 321 | */ 322 | OAuth.prototype.sortObject = function(data) { 323 | var keys = Object.keys(data); 324 | var result = {}; 325 | 326 | keys.sort(); 327 | 328 | for(var i = 0; i < keys.length; i++) { 329 | var key = keys[i]; 330 | result[key] = data[key]; 331 | } 332 | 333 | return result; 334 | }; 335 | -------------------------------------------------------------------------------- /Iniciar Processo via Rest/oauth/oauth-1.0a.js: -------------------------------------------------------------------------------- 1 | if (typeof(module) !== 'undefined' && typeof(exports) !== 'undefined') { 2 | module.exports = OAuth; 3 | var CryptoJS = require("crypto-js"); 4 | } 5 | 6 | /** 7 | * Constructor 8 | * @param {Object} opts consumer key and secret 9 | */ 10 | function OAuth(opts) { 11 | if(!(this instanceof OAuth)) { 12 | return new OAuth(opts); 13 | } 14 | 15 | if(!opts) { 16 | opts = {}; 17 | } 18 | 19 | if(!opts.consumer) { 20 | throw new Error('consumer option is required'); 21 | } 22 | 23 | this.consumer = opts.consumer; 24 | this.signature_method = opts.signature_method || 'HMAC-SHA1'; 25 | this.nonce_length = opts.nonce_length || 32; 26 | this.version = opts.version || '1.0'; 27 | this.parameter_seperator = opts.parameter_seperator || ', '; 28 | 29 | if(typeof opts.last_ampersand === 'undefined') { 30 | this.last_ampersand = true; 31 | } else { 32 | this.last_ampersand = opts.last_ampersand; 33 | } 34 | 35 | switch (this.signature_method) { 36 | case 'HMAC-SHA1': 37 | this.hash = function(base_string, key) { 38 | return CryptoJS.HmacSHA1(base_string, key).toString(CryptoJS.enc.Base64); 39 | }; 40 | break; 41 | 42 | case 'HMAC-SHA256': 43 | this.hash = function(base_string, key) { 44 | return CryptoJS.HmacSHA256(base_string, key).toString(CryptoJS.enc.Base64); 45 | }; 46 | break; 47 | 48 | case 'PLAINTEXT': 49 | this.hash = function(base_string, key) { 50 | return key; 51 | }; 52 | break; 53 | 54 | case 'RSA-SHA1': 55 | throw new Error('oauth-1.0a does not support this signature method right now. Coming Soon...'); 56 | default: 57 | throw new Error('The OAuth 1.0a protocol defines three signature methods: HMAC-SHA1, RSA-SHA1, and PLAINTEXT only'); 58 | } 59 | } 60 | 61 | /** 62 | * OAuth request authorize 63 | * @param {Object} request data 64 | * { 65 | * method, 66 | * url, 67 | * data 68 | * } 69 | * @param {Object} public and secret token 70 | * @return {Object} OAuth Authorized data 71 | */ 72 | OAuth.prototype.authorize = function(request, token) { 73 | var oauth_data = { 74 | oauth_consumer_key: this.consumer.public, 75 | oauth_nonce: this.getNonce(), 76 | oauth_signature_method: this.signature_method, 77 | oauth_timestamp: this.getTimeStamp(), 78 | oauth_version: this.version 79 | }; 80 | 81 | if(!token) { 82 | token = {}; 83 | } 84 | 85 | if(token.public) { 86 | oauth_data.oauth_token = token.public; 87 | } 88 | 89 | if(!request.data) { 90 | request.data = {}; 91 | } 92 | 93 | oauth_data.oauth_signature = this.getSignature(request, token.secret, oauth_data); 94 | 95 | return oauth_data; 96 | }; 97 | 98 | /** 99 | * Create a OAuth Signature 100 | * @param {Object} request data 101 | * @param {Object} token_secret public and secret token 102 | * @param {Object} oauth_data OAuth data 103 | * @return {String} Signature 104 | */ 105 | OAuth.prototype.getSignature = function(request, token_secret, oauth_data) { 106 | return this.hash(this.getBaseString(request, oauth_data), this.getSigningKey(token_secret)); 107 | }; 108 | 109 | /** 110 | * Base String = Method + Base Url + ParameterString 111 | * @param {Object} request data 112 | * @param {Object} OAuth data 113 | * @return {String} Base String 114 | */ 115 | OAuth.prototype.getBaseString = function(request, oauth_data) { 116 | return request.method.toUpperCase() + '&' + this.percentEncode(this.getBaseUrl(request.url)) + '&' + this.percentEncode(this.getParameterString(request, oauth_data)); 117 | }; 118 | 119 | /** 120 | * Get data from url 121 | * -> merge with oauth data 122 | * -> percent encode key & value 123 | * -> sort 124 | * 125 | * @param {Object} request data 126 | * @param {Object} OAuth data 127 | * @return {Object} Parameter string data 128 | */ 129 | OAuth.prototype.getParameterString = function(request, oauth_data) { 130 | var base_string_data = this.sortObject(this.percentEncodeData(this.mergeObject(oauth_data, this.mergeObject(request.data, this.deParamUrl(request.url))))); 131 | 132 | var data_str = ''; 133 | 134 | //base_string_data to string 135 | for(var key in base_string_data) { 136 | var value = base_string_data[key]; 137 | // check if the value is an array 138 | // this means that this key has multiple values 139 | if (value && Array.isArray(value)){ 140 | // sort the array first 141 | value.sort(); 142 | 143 | var valString = ""; 144 | // serialize all values for this key: e.g. formkey=formvalue1&formkey=formvalue2 145 | value.forEach((function(item, i){ 146 | valString += key + '=' + item; 147 | if (i < value.length){ 148 | valString += "&"; 149 | } 150 | }).bind(this)); 151 | data_str += valString; 152 | } else { 153 | data_str += key + '=' + value + '&'; 154 | } 155 | } 156 | 157 | //remove the last character 158 | data_str = data_str.substr(0, data_str.length - 1); 159 | return data_str; 160 | }; 161 | 162 | /** 163 | * Create a Signing Key 164 | * @param {String} token_secret Secret Token 165 | * @return {String} Signing Key 166 | */ 167 | OAuth.prototype.getSigningKey = function(token_secret) { 168 | token_secret = token_secret || ''; 169 | 170 | if(!this.last_ampersand && !token_secret) { 171 | return this.percentEncode(this.consumer.secret); 172 | } 173 | 174 | return this.percentEncode(this.consumer.secret) + '&' + this.percentEncode(token_secret); 175 | }; 176 | 177 | /** 178 | * Get base url 179 | * @param {String} url 180 | * @return {String} 181 | */ 182 | OAuth.prototype.getBaseUrl = function(url) { 183 | return url.split('?')[0]; 184 | }; 185 | 186 | /** 187 | * Get data from String 188 | * @param {String} string 189 | * @return {Object} 190 | */ 191 | OAuth.prototype.deParam = function(string) { 192 | var arr = string.split('&'); 193 | var data = {}; 194 | 195 | for(var i = 0; i < arr.length; i++) { 196 | var item = arr[i].split('='); 197 | data[item[0]] = decodeURIComponent(item[1]); 198 | } 199 | return data; 200 | }; 201 | 202 | /** 203 | * Get data from url 204 | * @param {String} url 205 | * @return {Object} 206 | */ 207 | OAuth.prototype.deParamUrl = function(url) { 208 | var tmp = url.split('?'); 209 | 210 | if (tmp.length === 1) 211 | return {}; 212 | 213 | return this.deParam(tmp[1]); 214 | }; 215 | 216 | /** 217 | * Percent Encode 218 | * @param {String} str 219 | * @return {String} percent encoded string 220 | */ 221 | OAuth.prototype.percentEncode = function(str) { 222 | return encodeURIComponent(str) 223 | .replace(/\!/g, "%21") 224 | .replace(/\*/g, "%2A") 225 | .replace(/\'/g, "%27") 226 | .replace(/\(/g, "%28") 227 | .replace(/\)/g, "%29"); 228 | }; 229 | 230 | /** 231 | * Percent Encode Object 232 | * @param {Object} data 233 | * @return {Object} percent encoded data 234 | */ 235 | OAuth.prototype.percentEncodeData = function(data) { 236 | var result = {}; 237 | 238 | for(var key in data) { 239 | var value = data[key]; 240 | // check if the value is an array 241 | if (value && Array.isArray(value)){ 242 | var newValue = []; 243 | // percentEncode every value 244 | value.forEach((function(val){ 245 | newValue.push(this.percentEncode(val)); 246 | }).bind(this)); 247 | value = newValue; 248 | } else { 249 | value = this.percentEncode(value); 250 | } 251 | result[this.percentEncode(key)] = value; 252 | } 253 | 254 | return result; 255 | }; 256 | 257 | /** 258 | * Get OAuth data as Header 259 | * @param {Object} oauth_data 260 | * @return {String} Header data key - value 261 | */ 262 | OAuth.prototype.toHeader = function(oauth_data) { 263 | oauth_data = this.sortObject(oauth_data); 264 | 265 | var header_value = 'OAuth '; 266 | 267 | for(var key in oauth_data) { 268 | if (key.indexOf('oauth_') === -1) 269 | continue; 270 | header_value += this.percentEncode(key) + '="' + this.percentEncode(oauth_data[key]) + '"' + this.parameter_seperator; 271 | } 272 | 273 | return { 274 | Authorization: header_value.substr(0, header_value.length - this.parameter_seperator.length) //cut the last chars 275 | }; 276 | }; 277 | 278 | /** 279 | * Create a random word characters string with input length 280 | * @return {String} a random word characters string 281 | */ 282 | OAuth.prototype.getNonce = function() { 283 | var word_characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; 284 | var result = ''; 285 | 286 | for(var i = 0; i < this.nonce_length; i++) { 287 | result += word_characters[parseInt(Math.random() * word_characters.length, 10)]; 288 | } 289 | 290 | return result; 291 | }; 292 | 293 | /** 294 | * Get Current Unix TimeStamp 295 | * @return {Int} current unix timestamp 296 | */ 297 | OAuth.prototype.getTimeStamp = function() { 298 | return parseInt(new Date().getTime()/1000, 10); 299 | }; 300 | 301 | ////////////////////// HELPER FUNCTIONS ////////////////////// 302 | 303 | /** 304 | * Merge object 305 | * @param {Object} obj1 306 | * @param {Object} obj2 307 | * @return {Object} 308 | */ 309 | OAuth.prototype.mergeObject = function(obj1, obj2) { 310 | var merged_obj = obj1; 311 | for(var key in obj2) { 312 | merged_obj[key] = obj2[key]; 313 | } 314 | return merged_obj; 315 | }; 316 | 317 | /** 318 | * Sort object by key 319 | * @param {Object} data 320 | * @return {Object} sorted object 321 | */ 322 | OAuth.prototype.sortObject = function(data) { 323 | var keys = Object.keys(data); 324 | var result = {}; 325 | 326 | keys.sort(); 327 | 328 | for(var i = 0; i < keys.length; i++) { 329 | var key = keys[i]; 330 | result[key] = data[key]; 331 | } 332 | 333 | return result; 334 | }; 335 | -------------------------------------------------------------------------------- /Pesquisa Customizada/modalTable.js: -------------------------------------------------------------------------------- 1 | // function openABC(id){ 2 | 3 | // if ($('#empresa_'+$this.instanceId).val() == ''){ 4 | // toast('Selecione a empresa','danger'); 5 | // return false; 6 | // } 7 | 8 | // var compon = new Array(); 9 | // compon['columns'] = ['select','classificacoes']; 10 | // compon['values'] = []; 11 | 12 | // var constraints = new Array(); 13 | 14 | // var SQL = " select distinct trim(classificacoes) as classificacoes from ITEM_ABC "+ 15 | // " where cod_empresa = '"+$('#empresa_'+ $this.instanceId).val() +"' "+ 16 | // " order by classificacoes "; 17 | 18 | // constraints.push(DatasetFactory.createConstraint("SQL", SQL, SQL, ConstraintType.MUST)); 19 | // constraints.push(DatasetFactory.createConstraint("DATABASE", 'java:/jdbc/LogixDS', null, ConstraintType.MUST)); 20 | 21 | // var compon = DatasetFactory.getDataset("select", null, constraints, null); 22 | 23 | 24 | // console.log('compon......',compon); 25 | // var fields = [ 26 | // {'field':'select', 27 | // 'titulo':'Sel.', 28 | // 'type':'checkbox', 29 | // 'style':'margin-top:0px;padding-top: 0px;padding-bottom: 0px;', 30 | // 'class':'form-control', 31 | // 'livre':'', 32 | // 'width':'10%'}, 33 | // {'field':'classificacoes', 34 | // 'titulo':'Classificações', 35 | // 'type':'text', 36 | // 'style':'padding-top: 0px;padding-bottom: 0px;', 37 | // 'class':'form-control', 38 | // 'livre':'readonly="readonly"', 39 | // //'precision':3, 40 | // 'width':'10%'}, 41 | // ]; 42 | // // var lista = id.split('___')[0].split('_')[2]; 43 | // if( $('#item_abc_'+ $this.instanceId ).val() != "" ){ 44 | // var lsClassificacoes = $('#item_abc_'+ $this.instanceId ).val().split(','); 45 | // console.log('lsClassificacoes.......',lsClassificacoes); 46 | // for( var j = 0; j < compon.values.length; j++ ){ 47 | // if( $.inArray( compon.values[j].classificacoes, lsClassificacoes ) >= 0 ){ 48 | // // compon.values[j]['classificacoes'] = lsClassificacoes[j].replace('.',','); 49 | // compon.values[j]['select'] = 'S'; 50 | // } 51 | // else{ 52 | // compon.values[j]['select'] = 'N'; 53 | // } 54 | // } 55 | // console.log('compon.values.......',compon.values); 56 | // } 57 | 58 | // var retorno = modalTable( 'zoom_abc', 'Classificacoes ABC', fields, compon.values, 'large', id, 'N' ); 59 | 60 | // console.log(retorno); 61 | // } 62 | 63 | function returnModalTable( retorno ){ 64 | console.log('retorno.....', retorno.id, retorno); 65 | // var lista = retorno.idChave.split('___')[0].split('_')[2]; 66 | if( retorno.id == 'zoom_abc' ){ 67 | var lstClassificacoes = []; 68 | for( var i = 0; i < retorno.dados.length; i++ ){ 69 | if( retorno.dados[i].select == 'S' ){ 70 | lstClassificacoes.push(retorno.dados[i].classificacoes); 71 | } 72 | } 73 | // console.log(lstClassificacoes); 74 | $('#item_abc_'+ $this.instanceId ).val( lstClassificacoes ); 75 | // autoSize(); 76 | return true; 77 | } 78 | return true; 79 | 80 | } 81 | 82 | function modalTable( id, titulo, fields, dados, size, idChave, seqInicial, addDel ){ 83 | 84 | //addDel (A=adiciona - D=deleta - A=ambos - N=Nenhum ) 85 | 86 | parent.$('#workflowView-cardViewer').css( 'zIndex', 1 ); 87 | //parent.$('#workflowview-header').hide(); 88 | 89 | console.log('id modal.....',id); 90 | 91 | var seq = seqInicial; 92 | 93 | $(".table-modal > thead").html(""); 94 | $(".table-modal > tbody").html(""); 95 | 96 | var html = "" + 97 | "
" + 98 | "" + 99 | "" + 100 | "" + 101 | "" + 102 | "" + 103 | "
" + 104 | "
" + 105 | ""; 106 | 107 | 108 | var seq_linhe_modal = 0; 109 | 110 | var actions = []; 111 | 112 | if( addDel == 'A' || addDel == 'T' ){ 113 | actions.push( {'label': 'Adiconar', 'classType': 'add_linha' } ); 114 | } 115 | actions.push( {'label': 'Salvar','classType': 'save','autoClose': false} ); 116 | actions.push( {'label': 'Fechar','autoClose': true} ); 117 | 118 | var myModal = FLUIGC.modal({ 119 | title: titulo, 120 | content: html, 121 | id: id, 122 | formModal: false, 123 | size: size, 124 | actions: actions, 125 | }, function(err, data) { 126 | if(err) { 127 | // do error handling 128 | } else { 129 | 130 | var setup = function(lista) { 131 | var html = ""; 132 | 133 | for (var i=0; i" + lista[i].titulo + "" 141 | } 142 | if( addDel == 'D' || addDel == 'T' ){ 143 | html += ""; 144 | } 145 | html += ""; 146 | $(".table-modal > thead").append(html); 147 | } 148 | 149 | RemoveTableRow = function( handler ) { 150 | 151 | var tr = $(handler).closest('tr'); 152 | tr.remove(); 153 | 154 | var campoBase = fields[0].field; 155 | var qtd = 0; 156 | $( "input[name*=md_"+campoBase+"___]" ).each(function( index ) { 157 | qtd += 1; 158 | }); 159 | 160 | if ( qtd == 0 ){ 161 | seq = "A"; 162 | console.log('Alterado sequencia.....',seq); 163 | } 164 | 165 | return false; 166 | } 167 | 168 | loadDados = function( dados, fields ){ 169 | console.log('Dados.....',dados); 170 | for (var i=0; i"); 209 | var cols = ""; 210 | for (var i=0; i " 229 | } 230 | if( addDel == 'D' || addDel == 'T' ){ 231 | cols += " "; 232 | } 233 | newRow.append(cols); 234 | $(".table-modal > tbody").append(newRow); 235 | 236 | for (var i=0; i thead").html(""); 32 | $(".table-zoom > tbody").html(""); 33 | } 34 | 35 | /* var cplHtml = ''; 36 | if ( size = 'none' ){ 37 | cplHtml += "style='display:none;'" 38 | }*/ 39 | 40 | var html = "" + 41 | //"
" + 42 | //"" + 43 | "
"+ 44 | "
"+ 45 | " " + 46 | "
"+ 47 | "
"+ 48 | "
"+ 49 | " " + 50 | " " + 51 | "
"+ 52 | "
"+ 53 | "
" + 54 | "
" + 55 | "" + 56 | "" + 57 | "" + 58 | "" + 59 | "" + 60 | "
" + 61 | "
" + 62 | ""; 63 | 64 | var dosearch = function() { 65 | var url = urlrequest(); 66 | $(".table-zoom > tbody").html(""); 67 | 68 | console.log("url", url); 69 | 70 | loading.show(); 71 | 72 | $.ajax({ 73 | type: "GET", 74 | dataType: "json", 75 | url: url, 76 | data: "", 77 | error: function(XMLHttpRequest, textStatus, errorThrown) { 78 | console.log("dataset error", XMLHttpRequest, textStatus, errorThrown); 79 | }, 80 | success: function (data, status, xhr) { 81 | console.log("dataset sucess", data, status, xhr); 82 | var dataset = data["invdata"]; 83 | readydataset(dataset); 84 | } 85 | }); 86 | }; 87 | 88 | var urlrequest = function(){ 89 | var request = "/ecm/api/rest/ecm/dataset/", 90 | json = {}; 91 | 92 | if (dataset != null) { 93 | request += "getDatasetZoom"; 94 | json.datasetId = dataset; 95 | } else if(cardDatasetId != null){ 96 | request += "getCardDatasetValues"; 97 | json.cardDatasetId = cardDatasetId; 98 | } 99 | 100 | if (resultfields != null && resultfields.length > 0 ){ 101 | json.resultFields = trimarray(resultfields.split(",")); 102 | } 103 | 104 | if (filters != null && filters.length > 0 ){ 105 | json.filterFields = trimarray(filters.split(",")); 106 | for (var x=0; x < json.filterFields.length; x++) { 107 | if( json.filterFields[x] == "sqlLimit" ){ 108 | sqlLimit = json.filterFields[x+1]; 109 | } 110 | } 111 | } 112 | 113 | if (likefield != null && likefield.length > 0 && likevalue != null && likevalue.length > 0 ){ 114 | json.likeField = likefield; 115 | json.likeValue = likevalue; 116 | } 117 | 118 | var searchValue = $("#search").val(); 119 | if(searchValue && searchValue.length > 0) { 120 | json.searchValue = searchValue; 121 | 122 | //filtra pelo número do pedido com esta chave 123 | if (searchby && searchby != "") { 124 | var searchbytratado; 125 | console.log('SEARCH'); 126 | console.log($('#search')); 127 | console.log($('#search').val()); 128 | searchbytratado = $('#search').val(); 129 | 130 | console.log( 'Filter.....',$('#fiedFilter').val(),'INDEX ',searchbytratado.indexOf('PEDIDO') ); 131 | if( $('#fiedFilter').val() != '' ){ 132 | console.log( 'Filtro ',$('#fiedFilter').val()+' like %'+$('#search').val().trim()+'% ' ); 133 | json.searchField = $('#fiedFilter').val(); 134 | } else { 135 | json.searchField = searchby; 136 | } 137 | } else { 138 | json.searchField = fields.split(",")[0]; 139 | } 140 | } 141 | 142 | return request +="?json=" + encodeURI(JSON.stringify(json)); 143 | }; 144 | 145 | var trimarray = function (fields) { 146 | for(var i=0; i < fields.length; i++){ 147 | fields[i] = fields[i].trim(); 148 | } 149 | return fields; 150 | }; 151 | 152 | var readydataset = function(dataset) { 153 | 154 | globaldataset = dataset; 155 | 156 | //gambi 157 | if ( dataset.length == 1 && size == 'none' ){ 158 | console.log('Entrei com 1',dataset); 159 | var row = dataset[0]; 160 | row["type"] = tipo; 161 | row["size"] = size; 162 | setSelectedZoomItem(row); 163 | loading.hide(); 164 | return true; 165 | //zoommodal.remove(); 166 | } 167 | 168 | var linhas = 0; 169 | for (var i=0; i"; 173 | for (var x=0; x"; 175 | } 176 | html += ""; 177 | $(".table-zoom > tbody").append(html); 178 | } 179 | $(".table-zoom > tbody > tr").click(function() { 180 | $(".table-zoom > tbody > tr").removeClass("active"); 181 | $(this).addClass("active"); 182 | current = $(this).data("dataset"); 183 | }); 184 | $(".table-zoom > tbody > tr").dblclick(function() { 185 | var row = globaldataset[$(this).data("dataset")]; 186 | row["type"] = type; 187 | row["size"] = size; 188 | setSelectedZoomItem(row); 189 | zoommodal.remove(); 190 | }); 191 | $('#msg').remove(); 192 | if ( linhas == sqlLimit ){ 193 | $(".modal-footer").prepend( ' *Foram listados '+sqlLimit+' registros, refine sua busca!' ); 194 | } 195 | loading.hide(); 196 | }; 197 | 198 | if ( size == 'none' ){ 199 | dosearch(); 200 | return true; 201 | } 202 | 203 | var zoommodal = FLUIGC.modal({ 204 | title: title, 205 | content: html, 206 | formModal: false, 207 | size: size, 208 | id: id, 209 | 210 | 211 | actions: [{ 212 | 'label': 'Selecionar', 213 | 'classType': 'btn-success zoom-selected', 214 | 'autoClose': true, 215 | },{ 216 | 'label': 'Fechar', 217 | 'autoClose': true 218 | }] 219 | }, 220 | function(err, data) { 221 | if(err) { 222 | FLUIGC.toast({ title: 'Erro:', message: err, type: 'danger' }); 223 | } else { 224 | 225 | console.log('Inicio processo...'); 226 | 227 | var searchtable = function (text) { 228 | var table = $('.table-zoom > tbody'); 229 | table.find('tr').each(function(index, row) { 230 | var allCells = $(row).find('td'); 231 | if(allCells.length > 0) { 232 | var found = false; 233 | allCells.each(function(index, td) { 234 | var regExp = new RegExp(text, 'i'); 235 | if(regExp.test($(td).text())) { 236 | found = true; 237 | return false; 238 | } 239 | }); 240 | if(found == true)$(row).show();else $(row).hide(); 241 | } 242 | }); 243 | }; 244 | 245 | var setup = function(lista) { 246 | var l = lista.split(","); 247 | var html = ""; 248 | 249 | $("#fiedFilter option").remove(); 250 | //$("#fiedFilter").append(""); 251 | 252 | for (var i=0; i"; 255 | $("#fiedFilter").append(""); 256 | i++; 257 | } 258 | html += ""; 259 | $(".table-zoom > thead").append(html); 260 | }; 261 | 262 | //var returnDataSet = function( dataset ){ 263 | // dataset["type"] = type; 264 | // setSelectedZoomItem( dataset ); 265 | //} 266 | 267 | var timeout = 0; 268 | $('#search').keyup(function( event ) { 269 | clearTimeout(timeout); 270 | var keycode; 271 | if (window.event) { 272 | keycode = window.event.keyCode; 273 | } else if (event) { 274 | keycode = event.which; 275 | } else { 276 | return true; 277 | } 278 | console.log("search", keycode); 279 | if (keycode == 13 && $("#search").val().length >= 2 ) { 280 | //if ( $("#search").val().length >= 3 ) 281 | if( $('#fiedFilter').val() == '' ){ 282 | 283 | alert( 'Favor selecionar um campo para aplicar o filtro.' ); 284 | return false; 285 | 286 | } else { 287 | dosearch(); 288 | } 289 | } else { 290 | timeout = setTimeout(searchtable($(this).val()), 500); 291 | } 292 | }); 293 | 294 | $('.lupa').click(function(){ 295 | if( $('#fiedFilter').val() == '' ){ 296 | 297 | alert( 'Favor selecionar um campo para aplicar o filtro.' ); 298 | return false; 299 | 300 | } else { 301 | dosearch(); 302 | } 303 | }); 304 | 305 | $('.zoom-selected').click(function() { 306 | var row = globaldataset[current]; 307 | row["type"] = type; 308 | row["size"] = size; 309 | setSelectedZoomItem(row); 310 | }); 311 | 312 | setup(fields); 313 | if ( !iniVazio || iniVazio == 'list' ) 314 | dosearch(); 315 | else 316 | loading.hide(); 317 | 318 | console.log('antes list...'+iniVazio); 319 | if ( iniVazio == 'list' ){ 320 | console.log('Entrou list...'); 321 | $('#busca').hide(); 322 | } 323 | 324 | } 325 | }); 326 | 327 | } 328 | }; 329 | })(); 330 | --------------------------------------------------------------------------------