Primeiro commit fluig
This commit is contained in:
commit
8b7a079235
13678
.metadata/.bak_0.log
Normal file
13678
.metadata/.bak_0.log
Normal file
File diff suppressed because it is too large
Load Diff
0
.metadata/.lock
Normal file
0
.metadata/.lock
Normal file
3651
.metadata/.log
Normal file
3651
.metadata/.log
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.metadata/.mylyn/.tasks.xml.zip
Normal file
BIN
.metadata/.mylyn/.tasks.xml.zip
Normal file
Binary file not shown.
BIN
.metadata/.mylyn/repositories.xml.zip
Normal file
BIN
.metadata/.mylyn/repositories.xml.zip
Normal file
Binary file not shown.
BIN
.metadata/.mylyn/tasks.xml.zip
Normal file
BIN
.metadata/.mylyn/tasks.xml.zip
Normal file
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//forms/7690\ -\ Aniversariantes/kit_aniversariantes.html=UTF-8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/application.info=utf8
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,61 @@
|
||||
function defineStructure() {
|
||||
addColumn("codigo");
|
||||
addColumn("descricao");
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
var dataSource = "/jdbc/ProtheusDSs"; // Nome da conexão cadastrada no Fluig
|
||||
var ic = new javax.naming.InitialContext();
|
||||
var ds = ic.lookup(dataSource);
|
||||
var conn = ds.getConnection();
|
||||
var stmt = null;
|
||||
var rs = null;
|
||||
|
||||
try {
|
||||
log.info("Iniciando execução do dataset...");
|
||||
|
||||
var sql = "SELECT b1_cod, b1_desc FROM sb1010 WHERE LEFT(b1_cod, 4) IN ('0001','0008', '0002', '0003', '0007', '0006', '0009', '0010', '0011', '0014','0016', 'PROD')";
|
||||
log.info("Query SQL: " + sql);
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
dataset.addColumn("codigo");
|
||||
dataset.addColumn("descricao");
|
||||
|
||||
var encontrados = {}; // Usando um objeto para evitar duplicação
|
||||
|
||||
while (rs.next()) {
|
||||
var codigo = rs.getString("b1_cod");
|
||||
var descricao = rs.getString("b1_desc");
|
||||
|
||||
if (!encontrados[codigo]) { // Verifica se já foi adicionado
|
||||
encontrados[codigo] = true; // Marca como processado
|
||||
log.info("Registro encontrado: " + codigo + " - " + descricao);
|
||||
dataset.addRow([codigo, descricao]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(encontrados).length === 0) {
|
||||
log.info("Nenhum registro encontrado para a consulta.");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
log.error("Erro ao executar dataset: " + e.message);
|
||||
} finally {
|
||||
try {
|
||||
if (rs) rs.close();
|
||||
if (stmt) stmt.close();
|
||||
if (conn) conn.close();
|
||||
} catch (e) {
|
||||
log.error("Erro ao fechar recursos: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
|
||||
function onMobileSync(user) {}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,15 @@
|
||||
<div id="HelloWorld_${instanceId}" class="super-widget wcm-widget-class fluig-style-guide"
|
||||
data-params="HelloWorld.instance({message: 'Hello world'})">
|
||||
|
||||
<!-- efetua a tradução do texto do objeto i18n -->
|
||||
<h1>${i18n.getTranslation('hello.example.hello')}</h1>
|
||||
|
||||
<div>
|
||||
<button type="button" class="btn btn-default" data-show-message>${i18n.getTranslation('hello.button.showMessage')}</button>
|
||||
</div>
|
||||
|
||||
<div id='helloMessage_${instanceId}'>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
</web-app>
|
||||
@ -0,0 +1,61 @@
|
||||
function defineStructure() {
|
||||
addColumn("codigo");
|
||||
addColumn("descricao");
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
var dataSource = "java:/jdbc/ProtheusP12"; // Nome da conexão cadastrada no Fluig
|
||||
var ic = new javax.naming.InitialContext();
|
||||
var ds = ic.lookup(dataSource);
|
||||
var conn = ds.getConnection();
|
||||
var stmt = null;
|
||||
var rs = null;
|
||||
|
||||
try {
|
||||
log.info("Iniciando execução do dataset...");
|
||||
|
||||
var sql = "SELECT b1_cod, b1_desc FROM sb1010 WHERE LEFT(b1_cod, 4) IN ('0001','0008', '0002', '0003', '0007', '0006', '0009', '0010', '0011', '0014','0016')";
|
||||
log.info("Query SQL: " + sql);
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
dataset.addColumn("codigo");
|
||||
dataset.addColumn("descricao");
|
||||
|
||||
var encontrados = {}; // Usando um objeto para evitar duplicação
|
||||
|
||||
while (rs.next()) {
|
||||
var codigo = rs.getString("b1_cod");
|
||||
var descricao = rs.getString("b1_desc");
|
||||
|
||||
if (!encontrados[codigo]) { // Verifica se já foi adicionado
|
||||
encontrados[codigo] = true; // Marca como processado
|
||||
log.info("Registro encontrado: " + codigo + " - " + descricao);
|
||||
dataset.addRow([codigo, descricao]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(encontrados).length === 0) {
|
||||
log.info("Nenhum registro encontrado para a consulta.");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
log.error("Erro ao executar dataset: " + e.message);
|
||||
} finally {
|
||||
try {
|
||||
if (rs) rs.close();
|
||||
if (stmt) stmt.close();
|
||||
if (conn) conn.close();
|
||||
} catch (e) {
|
||||
log.error("Erro ao fechar recursos: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
|
||||
function onMobileSync(user) {}
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
</web-app>
|
||||
@ -0,0 +1,102 @@
|
||||
function servicetask70(attempt, message) {
|
||||
log.info("🚀 Iniciando servicetask70");
|
||||
|
||||
var fornecedores = {};
|
||||
var qtdItens = hAPI.getChildrenIndexes("tabelaItens");
|
||||
log.info("📦 Total de itens na tabela: " + qtdItens.length);
|
||||
|
||||
for (var i = 0; i < qtdItens.length; i++) {
|
||||
var index = qtdItens[i];
|
||||
log.info("🔄 Processando item índice: " + index);
|
||||
|
||||
var fornecedor = String(hAPI.getCardValue("fornecedorIndica___" + index)).trim();
|
||||
|
||||
if (!fornecedor) {
|
||||
log.warn("⚠️ Item ignorado: fornecedor vazio no índice [" + index + "]");
|
||||
continue; // Pula para o próximo item
|
||||
}
|
||||
|
||||
var item = {
|
||||
"C7_PRODUTO": String(hAPI.getCardValue("itemCompraIndica___"+index)).trim(),
|
||||
"C7_QUANT": String(hAPI.getCardValue("quantidadeIndica___"+ index)),
|
||||
"C7_PRECO": String(hAPI.getCardValue("precoIndica___" +index)),
|
||||
"C7_COND": String(hAPI.getCardValue("condPagamentoIndica___"+ index))
|
||||
};
|
||||
|
||||
log.info("📌 Item coletado para fornecedor [" + fornecedor + "]: " + JSON.stringify(item));
|
||||
|
||||
// 🔍 Garante que o fornecedor tenha um array antes de adicionar itens
|
||||
if (!(fornecedor in fornecedores)) {
|
||||
fornecedores[fornecedor] = [];
|
||||
log.info("➕ Novo fornecedor adicionado: " + fornecedor);
|
||||
}
|
||||
|
||||
// 🔄 Adiciona o item ao fornecedor correspondente
|
||||
fornecedores[fornecedor].push(item);
|
||||
log.info("📌 Item adicionado ao fornecedor [" + fornecedor + "]: " + JSON.stringify(item));
|
||||
}
|
||||
|
||||
log.dir(fornecedores);
|
||||
|
||||
var numBase = String(getValue("WKNumProces"));
|
||||
log.info("📄 Número base do processo: " + numBase);
|
||||
|
||||
var contador = 0;
|
||||
|
||||
for (var fornecedor in fornecedores) {
|
||||
var numeroPedido = numBase + (contador > 0 ? String.fromCharCode(65 + contador - 1) : "");
|
||||
log.info("📝 Gerando pedido [" + numeroPedido + "] para fornecedor [" + fornecedor + "]");
|
||||
|
||||
var payload = {
|
||||
"C7_FILIAL": String(hAPI.getCardValue("estabelecimento")),
|
||||
"C7_NUM": numeroPedido,
|
||||
"C7_EMISSAO": String(hAPI.getCardValue("dataAbertura")),
|
||||
"C7_FORNECE": fornecedor,
|
||||
"C7_LOJA": "01",
|
||||
"C7_CONTATO": String(hAPI.getCardValue("userValidacaoCompras")),
|
||||
"C7_FILENT": String(hAPI.getCardValue("estabelecimento")),
|
||||
"C7_TPFRETE": "C",
|
||||
"C7_FRETE": "0",
|
||||
"ITENS": fornecedores[fornecedor]
|
||||
};
|
||||
|
||||
log.info("📦 Payload montado para envio:");
|
||||
log.dir(payload);
|
||||
|
||||
var data1 = {
|
||||
companyId: '1',
|
||||
serviceCode: 'Integrador Pedido de compra',
|
||||
endpoint: 'http://187.72.204.233:8089/rest/pedido/',
|
||||
method: 'post',
|
||||
timeoutService: '100',
|
||||
params: payload,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
|
||||
log.info("📡 Enviando requisição para o Protheus...");
|
||||
log.dir(data1);
|
||||
|
||||
try {
|
||||
var clientService = fluigAPI.getAuthorizeClientService();
|
||||
var response = clientService.invoke(JSON.stringify(data1));
|
||||
|
||||
log.info("📬 Resposta da API Protheus:");
|
||||
log.dir(response);
|
||||
|
||||
if (response && response.getResult()) {
|
||||
log.info("✅ Pedido [" + numeroPedido + "] enviado com sucesso para [" + fornecedor + "]");
|
||||
log.info("📬 Resposta: " + response.getResult());
|
||||
} else {
|
||||
log.warn("⚠️ API Protheus não retornou dados para fornecedor [" + fornecedor + "]");
|
||||
}
|
||||
} catch (e) {
|
||||
log.error("❌ Erro ao enviar pedido [" + numeroPedido + "] para fornecedor [" + fornecedor + "]: " + e.message);
|
||||
}
|
||||
|
||||
contador++;
|
||||
}
|
||||
|
||||
log.info("🏁 Finalização da servicetask70");
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
</web-app>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,48 @@
|
||||
function defineStructure() {
|
||||
addColumn("status"); // Código HTTP ou "Erro"
|
||||
addColumn("mensagem"); // Retorno da API ou sucesso
|
||||
addColumn("erro"); // Mensagem de erro, se houver
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
function onMobileSync(user) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var serviceCode = "API Protheus Full";
|
||||
var endpoint = "/uf_mata010"; // relativo à URL base configurada no serviço
|
||||
var method = "POST";
|
||||
var params = "{}"; // corpo da requisição JSON
|
||||
|
||||
if (constraints) {
|
||||
constraints.forEach(function(c) {
|
||||
if (c.fieldName == "serviceCode") serviceCode = c.initialValue;
|
||||
if (c.fieldName == "endpoint") endpoint = c.initialValue;
|
||||
if (c.fieldName == "method") method = c.initialValue.toUpperCase();
|
||||
if (c.fieldName == "params") params = c.initialValue;
|
||||
});
|
||||
}
|
||||
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
|
||||
try {
|
||||
var serviceHelper = ServiceManager.getService(serviceCode);
|
||||
|
||||
// 👉 chamada direta usando invokeServiceJSON
|
||||
var response = serviceHelper.invokeServiceJSON(
|
||||
endpoint, // endpoint relativo
|
||||
params, // corpo JSON
|
||||
method, // POST, GET, etc.
|
||||
"application/json" // Content-Type
|
||||
);
|
||||
|
||||
log.info("Retorno Protheus: " + response);
|
||||
|
||||
dataset.addRow(["200", response, ""]);
|
||||
|
||||
} catch (e) {
|
||||
log.error("Erro ao chamar Protheus: " + e);
|
||||
dataset.addRow(["Erro", "", (e.message || e.toString())]);
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,14 @@
|
||||
.cd-wrap{max-width:1200px;margin:0 auto;padding:24px}
|
||||
.cd-h2{margin:0 0 6px;font-weight:700;font-size:24px}
|
||||
.cd-sub{margin:0 0 22px;color:#6b7280}
|
||||
.cd-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:18px}
|
||||
.cd-card{display:block;background:#fff;border-radius:14px;padding:22px;text-decoration:none;color:#111827;
|
||||
box-shadow:0 1px 3px rgba(0,0,0,.08);min-height:210px;transition:transform .15s ease, box-shadow .15s ease}
|
||||
.cd-card:hover{transform:translateY(-2px);box-shadow:0 10px 24px rgba(0,0,0,.12)}
|
||||
.cd-illus{width:120px;height:120px;border-radius:60px;background:#f3f4f6;margin:0 auto 12px;
|
||||
display:flex;align-items:center;justify-content:center}
|
||||
.cd-ttl{text-align:center;font-weight:700;margin-bottom:6px}
|
||||
.cd-txt{text-align:center;color:#6b7280;font-size:13px}
|
||||
body.dark .cd-card{background:#1f2937;color:#e5e7eb}
|
||||
body.dark .cd-illus{background:#111827}
|
||||
body.dark .cd-txt{color:#9ca3af}
|
||||
@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@ -0,0 +1,78 @@
|
||||
function defineStructure() {
|
||||
addColumn("status");
|
||||
addColumn("mensagem");
|
||||
addColumn("erro");
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
function onMobileSync(user) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
dataset.addColumn("status");
|
||||
dataset.addColumn("mensagem");
|
||||
dataset.addColumn("erro");
|
||||
|
||||
log.info("### Enviando dados para Protheus com autenticação ###");
|
||||
|
||||
try {
|
||||
// ✅ 1. CAPTURAR DADOS DO FORMULÁRIO
|
||||
var jsonData = "{}";
|
||||
if (constraints) {
|
||||
for (var i = 0; i < constraints.length; i++) {
|
||||
if (constraints[i].fieldName == "params" && constraints[i].initialValue) {
|
||||
jsonData = constraints[i].initialValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Dados recebidos: " + jsonData);
|
||||
|
||||
// ✅ 2. URL CORRETA
|
||||
var url = "http://187.72.204.233:8099/rest_teste/uf_mata010";
|
||||
var urlObj = new java.net.URL(url);
|
||||
var connection = urlObj.openConnection();
|
||||
var httpConn = connection;
|
||||
|
||||
// ✅ 3. AUTENTICAÇÃO BASIC
|
||||
var usuario = "ezequiel.falcao";
|
||||
var senha = "Ginseng@";
|
||||
var auth = usuario + ":" + senha;
|
||||
var encodedAuth = java.util.Base64.getEncoder().encodeToString(auth.getBytes("UTF-8"));
|
||||
|
||||
// Configurar conexão
|
||||
httpConn.setDoOutput(true);
|
||||
httpConn.setRequestMethod("POST");
|
||||
httpConn.setRequestProperty("Content-Type", "application/json");
|
||||
httpConn.setRequestProperty("Accept", "application/json");
|
||||
httpConn.setRequestProperty("Authorization", "Basic " + encodedAuth); // ✅ HEADER DE AUTENTICAÇÃO
|
||||
httpConn.setConnectTimeout(30000);
|
||||
httpConn.setReadTimeout(30000);
|
||||
|
||||
// ✅ 4. ENVIAR DADOS
|
||||
var outputStream = httpConn.getOutputStream();
|
||||
var writer = new java.io.OutputStreamWriter(outputStream, "UTF-8");
|
||||
writer.write(jsonData);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
outputStream.close();
|
||||
|
||||
// ✅ 5. LER RESPOSTA
|
||||
var responseCode = httpConn.getResponseCode();
|
||||
var inputStream = httpConn.getInputStream();
|
||||
var scanner = new java.util.Scanner(inputStream, "UTF-8");
|
||||
var response = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
|
||||
scanner.close();
|
||||
|
||||
log.info("Status: " + responseCode + " - Response: " + response);
|
||||
dataset.addRow([responseCode.toString(), response, ""]);
|
||||
|
||||
} catch (error) {
|
||||
log.error("Erro completo: " + error.toString());
|
||||
var errorMsg = error.toString();
|
||||
dataset.addRow(["Erro", "", errorMsg]);
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,148 @@
|
||||
// ==== inicialização ====
|
||||
$(document).ready(function () {
|
||||
FLUIGC.calendar('#dataNec');
|
||||
|
||||
// eventos de quantidade/preço
|
||||
$('#precoRef').on('blur', recalcTotal);
|
||||
$('#quantidade').on('input', recalcTotal);
|
||||
$('#qtdMais').on('click', () => stepQtd(1));
|
||||
$('#qtdMenos').on('click', () => stepQtd(-1));
|
||||
|
||||
// produto
|
||||
$('#btnBuscaProd').on('click', openZoomProduto);
|
||||
$('#btnLimpaProd').on('click', () => {
|
||||
$('#produtoCod,#produtoDesc').val('');
|
||||
$('#ultimoPreco').val('0,00');
|
||||
recalcTotal();
|
||||
});
|
||||
|
||||
// zooms básicos
|
||||
bindZoom($('#empresaDesc'), 'dsSysCompany', ['codigo','descricao'], 'empresaCodigo','empresaDesc');
|
||||
bindZoom($('#filialDesc'), 'FILIAIS_DS', ['codigo','descricao'], 'filialCodigo','filialDesc');
|
||||
bindZoom($('#ccDesc'), 'CENTROCUSTO_DS',['codigo','descricao'], 'ccCod','ccDesc');
|
||||
|
||||
// itens
|
||||
$('#btnAddItem').on('click', addItem);
|
||||
});
|
||||
|
||||
// ==== helpers ====
|
||||
function stepQtd(n){
|
||||
const $q = $('#quantidade');
|
||||
let v = parseInt($q.val()||'0',10)+n;
|
||||
if (v < 0) v = 0;
|
||||
$q.val(v);
|
||||
recalcTotal();
|
||||
}
|
||||
|
||||
function parseMoneyBR(s){
|
||||
if(!s) return 0;
|
||||
s = (''+s).replace(/[^\d,,-]/g,'').replace(/\./g,'').replace(',', '.');
|
||||
const v = Number(s);
|
||||
return isNaN(v) ? 0 : v;
|
||||
}
|
||||
function formatMoneyBR(v){
|
||||
return v.toLocaleString('pt-BR',{style:'currency',currency:'BRL'});
|
||||
}
|
||||
|
||||
function recalcTotal(){
|
||||
const qtd = parseFloat($('#quantidade').val()||'0');
|
||||
const preco = parseMoneyBR($('#precoRef').val());
|
||||
const tot = (qtd * preco) || 0;
|
||||
$('#total').val(formatMoneyBR(tot));
|
||||
}
|
||||
|
||||
// ==== zooms genéricos ====
|
||||
function bindZoom($input, datasetId, displayFields, hiddenIdFld, displayFld){
|
||||
$input.on('click', function(){
|
||||
FLUIGC.filtermodal({
|
||||
title: 'Selecionar',
|
||||
size: 'large',
|
||||
filterFields: displayFields.join(', '),
|
||||
source: {
|
||||
url: '/api/public/ecm/dataset/search',
|
||||
contentType: 'application/json',
|
||||
root: 'content',
|
||||
limit: 50,
|
||||
pattern: '',
|
||||
param: { datasetId: datasetId }
|
||||
},
|
||||
columns: [
|
||||
{ title: 'Código', data: 'codigo' },
|
||||
{ title: 'Descrição', data: 'descricao' }
|
||||
],
|
||||
onSelected: function(data){
|
||||
$('#'+hiddenIdFld).val(data.codigo);
|
||||
$('#'+displayFld).val(data.codigo+' - '+data.descricao);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ==== zoom de produto com último preço ====
|
||||
function openZoomProduto(){
|
||||
FLUIGC.filtermodal({
|
||||
title: 'Buscar Produto/Serviço',
|
||||
size: 'large',
|
||||
filterFields: 'codigo, descricao',
|
||||
source: {
|
||||
url: '/api/public/ecm/dataset/search',
|
||||
contentType: 'application/json',
|
||||
root: 'content',
|
||||
limit: 50,
|
||||
param:{ datasetId: 'PRODUTOS_DS' }
|
||||
},
|
||||
columns: [
|
||||
{ title: 'Código', data: 'codigo' },
|
||||
{ title: 'Descrição', data: 'descricao' },
|
||||
{ title: 'UM', data: 'um' },
|
||||
{ title: 'Último Preço', data: 'ultimoPreco' }
|
||||
],
|
||||
onSelected: function(item){
|
||||
$('#produtoCod').val(item.codigo);
|
||||
$('#produtoDesc').val(item.codigo+' - '+item.descricao);
|
||||
$('#ultimoPreco').val(item.ultimoPreco || '0,00');
|
||||
recalcTotal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ==== itens (tabela filha) ====
|
||||
function addItem(){
|
||||
if(!$('#produtoCod').val()){
|
||||
FLUIGC.toast({title:'Atenção: ', message:'Selecione um produto.', type:'warning'}); return;
|
||||
}
|
||||
if(!$('#ccCod').val()){
|
||||
FLUIGC.toast({title:'Atenção: ', message:'Selecione o centro de custo.', type:'warning'}); return;
|
||||
}
|
||||
const qtd = parseFloat($('#quantidade').val()||'0');
|
||||
if(qtd <= 0){
|
||||
FLUIGC.toast({title:'Atenção: ', message:'Quantidade deve ser > 0.', type:'warning'}); return;
|
||||
}
|
||||
|
||||
const row = wdkAddChild('tbItens');
|
||||
$('#produtoCod___'+row).val($('#produtoCod').val());
|
||||
$('#produtoDesc___'+row).val($('#produtoDesc').val());
|
||||
$('#ccCod___'+row).val($('#ccCod').val());
|
||||
$('#ccDesc___'+row).val($('#ccDesc').val());
|
||||
$('#qtd___'+row).val(qtd);
|
||||
$('#precoRef___'+row).val($('#precoRef').val());
|
||||
$('#total___'+row).val($('#total').val());
|
||||
|
||||
// limpa campos do cabeçalho se quiser
|
||||
// $('#produtoCod,#produtoDesc').val('');
|
||||
}
|
||||
|
||||
// ==== validação (se seu projeto usa validateForm hook do Fluig) ====
|
||||
// crie events/validateForm.js chamando esta função, ou adapte ao seu template:
|
||||
function validateForm(form){
|
||||
var msgs = [];
|
||||
function req(id, label){ if(!form.getValue(id)) msgs.push('Preencha "'+label+'".'); }
|
||||
|
||||
req('tipoSolicitacao','Tipo de Solicitação');
|
||||
req('produtoCod','Produto/Serviço');
|
||||
req('quantidade','Quantidade');
|
||||
req('dataNec','Data da Necessidade');
|
||||
req('ccCod','Centro de Custo');
|
||||
|
||||
if(msgs.length){ throw msgs.join('\n'); }
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,92 @@
|
||||
function defineStructure() {
|
||||
dataset.addColumn("codigo");
|
||||
dataset.addColumn("descricao");
|
||||
dataset.addColumn("CNPJ");
|
||||
dataset.addColumn("ENDERECO");
|
||||
dataset.addColumn("COMPLEMENTO");
|
||||
dataset.addColumn("BAIRRO");
|
||||
dataset.addColumn("CIDADE");
|
||||
dataset.addColumn("ESTADO");
|
||||
dataset.addColumn("CEP");
|
||||
dataset.addColumn("CODIGO MUNICIPIO");
|
||||
dataset.addColumn("BPCS");
|
||||
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
var dataSource = "/jdbc/ProtheusDS"; // Nome da conexão cadastrada no Fluig
|
||||
var ic = new javax.naming.InitialContext();
|
||||
var ds = ic.lookup(dataSource);
|
||||
var conn = ds.getConnection();
|
||||
var stmt = null;
|
||||
var rs = null;
|
||||
|
||||
try {
|
||||
log.info("Iniciando execução do dataset...");
|
||||
|
||||
var sql = "SELECT M0_CODFIL, M0_FILIAL, M0_CGC, M0_ENDENT, M0_COMPENT, M0_BAIRENT, M0_CIDENT, M0_ESTENT, M0_CEPENT, M0_CODMUN, M0_TEL_, * from SYS_COMPANY WHERE M0_CODFIL LIKE '0101%' OR M0_CODFIL LIKE'03%' AND D_E_L_E_T_= ''";
|
||||
log.info("Query SQL: " + sql);
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
dataset.addColumn("CODIGO");
|
||||
dataset.addColumn("DESCRICAO");
|
||||
dataset.addColumn("CNPJ");
|
||||
dataset.addColumn("ENDERECO");
|
||||
dataset.addColumn("COMPLEMENTO");
|
||||
dataset.addColumn("BAIRRO");
|
||||
dataset.addColumn("CIDADE");
|
||||
dataset.addColumn("ESTADO");
|
||||
dataset.addColumn("CEP");
|
||||
dataset.addColumn("CODIGO MUNICIPIO");
|
||||
dataset.addColumn("BPCS");
|
||||
|
||||
|
||||
|
||||
var encontrados = {}; // Usando um objeto para evitar duplicação
|
||||
|
||||
while (rs.next()) {
|
||||
var codigo = rs.getString("M0_CODFIL");
|
||||
var descricao = rs.getString("M0_FILIAL");
|
||||
var cnpj = rs.getString("M0_CGC");
|
||||
var endereco = rs.getString("M0_ENDENT");
|
||||
var complemento = rs.getString("M0_COMPENT");
|
||||
var bairro = rs.getString("M0_BAIRENT");
|
||||
var cidade = rs.getString("M0_CIDENT");
|
||||
var estado = rs.getString("M0_ESTENT");
|
||||
var cep = rs.getString("M0_CEPENT");
|
||||
var ibge = rs.getString("M0_CODMUN");
|
||||
var bpcs = rs.getString("M0_TEL_PO");
|
||||
|
||||
|
||||
if (!encontrados[codigo]) { // Verifica se já foi adicionado
|
||||
encontrados[codigo] = true; // Marca como processado
|
||||
log.info("Registro encontrado: " + codigo + " - " + descricao);
|
||||
dataset.addRow([codigo, descricao,cnpj,endereco,complemento,bairro,cidade,estado,cep,ibge]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(encontrados).length === 0) {
|
||||
log.info("Nenhum registro encontrado para a consulta.");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
log.error("Erro ao executar dataset: " + e.message);
|
||||
} finally {
|
||||
try {
|
||||
if (rs) rs.close();
|
||||
if (stmt) stmt.close();
|
||||
if (conn) conn.close();
|
||||
} catch (e) {
|
||||
log.error("Erro ao fechar recursos: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
|
||||
function onMobileSync(user) {}
|
||||
@ -0,0 +1,14 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//forms/7690\ -\ Aniversariantes/kit_aniversariantes.html=UTF-8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_en_US.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_es.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_pt_BR.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/view.ftl=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/WEB-INF/jboss-web.xml=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/WEB-INF/web.xml=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/resources/css/cards_compras.css=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/resources/images/icon.png=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/resources/js/cards_compras.js=utf8
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
function validateForm(form){if(form.getValue("fullName")==null||form.getValue("fullName")==""){throw i18n.translate("kit.aniversary.validation.fullName")}if(form.getValue("birthDay")==null||form.getValue("birthDay")==""){throw i18n.translate("kit.aniversary.validation.birthDay")}if(form.getValue("birthMonth")==null||form.getValue("birthMonth")==""){throw i18n.translate("kit.aniversary.validation.birthMonth")}if(form.getValue("birthDay")<1||form.getValue("birthDay")>31){throw i18n.translate("kit.aniversary.validation.birthDayInvalid")}if(form.getValue("birthMonth")<1||form.getValue("birthMonth")>12){throw i18n.translate("kit.aniversary.validation.birthMonthInvalid")}if(isNaN(form.getValue("birthDay"))){throw i18n.translate("kit.aniversary.validation.dayNaN")}if(isNaN(form.getValue("birthMonth"))){throw i18n.translate("kit.aniversary.validation.monthNaN")}};
|
||||
@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//forms/7690\ -\ Aniversariantes/kit_aniversariantes.html=UTF-8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_en_US.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/view.ftl=utf8
|
||||
@ -0,0 +1,13 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//forms/7690\ -\ Aniversariantes/kit_aniversariantes.html=UTF-8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_en_US.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_es.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_pt_BR.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/view.ftl=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/WEB-INF/jboss-web.xml=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/resources/css/cards_compras.css=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/resources/images/icon.png=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/resources/js/cards_compras.js=utf8
|
||||
@ -0,0 +1,20 @@
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
|
||||
|
||||
var servicoURL = "http://187.72.204.233:8089/rest/api/retail/v1/retailitem?Fields=Code,Description,LastPurchasePrice"
|
||||
|
||||
var myApiConsumer = oauthUtil.getGenericConsumer("","", "","");
|
||||
var data = myApiConsumer.get(servicoURL);
|
||||
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
|
||||
var objdata = JSON.parse(data);
|
||||
|
||||
dataset.addColumn('Código');
|
||||
dataset.addColumn('Descrição');
|
||||
dataset.addColumn('último preço');
|
||||
|
||||
dataset.addRow([objdata['Código'], objdata['Descrição'], objdata['Último Preço']]);
|
||||
|
||||
return dataset;
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
var ComprasDigitalEdit = SuperWidget.extend({
|
||||
init: function () {},
|
||||
|
||||
bindings: {
|
||||
local: {
|
||||
'save': ['click_save'],
|
||||
'fill-example': ['click_fillExample']
|
||||
}
|
||||
},
|
||||
|
||||
save: function () {
|
||||
var txt = $('#cd-cards-' + this.instanceId).val() || '[]';
|
||||
try { JSON.parse(txt); } catch (e) {
|
||||
FLUIGC.toast({ title: 'Erro: ', message: 'JSON inválido', type: 'danger' });
|
||||
return;
|
||||
}
|
||||
this.setPreference({ 'cards': txt });
|
||||
FLUIGC.toast({ title: 'OK: ', message: 'Configurações salvas', type: 'success' });
|
||||
},
|
||||
|
||||
fillExample: function () {
|
||||
var ex = [
|
||||
{
|
||||
"title": "Cadastro de Produtos",
|
||||
"text": "Gerencie produtos.",
|
||||
"href": "/portal/p/1/pageprocessstart?processId=CadastroProdutos",
|
||||
"icon": "fluigicon-box",
|
||||
"target": "_self"
|
||||
},
|
||||
{
|
||||
"title": "Solicitação de Compras",
|
||||
"text": "Abra uma solicitação.",
|
||||
"href": "/portal/p/1/pageprocessstart?processId=Solicita%C3%A7%C3%A3o%20de%20compras%20-%20v2",
|
||||
"icon": "fluigicon-cart"
|
||||
},
|
||||
{
|
||||
"title": "Cotações",
|
||||
"text": "Compare orçamentos.",
|
||||
"href": "/portal/p/1/pagina-cotacoes",
|
||||
"icon": "fluigicon-money"
|
||||
},
|
||||
{
|
||||
"title": "Pedidos de Compras",
|
||||
"text": "Acompanhe pedidos.",
|
||||
"href": "/portal/p/1/pageworkflowview",
|
||||
"icon": "fluigicon-check"
|
||||
},
|
||||
{
|
||||
"title": "Notas Fiscais",
|
||||
"text": "Entrada e conferência.",
|
||||
"href": "/portal/p/1/ecmnavigator",
|
||||
"icon": "fluigicon-document-alt"
|
||||
},
|
||||
{
|
||||
"title": "Parâmetros",
|
||||
"text": "Configurações do módulo.",
|
||||
"href": "/portal/p/1/pagina-parametros",
|
||||
"icon": "fluigicon-cog"
|
||||
}
|
||||
];
|
||||
$('#cd-cards-' + this.instanceId).val(JSON.stringify(ex, null, 2));
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,24 @@
|
||||
application.type=layout
|
||||
application.code=TIginseng_layoutblocado
|
||||
application.title=Layout blocado
|
||||
application.description=Layout blocado carrosel
|
||||
application.fluig.version=null
|
||||
application.category=Compras Digital
|
||||
application.renderer=freemarker
|
||||
developer.code=G-ALES1NT-TEC06
|
||||
developer.name=andrey.cunha
|
||||
developer.url=http://www.fluig.com
|
||||
layout.defaultSlot=SlotA
|
||||
layout.file=layout.ftl
|
||||
locale.file.base.name=TIginseng_layoutblocado
|
||||
slot.SlotGlobalAlert=alertpopover
|
||||
slot.SlotInstantSearch=suggestsearch
|
||||
slot.SlotLogin=sociallogin
|
||||
slot.SlotMenu=menu
|
||||
slot.SlotUsePolicy=usepolicy
|
||||
application.icon=icon.png
|
||||
application.resource.css.1=/portal/resources/css/wcm_responsive_layout.css
|
||||
application.responsiveLayout=true
|
||||
application.newBuilder=true
|
||||
hash=4a16315e9e66fa7d797b3f6b1fb365b69f9a4ce2
|
||||
slot.SlotInstantSearch=suggestsearch
|
||||
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
var HelloWorld = SuperWidget.extend({
|
||||
message: null,
|
||||
init: function () {
|
||||
//code
|
||||
},
|
||||
bindings: {
|
||||
local: {
|
||||
'show-message': ['click_showMessage']
|
||||
}
|
||||
},
|
||||
showMessage: function () {
|
||||
$div = $('#helloMessage_' + this.instanceId);
|
||||
$message = $('<div>').addClass('message').append(this.message);
|
||||
$div.append($message);
|
||||
}
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
application.type=layout
|
||||
application.code=LayoutCadastro
|
||||
application.title=Layout Cadastro
|
||||
application.description=Layout para página principal do site
|
||||
application.fluig.version=null
|
||||
application.category=SYSTEM
|
||||
application.renderer=freemarker
|
||||
developer.code=G-ALES1NT-TEC06
|
||||
developer.name=andrey.cunha
|
||||
developer.url=http://www.fluig.com
|
||||
layout.defaultSlot=SlotA
|
||||
layout.file=layout.ftl
|
||||
locale.file.base.name=LayoutCadastro
|
||||
slot.SlotGlobalAlert=alertpopover
|
||||
slot.SlotInstantSearch=suggestsearch
|
||||
slot.SlotLogin=sociallogin
|
||||
slot.SlotMenu=menu
|
||||
slot.SlotUsePolicy=usepolicy
|
||||
application.icon=icon.png
|
||||
application.resource.css.1=/portal/resources/css/wcm_responsive_layout.css
|
||||
application.responsiveLayout=true
|
||||
application.newBuilder=true
|
||||
hash=4a16315e9e66fa7d797b3f6b1fb365b69f9a4ce2
|
||||
@ -0,0 +1,102 @@
|
||||
function servicetask70(attempt, message) {
|
||||
log.info("🚀 Iniciando servicetask70");
|
||||
|
||||
var fornecedores = {};
|
||||
var qtdItens = hAPI.getChildrenIndexes("tabelaItens");
|
||||
log.info("📦 Total de itens na tabela: " + qtdItens.length);
|
||||
|
||||
for (var i = 0; i < qtdItens.length; i++) {
|
||||
var index = qtdItens[i];
|
||||
log.info("🔄 Processando item índice: " + index);
|
||||
|
||||
var fornecedor = String(hAPI.getCardValue("fornecedorIndica___" + index)).trim();
|
||||
|
||||
if (!fornecedor) {
|
||||
log.warn("⚠️ Item ignorado: fornecedor vazio no índice [" + index + "]");
|
||||
continue; // Pula para o próximo item
|
||||
}
|
||||
|
||||
var item = {
|
||||
"C7_PRODUTO": String(hAPI.getCardValue("itemCompraIndica___" + index)),
|
||||
"C7_QUANT": String(hAPI.getCardValue("quantidadeIndica___" + index)),
|
||||
"C7_PRECO": String(hAPI.getCardValue("precoIndica___" + index)),
|
||||
"C7_COND": String(hAPI.getCardValue("condPagamentoIndica___" + index))
|
||||
};
|
||||
|
||||
log.info("📌 Item coletado para fornecedor [" + fornecedor + "]: " + JSON.stringify(item));
|
||||
|
||||
// 🔍 Garante que o fornecedor tenha um array antes de adicionar itens
|
||||
if (!(fornecedor in fornecedores)) {
|
||||
fornecedores[fornecedor] = [];
|
||||
log.info("➕ Novo fornecedor adicionado: " + fornecedor);
|
||||
}
|
||||
|
||||
// 🔄 Adiciona o item ao fornecedor correspondente
|
||||
fornecedores[fornecedor].push(item);
|
||||
log.info("📌 Item adicionado ao fornecedor [" + fornecedor + "]: " + JSON.stringify(item));
|
||||
}
|
||||
|
||||
log.dir(fornecedores);
|
||||
|
||||
var numBase = String(getValue("WKNumProces"));
|
||||
log.info("📄 Número base do processo: " + numBase);
|
||||
|
||||
var contador = 0;
|
||||
|
||||
for (var fornecedor in fornecedores) {
|
||||
var numeroPedido = numBase + (contador > 0 ? String.fromCharCode(65 + contador - 1) : "");
|
||||
log.info("📝 Gerando pedido [" + numeroPedido + "] para fornecedor [" + fornecedor + "]");
|
||||
|
||||
var payload = {
|
||||
"C7_FILIAL": String(hAPI.getCardValue("estabelecimento")),
|
||||
"C7_NUM": numeroPedido,
|
||||
"C7_EMISSAO": String(hAPI.getCardValue("dataAbertura")),
|
||||
"C7_FORNECE": fornecedor,
|
||||
"C7_LOJA": "01",
|
||||
"C7_CONTATO": String(hAPI.getCardValue("userValidacaoCompras")),
|
||||
"C7_FILENT": String(hAPI.getCardValue("estabelecimento")),
|
||||
"C7_TPFRETE": "C",
|
||||
"C7_FRETE": "0",
|
||||
"ITENS": fornecedores[fornecedor]
|
||||
};
|
||||
|
||||
log.info("📦 Payload montado para envio:");
|
||||
log.dir(payload);
|
||||
|
||||
var data1 = {
|
||||
companyId: '1',
|
||||
serviceCode: 'Integrador Pedido de compra',
|
||||
endpoint: 'http://187.72.204.233:8089/rest/pedido/',
|
||||
method: 'post',
|
||||
timeoutService: '100',
|
||||
params: payload,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
|
||||
log.info("📡 Enviando requisição para o Protheus...");
|
||||
log.dir(data1);
|
||||
|
||||
try {
|
||||
var clientService = fluigAPI.getAuthorizeClientService();
|
||||
var response = clientService.invoke(JSON.stringify(data1));
|
||||
|
||||
log.info("📬 Resposta da API Protheus:");
|
||||
log.dir(response);
|
||||
|
||||
if (response && response.getResult()) {
|
||||
log.info("✅ Pedido [" + numeroPedido + "] enviado com sucesso para [" + fornecedor + "]");
|
||||
log.info("📬 Resposta: " + response.getResult());
|
||||
} else {
|
||||
log.warn("⚠️ API Protheus não retornou dados para fornecedor [" + fornecedor + "]");
|
||||
}
|
||||
} catch (e) {
|
||||
log.error("❌ Erro ao enviar pedido [" + numeroPedido + "] para fornecedor [" + fornecedor + "]: " + e.message);
|
||||
}
|
||||
|
||||
contador++;
|
||||
}
|
||||
|
||||
log.info("🏁 Finalização da servicetask70");
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/view.ftl=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_en_US.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_es.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_pt_BR.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/css/widget_code_compras.css=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/images/icon.png=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/js/widget_code_compras.js=utf8
|
||||
@ -0,0 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/TIginseng_comprasdigital.properties=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/TIginseng_comprasdigital_en_US.properties=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/TIginseng_comprasdigital_es.properties=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/TIginseng_comprasdigital_pt_BR.properties=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/view.ftl=utf8
|
||||
@ -0,0 +1,86 @@
|
||||
function defineStructure() {
|
||||
addColumn("status");
|
||||
addColumn("mensagem");
|
||||
addColumn("erro");
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
function onMobileSync(user) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
dataset.addColumn("status");
|
||||
dataset.addColumn("mensagem");
|
||||
dataset.addColumn("erro");
|
||||
|
||||
log.info("### Recebendo dados do formulário para Protheus ###");
|
||||
|
||||
// ✅ VALORES PADRÃO (serão sobrescritos pelas constraints)
|
||||
var serviceCode = "API Protheus Full";
|
||||
var endpoint = "/uf_mata010";
|
||||
var method = "POST";
|
||||
var params = "{}";
|
||||
|
||||
// ✅ CAPTURAR DADOS DO FORMULÁRIO (via constraints)
|
||||
if (constraints && constraints.length > 0) {
|
||||
for (var i = 0; i < constraints.length; i++) {
|
||||
var constraint = constraints[i];
|
||||
|
||||
if (constraint.fieldName == "serviceCode" && constraint.initialValue) {
|
||||
serviceCode = constraint.initialValue;
|
||||
}
|
||||
if (constraint.fieldName == "endpoint" && constraint.initialValue) {
|
||||
endpoint = constraint.initialValue;
|
||||
}
|
||||
if (constraint.fieldName == "method" && constraint.initialValue) {
|
||||
method = constraint.initialValue.toUpperCase();
|
||||
}
|
||||
if (constraint.fieldName == "params" && constraint.initialValue) {
|
||||
params = constraint.initialValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Service: " + serviceCode);
|
||||
log.info("Endpoint: " + endpoint);
|
||||
log.info("Method: " + method);
|
||||
log.info("Params: " + params);
|
||||
|
||||
try {
|
||||
// ✅ USAR FLUIG API PARA CHAMADA AUTORIZADA
|
||||
var clientService = fluigAPI.getAuthorizeClientService();
|
||||
|
||||
var requestData = {
|
||||
companyId: "1",
|
||||
serviceCode: serviceCode,
|
||||
endpoint: endpoint,
|
||||
method: method.toLowerCase(),
|
||||
timeoutService: "60000",
|
||||
params: params, // ✅ SEUS DADOS DO FORMULÁRIO
|
||||
options: {
|
||||
encoding: "UTF-8",
|
||||
contentType: "application/json", // ✅ IMPORTANTE
|
||||
useBasicAuth: true,
|
||||
username: "ezequiel.falcao", // ✅ SEU USUÁRIO
|
||||
password: "Ginseng@" // ✅ SUA SENHA
|
||||
}
|
||||
};
|
||||
|
||||
log.info("Enviando para Protheus: " + JSON.stringify(requestData));
|
||||
|
||||
// ✅ FAZER A CHAMADA
|
||||
var result = clientService.invoke(JSON.stringify(requestData));
|
||||
var response = result.getResult();
|
||||
|
||||
log.info("Resposta do Protheus: " + response);
|
||||
|
||||
// ✅ RETORNAR SUCESSO
|
||||
dataset.addRow(["200", response, ""]);
|
||||
|
||||
} catch (error) {
|
||||
log.error("Erro ao enviar para Protheus: " + error.toString());
|
||||
dataset.addRow(["Erro", "", error.toString()]);
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/TIginseng_comprasdigital.properties=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/view.ftl=utf8
|
||||
@ -0,0 +1,41 @@
|
||||
<#import "/wcm.ftl" as wcm />
|
||||
|
||||
<#-- Variaveis globais para os layouts -->
|
||||
<#import "/layout-globals.ftl" as globals />
|
||||
|
||||
<!-- layout ECM-DEFAULT-DASHBOARD -->
|
||||
|
||||
<#if pageRender.isPreviewMode() = true>
|
||||
<@wcm.previewPageAlert />
|
||||
<@wcm.deviceTogglePreview />
|
||||
</#if>
|
||||
|
||||
<div class="wcm-wrapper-content ${wcmLayoutEditClass!""} ${pageAuthTypeClass!""}">
|
||||
|
||||
<#if pageRender.isEditMode() != true>
|
||||
<@wcm.header />
|
||||
<@wcm.menu />
|
||||
</#if>
|
||||
|
||||
<div class="wcm-all-content">
|
||||
|
||||
<div id="wcm-content" class="clearfix wcm-background">
|
||||
|
||||
<#if pageRender.isEditMode() = true>
|
||||
<@wcm.editHeader />
|
||||
<@wcm.widgetsList />
|
||||
</#if>
|
||||
|
||||
<div id="${divMasterId!""}" class="clearfix">
|
||||
|
||||
<!-- Conteúdo aqui -->
|
||||
|
||||
|
||||
<#if fluigThemeCode != "responsive_theme">
|
||||
<@wcm.footer layoutuserlabel="wcm.layoutdefaultecmdashboard.user" />
|
||||
</#if>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,10 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//forms/7690\ -\ Aniversariantes/kit_aniversariantes.html=UTF-8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_en_US.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_es.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras_pt_BR.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/view.ftl=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/webapp/resources/css/cards_compras.css=utf8
|
||||
@ -0,0 +1,4 @@
|
||||
<div id="MyWidget_${instanceId}" class="super-widget wcm-widget-class fluig-style-guide" data-params="MyWidget.instance()">
|
||||
|
||||
</div>
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//wcm/layout/LayoutCadastro/src/main/resources/LayoutCadastro.properties=utf8
|
||||
encoding//wcm/layout/LayoutCadastro/src/main/resources/application.info=utf8
|
||||
encoding//wcm/layout/LayoutCadastro/src/main/resources/layout.ftl=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/view.ftl=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_en_US.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_es.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_pt_BR.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/WEB-INF/jboss-web.xml=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/WEB-INF/web.xml=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/css/widget_code_compras.css=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/images/icon.png=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/js/widget_code_compras.js=utf8
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//wcm/widget/TIginseng_comprasdigital/src/main/resources/application.info=utf8
|
||||
@ -0,0 +1,5 @@
|
||||
application.title=Ol\u00E1 Mundo
|
||||
application.description=Ol\u00E1 Mundo
|
||||
hello.example.hello=Ol\u00E1 Mundo!
|
||||
hello.example.helloedit=Ol\u00E1 Mundo! (Edit)
|
||||
hello.button.showMessage=Exibir mensagem
|
||||
@ -0,0 +1,4 @@
|
||||
/* Coloque aqui seu codigo CSS */
|
||||
.message{
|
||||
margin-top: 10px;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<div id="HelloWorld_${instanceId}" class="super-widget wcm-widget-class fluig-style-guide"
|
||||
data-params="HelloWorld.instance({message: 'Hello world'})">
|
||||
|
||||
<!-- efetua a tradução do texto do objeto i18n -->
|
||||
<h1>${i18n.getTranslation('hello.example.helloedit')}</h1>
|
||||
|
||||
</div>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,50 @@
|
||||
function defineStructure() {
|
||||
|
||||
}
|
||||
function onSync(lastSyncDate) {
|
||||
|
||||
}
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
|
||||
// Definir as colunas
|
||||
dataset.addColumn("codigoCentroCusto");
|
||||
dataset.addColumn("centroCusto");
|
||||
dataset.addColumn("gestorCentroCusto");
|
||||
dataset.addColumn("emailGestor");
|
||||
dataset.addColumn("id");
|
||||
dataset.addColumn("idGestor"); // Aqui será armazenada a matrícula do gestor
|
||||
|
||||
// Lista dos centros de custo
|
||||
var dados = [
|
||||
["41101", "Comercial", "Analanny Magalhães", "analanny.magalhaes@grupoginseng.com.br", "1"],
|
||||
["51101", "Diretoria e Gestão", "João Marcelo", "joao.loureiro@grupoginseng.com.br", "2"],
|
||||
["51102", "Operações", "Diogo Demetrio", "diogo.martins@grupoginseng.com.br", "3"],
|
||||
["51103", "Controladoria", "Ariklenyo Nascimento", "ari.nascimento@grupoginseng.com.br", "4"],
|
||||
["51104", "Compliance", "Marla Palma", "marla.palma@grupoginseng.com.br", "5"],
|
||||
["51107", "Administrativo", "Lucila Brandão", "lucila.brandao@grupoginseng.com.br", "6"],
|
||||
["51110", "Gente e Cultura", "Francine Peiter", "francine.silva@grupoginseng.com.br", "7"],
|
||||
["51113", "TI", "Igor Oliveira", "igor.oliveira@grupoginseng.com.br", "8"],
|
||||
["51114", "Projetos e Performance", "Lucas Rocha", "lucas.rocha@grupoginseng.com.br", "9"],
|
||||
["teste", "teste", "Andrey Cunha", "andrey.cunha@grupoginseng.com.br", "10"]
|
||||
];
|
||||
|
||||
// Buscar matrícula do gestor no dataset "colleague"
|
||||
function getMatricula(gestorNome) {
|
||||
var c1 = DatasetFactory.createConstraint("colleagueName", gestorNome, gestorNome, ConstraintType.MUST);
|
||||
var dsUser = DatasetFactory.getDataset("colleague", ["colleagueId"], [c1], null);
|
||||
return dsUser.rowsCount > 0 ? dsUser.getValue(0, "colleagueId") : "";
|
||||
}
|
||||
|
||||
// Percorrer a lista e adicionar ao dataset
|
||||
for (var i = 0; i < dados.length; i++) {
|
||||
var matricula = getMatricula(dados[i][2]); // Obtém a matrícula do gestor
|
||||
dataset.addRow([dados[i][0], dados[i][1], dados[i][2], dados[i][3], dados[i][4], matricula]);
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
|
||||
function onMobileSync(user) {
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
function defineStructure() {
|
||||
addColumn("status");
|
||||
addColumn("mensagem");
|
||||
addColumn("erro");
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
function onMobileSync(user) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
dataset.addColumn("status");
|
||||
dataset.addColumn("mensagem");
|
||||
dataset.addColumn("erro");
|
||||
|
||||
log.info("### Enviando dados para Protheus ###");
|
||||
|
||||
try {
|
||||
// ✅ 1. CAPTURAR DADOS DO FORMULÁRIO
|
||||
var jsonData = "{}";
|
||||
if (constraints) {
|
||||
for (var i = 0; i < constraints.length; i++) {
|
||||
if (constraints[i].fieldName == "params" && constraints[i].initialValue) {
|
||||
jsonData = constraints[i].initialValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Dados recebidos: " + jsonData);
|
||||
|
||||
// ✅ 2. URL CORRETA - com /rest_teste/
|
||||
var url = "http://187.72.204.233:8099/rest_teste/uf_mata010";
|
||||
var urlObj = new java.net.URL(url);
|
||||
var connection = urlObj.openConnection();
|
||||
var httpConn = connection;
|
||||
|
||||
// Configurar conexão
|
||||
httpConn.setDoOutput(true);
|
||||
httpConn.setRequestMethod("POST");
|
||||
httpConn.setRequestProperty("Content-Type", "application/json");
|
||||
httpConn.setRequestProperty("Accept", "application/json");
|
||||
httpConn.setConnectTimeout(30000);
|
||||
httpConn.setReadTimeout(30000);
|
||||
|
||||
// ✅ 3. ENVIAR DADOS
|
||||
var outputStream = httpConn.getOutputStream();
|
||||
var writer = new java.io.OutputStreamWriter(outputStream, "UTF-8");
|
||||
writer.write(jsonData);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
outputStream.close();
|
||||
|
||||
// ✅ 4. LER RESPOSTA
|
||||
var responseCode = httpConn.getResponseCode();
|
||||
var inputStream = httpConn.getInputStream();
|
||||
var scanner = new java.util.Scanner(inputStream, "UTF-8");
|
||||
var response = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
|
||||
scanner.close();
|
||||
|
||||
log.info("Status: " + responseCode + " - Response: " + response);
|
||||
dataset.addRow([responseCode.toString(), response, ""]);
|
||||
|
||||
} catch (error) {
|
||||
log.error("Erro completo: " + error.toString());
|
||||
var errorMsg = error.toString();
|
||||
dataset.addRow(["Erro", "", errorMsg]);
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
application.title=applicationTitle
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,4 @@
|
||||
<div id="MyWidget_${instanceId}" class="super-widget wcm-widget-class fluig-style-guide" data-params="MyWidget.instance()">
|
||||
|
||||
</div>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
</web-app>
|
||||
@ -0,0 +1,18 @@
|
||||
application.type=widget
|
||||
application.code=widget_code_compras
|
||||
application.title=Cadastro de fornecedor
|
||||
application.description=Efetua o cadastro de fornecedor no Protheus
|
||||
application.fluig.version=null
|
||||
application.category=Suprimentos
|
||||
application.renderer=freemarker
|
||||
developer.code=G-ALES1NT-TEC06
|
||||
developer.name=andrey.cunha
|
||||
developer.url=http://www.fluig.com
|
||||
application.uiwidget=true
|
||||
application.mobileapp=false
|
||||
view.file=view.ftl
|
||||
edit.file=edit.ftl
|
||||
locale.file.base.name=widget_code_compras
|
||||
application.resource.js.1=/resources/js/widget_code_compras.js
|
||||
application.resource.css.2=/resources/css/widget_code_compras.css
|
||||
hash=4a16315e9e66fa7d797b3f6b1fb365b69f9a4ce2
|
||||
@ -0,0 +1,2 @@
|
||||
// Insira aqui seu codigo JavaScript
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var serviceCode = "API Protheus Full";
|
||||
var endpoint = "/uf_mata010"; // relativo à URL base configurada no serviço
|
||||
var method = "POST";
|
||||
var params = "{}"; // corpo da requisição JSON
|
||||
|
||||
if (constraints) {
|
||||
constraints.forEach(function(c) {
|
||||
if (c.fieldName == "serviceCode") serviceCode = c.initialValue;
|
||||
if (c.fieldName == "endpoint") endpoint = c.initialValue;
|
||||
if (c.fieldName == "method") method = c.initialValue.toUpperCase();
|
||||
if (c.fieldName == "params") params = c.initialValue;
|
||||
});
|
||||
}
|
||||
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
|
||||
try {
|
||||
var serviceHelper = ServiceManager.getService(serviceCode);
|
||||
var serviceLocator = serviceHelper.getBean();
|
||||
var httpService = serviceLocator.getHttpService();
|
||||
|
||||
var response = httpService.invoke(
|
||||
params,
|
||||
endpoint,
|
||||
method,
|
||||
"application/json",
|
||||
null,
|
||||
5000
|
||||
);
|
||||
|
||||
log.info("Retorno Protheus: " + response); // 👈 debug no server.log
|
||||
|
||||
dataset.addRow(["200", response, ""]);
|
||||
|
||||
} catch (e) {
|
||||
log.error("Erro ao chamar Protheus: " + e);
|
||||
dataset.addRow(["Erro", "", (e.message || e.toString())]);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,102 @@
|
||||
function servicetask70(attempt, message) {
|
||||
log.info("🚀 Iniciando servicetask70");
|
||||
|
||||
var fornecedores = {};
|
||||
var qtdItens = hAPI.getChildrenIndexes("tabelaItens");
|
||||
log.info("📦 Total de itens na tabela: " + qtdItens.length);
|
||||
|
||||
for (var i = 0; i < qtdItens.length; i++) {
|
||||
var index = qtdItens[i];
|
||||
log.info("🔄 Processando item índice: " + index);
|
||||
|
||||
var fornecedor = String(hAPI.getCardValue("fornecedorIndica___" + index)).trim();
|
||||
|
||||
if (!fornecedor) {
|
||||
log.warn("⚠️ Item ignorado: fornecedor vazio no índice [" + index + "]");
|
||||
continue; // Pula para o próximo item
|
||||
}
|
||||
|
||||
var item = {
|
||||
"produto": String(hAPI.getCardValue("itemCompraIndica___"+index)).trim(),
|
||||
"qtdVen": Number(hAPI.getCardValue("quantidadeIndica___"+ index)),
|
||||
"preco": Number(hAPI.getCardValue("precoIndica___" +index)),
|
||||
"cond": String(hAPI.getCardValue("condPagamentoIndica___"+ index))
|
||||
};
|
||||
|
||||
log.info("📌 Item coletado para fornecedor [" + fornecedor + "]: " + JSON.stringify(item));
|
||||
|
||||
// 🔍 Garante que o fornecedor tenha um array antes de adicionar itens
|
||||
if (!(fornecedor in fornecedores)) {
|
||||
fornecedores[fornecedor] = [];
|
||||
log.info("➕ Novo fornecedor adicionado: " + fornecedor);
|
||||
}
|
||||
|
||||
// 🔄 Adiciona o item ao fornecedor correspondente
|
||||
fornecedores[fornecedor].push(item);
|
||||
log.info("📌 Item adicionado ao fornecedor [" + fornecedor + "]: " + JSON.stringify(item));
|
||||
}
|
||||
|
||||
log.dir(fornecedores);
|
||||
|
||||
var numBase = String(getValue("WKNumProces"));
|
||||
log.info("📄 Número base do processo: " + numBase);
|
||||
|
||||
var contador = 0;
|
||||
|
||||
for (var fornecedor in fornecedores) {
|
||||
var numeroPedido = numBase + (contador > 0 ? String.fromCharCode(65 + contador - 1) : "");
|
||||
log.info("📝 Gerando pedido [" + numeroPedido + "] para fornecedor [" + fornecedor + "]");
|
||||
|
||||
var payload = {
|
||||
"filial": String(hAPI.getCardValue("estabelecimento")),
|
||||
"numero": numeroPedido,
|
||||
"emissao": String(hAPI.getCardValue("dataAbertura")),
|
||||
"fornece": fornecedor,
|
||||
"loja": "01",
|
||||
"contato": String(hAPI.getCardValue("userValidacaoCompras")),
|
||||
"filialent": String(hAPI.getCardValue("estabelecimento")),
|
||||
"tipofrete": "C",
|
||||
"frete": 0,
|
||||
"itens": fornecedores[fornecedor]
|
||||
};
|
||||
|
||||
log.info("📦 Payload montado para envio:");
|
||||
log.dir(payload);
|
||||
|
||||
var data1 = {
|
||||
companyId: '1',
|
||||
serviceCode: 'Integrador Pedido de compra',
|
||||
endpoint: 'http://187.72.204.233:8089/rest/pedido/',
|
||||
method: 'post',
|
||||
timeoutService: '1000000',
|
||||
params: payload,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
|
||||
log.info("📡 Enviando requisição para o Protheus...");
|
||||
log.dir(data1);
|
||||
|
||||
try {
|
||||
var clientService = fluigAPI.getAuthorizeClientService();
|
||||
var response = clientService.invoke(JSON.stringify(data1));
|
||||
|
||||
log.info("📬 Resposta da API Protheus:");
|
||||
log.dir(response);
|
||||
|
||||
if (response && response.getResult()) {
|
||||
log.info("✅ Pedido [" + numeroPedido + "] enviado com sucesso para [" + fornecedor + "]");
|
||||
log.info("📬 Resposta: " + response.getResult());
|
||||
} else {
|
||||
log.warn("⚠️ API Protheus não retornou dados para fornecedor [" + fornecedor + "]");
|
||||
}
|
||||
} catch (e) {
|
||||
log.error("❌ Erro ao enviar pedido [" + numeroPedido + "] para fornecedor [" + fornecedor + "]: " + e.message);
|
||||
}
|
||||
|
||||
contador++;
|
||||
}
|
||||
|
||||
log.info("🏁 Finalização da servicetask70");
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/TIginseng_layoutblocado.properties=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/TIginseng_layoutblocado_en_US.properties=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/TIginseng_layoutblocado_es.properties=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/TIginseng_layoutblocado_pt_BR.properties=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/application.info=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/layout.ftl=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/webapp/resources/css/TIginseng_layoutblocado.css=utf8
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jboss-web>
|
||||
<context-root>/widget_code_compras</context-root>
|
||||
<disable-cross-context>false</disable-cross-context>
|
||||
</jboss-web>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//forms/7690\ -\ Aniversariantes/kit_aniversariantes.html=UTF-8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/cards_compras.properties=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/view.ftl=utf8
|
||||
@ -0,0 +1 @@
|
||||
application.title=applicationTitle
|
||||
@ -0,0 +1,92 @@
|
||||
function defineStructure() {
|
||||
dataset.addColumn("codigo");
|
||||
dataset.addColumn("descricao");
|
||||
dataset.addColumn("CNPJ");
|
||||
dataset.addColumn("ENDERECO");
|
||||
dataset.addColumn("COMPLEMENTO");
|
||||
dataset.addColumn("BAIRRO");
|
||||
dataset.addColumn("CIDADE");
|
||||
dataset.addColumn("ESTADO");
|
||||
dataset.addColumn("CEP");
|
||||
dataset.addColumn("CODIGO MUNICIPIO");
|
||||
dataset.addColumn("BPCS");
|
||||
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
var dataSource = "/jdbc/ProtheusDS"; // Nome da conexão cadastrada no Fluig
|
||||
var ic = new javax.naming.InitialContext();
|
||||
var ds = ic.lookup(dataSource);
|
||||
var conn = ds.getConnection();
|
||||
var stmt = null;
|
||||
var rs = null;
|
||||
|
||||
try {
|
||||
log.info("Iniciando execução do dataset...");
|
||||
|
||||
var sql = "SELECT M0_CODFIL, M0_FILIAL, M0_CGC, M0_ENDENT, M0_COMPENT, M0_BAIRENT, M0_CIDENT, M0_ESTENT, M0_CEPENT, M0_CODMUN, M0_TEL_, * from SYS_COMPANY WHERE M0_CODFIL LIKE '0101%' OR M0_CODFIL LIKE'03%' AND D_E_L_E_T_= ''";
|
||||
log.info("Query SQL: " + sql);
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
dataset.addColumn("CODIGO");
|
||||
dataset.addColumn("DESCRICAO");
|
||||
dataset.addColumn("CNPJ");
|
||||
dataset.addColumn("ENDERECO");
|
||||
dataset.addColumn("COMPLEMENTO");
|
||||
dataset.addColumn("BAIRRO");
|
||||
dataset.addColumn("CIDADE");
|
||||
dataset.addColumn("ESTADO");
|
||||
dataset.addColumn("CEP");
|
||||
dataset.addColumn("CODIGO MUNICIPIO");
|
||||
dataset.addColumn("BPCS");
|
||||
|
||||
|
||||
|
||||
var encontrados = {}; // Usando um objeto para evitar duplicação
|
||||
|
||||
while (rs.next()) {
|
||||
var codigo = rs.getString("M0_CODFIL");
|
||||
var descricao = rs.getString("M0_FILIAL");
|
||||
var cnpj = rs.getString("M0_CGC");
|
||||
var endereco = rs.getString("M0_ENDENT");
|
||||
var complemento = rs.getString("M0_COMPENT");
|
||||
var bairro = rs.getString("M0_BAIRENT");
|
||||
var cidade = rs.getString("M0_CIDENT");
|
||||
var estado = rs.getString("M0_ESTENT");
|
||||
var cep = rs.getString("M0_CEPENT");
|
||||
var ibge = rs.getString("M0_CODMUN");
|
||||
var bpcs = rs.getString("M0_TEL_PO");
|
||||
|
||||
|
||||
if (!encontrados[codigo]) { // Verifica se já foi adicionado
|
||||
encontrados[codigo] = true; // Marca como processado
|
||||
log.info("Registro encontrado: " + codigo + " - " + descricao);
|
||||
dataset.addRow([codigo, descricao,cnpj,endereco,complemento,bairro,cidade,estado,cep,ibge, bpcs]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(encontrados).length === 0) {
|
||||
log.info("Nenhum registro encontrado para a consulta.");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
log.error("Erro ao executar dataset: " + e.message);
|
||||
} finally {
|
||||
try {
|
||||
if (rs) rs.close();
|
||||
if (stmt) stmt.close();
|
||||
if (conn) conn.close();
|
||||
} catch (e) {
|
||||
log.error("Erro ao fechar recursos: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
|
||||
function onMobileSync(user) {}
|
||||
@ -0,0 +1,134 @@
|
||||
function initForm() {
|
||||
// calendário e máscara simples
|
||||
FLUIGC.calendar('#dataNec');
|
||||
$('#precoRef').on('blur', recalcTotal);
|
||||
$('#quantidade').on('input', recalcTotal);
|
||||
$('#qtdMais').on('click', () => stepQtd(1));
|
||||
$('#qtdMenos').on('click', () => stepQtd(-1));
|
||||
|
||||
// botões produto
|
||||
$('#btnBuscaProd').on('click', () => openZoomProduto());
|
||||
$('#btnLimpaProd').on('click', () => { $('#produtoCod,#produtoDesc').val(''); $('#ultimoPreco').val('0,00'); recalcTotal(); });
|
||||
|
||||
// zooms (empresa, filial, centro de custo)
|
||||
bindZoom($('#empresaDesc'), 'EMPRESAS_DS', ['codigo','descricao'], 'empresaCodigo','empresaDesc');
|
||||
bindZoom($('#filialDesc'), 'FILIAIS_DS', ['codigo','descricao'], 'filialCodigo','filialDesc');
|
||||
bindZoom($('#ccDesc'), 'CENTROCUSTO_DS',['codigo','descricao'], 'ccCod','ccDesc');
|
||||
|
||||
// adicionar item à tabela
|
||||
$('#btnAddItem').on('click', addItem);
|
||||
}
|
||||
|
||||
function stepQtd(n){
|
||||
const $q = $('#quantidade');
|
||||
let v = parseInt($q.val()||'0',10)+n;
|
||||
if (v<0) v=0;
|
||||
$q.val(v);
|
||||
recalcTotal();
|
||||
}
|
||||
|
||||
function parseMoneyBR(s){
|
||||
if(!s) return 0;
|
||||
s = (''+s).replace(/[^\d,.-]/g,'').replace('.','').replace(',','.');
|
||||
const v = Number(s);
|
||||
return isNaN(v)?0:v;
|
||||
}
|
||||
function formatMoneyBR(v){
|
||||
return v.toLocaleString('pt-BR',{style:'currency',currency:'BRL'});
|
||||
}
|
||||
|
||||
function recalcTotal(){
|
||||
const qtd = parseFloat($('#quantidade').val()||'0');
|
||||
const preco = parseMoneyBR($('#precoRef').val());
|
||||
const tot = (qtd*preco) || 0;
|
||||
$('#total').val(formatMoneyBR(tot));
|
||||
}
|
||||
|
||||
function bindZoom($input, datasetId, displayFields, hiddenIdFld, displayFld){
|
||||
$input.on('click', function(){
|
||||
FLUIGC.filtermodal({
|
||||
title: 'Selecionar',
|
||||
size: 'large',
|
||||
filterFields: displayFields.join(', '),
|
||||
source: {
|
||||
url: '/api/public/ecm/dataset/search',
|
||||
contentType: 'application/json',
|
||||
root: 'content',
|
||||
pattern: '',
|
||||
limit: 50,
|
||||
param:{
|
||||
datasetId: datasetId
|
||||
}
|
||||
},
|
||||
columns: [
|
||||
{ title: 'Código', data: 'codigo' },
|
||||
{ title: 'Descrição', data: 'descricao' }
|
||||
],
|
||||
onSelected: function(data){
|
||||
$('#'+hiddenIdFld).val(data.codigo);
|
||||
$('#'+displayFld).val(data.codigo+' - '+data.descricao);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function openZoomProduto(){
|
||||
FLUIGC.filtermodal({
|
||||
title: 'Buscar Produto/Serviço',
|
||||
size: 'large',
|
||||
filterFields: 'codigo, descricao',
|
||||
source: {
|
||||
url: '/api/public/ecm/dataset/search',
|
||||
contentType: 'application/json',
|
||||
root: 'content',
|
||||
limit: 50,
|
||||
param:{ datasetId: 'PRODUTOS_DS' }
|
||||
},
|
||||
columns: [
|
||||
{ title: 'Código', data: 'codigo' },
|
||||
{ title: 'Descrição', data: 'descricao' },
|
||||
{ title: 'UM', data: 'um' },
|
||||
{ title: 'Último Preço', data: 'ultimoPreco' }
|
||||
],
|
||||
onSelected: function(item){
|
||||
$('#produtoCod').val(item.codigo);
|
||||
$('#produtoDesc').val(item.codigo+' - '+item.descricao);
|
||||
$('#ultimoPreco').val((item.ultimoPreco||'0,00'));
|
||||
recalcTotal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addItem(){
|
||||
// valida campos mínimos
|
||||
if(!$('#produtoCod').val()){ FLUIGC.toast({title:'Atenção: ', message:'Selecione um produto.', type:'warning'}); return; }
|
||||
if(!$('#ccCod').val()){ FLUIGC.toast({title:'Atenção: ', message:'Selecione o centro de custo.', type:'warning'}); return; }
|
||||
const qtd = parseFloat($('#quantidade').val()||'0'); if(qtd<=0){ FLUIGC.toast({title:'Atenção: ', message:'Quantidade deve ser > 0.', type:'warning'}); return; }
|
||||
|
||||
const row = wdkAddChild('tbItens');
|
||||
$('#produtoCod___'+row).val($('#produtoCod').val());
|
||||
$('#produtoDesc___'+row).val($('#produtoDesc').val());
|
||||
$('#ccCod___'+row).val($('#ccCod').val());
|
||||
$('#ccDesc___'+row).val($('#ccDesc').val());
|
||||
$('#qtd___'+row).val(qtd);
|
||||
$('#precoRef___'+row).val($('#precoRef').val());
|
||||
$('#total___'+row).val($('#total').val());
|
||||
}
|
||||
|
||||
// validação de processo
|
||||
function validateForm(form){
|
||||
var msgs = [];
|
||||
function req(id, label){ if(!form.getValue(id)) msgs.push('Preencha "'+label+'".'); }
|
||||
|
||||
req('tipoSolicitacao','Tipo de Solicitação');
|
||||
req('produtoCod','Produto/Serviço');
|
||||
req('quantidade','Quantidade');
|
||||
req('dataNec','Data da Necessidade');
|
||||
req('ccCod','Centro de Custo');
|
||||
|
||||
if(msgs.length){
|
||||
throw msgs.join('\n');
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(initForm);
|
||||
@ -0,0 +1,93 @@
|
||||
<#import "/wcm.ftl" as wcm />
|
||||
<#import "/layout-globals.ftl" as globals />
|
||||
|
||||
<#-- Layout base do portal -->
|
||||
<div class="wcm-wrapper-content ${wcmLayoutEditClass!""} ${pageAuthTypeClass!""}">
|
||||
|
||||
<#-- Cabeçalho/menu aparecem só fora do modo de edição -->
|
||||
<#if pageRender.isEditMode() != true>
|
||||
<@wcm.header />
|
||||
<@wcm.menu />
|
||||
</#if>
|
||||
|
||||
<div class="wcm-all-content">
|
||||
<div id="wcm-content" class="clearfix wcm-background">
|
||||
|
||||
<#-- Ferramentas do editor quando estiver no modo edição -->
|
||||
<#if pageRender.isEditMode() = true>
|
||||
<@wcm.editHeader />
|
||||
<@wcm.widgetsList />
|
||||
</#if>
|
||||
|
||||
<div id="${divMasterId!""}" class="clearfix">
|
||||
|
||||
<!-- CONTEÚDO DA SUA PÁGINA (layout de cards) -->
|
||||
<div class="cd-wrap">
|
||||
<h2 class="cd-h2">Compras Digital</h2>
|
||||
<p class="cd-sub">
|
||||
Solução para simplificar e otimizar a aquisição de produtos e serviços.
|
||||
</p>
|
||||
|
||||
<div class="cd-grid">
|
||||
<!-- Ajuste APENAS os hrefs abaixo para seus links/processos reais -->
|
||||
|
||||
<a class="cd-card" href="/portal/p/1/pageprocessstart?processId=CadastroProdutos">
|
||||
<div class="cd-illus"><i class="fluigicon fluigicon-box fluigicon-3x"></i></div>
|
||||
<div class="cd-ttl">Cadastro de Produtos</div>
|
||||
<div class="cd-txt">Adicione e gerencie produtos de maneira centralizada.</div>
|
||||
</a>
|
||||
|
||||
<a class="cd-card" href="/portal/p/1/pageprocessstart?processId=Solicita%C3%A7%C3%A3o%20de%20compras%20-%20v2">
|
||||
<div class="cd-illus"><i class="fluigicon fluigicon-cart fluigicon-3x"></i></div>
|
||||
<div class="cd-ttl">Solicitação de Compras</div>
|
||||
<div class="cd-txt">Faça suas solicitações de forma rápida e eficiente.</div>
|
||||
</a>
|
||||
|
||||
<a class="cd-card" href="/portal/p/1/pagina-cotacoes">
|
||||
<div class="cd-illus"><i class="fluigicon fluigicon-money fluigicon-3x"></i></div>
|
||||
<div class="cd-ttl">Cotações</div>
|
||||
<div class="cd-txt">Compare orçamentos e encontre as melhores ofertas.</div>
|
||||
</a>
|
||||
|
||||
<a class="cd-card" href="/portal/p/1/pageworkflowview">
|
||||
<div class="cd-illus"><i class="fluigicon fluigicon-check fluigicon-3x"></i></div>
|
||||
<div class="cd-ttl">Pedidos de Compras</div>
|
||||
<div class="cd-txt">Acompanhe e confirme pedidos de compra.</div>
|
||||
</a>
|
||||
|
||||
<a class="cd-card" href="/portal/p/1/ecmnavigator">
|
||||
<div class="cd-illus"><i class="fluigicon fluigicon-document-alt fluigicon-3x"></i></div>
|
||||
<div class="cd-ttl">Notas Fiscais</div>
|
||||
<div class="cd-txt">Simplifique a entrada e conferência de NFs.</div>
|
||||
</a>
|
||||
|
||||
<a class="cd-card" href="/portal/p/1/pagina-parametros">
|
||||
<div class="cd-illus"><i class="fluigicon fluigicon-cog fluigicon-3x"></i></div>
|
||||
<div class="cd-ttl">Parâmetros</div>
|
||||
<div class="cd-txt">Personalize as configurações conforme a necessidade.</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.cd-wrap{max-width:1200px;margin:0 auto;padding:24px}
|
||||
.cd-h2{margin:0 0 6px;font-weight:700;font-size:24px}
|
||||
.cd-sub{margin:0 0 22px;color:#6b7280}
|
||||
.cd-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:18px}
|
||||
.cd-card{display:block;background:#fff;border-radius:14px;padding:22px;text-decoration:none;color:#111827;
|
||||
box-shadow:0 1px 3px rgba(0,0,0,.08);min-height:210px;transition:transform .15s ease, box-shadow .15s ease}
|
||||
.cd-card:hover{transform:translateY(-2px);box-shadow:0 10px 24px rgba(0,0,0,.12)}
|
||||
.cd-illus{width:120px;height:120px;border-radius:60px;background:#f3f4f6;margin:0 auto 12px;
|
||||
display:flex;align-items:center;justify-content:center}
|
||||
.cd-ttl{text-align:center;font-weight:700;margin-bottom:6px}
|
||||
.cd-txt{text-align:center;color:#6b7280;font-size:13px}
|
||||
body.dark .cd-card{background:#1f2937;color:#e5e7eb}
|
||||
body.dark .cd-illus{background:#111827}
|
||||
body.dark .cd-txt{color:#9ca3af}
|
||||
</style>
|
||||
<!-- FIM DO CONTEÚDO -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,11 @@
|
||||
kit_aniversariantes.fullname=Nome completo
|
||||
kit_aniversariantes.month=M\u00EAs
|
||||
kit_aniversariantes.day=Dia
|
||||
kit_aniversariantes.validation.fullName=Nome completo \u00E9 um campo obrigat\u00F3rio
|
||||
kit_aniversariantes.validation.birthDay=Dia \u00E9 um campo obrigat\u00F3rio
|
||||
kit_aniversariantes.validation.birthMonth=M\u00EAs \u00E9 um campo obrigat\u00F3rio
|
||||
kit_aniversariantes.validation.birthMonthInvalid=Valor inv\u00E1lido no campo M\u00EAs
|
||||
kit_aniversariantes.validation.birthDayInvalid=Valor inv\u00E1lido no campo Dia
|
||||
kit_aniversariantes.validation.dayNaN=Dia \u00E9 um campo num\u00E9rico
|
||||
kit_aniversariantes.validation.monthNaN=M\u00EAs \u00E9 um campo num\u00E9rico
|
||||
kit_aniversariantes.imagedimension=Na aba anexos, fa\u00E7a upload da foto do usu\u00E1rio enviando uma imagem com altura e largura equivalentes
|
||||
@ -0,0 +1,23 @@
|
||||
application.type=layout
|
||||
application.code=TIginseng_layoutblocado
|
||||
application.title=Layout blocado
|
||||
application.description=Layout blocado carrosel
|
||||
application.fluig.version=null
|
||||
application.category=Compras Digital
|
||||
application.renderer=freemarker
|
||||
developer.code=G-ALES1NT-TEC06
|
||||
developer.name=andrey.cunha
|
||||
developer.url=http://www.fluig.com
|
||||
layout.defaultSlot=SlotA
|
||||
layout.file=layout.ftl
|
||||
locale.file.base.name=TIginseng_layoutblocado
|
||||
slot.SlotGlobalAlert=alertpopover
|
||||
slot.SlotInstantSearch=suggestsearch
|
||||
slot.SlotLogin=sociallogin
|
||||
slot.SlotMenu=menu
|
||||
slot.SlotUsePolicy=usepolicy
|
||||
application.icon=icon.png
|
||||
application.resource.css.1=/portal/resources/css/wcm_responsive_layout.css
|
||||
application.responsiveLayout=true
|
||||
application.newBuilder=true
|
||||
hash=4a16315e9e66fa7d797b3f6b1fb365b69f9a4ce2
|
||||
@ -0,0 +1,61 @@
|
||||
function defineStructure() {
|
||||
addColumn("codigo");
|
||||
addColumn("descricao");
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
var dataSource = "/jdbc/ProtheusP12"; // Nome da conexão cadastrada no Fluig
|
||||
var ic = new javax.naming.InitialContext();
|
||||
var ds = ic.lookup(dataSource);
|
||||
var conn = ds.getConnection();
|
||||
var stmt = null;
|
||||
var rs = null;
|
||||
|
||||
try {
|
||||
log.info("Iniciando execução do dataset...");
|
||||
|
||||
var sql = "SELECT b1_cod, b1_desc FROM sb1010 WHERE LEFT(b1_cod, 4) IN ('0001','0008', '0002', '0003', '0007', '0006', '0009', '0010', '0011', '0014','0016')";
|
||||
log.info("Query SQL: " + sql);
|
||||
|
||||
stmt = conn.prepareStatement(sql);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
dataset.addColumn("codigo");
|
||||
dataset.addColumn("descricao");
|
||||
|
||||
var encontrados = {}; // Usando um objeto para evitar duplicação
|
||||
|
||||
while (rs.next()) {
|
||||
var codigo = rs.getString("b1_cod");
|
||||
var descricao = rs.getString("b1_desc");
|
||||
|
||||
if (!encontrados[codigo]) { // Verifica se já foi adicionado
|
||||
encontrados[codigo] = true; // Marca como processado
|
||||
log.info("Registro encontrado: " + codigo + " - " + descricao);
|
||||
dataset.addRow([codigo, descricao]);
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(encontrados).length === 0) {
|
||||
log.info("Nenhum registro encontrado para a consulta.");
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
log.error("Erro ao executar dataset: " + e.message);
|
||||
} finally {
|
||||
try {
|
||||
if (rs) rs.close();
|
||||
if (stmt) stmt.close();
|
||||
if (conn) conn.close();
|
||||
} catch (e) {
|
||||
log.error("Erro ao fechar recursos: " + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
|
||||
function onMobileSync(user) {}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 587 B |
@ -0,0 +1,52 @@
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var serviceCode = "API Protheus Full";
|
||||
var endpoint = "/rest_teste/uf_mata010";
|
||||
var method = "POST";
|
||||
var params = "{}";
|
||||
|
||||
if (constraints) {
|
||||
constraints.forEach(function(c) {
|
||||
if (c.fieldName == "serviceCode") serviceCode = c.initialValue;
|
||||
if (c.fieldName == "endpoint") endpoint = c.initialValue;
|
||||
if (c.fieldName == "method") method = c.initialValue.toUpperCase();
|
||||
if (c.fieldName == "params") params = c.initialValue;
|
||||
});
|
||||
}
|
||||
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
|
||||
try {
|
||||
var clientService = ServiceManager.getServiceInstance(serviceCode);
|
||||
var client = clientService.getClient();
|
||||
|
||||
// Configurar headers
|
||||
client.addHeader("Content-Type", "application/json");
|
||||
client.addHeader("Accept", "application/json");
|
||||
|
||||
// ✅ CORREÇÃO: Substituir switch por if/else mais simples
|
||||
var result;
|
||||
if (method === "GET") {
|
||||
result = client.get(endpoint);
|
||||
} else if (method === "POST") {
|
||||
result = client.post(endpoint, params);
|
||||
} else if (method === "PUT") {
|
||||
result = client.put(endpoint, params);
|
||||
} else {
|
||||
throw new Error("Método HTTP não suportado: " + method);
|
||||
}
|
||||
|
||||
var statusCode = result.getStatusCode();
|
||||
var response = result.getResult();
|
||||
|
||||
log.info("Status Code: " + statusCode);
|
||||
log.info("Response: " + response);
|
||||
|
||||
dataset.addRow([statusCode.toString(), response, ""]);
|
||||
|
||||
} catch (e) {
|
||||
log.error("Erro ao chamar Protheus: " + e);
|
||||
dataset.addRow(["Erro", "", (e.message || e.toString())]);
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,5 @@
|
||||
<div id="SlotInstantSearch" slot="true" class="slotint slot-header-actions">
|
||||
<#list (pageRender.getInstancesIds("SlotInstantSearch"))! as id>
|
||||
${pageRender.renderInstanceNoDecorator(id)}
|
||||
</#list>
|
||||
</div>
|
||||
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/TIginseng_layoutblocado.properties=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/TIginseng_layoutblocado_en_US.properties=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/TIginseng_layoutblocado_es.properties=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/TIginseng_layoutblocado_pt_BR.properties=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/application.info=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/resources/layout.ftl=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/webapp/WEB-INF/jboss-web.xml=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/webapp/resources/css/TIginseng_layoutblocado.css=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/webapp/resources/images/icon.png=utf8
|
||||
encoding//wcm/layout/TIginseng_layoutblocado/src/main/webapp/resources/js/TIginseng_layoutblocado.js=utf8
|
||||
@ -0,0 +1,15 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//wcm/layout/LayoutCadastro/src/main/resources/application.info=utf8
|
||||
encoding//wcm/layout/LayoutCadastro/src/main/resources/layout.ftl=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/edit.ftl=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/view.ftl=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_en_US.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_es.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/resources/widget_code_compras_pt_BR.properties=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/WEB-INF/jboss-web.xml=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/WEB-INF/web.xml=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/css/widget_code_compras.css=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/images/icon.png=utf8
|
||||
encoding//wcm/widget/widget_code_compras/src/main/webapp/resources/js/widget_code_compras.js=utf8
|
||||
@ -0,0 +1,45 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="/portal/resources/js/jquery/jquery.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="/portal/resources/style-guide/css/fluig-style-guide.min.css"/>
|
||||
<script type="text/javascript" src="/portal/resources/style-guide/js/fluig-style-guide.min.js"
|
||||
charset="utf-8"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="fluig-style-guide">
|
||||
<form name="kit_aniversariantes" role="form">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="fullName">i18n.translate("kit_aniversariantes.fullname")</label>
|
||||
<input name="fullName" id="fullName" type="text" class="form-control"
|
||||
placeholder="i18n.translate("kit_aniversariantes.fullname")">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label for="birthDay">i18n.translate("kit_aniversariantes.day")</label>
|
||||
<input name="birthDay" id="birthDay" type="number" class="form-control" min="1" max="31" step="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div class="form-group">
|
||||
<label for="birthMonth">i18n.translate("kit_aniversariantes.month")</label>
|
||||
<input name="birthMonth" id="birthMonth" type="number" class="form-control" min="1" max="12"
|
||||
step="1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="alert alert-info" role="alert">i18n.translate("kit_aniversariantes.imagedimension")</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -0,0 +1,11 @@
|
||||
kit_aniversariantes.fullname=Full name
|
||||
kit_aniversariantes.month=Month
|
||||
kit_aniversariantes.day=Day
|
||||
kit_aniversariantes.validation.fullName=Full name is a mandatory field
|
||||
kit_aniversariantes.validation.birthDay=Day is a mandatory field
|
||||
kit_aniversariantes.validation.birthMonth=Month is a mandatory field
|
||||
kit_aniversariantes.validation.birthMonthInvalid=Invalid value in the month field
|
||||
kit_aniversariantes.validation.birthDayInvalid=Invalid value in the day field
|
||||
kit_aniversariantes.validation.dayNaN=Day is a numeric field
|
||||
kit_aniversariantes.validation.monthNaN=Month is a numeric field
|
||||
kit_aniversariantes.imagedimension=In the attachments tab, upload the photo of the user by sending an image with equivalent height and width
|
||||
@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//forms/7690\ -\ Aniversariantes/kit_aniversariantes.html=UTF-8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/application.info=utf8
|
||||
encoding//wcm/widget/cards_compras/src/main/resources/edit.ftl=utf8
|
||||
@ -0,0 +1 @@
|
||||
application.title=applicationTitle
|
||||
@ -0,0 +1 @@
|
||||
application.title=applicationTitle
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,70 @@
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
dataset.addColumn("status");
|
||||
dataset.addColumn("mensagem");
|
||||
dataset.addColumn("erro");
|
||||
|
||||
log.info("### Recebendo dados do formulário para Protheus ###");
|
||||
|
||||
// ✅ VALORES PADRÃO
|
||||
var serviceCode = "Postprod";
|
||||
var endpoint = "/rest_teste/uf_mata010";
|
||||
var method = "POST";
|
||||
var params = "{}";
|
||||
|
||||
// ✅ CAPTURAR DADOS DO FORMULÁRIO
|
||||
if (constraints && constraints.length > 0) {
|
||||
for (var i = 0; i < constraints.length; i++) {
|
||||
var constraint = constraints[i];
|
||||
|
||||
if (constraint.fieldName == "serviceCode" && constraint.initialValue) {
|
||||
serviceCode = constraint.initialValue;
|
||||
}
|
||||
if (constraint.fieldName == "endpoint" && constraint.initialValue) {
|
||||
endpoint = constraint.initialValue;
|
||||
}
|
||||
if (constraint.fieldName == "method" && constraint.initialValue) {
|
||||
method = constraint.initialValue.toUpperCase();
|
||||
}
|
||||
if (constraint.fieldName == "params" && constraint.initialValue) {
|
||||
params = constraint.initialValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
var clientService = fluigAPI.getAuthorizeClientService();
|
||||
|
||||
// ✅ CORREÇÃO: Criar um MAP em vez de String
|
||||
var requestMap = {
|
||||
"companyId": "1",
|
||||
"serviceCode": serviceCode,
|
||||
"endpoint": endpoint,
|
||||
"method": method.toLowerCase(),
|
||||
"timeoutService": "60000",
|
||||
"params": params, // ✅ String JSON aqui
|
||||
"options": {
|
||||
"encoding": "UTF-8",
|
||||
"contentType": "application/json",
|
||||
"useBasicAuth": true,
|
||||
"username": "ezequiel.falcao",
|
||||
"password": "Ginseng@"
|
||||
}
|
||||
};
|
||||
|
||||
log.info("Enviando MAP: " + JSON.stringify(requestMap));
|
||||
|
||||
// ✅ AGORA SIM: passar o Map diretamente
|
||||
var result = clientService.invoke(requestMap); // ← SEM JSON.stringify()
|
||||
var response = result.getResult();
|
||||
|
||||
log.info("Resposta do Protheus: " + response);
|
||||
dataset.addRow(["200", response, ""]);
|
||||
|
||||
} catch (error) {
|
||||
log.error("Erro: " + error.toString());
|
||||
dataset.addRow(["Erro", "", error.toString()]);
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jboss-web>
|
||||
<context-root>/TIginseng_comprasdigital</context-root>
|
||||
<disable-cross-context>false</disable-cross-context>
|
||||
</jboss-web>
|
||||
@ -0,0 +1,47 @@
|
||||
function defineStructure() {
|
||||
addColumn("status"); // Código HTTP ou "Erro"
|
||||
addColumn("mensagem"); // Retorno da API ou sucesso
|
||||
addColumn("erro"); // Mensagem de erro, se houver
|
||||
}
|
||||
|
||||
function onSync(lastSyncDate) {}
|
||||
|
||||
function onMobileSync(user) {}
|
||||
|
||||
function createDataset(fields, constraints, sortFields) {
|
||||
var serviceCode = "API Protheus Full";
|
||||
var endpoint = "/uf_mata010";
|
||||
var method = "post";
|
||||
var params = "";
|
||||
|
||||
if (constraints) {
|
||||
constraints.forEach(function(c) {
|
||||
if (c.fieldName == "serviceCode") serviceCode = c.initialValue;
|
||||
if (c.fieldName == "endpoint") endpoint = c.initialValue;
|
||||
if (c.fieldName == "method") method = c.initialValue.toLowerCase();
|
||||
if (c.fieldName == "params") params = c.initialValue;
|
||||
});
|
||||
}
|
||||
|
||||
var dataset = DatasetBuilder.newDataset();
|
||||
|
||||
try {
|
||||
var serviceHelper = ServiceManager.getService(serviceCode);
|
||||
var serviceLocator = serviceHelper.instantiate("com.totvs.technology.ajax.http.HttpClientService");
|
||||
|
||||
var data = serviceLocator.invoke({
|
||||
"endpoint": endpoint,
|
||||
"method": method,
|
||||
"timeout": 5000,
|
||||
"mediaType": "application/json",
|
||||
"content": params
|
||||
});
|
||||
|
||||
dataset.addRow(["200", data, ""]); // Sucesso
|
||||
|
||||
} catch (e) {
|
||||
dataset.addRow(["Erro", "", e.message]); // Captura erro detalhado
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user