diff --git a/ci4/app/Language/es/Presupuestos.php b/ci4/app/Language/es/Presupuestos.php index fee02953..b9bcfc34 100755 --- a/ci4/app/Language/es/Presupuestos.php +++ b/ci4/app/Language/es/Presupuestos.php @@ -361,7 +361,7 @@ return [ 'sin_gramaje' => "Seleccione gramaje", 'tipo_cubierta' => 'Seleccione tipo de cubierta', 'opcion_solapas' => 'Seleccione la opción para las solapas', - 'paginas_cosido' => 'El número de páginas para cosido debe ser múltiplo de 4', + 'paginas_multiplo_4' => 'El número de páginas para cosido o grapado debe ser múltiplo de 4', 'paginas_pares' => 'El número de páginas debe ser par', ], diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js index 5cb58bd9..28f5a068 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/datosGenerales.js @@ -330,17 +330,18 @@ class DatosGenerales { divTipoLibro.find('.fv-plugins-message-container').remove(); if ($('.tipo-libro.selected').length > 0) { - if ($('#cosido').hasClass('selected')) { + if ($('#cosido').hasClass('selected') || $('#grapado').hasClass('selected')) { const value = parseInt($("#paginas").val()); if (value % 4 != 0) { divTipoLibro.append(`
`); } + return false; } return true; @@ -583,6 +584,10 @@ class DatosGenerales { this.tiposLibro.removeClass('selected'); this.tiposLibro.find('.image-presupuesto').removeClass('selected'); this.domItem.find('#' + datos.tipo).addClass('selected'); + + if(datos.tipo == 'cosido'){ + this.divPaginasCuaderillo.removeClass('d-none'); + } } this.prototipo.prop('checked', datos.prototipo); @@ -726,6 +731,8 @@ class DatosGenerales { } } + this.checkPaginasMultiplo4(); + // Para recalcular el presupuesto $('#divGramajeInterior').empty(); $('#divGramajeInteriorColor').empty(); @@ -789,6 +796,29 @@ class DatosGenerales { this.divPaginasColorConsecutivas.removeClass('d-none'); this.divPosPaginasColor.removeClass('d-none'); } + + this.checkPaginasMultiplo4(); + } + + checkPaginasMultiplo4(){ + + const divTipoLibro = $('#divTipoLibro'); // Selecciona el div + divTipoLibro.find('.fv-plugins-message-container').remove(); + + if ($('#cosido').hasClass('selected') || $('#grapado').hasClass('selected')) { + const value = parseInt($("#paginas").val()); + if (value % 4 != 0) { + divTipoLibro.append(` + + `); + return false; + } + } + return true; } diff --git a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js index 674176cf..9075122b 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoCliente/presupuestoCliente.js @@ -211,11 +211,19 @@ class PresupuestoCliente { let datos_to_check = this.#prepareData(); if (Object.values(datos_to_check).every(this.#isValidDataForm)) { + try { + if (!this.datosGenerales.checkPaginasMultiplo4()) { + popErrorAlert("Compruebe que todos los campos son correctos."); + return; + } + setTimeout(function () { $('#loader').modal('show'); }, 0); + + // Si se está ejecutando la petición, abortar la petición anterior this.ajax_calcular.abort(); @@ -453,6 +461,12 @@ class PresupuestoCliente { return; } + if ($('.invalid-feedback').length > 0) { + popErrorAlert("Compruebe que todos los campos son correctos."); + $('#loader').modal('hide'); + return; + } + this.#getDatos(true); if (confirmar) {