Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- <!--
- <link rel="stylesheet" type="text/css" href="style.css?1" media="screen"/>
- <link rel="stylesheet" type="text/css" href="style_custon.css?1" media="screen"/>
- -->
- <script type="text/javascript" src="jquery_1.7.2.js"></script>
- <script type="text/javascript">
- /**
- Insere ponto e a virgula em valores monetários:
- */
- function moeda(z) {
- v = z.value;
- v = v.replace(/\D/g,""); // permite digitar apenas números
- v = v.replace(/[0-9]{12}/,"Valor inválido."); // limita pra máximo 999.999.999,99
- v = v.replace(/(\d{1})(\d{8})$/,"$1.$2"); // coloca ponto antes dos últimos 8 digitos
- v = v.replace(/(\d{1})(\d{5})$/,"$1.$2"); // coloca ponto antes dos últimos 5 digitos
- v = v.replace(/(\d{1})(\d{1,2})$/,"$1,$2"); // coloca virgula antes dos últimos 2 digitos
- z.value = v;
- }
- /**
- Insere ponto e a virgula em valores monetários:
- */
- function formataMoeda(valor) {
- v = valor;
- v = v.replace(/\D/g,""); // permite digitar apenas números
- v = v.replace(/[0-9]{12}/,"Valor inválido."); // limita pra máximo 999.999.999,99
- v = v.replace(/(\d{1})(\d{8})$/,"$1.$2"); // coloca ponto antes dos últimos 8 digitos
- v = v.replace(/(\d{1})(\d{5})$/,"$1.$2"); // coloca ponto antes dos últimos 5 digitos
- v = v.replace(/(\d{1})(\d{1,2})$/,"$1,$2"); // coloca virgula antes dos últimos 2 digitos
- return v;
- } // function formataMoeda(valor)
- /**
- Verifica se existe PONTO no valor recebido;
- */
- function retiraPonto(valor){
- var regExp = /\./ig;
- var bool = regExp.test(valor);
- if (bool) {
- var valor = valor.replace('.','');
- return valor;
- }
- return valor;
- } // function retiraPonto(valor)
- function recalcular_valor_demais_parcelas(id, valor_parcela){
- /*
- Valor da parcela:
- */
- var valor = retiraPonto(valor_parcela);
- valor = valor.replace(',','.');
- total_valor_parcela = new Number(valor);
- var parcela = total_valor_parcela.toFixed(2);
- // console.log('PARCELA: '+parcela);
- /*
- Valor Total inicial:
- */
- var total1 = $("#valor_total").val();
- // console.log('TOTAL 1: '+total1);
- var total2 = retiraPonto(total1);
- total3 = total2.replace(',','.');
- // console.log('TOTAL 3: '+total3);
- valor_total = new Number(total3);
- var total4 = valor_total.toFixed(2);
- // console.log('TOTAL 4: '+total4);
- /*
- Novo total: Total inicial MENOS o novo valor da primeira
- parcela;
- */
- var novo_total = 0;
- novo_total += (+total4) - (+parcela);
- var total = new Number(novo_total);
- var resNovoTotal = total.toFixed(2);
- // console.log('NOVO TOTAL: '+resNovoTotal);
- /*
- Pega todos os inputs de parcela:
- */
- var tabela = document.getElementById("tabela");
- var inputs_parcela = tabela.getElementsByClassName("pmt");
- var inputs = (inputs_parcela.length - 1);
- // console.log('INPUTS: '+inputs);
- /*
- Novo valor das parcelas;
- */
- var resultado = 0;
- resultado += (+resNovoTotal) / (inputs);
- var total = new Number(resultado);
- var resTotal = total.toFixed(2);
- /*
- Insere o total atualizado no campo input: '#valor_total',
- em caso de outros campos de parcela terem seus
- valores alterados;
- E recalcula o valor das demais parcelas com base neste novo
- valor total;
- */
- /*
- var total_atualizado = (+resTotal) * (+inputs);
- var total = new Number(total_atualizado);
- total_atualizado = total.toFixed(2);
- total_atualizado = retiraPonto(total_atualizado.toString());
- $("#valor_total").val( formataMoeda(total_atualizado) );
- */
- /*
- Seta o novo valor das parcelas em todos os campos
- com id 'valor_parcela';
- */
- for (var i = 0; i < inputs_parcela.length; i++) {
- /*
- Altera todos os campos, que ficam ABAIXO ou APARTIR do
- campo que está sendo editado, exceto o campo que está
- recebendo a edição:
- */
- if ((i+id) != id) {
- $('#valor_parcela'+(i+id)).val(formataMoeda(resTotal));
- }
- }
- } // function recalcular_valor_demais_parcelas()
- </script>
- </head>
- <fieldset class="lb">
- <legend id="load_parcelas"><strong>PARCELAS</strong>
- <i class="info" dica="Valores apresentados com base no cálculo da Tabela Price." rel="tooltip4"></i>
- </legend>
- </fieldset>
- <!--Recebe a reposta do PHP (via AJAX);-->
- <div id="respAjaxValoresParcelas">
- <input type="hidden" id="valor_total" value="10.000,00">
- <table id="tabela" class="table table-striped status-orcamento table-hover">
- <thead>
- <tr><th>Parcela</th>
- <th>Vencimento</th>
- <th>Desconto <i class="f12">(R$)</i></th>
- <th>Juro <i class="f12">(R$)</i></th>
- <th>Recebido</th>
- <th>Valor Parcela</th>
- <th>Status</th>
- </tr></thead>
- <tbody>
- <tr class="status-nao-aprovado"> <th><normal>1</normal></th>
- <th>
- <input type="date" class="form_alfa" id="lancamento_receita_data_incio" value="2019-09-21" onchange="data_conta_receber(1024, 000, this.value)" title="Alterar Data." rel="tooltip2">
- </th>
- <th>
- <input type="text" class="form_alfa" id="desconto1" value="0,00" onkeyup="moeda(this); recalcular_valor_recebido_desconto(1, this.value);">
- </th>
- <th>
- <input type="text" class="form_alfa" id="juro1" value="0,00" onkeyup="moeda(this); recalcular_valor_recebido_juro(1, this.value);">
- </th>
- <th>
- <input type="text" class="form_alfa" id="recebido1" value="0,00" onkeyup="moeda(this);">
- </th>
- <th>
- <input type="text" class="form_alfa pmt" id="valor_parcela1" value="2.500,00" onkeyup="moeda(this); recalcular_valor_demais_parcelas(1, this.value);">
- </th>
- <th>
- <select class="form_alfa" onchange="status_conta_receber('1','lrcb-1000844569', this.value)">
- <option id="status_conta_receber" 0="">Aguardando</option>
- <option value="1">Recebido</option>
- <option value="2">Cancelado</option>
- </select>
- </th>
- </tr>
- <tr class="status-aprovado"> <th><strong>2</strong></th>
- <th>
- <input type="date" class="form_alfa" id="lancamento_receita_data_incio" value="2019-10-21" onchange="data_conta_receber(1025, 000, this.value)" title="Alterar Data." rel="tooltip2">
- </th>
- <th>
- <input type="text" class="form_alfa" id="desconto2" value="0,00" onkeyup="moeda(this); recalcular_valor_recebido_desconto(2, this.value);">
- </th>
- <th>
- <input type="text" class="form_alfa" id="juro2" value="0,00" onkeyup="moeda(this); recalcular_valor_recebido_juro(2, this.value);">
- </th>
- <th>
- <input type="text" class="form_alfa" id="recebido2" value="0,00" onkeyup="moeda(this);" >
- </th>
- <th>
- <input type="text" class="form_alfa pmt" id="valor_parcela2" value="2.500,00" onkeyup="moeda(this); recalcular_valor_demais_parcelas(2, this.value);">
- </th>
- <th>
- <select class="form_alfa" onchange="status_conta_receber('2','lrcb-1000844569', this.value)">
- <option id="status_conta_receber" 0="">Aguardando</option>
- <option value="1">Recebido</option>
- <option value="2">Cancelado</option>
- </select>
- </th>
- </tr>
- <tr class="status-aprovado"> <th><normal>3</normal></th>
- <th>
- <input type="date" class="form_alfa" id="lancamento_receita_data_incio" value="2019-11-21" onchange="data_conta_receber(1026, 000, this.value)" title="Alterar Data." rel="tooltip2">
- </th>
- <th>
- <input type="text" class="form_alfa" id="desconto3" value="0,00" onkeyup="moeda(this); recalcular_valor_recebido_desconto(3, this.value);">
- </th>
- <th>
- <input type="text" class="form_alfa" id="juro3" value="0,00" onkeyup="moeda(this); recalcular_valor_recebido_juro(3, this.value);" >
- </th>
- <th>
- <input type="text" class="form_alfa" id="recebido3" value="0,00" onkeyup="moeda(this);" >
- </th>
- <th>
- <input type="text" class="form_alfa pmt" id="valor_parcela3" value="2.500,00" onkeyup="moeda(this); recalcular_valor_demais_parcelas(3, this.value);" >
- </th>
- <th>
- <select class="form_alfa" onchange="status_conta_receber('3','lrcb-1000844569', this.value)">
- <option id="status_conta_receber" 0="">Aguardando</option>
- <option value="1">Recebido</option>
- <option value="2">Cancelado</option>
- </select>
- </th>
- </tr>
- <tr class="status-aprovado"> <th><strong>4</strong></th>
- <th>
- <input type="date" class="form_alfa" id="lancamento_receita_data_incio" value="2019-12-21" onchange="data_conta_receber(1027, 000, this.value)" title="Alterar Data." rel="tooltip2" >
- </th>
- <th>
- <input type="text" class="form_alfa" id="desconto4" value="0,00" onkeyup="moeda(this); recalcular_valor_recebido_desconto(4, this.value);" >
- </th>
- <th>
- <input type="text" class="form_alfa" id="juro4" value="0,00" onkeyup="moeda(this); recalcular_valor_recebido_juro(4, this.value);" >
- </th>
- <th>
- <input type="text" class="form_alfa" id="recebido4" value="0,00" onkeyup="moeda(this);" >
- </th>
- <th>
- <input type="text" class="form_alfa pmt" id="valor_parcela4" value="2.500,00" onkeyup="moeda(this); recalcular_valor_demais_parcelas(4, this.value);" >
- </th>
- <th>
- <select class="form_alfa" onchange="status_conta_receber('4','lrcb-1000844569', this.value)">
- <option id="status_conta_receber" 0="">Aguardando</option>
- <option value="1">Recebido</option>
- <option value="2">Cancelado</option>
- </select>
- </th>
- </tr>
- </tbody>
- </table>
- <table class="table table-striped status-orcamento table-hover">
- <thead>
- <tr><th></th>
- <th></th>
- <th></th>
- <th></th>
- </tr></thead>
- <tbody>
- <tr>
- <td colspan="7">
- <span style="float:right;text-align: right; margin-top:0px;" class="f24 grand_total box-shadow">
- <i class="f10">TOTAL </i>
- <b id="grand_total">R$
- 10.000,00
- </b>
- </span>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!--Recebe a reposta do PHP (via AJAX) - respAjaxValoresParcelas -->
- <div class="clear_form"></div>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement