12 |
13 |
14 | <#if pageRender.isEditMode()=true>
15 |
16 |
17 |
18 |
19 | <#else>
20 |
21 | #if>
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 |
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 += "
"+
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 |
--------------------------------------------------------------------------------
/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: '
',
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