Good morning.
I currently have 2 tables in this way:
The table we lend the genre dynamically in the following way:
var prestamos_creditos = $('.prestamos_creditos');
$.each(response.data, function(index,value){
$('<tr>')
.append($('<td/>').addClass('nuevo-td noPrestamo').text(value.Numero_Prestamo))
.append($('<td/>').addClass('nuevo-td fiador').text(value.Cod_Cliente_P))
.append($('<td/>').addClass('nuevo-td montoPrestamo').text(value.Saldo.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')))
.append('<div class="monto_prestamo_seleccionado" style="display:none">' + value.Saldo + '</div>')
.append('<div class="fecha_prestamo" style="display:none">' + value.Fecha + '</div>')
.append('<div class="numero_prestamo" style="display:none">' + value.Numero_Prestamo + '</div>')
.append('<div class="cod_cliente_prestamo" style="display:none">' + value.Cod_Cliente_P + '</div>')
.append($('<td/>').addClass('label-cell nuevo-td classCantidad')
.append($('<label/>').addClass('label-checkbox item-content')
.append('<input type="checkbox" name="prestamo" class="prestamo" value="' + value.Cod_Tipo_Prestamo + '"/>')
.append($('<span/>').addClass('item-media').append('<i class="icon icon-form-checkbox"></i>'))))
.appendTo(prestamos_creditos);
});
In the table "Credit loans assigned to your code" I select a loan, which will fill the table "Selected forms of payment".
function formaspagoSeleccionadas(nombre_forma_pago, cantPago,resultado, fecha_prestamo, numero_documento, cod_cliente){
console.log("FUNCION, FORMAS PAGOS SELECCIONADOS: ");
console.log(nombre_forma_pago);
console.log(cantPago);
console.log(resultado);
console.log(fecha_prestamo);
console.log(numero_documento);
console.log(cod_cliente);
let formas_pagos_seleccionados = $('.formas_pagos_seleccionados');
$('<tr class="pagos"/>')
.append($('<td>/').addClass('nuevo-td')
.append($('<label/>').addClass('label-radio item-content').text(nombre_forma_pago)))
.append($('<td/>').addClass('label-cell nuevo-td').text(cantPago))
.append('<div class="fecha_prestamo" style="display:none">' + fecha_prestamo + '</div>')
.append('<div class="numero_documento" style="display:none">' + numero_documento + '</div>')
.append('<div class="cod_cliente" style="display:none">' + cod_cliente + '</div>')
.append('<div class="monto" style="display:none">' + cantPago + '</div>')
.append($('<td/>').addClass('label-cell').append('<button value="' + resultado + '" type="button" class="eliminarformaPago button button-fill button-raised button-circle" title="Comment"><i class="fa fa-trash-o"></i></button>'))
.appendTo(formas_pagos_seleccionados);
console.log("Este es el resultado despues de llenar la tabla: "+resultado);
$('.saldo_pendiente').text(resultado.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'));
}
In the selected forms of payment table I have a button to delete the record, for which I have the following function:
$$('.formas_pagos_seleccionados').on('click', '.eliminarformaPago', function(){
console.log("Eliminar forma de pago");
let forma_pago = $(this).closest('tr');
let fecha_prestamo = forma_pago.find('.fecha_prestamo').text();
let numero_documento = forma_pago.find('.numero_documento').text();
let cod_cliente = forma_pago.find('.cod_cliente').text();
let monto = forma_pago.find('.monto').text();
let cod_banco;
console.log(idPedido);
console.log(cod_forma_pago);
console.log(monto);
console.log(cod_banco);
console.log(fecha_prestamo);
console.log(numero_documento);
console.log(cod_cliente);
$(this).closest('tr').remove();
});
The detail that I want to solve is when you remove the check of the loan that you have selected in the table "Loans of credit assigned to your code" in the same way automatically delete the record of the table "Selected forms of payment". For this case, select loan 0001, and add it to the other table, then remove the check from 0001 and delete record 0001 from the table "selected forms of payment"
Thank you in advance.