mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
arreglado bug en albaranes
This commit is contained in:
@ -449,31 +449,6 @@ function generarAlbaran(item){
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(document).on('change', '#tablaAlbaran' + item.albaran.id + ' .cantidad-albaran', function(){
|
||||
|
||||
let table = $('#tablaAlbaran' + item.albaran.id).DataTable();
|
||||
let row = $(this).closest('tr'); // Encuentra la fila actual
|
||||
let rowIndex = table.row(row).index(); // Obtiene el índice de la fila
|
||||
|
||||
const previousValue = table.cell(rowIndex, 2).data();
|
||||
const newValue = parseInt($(this).val()); // Obtiene el nuevo valor del input
|
||||
|
||||
let cantidad = calcular_cantidad_albaranes();
|
||||
|
||||
if(cantidad-previousValue+newValue <= parseInt($('#total_tirada').val()) ){
|
||||
// Actualiza el DataTable
|
||||
table.cell(rowIndex, 2).data(newValue);
|
||||
const cajas = parseInt(table.cell(rowIndex, 6).data());
|
||||
table.cell(rowIndex, 7).data(parseInt(newValue/cajas));
|
||||
cambios_cantidad_albaranes();
|
||||
}
|
||||
else{
|
||||
$(this).val(previousValue);
|
||||
table.cell(rowIndex, 7).data(previousValue);
|
||||
table.draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click', '.accordion-button', function(){
|
||||
@ -575,6 +550,35 @@ $(document).on('change', '.albaran_linea', function(){
|
||||
|
||||
var elementId = $(this).attr('id');
|
||||
|
||||
if(elementId.includes('cantidad')){
|
||||
const item_id = elementId.split('_').slice(-1)[0];
|
||||
let table = $(this).closest('table').DataTable(); // Obtiene la tabla DataTable
|
||||
let row = $(this).closest('tr'); // Encuentra la fila actual
|
||||
let rowIndex = table.row(row).index(); // Obtiene el índice de la fila
|
||||
|
||||
const previousValue = table.cell(rowIndex, 2).data();
|
||||
const newValue = parseInt($(this).val()); // Obtiene el nuevo valor del input
|
||||
|
||||
let cantidad = calcular_cantidad_albaranes();
|
||||
|
||||
if(cantidad-previousValue+newValue <= parseInt($('#total_tirada').val()) ){
|
||||
// Actualiza el DataTable
|
||||
table.cell(rowIndex, 2).data(newValue);
|
||||
const cajas = parseInt(table.cell(rowIndex, 6).data());
|
||||
table.cell(rowIndex, 7).data(parseInt(newValue/cajas));
|
||||
table.cell(rowIndex, 9).data(parseFloat(parseFloat(table.cell(rowIndex, 8).data()) * newValue).toFixed(2));
|
||||
$('#ejemplares_por_caja_' + item_id).val(parseInt(newValue/cajas)).trigger('change');
|
||||
$('#total_' + item_id).val(parseFloat((table.cell(rowIndex, 8).data()) * newValue).toFixed(2)).trigger('change');
|
||||
cambios_cantidad_albaranes();
|
||||
table.draw();
|
||||
}
|
||||
else{
|
||||
$(this).val(previousValue);
|
||||
table.cell(rowIndex, 7).data(previousValue);
|
||||
table.draw();
|
||||
}
|
||||
}
|
||||
|
||||
data = {
|
||||
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
||||
};
|
||||
@ -771,10 +775,12 @@ function check_cantidad_albaranes(unidades_albaranes){
|
||||
html('<?= lang('Pedidos.validation.errorCantidadAlbaranes') ?>'
|
||||
.replace('{0}', unidades_albaranes)
|
||||
.replace('{1}', $('#total_tirada').val()));
|
||||
$('#generar_albaranes').removeClass('d-none');
|
||||
}
|
||||
else{
|
||||
$('#alert-albaranes').addClass('d-none');
|
||||
$('#error-albaranes').html('');
|
||||
$('#generar_albaranes').addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user