From 287132698955a1bb8c2eb95ee57cbc0fe006b5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 29 Jan 2025 20:42:19 +0100 Subject: [PATCH 1/2] arreglados multiples fallos de presupuesto admin y problema en los forms de las tarifas --- .../presupuestos/admin/_datosLibroItems.php | 52 ++++++------ .../tarifas/acabado/viewTarifaAcabadoForm.php | 3 +- .../manipulado/viewTarifaManipuladoForm.php | 3 +- .../viewTarifapreimpresionForm.php | 20 +---- .../presupuestoAdmin/presupuestoAdminEdit.js | 76 +++++++++++++++++- .../presupuestoAdmin/sections/datosLibro.js | 27 ++++++- .../pages/presupuestoAdmin/sections/envios.js | 15 ++-- .../presupuestoAdmin/sections/servicios.js | 79 ++++++++++++++++--- .../presupuestoCliente/presupuestoCliente.js | 2 +- 9 files changed, 202 insertions(+), 75 deletions(-) diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php index c442c76c..d2149259 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -107,7 +107,18 @@ for="solapas"> - + +
+
+ + +
+ Entre 60 y 120 mm +
+
@@ -122,6 +133,19 @@ +
+
+ + +
+ Entre 60 y 120 mm +
+
+
@@ -138,32 +162,6 @@
- -
- -
-
- - -
-
- -
-
- - -
- -
- -
diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php index ced61c74..4e42b95a 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php @@ -258,8 +258,7 @@ paging: true, info: false, stateSave: false, - dom: '<"mt-4"><"float-end"B><"float-start"l> - <"mt-4 mb-3"p>', + dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', ajax : $.fn.dataTable.pipeline( { url: '', data: { diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php index 47bbb8ce..f07210b3 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php @@ -173,8 +173,7 @@ searching: false, paging: true, info: false, - dom: '<"mt-4"><"float-end"B><"float-start"l> - <"mt-4 mb-3"p>', + dom: '<"mt-4"><"float-end"B><"float-start"l><"mt-4 mb-3"p>', ajax : $.fn.dataTable.pipeline( { url: '', data: { diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php index 8eb895fa..a3f3f0dc 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php @@ -1,4 +1,5 @@ include("themes/_commonPartialsBs/select2bs5") ?> +include("themes/_commonPartialsBs/datatables") ?> include("themes/_commonPartialsBs/sweetalert") ?> extend('themes/vuexy/main/defaultlayout') ?> section("content") ?> @@ -26,25 +27,6 @@ - -
-
-

- -

-
-
- "tarifa_maquina_component", "tarifaId" => $tarifapreimpresionEntity?->id]) ?> -
-
-
-
- -endSection() ?> -section("additionalExternalJs") ?> - endSection() ?> \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 5cf763c8..8b9e7cf3 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -382,14 +382,35 @@ class PresupuestoAdminEdit { ).get(); } + /* + calcularSolapas() { + + + this.#getDatos(false, true); + if (Object.values(this.datos).every(this.#isValidDataForm)) { + new Ajax('/presupuestocliente/calcularsolapas', + this.datos, + {}, + (response) => { + if (response === null || response === undefined || response === "") { + console.error("Error en el calculo máximo de solapas."); + return; + } + this.disenioCubierta.tamanioSolapasCubierta.attr('max', response); + this.disenioCubierta.solapasSobrecubierta.attr('max', response); + this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm"); + this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm"); + }, + () => { } + ).post(); + } + }*/ checkPaginasPresupuesto() { let cantidad_total = 0; - // TO-DO - /* - tableLineasPresupuesto.rows().every(function (rowIdx, tableLoop, rowLoop) { + this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) { var rowData = this.data(); if (rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta' && rowData.row_id != 'lp_guardas') cantidad_total += parseInt(rowData.paginas) @@ -409,7 +430,54 @@ class PresupuestoAdminEdit { `; } - $('#divAlarmasLineasPresupuesto').html(htmlString)*/ + $('#divAlarmasLineasPresupuesto').html(htmlString) + } + + + getPaginasColor(){ + + let paginasColor = 0; + this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) { + var rowData = this.data(); + if (rowData.row_id === 'lp_color' || rowData.row_id === 'lp_colorhq') { + return parseInt(rowData.paginas); + } + if(rowData.row_id === 'lp_rot_color'){ + return parseInt(rowData.numPagColor); + } + }); + return paginasColor; + } + + calcularSolapas() { + + let datos = { + cliente_id: this.datosGenerales.cliente.getVal(), + tirada: this.datosGenerales.tirada.val(), + tamanio: this.getDimensionLibro(), + paginas: this.datosLibro.paginas.val(), + //paginasColor: + + + } + + /*if (Object.values(this.datos).every(this.#isValidDataForm)) { + new Ajax('/presupuestocliente/calcularsolapas', + this.datos, + {}, + (response) => { + if (response === null || response === undefined || response === "") { + console.error("Error en el calculo máximo de solapas."); + return; + } + this.disenioCubierta.tamanioSolapasCubierta.attr('max', response); + this.disenioCubierta.solapasSobrecubierta.attr('max', response); + this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm"); + this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm"); + }, + () => { } + ).post(); + }*/ } getDimensionLibro() { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 8bd7c1bc..099f08d0 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -225,7 +225,7 @@ class DatosLibro { }, 100); // para que se actualice el comparador - $('paginas').trigger('change'); + this.updateComparador(); } changeAnchoSolapasCubierta(){ @@ -238,7 +238,7 @@ class DatosLibro { } // para que se actualice el comparador - $('paginas').trigger('change'); + this.updateComparador(); } @@ -269,7 +269,7 @@ class DatosLibro { } // para que se actualice el comparador - $('paginas').trigger('change'); + this.updateComparador(); } @@ -332,10 +332,29 @@ class DatosLibro { } } + updateComparador(){ + + if($("#compPaginasNegro").hasClass('d-none')){ + $('#compPaginasNegrohq').trigger('change'); + } + else{ + $('#compPaginasNegro').trigger('change'); + } + $('#compCarasCubierta').trigger('change'); + + if($('#compSobrecubierta').length){ + $('#compSobrecubierta').trigger('change'); + } + if($('#compCarasGuardas').length){ + $('#compCarasGuardas').trigger('change'); + } + } changeTirada(update_tiradas_alternativas = true) { - this.calcular_mermas() + this.calcular_mermas(); + + this.updateComparador(); const url2 = window.location.href; const url_parts2 = url2.split('/'); diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js index e4126ce3..4217cc10 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js @@ -108,7 +108,7 @@ class Envios { $("#costeEnvios").text(total.toFixed(2) + "€" || "0€"); - self.check_unidades_enviadas(); + self.check_unidades_enviadas(null, self.recogerTaller.prop('checked')); } }); @@ -169,11 +169,10 @@ class Envios { self.modalYesNo.init(); self.modalYesNo.show(() => { self.table.clear().draw(); - self.check_unidades_enviadas(); + self.check_unidades_enviadas(null, true); self.recogerTaller.prop('checked', true); - self.modalYesNo.hide(); self.insertarEnvio.addClass('d-none'); - + self.modalYesNo.hide(); }); } else { @@ -641,7 +640,11 @@ class Envios { } } - check_unidades_enviadas() { + check_unidades_enviadas(event, recogerTaller = null) { + + if(recogerTaller === null) { + recogerTaller = this.recogerTaller.prop('checked'); + } let cantidad_total = 0 this.table.rows().every(function (rowIdx, tableLoop, rowLoop) { @@ -650,7 +653,7 @@ class Envios { const tirada = parseInt($('#tirada').val()); let htmlString = ''; - if (cantidad_total < tirada && this.recogerTaller.prop('checked') === false) { + if (cantidad_total < tirada && recogerTaller === false) { htmlString = ` `; - } + } $('#divAlarmasLineasPresupuesto').html(htmlString) } - getPaginasColor(){ + getPaginasColor() { let paginasColor = 0; this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) { @@ -442,42 +421,51 @@ class PresupuestoAdminEdit { if (rowData.row_id === 'lp_color' || rowData.row_id === 'lp_colorhq') { return parseInt(rowData.paginas); } - if(rowData.row_id === 'lp_rot_color'){ + if (rowData.row_id === 'lp_rot_color') { return parseInt(rowData.numPagColor); } }); - return paginasColor; + return paginasColor; } calcularSolapas() { - let datos = { - cliente_id: this.datosGenerales.cliente.getVal(), - tirada: this.datosGenerales.tirada.val(), - tamanio: this.getDimensionLibro(), - paginas: this.datosLibro.paginas.val(), - //paginasColor: + let anchoTotal = 2*this.getDimensionLibro().ancho; + let maxSolapas = 120; + let mano = 0; + this.lineasPresupuesto.table.rows().every(function (rowIdx, tableLoop, rowLoop) { + var rowData = this.data(); + if (rowData.row_id != 'lp_cubierta' || rowData.row_id === 'lp_sobrecubierta' + || rowData.row_id === 'lp_guardas' || rowData.row_id === 'lp_faja' + ) { + mano += parseInt(rowData.mano); + } + }); + if (mano > 0) { + anchoTotal += 6 + 5; // dobleces + sangre + maxSolapas = Math.min(Math.floor((865-anchoTotal)/2), 0.75*this.getDimensionLibro().ancho); } - - /*if (Object.values(this.datos).every(this.#isValidDataForm)) { - new Ajax('/presupuestocliente/calcularsolapas', - this.datos, - {}, - (response) => { - if (response === null || response === undefined || response === "") { - console.error("Error en el calculo máximo de solapas."); - return; - } - this.disenioCubierta.tamanioSolapasCubierta.attr('max', response); - this.disenioCubierta.solapasSobrecubierta.attr('max', response); - this.disenioCubierta.textoSolapasCubierta.text("Entre 60 y " + response + " mm"); - this.disenioCubierta.textoSolapasSobrecubierta.text("Entre 60 y " + response + " mm"); - }, - () => { } - ).post(); - }*/ + else{ + maxSolapas = 0.75*this.getDimensionLibro().ancho; + } + if($('#solapas_ancho').length>0 && $('#solapas_ancho').attr('max') != maxSolapas){ + $('#solapas_ancho').attr('max', maxSolapas); + $('#solapas_ancho').trigger('change'); + $('#solapas_ancho').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); + } + if($('#solapas_ancho_sobrecubierta').length>0 && $('#solapas_ancho_sobrecubierta').attr('max') != maxSolapas){ + $('#solapas_ancho_sobrecubierta').attr('max', maxSolapas); + $('#solapas_ancho_sobrecubierta').trigger('change'); + $('#solapas_ancho_sobrecubierta').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); + } + if($('#solapas_ancho_faja').length>0 && $('#solapas_ancho_faja').attr('max') != maxSolapas){ + $('#solapas_ancho_faja').attr('max', maxSolapas); + $('#solapas_ancho_faja').trigger('change'); + $('#solapas_ancho_faja').closest('.mb-1').find('.form-text').text('Entre 60 y ' + maxSolapas + ' mm'); + } + console.log('maxSolapas', maxSolapas); } getDimensionLibro() { diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js index 099f08d0..b14e3026 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/datosLibro.js @@ -95,6 +95,24 @@ class DatosLibro { this.paginas.on('change', this.changePaginas.bind(this)); this.tirada.on('change', this.changeTirada.bind(this)); + + this.anchoSolapasCubierta.on('focusout', this.checkSolapasMax.bind(this)); + this.anchoSolapasSobrecubierta.on('focusout', this.checkSolapasMax.bind(this)); + } + } + + checkSolapasMax(event) { + const el = event.target; + if (el.value != "") { + if (parseInt(el.value) < parseInt(el.min)) { + el.value = el.min; + } + if (parseInt(el.value) > parseInt(el.max)) { + el.value = el.max; + } + } + else{ + el.value = el.min; } } @@ -172,8 +190,8 @@ class DatosLibro { this.checkPaginasPresupuesto(); $(document).trigger('update-presupuesto', { - update_lineas : true, - update_servicios : true, + update_lineas: true, + update_servicios: true, update_envios: true, update_resumen: true, update_tiradas_alternativas: true @@ -199,10 +217,10 @@ class DatosLibro { $("#label_papelFormatoId").text( window.language.Presupuestos.papelFormatoId + '*'); } - + $(document).trigger('update-presupuesto', { - update_lineas : true, - update_servicios : false, + update_lineas: true, + update_servicios: false, update_envios: false, update_resumen: false, update_tiradas_alternativas: false @@ -228,12 +246,12 @@ class DatosLibro { this.updateComparador(); } - changeAnchoSolapasCubierta(){ + changeAnchoSolapasCubierta() { - if(this.checkSolapasGrandes('cubierta')){ + if (this.checkSolapasGrandes('cubierta')) { $(document).trigger('add-servicio-lineas', 'solapas_grandes_cubierta'); } - else{ + else { $(document).trigger('remove-servicio-lineas', 'solapas_grandes_cubierta'); } @@ -259,12 +277,12 @@ class DatosLibro { } - changeAnchoSolapasSobrecubierta(){ + changeAnchoSolapasSobrecubierta() { - if(this.checkSolapasGrandes('cubierta')){ + if (this.checkSolapasGrandes('cubierta')) { $(document).trigger('add-servicio-lineas', 'solapas_grandes_sobrecubierta'); } - else{ + else { $(document).trigger('remove-servicio-lineas', 'solapas_grandes_sobrecubierta'); } @@ -274,24 +292,24 @@ class DatosLibro { } checkSolapasGrandes(elemento) { - + const ancho_libro = 2 * this.getDimensionLibro().ancho; let ancho_solapas = 0.0; let lomo = 0.0; - if(elemento == 'cubierta'){ - ancho_solapas = 2 * parseFloat($('solapas_ancho').val()); - lomo = parseFloat($('lomo_cubierta').val()); + if (elemento == 'cubierta') { + ancho_solapas = 2 * parseFloat($('solapas_ancho').val()); + lomo = parseFloat($('lomo_cubierta').val()); } - else if (elemento == 'sobrecubierta'){ - ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val()); - lomo = parseFloat($('lomo_sobrecubierta').val()); + else if (elemento == 'sobrecubierta') { + ancho_solapas = 2 * parseFloat($('solapas_ancho_sobrecubierta').val()); + lomo = parseFloat($('lomo_sobrecubierta').val()); } - else + else return false; - if (ancho_libro + ancho_solapas + lomo > 630) + if (ancho_libro + ancho_solapas + lomo > 630) return true; - else + else return false } @@ -320,32 +338,32 @@ class DatosLibro { $('#compPaginasNegrohq').trigger('change'); } - + $(document).trigger('update-presupuesto', { - update_lineas : true, - update_servicios : true, + update_lineas: true, + update_servicios: true, update_envios: true, update_resumen: true, update_tiradas_alternativas: true }); - + } } - updateComparador(){ + updateComparador() { - if($("#compPaginasNegro").hasClass('d-none')){ + if ($("#compPaginasNegro").hasClass('d-none')) { $('#compPaginasNegrohq').trigger('change'); } - else{ + else { $('#compPaginasNegro').trigger('change'); } $('#compCarasCubierta').trigger('change'); - - if($('#compSobrecubierta').length){ + + if ($('#compSobrecubierta').length) { $('#compSobrecubierta').trigger('change'); } - if($('#compCarasGuardas').length){ + if ($('#compCarasGuardas').length) { $('#compCarasGuardas').trigger('change'); } } @@ -361,13 +379,13 @@ class DatosLibro { if (url_parts2[url_parts2.length - 2] == 'edit') { $(document).trigger('update-presupuesto', { - update_lineas : true, - update_servicios : false, + update_lineas: true, + update_servicios: false, update_envios: false, update_resumen: false, update_tiradas_alternativas: false }); - + $(document).trigger('ckeck-lineas-envios'); } }