From 130dbba303af483a75a90f1e87575b7fa24c488f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 6 Mar 2024 14:49:59 +0100 Subject: [PATCH] arreglados bug al actualizar la tabla de lineas (vuelta a lo anterior). el tabulador no se mueve cuando se actualiza las coberturas --- .../cosidotapablanda/_datosEnvios.php | 5 +- .../cosidotapablanda/_datosServiciosItems.php | 18 +++++- .../_lineasPresupuestoItems.php | 59 ++++++++++++++++--- .../_resumenPresupuestoItems.php | 17 ++---- 4 files changed, 77 insertions(+), 22 deletions(-) diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php index b8ab53ea..51f6898d 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php @@ -140,7 +140,8 @@ function updateTablaEnvios(){ }) .draw(); - checkInsertar() + checkInsertar() + updateTotales(false, false, true) } else{ popErrorAlert('', 'error-tarifa') @@ -154,6 +155,8 @@ $(document).on('click', '.delete-add-row', function(e) { .remove() .draw(); checkInsertar() + updateTotales(false, false, true) + }) $(document).on('click', '.btn-edit-add', function(e) { diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php index 3b55db5c..dbc84863 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosServiciosItems.php @@ -521,6 +521,10 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, + "drawCallback": function(settings ) { + updateTotales(false, true, false) + } + }); function init_servicio_acabado(){ @@ -727,7 +731,11 @@ select: false, language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" - }, + }, + "drawCallback": function(settings ) { + updateTotales(false, true, false) + } + }); @@ -1001,6 +1009,10 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, + "drawCallback": function(settings ) { + updateTotales(false, true, false) + } + }); function init_servicio_manipulado(){ @@ -1155,6 +1167,10 @@ language: { url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" }, + "drawCallback": function(settings ) { + updateTotales(false, true, false) + } + }); diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index e90c4ed3..d57ba93b 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -87,6 +87,8 @@ const papelGenericoRotativaColorList = ; +// variable para controlar el foco en los inputs +let focused = 0; // Formatting function for row details - modify as you need function format(d) { @@ -1548,6 +1550,7 @@ function fill_lp_bn(row, fromComparator=false){ $('#lp_bn_checkPapel').change() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() @@ -1877,6 +1880,7 @@ function fill_lp_color(row, fromComparator=false){ $('#lp_color_checkPapel').change() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() @@ -2188,7 +2192,8 @@ function fill_lp_bnhq(row, fromComparator=false){ mostrar_calculos = ($( ".calculos_lp_bnhq").css('display') == 'table-row') // Si viene de hacerlo a mano... data = processRowData(row, 'lp_bnhq', 'lp-bnhq'); - + focused = $(':focus').attr('id'); + var row = tableLineasPresupuesto.row('#lp_bnhq'); if(row.length>0) tableLineasPresupuesto.row('#lp_bnhq').data(data).draw() @@ -2203,6 +2208,7 @@ function fill_lp_bnhq(row, fromComparator=false){ $('#lp_bnhq_checkPapel').change() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() @@ -2215,6 +2221,11 @@ function fill_lp_bnhq(row, fromComparator=false){ } $("#tableLineasPresupuesto").DataTable().columns.adjust(); + if(focused){ + $('#'+focused).focus(); + $('#'+focused).select(); + focused = 0; + } } function eventos_lp_bnhq(isInkjet = false){ @@ -2366,6 +2377,9 @@ function change_lp_colorhq_paginas(){ 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 && parseInt($('#lp_colorhq_papel option:selected').val())>0 && $('#lp_colorhq_gramaje option:selected').text().length>0 && @@ -2373,6 +2387,7 @@ function change_lp_colorhq_tipologia(){ ){ calcularPresupuesto_colorhq({},true); + } } @@ -2499,6 +2514,7 @@ function calcularPresupuesto_colorhq(input_data={}, updatedTipologias = false){ }) } + function fill_lp_colorhq(row, fromComparator=false){ if(fromComparator){ @@ -2514,6 +2530,7 @@ function fill_lp_colorhq(row, fromComparator=false){ else{ // Se guarda el estado de "ver calculos" mostrar_calculos = ($( ".calculos_lp_colorhq").css('display') == 'table-row') + focused = $(':focus').attr('id'); // Si viene de hacerlo a mano... data = processRowData(row, 'lp_colorhq', 'lp-colorhq'); @@ -2532,6 +2549,7 @@ function fill_lp_colorhq(row, fromComparator=false){ $('#lp_colorhq_checkPapel').change() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() @@ -2540,11 +2558,15 @@ function fill_lp_colorhq(row, fromComparator=false){ if(mostrar_calculos){ $( ".calculos_lp_colorhq").css('display','table-row') - } + } } $("#tableLineasPresupuesto").DataTable().columns.adjust(); - + if(focused){ + $('#'+focused).focus(); + $('#'+focused).select(); + focused = 0; + } } 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_checkClicks').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea); + } endSection() ?> @@ -2853,6 +2876,7 @@ function fill_lp_rot_bn(row, fromComparador=false){ else{ // Se guarda el estado de "ver calculos" mostrar_calculos = ($( ".calculos_lp_rot_bn").css('display') == 'table-row') + focused = $(':focus').attr('id'); // Si viene de hacerlo a mano... 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() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() @@ -2884,6 +2909,11 @@ function fill_lp_rot_bn(row, fromComparador=false){ $('.lp_rot_bn').css('display', '') $("#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{ // 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... 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() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() @@ -3226,7 +3258,12 @@ function fill_lp_rot_color(row, fromComparador=false){ } $("#tableLineasPresupuesto").DataTable().columns.adjust(); - + if(focused){ + $('#'+focused).focus(); + $('#'+focused).select(); + focused = 0; + } + } function eventos_lp_rot_color(){ @@ -3474,6 +3511,7 @@ function fill_lp_cubierta(row, fromComparador=false){ // Si viene de hacerlo a mano... data = processRowData(row, 'lp_cubierta', 'lp-cubierta'); + focused = $(':focus').attr('id'); var row = tableLineasPresupuesto.row('#lp_cubierta'); if(row.length>0) @@ -3491,13 +3529,18 @@ function fill_lp_cubierta(row, fromComparador=false){ check_update_sobrecubierta() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() } $("#tableLineasPresupuesto").DataTable().columns.adjust(); - + if(focused){ + $('#'+focused).focus(); + $('#'+focused).select(); + focused = 0; + } } function eventos_lp_cubierta(){ @@ -3754,6 +3797,7 @@ function fill_lp_sobrecubierta(row, fromComparador=false){ $('#lp_sobrecubierta_checkPapel').change() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() @@ -3949,6 +3993,7 @@ function fill_lp_guardas(row, fromComparador=false){ $('#lp_guardas_checkPapel').change() calcular_mermas() + updateTotales(true, false, false); updateTablaEnvios() diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php index 1b29cc49..32c509ad 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php @@ -83,17 +83,6 @@ 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){ var totalPapel = 0 @@ -113,11 +102,13 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){ if(typeof tableLineasPresupuesto !== 'undefined'){ tableLineasPresupuesto.rows().every( function ( rowIdx, tableLoop, rowLoop ) { var rowData = this.data(); - if($('#' + rowData.row_id + '_checkPapel').prop('checked')){ + + if(rowData.check_papel_total){ totalPapel += parseFloat($('#' + rowData.row_id + '_totalPapelPedido').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 + '_totalClicks').val())