From 0da8ae97157ad0b44a902dee503cf0b44808a02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Fri, 22 Dec 2023 13:43:49 +0100 Subject: [PATCH 1/3] falta actualizar linea completa cuando cambia tirada --- ci4/app/Language/en/Presupuestos.php | 1 + .../Language/en/PresupuestosDirecciones.php | 2 +- ci4/app/Language/es/Presupuestos.php | 1 + .../cosidotapablanda/_datosLibroItems.php | 34 ++++++++- .../_lineasPresupuestoItems.php | 75 +++++++++++++++++-- 5 files changed, 104 insertions(+), 9 deletions(-) diff --git a/ci4/app/Language/en/Presupuestos.php b/ci4/app/Language/en/Presupuestos.php index c9acb767..c3115c84 100755 --- a/ci4/app/Language/en/Presupuestos.php +++ b/ci4/app/Language/en/Presupuestos.php @@ -159,6 +159,7 @@ return [ 'errores' => [ 'paginas' => 'The field pages must be greater than zero', + 'paginasLP' => 'The number of pages does not match the total', 'tiradas' => 'The field print must be greater than zero', 'dimension' => 'The book dimension must be greater than 60mm', 'lineaDuplicada' => 'That type of line already exists in the budget.', diff --git a/ci4/app/Language/en/PresupuestosDirecciones.php b/ci4/app/Language/en/PresupuestosDirecciones.php index 6c80ae4e..5ea2abfe 100755 --- a/ci4/app/Language/en/PresupuestosDirecciones.php +++ b/ci4/app/Language/en/PresupuestosDirecciones.php @@ -18,7 +18,7 @@ return [ 'precio' => 'Price', 'saveDirection' => 'Save to client addresses (shipped on pallets)', 'validation' => [ - 'ejemplares_envio' => 'The number of copies sent does not match the print run' + 'ejemplares_envio' => 'The number of copies sent does not match the print run', 'max_length' => 'Max. length ', 'required' => 'Field required', 'valid_email' => 'The email is not valid', diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index ebbf64e3..33332585 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -218,6 +218,7 @@ return [ 'errores' => [ 'paginas' => 'El campo páginas tiene que ser mayor que cero', + 'paginasLP' => 'El número de páginas no coincide con el total', 'tiradas' => 'El campo tiradas tiene que ser mayor que cero', 'dimension' => 'La dimensión del libro tiene que ser mayor que 60mm', 'lineaDuplicada' => 'Ya existe ese tipo de linea en el presupuesto', diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php index d65f2e5b..5fa56170 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosLibroItems.php @@ -95,7 +95,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -273,6 +273,9 @@ section("additionalInlineJs") ?> $('#paginas').on("change", function () { + checkPaginasPresupuesto() + updateLineasPresupuesto() + // Si es negro o color if ($('#tipoImpresion').select2('data')[0].id == 'negro' || $('#tipoImpresion').select2('data')[0].id == 'color') { @@ -292,9 +295,36 @@ $('#paginas').on("change", function () { $('#tirada').on("change", function () { update_servicios(false) + calcular_mermas() + updateLineasPresupuesto() checkInsertar() }) +function calcular_mermas(){ + + const tirada = parseInt($('#tirada').val()) + var merma = 0 + + if(tirada>POD){ + merma = tirada*0.1<=30 ? tirada*0.1 : 30 + } + else{ + merma_lineas = [] + $('#tableLineasPresupuesto tbody tr:visible ').each(function(){ + if(!this.id.includes('_data') && !this.id.endsWith('_cubierta') && !this.id.endsWith('_sobrecubierta')){ + merma_lineas.push(tirada%parseInt($('#' + this.id + '_formas').val())) + } + }) + if(merma_lineas.length>0) + merma = Math.max(...merma_lineas) + else + merma = 0 + } + $('#mermacubierta').val(parseInt(merma)) + $('#merma').val(parseInt(merma)) +} + + $('#papelFormatoId').select2({ allowClear: 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 dde34e34..a9333d0b 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 @@ -51,7 +51,7 @@ - + - + - + - + - + - + + @@ -20,25 +20,25 @@ - +
- +
- +
- +
@@ -46,7 +46,7 @@ -