From 31f7f924488f974a25ab6b06b91cb417c21aba5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Fri, 31 Jan 2025 10:14:47 +0100 Subject: [PATCH] trabajando en eventos de lineas --- ci4/app/Language/es/Presupuestos.php | 4 +- .../presupuestos/admin/_datosLibroItems.php | 41 ++++ .../admin/_datosPresupuestoClienteItems.php | 212 +++++++++++++--- .../admin/_resumenPresupuestoItems.php | 2 +- .../presupuestoAdmin/presupuestoAdminAdd.js | 1 + .../presupuestoAdmin/presupuestoAdminEdit.js | 83 ++++--- .../presupuestoAdmin/sections/comparador.js | 230 +++++++++++++++++- .../presupuestoAdmin/sections/datosLibro.js | 42 ++-- .../sections/lineasPresupuesto.js | 112 +++++++-- .../sections/tiradasAlternativas.js | 2 +- 10 files changed, 603 insertions(+), 126 deletions(-) diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index 18e5f56b..4a8f06c5 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -166,6 +166,7 @@ return [ 'solapasSobrecubierta' => 'Solapas sobrecub.', 'solapasAnchoCubierta' => 'Ancho solapas cub.', 'solapasAnchoSobrecubierta' => 'Ancho solapas sobrecub.', + 'sinImpresion' => 'Sin impresion', 'unaCara' => '1 cara', 'dosCaras' => '2 caras', @@ -387,7 +388,8 @@ return [ 'noInterior' => 'No se hay resultados para el interior', 'noCubiertaSobrecubierta' => 'No se hay resultados para cubierta/sobrecubierta', 'errorPresupuesto' => 'Se ha producido un error al calcular el presupuesto. Póngase en contacto con el administrador', - 'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa' + 'error_sobrecubierta_sin_solapas' => 'Debe seleccionar "sobrecubierta" en los datos del libro para introducir el ancho de solapa', + 'error_faja_sin_solapas' => 'Debe seleccionar "faja" en los datos del libro para introducir el ancho de solapa' ], ]; 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 d2149259..c8172bbe 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosLibroItems.php @@ -162,6 +162,47 @@ + +
+ +
+
+
+
+ + +
+
+
+ +
+
+ + +
+ Entre 50 y 120 mm +
+
+
+
+
+ + +
+ Entre 60 y 120 mm +
+
+
+ +
+
diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php index eb45cbe1..b8ad40ff 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosPresupuestoClienteItems.php @@ -222,46 +222,46 @@ -
-
+
+
-
- - -
-
- - -
+
+ + +
+
+ + +

@@ -345,13 +345,49 @@ class="form-control select2bs2 comp_guardas_items" style="width: 100%;">
- +

+
+
+

+ +

+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
@@ -799,6 +835,102 @@
+
+
+

+ +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + : + + 0.00
+ +
+ +
+ +
+
+
+
+ diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php index 1ecd5e1f..4eb6c8a2 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_resumenPresupuestoItems.php @@ -82,7 +82,7 @@ estado_id == 2): ?>
-
' + + '' + + '' + } + if (d.maquinaTipo == 'inkjet') { value += '' + @@ -1389,6 +1405,22 @@ class LineasPresupuesto { const self = this; const dimension = this.getDimensionLibro(); + if (linea == 'lp_faja') { + if (Object.keys(input_data).length == 0) { + let altoSelected = parseInt($('#' + linea + '_altoFaja').val()); + if(altoSelected == 0 || isNaN(altoSelected) || altoSelected == '' || altoSelected < 50){ + altoSelected = 50; + } + else if(altoSelected > dimension.alto){ + altoSelected = dimension.alto; + } + dimension.alto = altoSelected; + } + else{ + dimension.alto = parseInt($('#faja_alto').val()); + } + } + const dataFromComparador = fromComparador; if (Object.keys(input_data).length == 0) { @@ -1406,7 +1438,7 @@ class LineasPresupuesto { if (linea == 'lp_cubierta') { input_data.paginas = parseInt($('#lp_cubierta_paginas option:selected').val()); } - else if (linea == 'lp_sobrecubierta') { + else if (linea == 'lp_sobrecubierta' || linea == 'lp_faja') { input_data.paginas = 4; } else if (linea == 'lp_guardas') { @@ -1433,6 +1465,7 @@ class LineasPresupuesto { uso = 'cubierta'; break; case 'lp_sobrecubierta': + case 'lp_faja': uso = 'sobrecubierta'; break; case 'lp_guardas': @@ -1453,7 +1486,6 @@ class LineasPresupuesto { hq = 0; } - var datos = { tipo_impresion_id: $('#tipo_impresion_id').val(), type: uso, @@ -1496,6 +1528,11 @@ class LineasPresupuesto { datos.solapas_ancho = $('#solapas_sobrecubierta').is(':checked') ? parseInt($('#solapas_ancho_sobrecubierta').val()) : 0; datos.lomo = $('#lomo_sobrecubierta').val(); } + else if (linea == 'lp_faja') { + datos.solapas = 1; + datos.solapas_ancho = parseInt($('#faja_solapas_ancho').val()); + datos.lomo = $('#lomo_sobrecubierta').val(); + } else if (linea == 'lp_guardas') { datos.paginas_impresion = input_data.paginas_impresion; } @@ -1503,7 +1540,7 @@ class LineasPresupuesto { // Si es inkjet, existe este check if ($('#' + linea + '_aFavorFibra').length) { - datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') ? 1: 0; + datos.a_favor_fibra = $('#' + linea + '_aFavorFibra').prop('checked') ? 1 : 0; } if (updatedTipologias && $('#' + linea + '_gotaNegro').length) { @@ -1549,6 +1586,9 @@ class LineasPresupuesto { response.lineas[$i].fields.check_papel_total = 1; response.lineas[$i].fields.check_impresion_total = 1; } + if (linea == 'lp_faja') { + response.lineas[$i].fields.alto_faja = dimension.alto; + } self.rellenarDatosLinea(linea, response.lineas[$i].fields); return true; @@ -1583,7 +1623,7 @@ class LineasPresupuesto { papel_impresion_id: row.papelImpresionId, maquina_id: row.maquinaId, } - if(linea.includes('guardas')) { + if (linea.includes('guardas')) { input_data.paginas_impresion = parseInt($('#compCarasGuardas').select2('data')[0].id); } this.obtenerLinea(linea, fromComparator, false, input_data) @@ -1602,7 +1642,13 @@ class LineasPresupuesto { this.table.row.add(data).draw() currentRow = this.table.row('#' + linea); } - currentRow.child(this.formatRow(currentRow.data())).show(); + + let datosLinea = currentRow.data(); + if(linea == 'lp_faja') { + datosLinea.alto_faja = row.alto_faja; + } + + currentRow.child(this.formatRow(datosLinea)).show(); this.#addEventosLineas(linea, data.maquinaTipo == 'inkjet' ? true : false); @@ -1615,16 +1661,16 @@ class LineasPresupuesto { */ $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : true, + update_lineas: false, + update_servicios: true, update_envios: true, update_resumen: true, update_tiradas_alternativas: true }); - + // Si existe cubierta, hay que actualizar con el valor del lomo - if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && this.table.row('#lp_cubierta').length > 0) { + if (linea != 'lp_cubierta' && linea != 'lp_sobrecubierta' && linea != 'lp_faja' && this.table.row('#lp_cubierta').length > 0) { this.obtenerLinea('lp_cubierta', false, false); } if (mostrar_calculos) { @@ -1666,6 +1712,7 @@ class LineasPresupuesto { uso = 'cubierta'; break; case 'lp_sobrecubierta': + case 'lp_faja': uso = 'sobrecubierta'; break; case 'lp_guardas': @@ -1765,6 +1812,12 @@ class LineasPresupuesto { $('#' + tipoLinea + '_defecto').on("click", () => { this.lp_por_defecto(tipoLinea); }); $('#' + tipoLinea + '_aFavorFibra').on("change", () => { this.change_aFavorFibra(tipoLinea); }); } + + if(tipoLinea == 'lp_faja') { + $('#' + tipoLinea + '_altoFaja').on("change", function (event) { + self.obtenerLinea(tipoLinea, false, false, {}, event); // Pasamos explícitamente 'tipoLinea' + }.bind(this)); + } } @@ -1922,19 +1975,36 @@ class LineasPresupuesto { } } self.table.draw(); - + var rows = $("#tableCompGuardas").DataTable().rows('.selected').data().toArray(); for (const row of rows) { this.rellenarDatosLinea('lp_guardas', row, true); } - + $(document).trigger('add-servicio-lineas', 'plegado_guardas'); } + else if (e.target.id.includes("Faja")) { + + for (let i = self.table.rows().data().length - 1; i >= 0; i--) { + let row = self.table.row(i).data(); // Obtener datos de la fila actual + + if (row.row_id.includes('lp_faja')) { + self.table.row(i).remove(); // Eliminar fila + } + } + self.table.draw(); + + var rows = $("#tableCompFaja").DataTable().rows('.selected').data().toArray(); + for (const row of rows) { + this.rellenarDatosLinea('lp_faja', row, true); + } + } + $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : true, + update_lineas: false, + update_servicios: true, update_envios: true, update_resumen: true, update_tiradas_alternativas: true diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js index 897566d1..f2c327ce 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/tiradasAlternativas.js @@ -147,7 +147,7 @@ class TiradasAlernativas { const self = this; const id = window.location.href.split('/').pop(); - const tirada = tiradaExterna === null ? parseInt(this.tirada.val()) : tiradaExterna; + const tirada = tiradaExterna === null || isNaN(tiradaExterna) ? parseInt(this.tirada.val()) : tiradaExterna; const tirada_ejemplo = parseInt($('#tirada').val()); const POD = parseInt($('#POD').val());