arreglados bug al actualizar la tabla de lineas (vuelta a lo anterior). el tabulador no se mueve cuando se actualiza las coberturas

This commit is contained in:
Jaime Jiménez
2024-03-06 14:49:59 +01:00
parent 6a4179ec8a
commit 130dbba303
4 changed files with 77 additions and 22 deletions

View File

@ -140,7 +140,8 @@ function updateTablaEnvios(){
}) })
.draw(); .draw();
checkInsertar() checkInsertar()
updateTotales(false, false, true)
} }
else{ else{
popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa') popErrorAlert('<?= lang('PresupuestosDirecciones.validation.no_tarifa') ?>', 'error-tarifa')
@ -154,6 +155,8 @@ $(document).on('click', '.delete-add-row', function(e) {
.remove() .remove()
.draw(); .draw();
checkInsertar() checkInsertar()
updateTotales(false, false, true)
}) })
$(document).on('click', '.btn-edit-add', function(e) { $(document).on('click', '.btn-edit-add', function(e) {

View File

@ -521,6 +521,10 @@
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
}, },
"drawCallback": function(settings ) {
updateTotales(false, true, false)
}
}); });
function init_servicio_acabado(){ function init_servicio_acabado(){
@ -727,7 +731,11 @@
select: false, select: false,
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
}, },
"drawCallback": function(settings ) {
updateTotales(false, true, false)
}
}); });
@ -1001,6 +1009,10 @@
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
}, },
"drawCallback": function(settings ) {
updateTotales(false, true, false)
}
}); });
function init_servicio_manipulado(){ function init_servicio_manipulado(){
@ -1155,6 +1167,10 @@
language: { language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
}, },
"drawCallback": function(settings ) {
updateTotales(false, true, false)
}
}); });

View File

@ -87,6 +87,8 @@ const papelGenericoRotativaColorList = <?php echo json_encode($papelGenericoRota
const papelGenericoGuardasList = <?php echo json_encode($papelGenericoGuardasList); ?>; const papelGenericoGuardasList = <?php echo json_encode($papelGenericoGuardasList); ?>;
<?php endif; ?> <?php endif; ?>
// variable para controlar el foco en los inputs
let focused = 0;
// Formatting function for row details - modify as you need // Formatting function for row details - modify as you need
function format(d) { function format(d) {
@ -1548,6 +1550,7 @@ function fill_lp_bn(row, fromComparator=false){
$('#lp_bn_checkPapel').change() $('#lp_bn_checkPapel').change()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()
@ -1877,6 +1880,7 @@ function fill_lp_color(row, fromComparator=false){
$('#lp_color_checkPapel').change() $('#lp_color_checkPapel').change()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()
@ -2188,7 +2192,8 @@ function fill_lp_bnhq(row, fromComparator=false){
mostrar_calculos = ($( ".calculos_lp_bnhq").css('display') == 'table-row') mostrar_calculos = ($( ".calculos_lp_bnhq").css('display') == 'table-row')
// Si viene de hacerlo a mano... // Si viene de hacerlo a mano...
data = processRowData(row, 'lp_bnhq', 'lp-bnhq'); data = processRowData(row, 'lp_bnhq', 'lp-bnhq');
focused = $(':focus').attr('id');
var row = tableLineasPresupuesto.row('#lp_bnhq'); var row = tableLineasPresupuesto.row('#lp_bnhq');
if(row.length>0) if(row.length>0)
tableLineasPresupuesto.row('#lp_bnhq').data(data).draw() tableLineasPresupuesto.row('#lp_bnhq').data(data).draw()
@ -2203,6 +2208,7 @@ function fill_lp_bnhq(row, fromComparator=false){
$('#lp_bnhq_checkPapel').change() $('#lp_bnhq_checkPapel').change()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()
@ -2215,6 +2221,11 @@ function fill_lp_bnhq(row, fromComparator=false){
} }
$("#tableLineasPresupuesto").DataTable().columns.adjust(); $("#tableLineasPresupuesto").DataTable().columns.adjust();
if(focused){
$('#'+focused).focus();
$('#'+focused).select();
focused = 0;
}
} }
function eventos_lp_bnhq(isInkjet = false){ function eventos_lp_bnhq(isInkjet = false){
@ -2366,6 +2377,9 @@ function change_lp_colorhq_paginas(){
function change_lp_colorhq_tipologia(){ function change_lp_colorhq_tipologia(){
// Se obtiene el id del elemento que ha disparado el evento
var id = $(this).attr('id')
if( parseInt($('#lp_colorhq_paginas').val())>0 && if( parseInt($('#lp_colorhq_paginas').val())>0 &&
parseInt($('#lp_colorhq_papel option:selected').val())>0 && parseInt($('#lp_colorhq_papel option:selected').val())>0 &&
$('#lp_colorhq_gramaje option:selected').text().length>0 && $('#lp_colorhq_gramaje option:selected').text().length>0 &&
@ -2373,6 +2387,7 @@ function change_lp_colorhq_tipologia(){
){ ){
calcularPresupuesto_colorhq({},true); calcularPresupuesto_colorhq({},true);
} }
} }
@ -2499,6 +2514,7 @@ function calcularPresupuesto_colorhq(input_data={}, updatedTipologias = false){
}) })
} }
function fill_lp_colorhq(row, fromComparator=false){ function fill_lp_colorhq(row, fromComparator=false){
if(fromComparator){ if(fromComparator){
@ -2514,6 +2530,7 @@ function fill_lp_colorhq(row, fromComparator=false){
else{ else{
// Se guarda el estado de "ver calculos" // Se guarda el estado de "ver calculos"
mostrar_calculos = ($( ".calculos_lp_colorhq").css('display') == 'table-row') mostrar_calculos = ($( ".calculos_lp_colorhq").css('display') == 'table-row')
focused = $(':focus').attr('id');
// Si viene de hacerlo a mano... // Si viene de hacerlo a mano...
data = processRowData(row, 'lp_colorhq', 'lp-colorhq'); data = processRowData(row, 'lp_colorhq', 'lp-colorhq');
@ -2532,6 +2549,7 @@ function fill_lp_colorhq(row, fromComparator=false){
$('#lp_colorhq_checkPapel').change() $('#lp_colorhq_checkPapel').change()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()
@ -2540,11 +2558,15 @@ function fill_lp_colorhq(row, fromComparator=false){
if(mostrar_calculos){ if(mostrar_calculos){
$( ".calculos_lp_colorhq").css('display','table-row') $( ".calculos_lp_colorhq").css('display','table-row')
} }
} }
$("#tableLineasPresupuesto").DataTable().columns.adjust(); $("#tableLineasPresupuesto").DataTable().columns.adjust();
if(focused){
$('#'+focused).focus();
$('#'+focused).select();
focused = 0;
}
} }
function eventos_lp_colorhq(isInkjet = false){ function eventos_lp_colorhq(isInkjet = false){
@ -2565,6 +2587,7 @@ function eventos_lp_colorhq(isInkjet = false){
$('#lp_colorhq_checkPapel').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea); $('#lp_colorhq_checkPapel').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea);
$('#lp_colorhq_checkClicks').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea); $('#lp_colorhq_checkClicks').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea);
} }
<?= $this->endSection() ?> <?= $this->endSection() ?>
@ -2853,6 +2876,7 @@ function fill_lp_rot_bn(row, fromComparador=false){
else{ else{
// Se guarda el estado de "ver calculos" // Se guarda el estado de "ver calculos"
mostrar_calculos = ($( ".calculos_lp_rot_bn").css('display') == 'table-row') mostrar_calculos = ($( ".calculos_lp_rot_bn").css('display') == 'table-row')
focused = $(':focus').attr('id');
// Si viene de hacerlo a mano... // Si viene de hacerlo a mano...
data = processRowData(row, 'lp_rot_bn', 'lp-rot-bn'); data = processRowData(row, 'lp_rot_bn', 'lp-rot-bn');
@ -2871,6 +2895,7 @@ function fill_lp_rot_bn(row, fromComparador=false){
$('#lp_rot_bn_checkPapel').change() $('#lp_rot_bn_checkPapel').change()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()
@ -2884,6 +2909,11 @@ function fill_lp_rot_bn(row, fromComparador=false){
$('.lp_rot_bn').css('display', '') $('.lp_rot_bn').css('display', '')
$("#tableLineasPresupuesto").DataTable().columns.adjust(); $("#tableLineasPresupuesto").DataTable().columns.adjust();
if(focused){
$('#'+focused).focus();
$('#'+focused).select();
focused = 0;
}
} }
@ -3195,8 +3225,9 @@ function fill_lp_rot_color(row, fromComparador=false){
} }
else{ else{
// Se guarda el estado de "ver calculos" // Se guarda el estado de "ver calculos"
mostrar_calculos = ($( ".calculos_lp_rot_color").css('display') == 'table-row') mostrar_calculos = ($( ".calculos_lp_rot_color").css('display') == 'table-row')
focused = $(':focus').attr('id');
// Si viene de hacerlo a mano... // Si viene de hacerlo a mano...
data = processRowData(row, 'lp_rot_color', 'lp-rot-color'); data = processRowData(row, 'lp_rot_color', 'lp-rot-color');
@ -3214,6 +3245,7 @@ function fill_lp_rot_color(row, fromComparador=false){
$('#lp_rot_color_checkPapel').change() $('#lp_rot_color_checkPapel').change()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()
@ -3226,7 +3258,12 @@ function fill_lp_rot_color(row, fromComparador=false){
} }
$("#tableLineasPresupuesto").DataTable().columns.adjust(); $("#tableLineasPresupuesto").DataTable().columns.adjust();
if(focused){
$('#'+focused).focus();
$('#'+focused).select();
focused = 0;
}
} }
function eventos_lp_rot_color(){ function eventos_lp_rot_color(){
@ -3474,6 +3511,7 @@ function fill_lp_cubierta(row, fromComparador=false){
// Si viene de hacerlo a mano... // Si viene de hacerlo a mano...
data = processRowData(row, 'lp_cubierta', 'lp-cubierta'); data = processRowData(row, 'lp_cubierta', 'lp-cubierta');
focused = $(':focus').attr('id');
var row = tableLineasPresupuesto.row('#lp_cubierta'); var row = tableLineasPresupuesto.row('#lp_cubierta');
if(row.length>0) if(row.length>0)
@ -3491,13 +3529,18 @@ function fill_lp_cubierta(row, fromComparador=false){
check_update_sobrecubierta() check_update_sobrecubierta()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()
} }
$("#tableLineasPresupuesto").DataTable().columns.adjust(); $("#tableLineasPresupuesto").DataTable().columns.adjust();
if(focused){
$('#'+focused).focus();
$('#'+focused).select();
focused = 0;
}
} }
function eventos_lp_cubierta(){ function eventos_lp_cubierta(){
@ -3754,6 +3797,7 @@ function fill_lp_sobrecubierta(row, fromComparador=false){
$('#lp_sobrecubierta_checkPapel').change() $('#lp_sobrecubierta_checkPapel').change()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()
@ -3949,6 +3993,7 @@ function fill_lp_guardas(row, fromComparador=false){
$('#lp_guardas_checkPapel').change() $('#lp_guardas_checkPapel').change()
calcular_mermas() calcular_mermas()
updateTotales(true, false, false);
updateTablaEnvios() updateTablaEnvios()

View File

@ -83,17 +83,6 @@
<?= $this->section("additionalInlineJs") ?> <?= $this->section("additionalInlineJs") ?>
$('.update-resumen-presupuesto').each(function() {
if ($(this).is('table')) {
if($(this).attr('id') == 'tableLineasPresupuesto')
$(this).bind('draw.dt',{updateLP:true, updateServicios:false, updateEnvio:false}, updateTotales);
else if ($(this).attr('id') == 'tableOfServiciosAcabado' || $(this).attr('id') == 'tableOfServiciosPreimpresion' ||
$(this).attr('id') == 'tableOfServiciosEncuadernacion' || $(this).attr('id') == 'tableOfServiciosManipulado')
$(this).bind('draw.dt',{updateLP:false, updateServicios:true, updateEnvio:false}, updateTotales);
else if ($(this).attr('id') == 'tableOfDireccionesEnvio')
$(this).bind('draw.dt',{updateLP:false, updateServicios:false, updateEnvio:true}, updateTotales);
}
});
function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
var totalPapel = 0 var totalPapel = 0
@ -113,11 +102,13 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
if(typeof tableLineasPresupuesto !== 'undefined'){ if(typeof tableLineasPresupuesto !== 'undefined'){
tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) { tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data(); var rowData = this.data();
if($('#' + rowData.row_id + '_checkPapel').prop('checked')){
if(rowData.check_papel_total){
totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val()) totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').val())
margenPapel += parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val()) margenPapel += parseFloat($('#' + rowData.row_id + '_margenPapelPedido').val())
} }
if($('#' + rowData.row_id + '_checkClicks').prop('checked')){ if(rowData.check_impresion_total){
totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val()) totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val()) totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())