Boa tarde,
Tenho o seguinte formulário:
<html>
<head>
<link type="text/css" rel="stylesheet" href="/style-guide/css/fluig-style-guide.min.css"/>
<script type="text/javascript" src="/portal/resources/js/jquery/jquery.js"></script>
<script type="text/javascript" src="/portal/resources/js/jquery/jquery-ui.min.js"></script>
<script type="text/javascript" src="/portal/resources/js/mustache/mustache-min.js"></script>
<script type="text/javascript" src="/style-guide/js/fluig-style-guide.min.js" charset="utf-8"></script>
<link href='/webdesk/customresources?cid=1&resourceName=temaFormulario/0.css' type='text/css' rel='stylesheet' />
</head>
<body>
<div class="fluig-style-guide">
<form name="form" role="form">
<!--Painel1-->
<div name="painel1" class="panel panel-primary">
<!--Painel Informacoes Gerais-->
<div class="panel-heading" name="infoGer">
<h3 class="panel-title"><i class="fluigicon fluigicon-file icon-md" style="margin-right: 10px"></i> Informações Gerais</h3>
</div>
<div class="panel-body" name="infoGer">
<!--linha 1-->
<div class="row">
<div class="form-group col-xs-6 col-sm-2 col-md-3">
<label for="codCli">Codigo Cliente</label>
<input type="text" name="codCli" id="codCli" class="form-control" mask="000000000000000000000000000000">
</div>
<div class="form-group col-xs-6 col-sm-10 col-md-9">
<label for="nomeCli">Nome Cliente</label>
<input type="text" name="nomeCli" id="nomeCli" class="form-control">
</div>
</div>
<!--linha 1-->
<!--linha 2-->
<div class="row">
<div class="form-group col-xs-6 col-sm-2 col-md-3">
<label for="condPgto">Cond. Pgto.</label>
<select id="condPgto" name="condPgto" class="form-control">
<option value="A vista">A vista</option>
<option value="2x">2x</option>
<option value="3x">3x</option>
</select>
</div>
<div class="form-group col-xs-6 col-sm-2 col-md-3">
<label for="codTransp">Codigo Transportadora</label>
<input type="text" name="codTransp" id="codTransp" class="form-control" mask="000000000000000000000000000000">
</div>
<div class="form-group col-xs-6 col-sm-2 col-md-3">
<label for="dataEnt">Data Entrega</label>
<input type="text" name="dataEnt" id="dataEnt" class="form-control" mask="00/00/0000">
</div>
<div class="form-group col-xs-6 col-sm-2 col-md-3">
<label for="pedCli">Numero do Pedido</label>
<input type="text" name="pedCli" id="pedCli" class="form-control" mask="000000000000000000000000000000">
</div>
</div>
<!--linha 2-->
<!--linha 3-->
<div class="row">
<div class="form-group col-xs-6 col-sm-2 col-md-12">
<label for="obsGer">Observações Gerais</label>
<textarea rows="5" name="obsGer" id="obsGer" class="form-control"></textarea>
</div>
</div>
<!--linha 3-->
</div>
<!--Painel Informacoes Gerais FIM-->
</div>
<!--Painel1 FIM-->
<!--Painel2-->
<div name="panel2" class="panel panel-primary">
<div class="panel-heading" name="itensPed">
<h3 class="panel-title"><i class="fluigicon fluigicon-paste icon-md" style="margin-right: 10px"></i> Itens do Pedido</h3>
</div>
<div class="panel-body" name="itensPed">
<div class="row">
<div class="form-group col-xs-12 col-sm-12 col-md-12">
<div class="form-field" data-type="tabledetail" data-show-properties="" data-field-name="Contatos_com_o_" style="position: relative; left: 0px; top: 0px;">
<div class="form-input">
<div class="form-group">
<!--<label>Contato(s) com o Cliente durante a NEGOCIAÇÃO</label></br>-->
<table id="itensPed" tablename="itensPed" class="table" noaddbutton="true">
<thead>
<tr class="tableHeadRow">
<th></th>
<th class="tableColumn">Cod. Produto</th>
<th class="tableColumn">Descrição</th>
<th class="tableColumn">Quantidade</th>
<th class="tableColumn">Preço (R$)</th>
<th class="tableColumn">Desconto (%)</th>
<th class="tableColumn">Total</th>
</tr>
</thead>
<tbody>
<tr class="tableBodyRow">
<td class="fs-v-align-middle"></td>
<td class="fs-v-align-middle">
<div class="form-input">
<input class="form-control" type="text" name="codProd" id="codProd"
mask="000000000000000000000000000000" onkeypress="MaskEvent.init()">
</div>
</td>
<td class="fs-v-align-middle col-md-4">
<div class="form-input">
<input class="form-control" type="text" name="descri" id="descri">
</div>
</td>
<td class="fs-v-align-middle">
<div class="form-input">
<input class="form-control" type="text" name="quant" id="quant" mask="000000000000000"
onkeypress="MaskEvent.init()">
</div>
</td>
<td class="fs-v-align-middle">
<div class="form-input">
<input class="form-control" type="text" name="preco" id="preco"
mask="#00.000.000.000.000,00" onkeypress="MaskEvent.init()">
</div>
</td>
<td class="fs-v-align-middle">
<div class="form-input">
<input class="form-control" type="text" name="desconto" id="desconto"
mask="#00.000,00%" onkeypress="MaskEvent.init()">
</div>
</td>
<td class="fs-v-align-middle">
<div class="form-input">
<input class="form-control" type="text" name="total" id="total" readonly>
</div>
</td>
</tr>
</tbody>
</table>
<button id="addItem" type="button" class="btn btn-primary" onclick="wdkAddChild('itensPed');addBlurInputs();">Add Item</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--Painel2 FIM-->
</form>
</div>
<script>
var itensTotal = 0;
var calendarioDataEntr = FLUIGC.calendar('#dataEnt');
function addBlurInputs() {
$("input[id^='quant___']:last").blur(calculaLinha);
$("input[id^='preco___']:last").blur(calculaLinha);
$("input[id^='desconto___']:last").blur(calculaLinha);
}
function calculaLinha() {
//pega o numero da linha inserida:
var index = this.id.substring(this.id.indexOf('___') + 3);
//pega os valores dos campos:
var quant = $("#quant___" + index).val();
var preco = $("#preco___" + index).val();
var desco = $("#desconto___" + index).val();
//trata os valores:
var precoS = preco.replace(',', '.');
var descoF = desco.replace('%', '');
descoF = descoF.replace(',', '.');
//calcula total:
var total = (quant * precoS) - ((quant * precoS) * (descoF / 100));
//coloca virgula no valor total
var totalF = total.toFixed(2).replace('.', ',');
//atribui o total ao input:
$("#total___" + index).val(totalF);
}
</script>
</body>
</html>
Preciso que ao digitar o codigo do cliente ele busque codigo na tabela de clientes do protheus e ao escolhido ele preencha o nome tambem.
Fiz um dataset que aciona um servico soap para buscar na tabela do protheus utilizando o CFGTABLE com o metodo GETTABLE onde passo a tabela SA1 com campos A1_COD e A1_NOME (O qual tambem nao sei se é o modo mais indicado de buscar pelos clientes).
Agora preciso que o meu formulário retorne os dados desse dataset e preencha o codigo e nome do cliente selecionados.
Alguma ideia?