cargando presupuesto datos generales

This commit is contained in:
2024-10-18 14:33:27 +02:00
parent 8a044d41fe
commit 464e136025
17 changed files with 12250 additions and 469 deletions

View File

@ -212,7 +212,7 @@ class DatosGenerales {
// Get the selected options
const value = $("#paginasColor").val();
if (value.length >= 0 && Number.isInteger(parseInt(value)) && parseInt(value) >= 0) {
if (parseInt(value) % 2 != 0) {
return {
valid: false,
@ -227,14 +227,14 @@ class DatosGenerales {
}
},
paginasNegro: {
validators: {
callback: {
validators: {
callback: {
message: window.translations["validation"].integer_greatherThan_0,
callback: function (input) {
// Get the selected options
const value = $("#paginasNegro").val();
if (value.length >= 0 && Number.isInteger(parseInt(value)) && parseInt(value) >= 0) {
if (parseInt(value) % 2 != 0) {
return {
valid: false,
@ -353,11 +353,28 @@ class DatosGenerales {
this.tirada3.val(parseInt(datos.tirada3));
if (datos.tirada4)
this.tirada4.val(parseInt(datos.tirada4));
if (datos.checkFormatoPersonalizado) {
this.checkFormatoPersonalizado.prop(':checked', datos.checkFormatoPersonalizado);
this.checkFormatoPersonalizado.trigger('change');
this.papel_formato_alto.val(datos.papelFormatoAlto);
this.papel_formato_ancho.val(datos.papelFormatoAncho);
}
else {
this.formatoLibro.setOption(datos.papelFormatoId, datos.papelFormatoNombre);
this.formatoLibro.setVal(datos.papelFormatoId);
}
this.cliente.setOption(datos.clienteId, datos.clienteNombre);
this.cliente.setVal(datos.clienteId);
$(this.cliente).trigger('change');
this.paginas.val(parseInt(datos.paginas));
this.paginasNegro.val(parseInt(datos.paginasNegro));
this.paginasColor.val(parseInt(datos.paginasColor));
this.paginasColor.trigger('change');
this.posPaginasColor.val(datos.posPaginasColor);
/*
@ -423,9 +440,9 @@ class DatosGenerales {
return tiradas;
}
getIsColor() {
if(this.paginasColor.val() > 0) {
if (this.paginasColor.val() > 0) {
return true;
}
return false;
@ -464,11 +481,11 @@ class DatosGenerales {
if (this.fresado.hasClass('selected') || this.cosido.hasClass('selected')) {
$('#tapaDuraLomoRedondo').removeClass('d-none');
if(this.cosido.hasClass('selected')){
if (this.cosido.hasClass('selected')) {
$('#tapaDuraLomoRedondo').addClass('selected');
this.divPaginasCuaderillo.removeClass('d-none');
}
else{
else {
this.divPaginasCuaderillo.addClass('d-none');
}
}
@ -558,7 +575,7 @@ class DatosGenerales {
$(".papel-interior").removeClass('selected');
$(".interior-color").removeClass('d-none');
this.#handleInteriorLayout('mixto');
}
else {
$(".interior-color").addClass('d-none');

View File

@ -212,12 +212,12 @@ class Direcciones {
if (unidades == null || unidades <= 0 || unidades == undefined)
return;
$('#loader').show();
$('#loader').modal('show');
let peticion = new Ajax('/misdirecciones/get/' + id, {}, {},
(response) => {
if (this.direcciones.length == 0) {
$('#loader').hide();
$('#loader').modal('hide');
if (entregaPalets) {
this.calcularPresupuesto = true;
}
@ -237,13 +237,13 @@ class Direcciones {
},
() => {
console.error('Error getting address');
$('#loader').hide();
$('#loader').modal('hide');
});
peticion.get();
} catch (e) {
console.error(e);
$('#loader').hide();
$('#loader').modal('hide');
}
}

View File

@ -39,7 +39,7 @@ class PresupuestoCliente {
this.ajax_calcular = new Ajax('/presupuestocliente/calcular',
{}, this.datos,
this.#procesarPresupuesto.bind(this),
() => { $('#loader').hide(); });
() => { $('#loader').modal('hide'); });
this.actualizarTiradasEnvio = false;
}
@ -66,12 +66,10 @@ class PresupuestoCliente {
this.btnPrev.on('click', this.#prevtStep.bind(this));
this.btnSave.on('click', this.#savePresupuesto.bind(this));
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
//this.RELLENAR_PRESUPUESTO(true);
if (window.location.href.includes("edit")) {
$(".calcular-presupuesto").off('change');
$(".calcular-presupuesto").on('change', ()=>{});
this.#cargarPresupuesto();
const successMessage = sessionStorage.getItem('message');
if (successMessage) {
@ -79,6 +77,10 @@ class PresupuestoCliente {
sessionStorage.removeItem('message');
}
}
else{
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
}
}
@ -87,7 +89,7 @@ class PresupuestoCliente {
if (event.target.id === 'divDirecciones') {
if (!this.direcciones.calcularPresupuesto) {
this.actualizarTiradasEnvio = false;
$('#loader').hide();
$('#loader').modal('hide');
return;
}
@ -108,7 +110,7 @@ class PresupuestoCliente {
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
try {
$('#loader').show();
$('#loader').modal('show');
// Si se está ejecutando la petición, abortar la petición anterior
this.ajax_calcular.abort();
@ -119,7 +121,7 @@ class PresupuestoCliente {
}
catch (e) {
console.log(e);
$('#loader').hide();
$('#loader').modal('hide');
}
}
@ -225,7 +227,7 @@ class PresupuestoCliente {
this.#getDatos(true);
try {
$('#loader').show();
$('#loader').modal('show');
if (window.location.href.includes("edit")) {
this.datos["id"] = window.location.href.split("/").pop();
@ -234,7 +236,7 @@ class PresupuestoCliente {
this.datos,
{},
(response) => {
$('#loader').hide();
$('#loader').modal('hide');
console.log(response);
if (this.datos["confirmar"] || window.location.href.includes("add")) {
sessionStorage.setItem('message', response.message);
@ -244,20 +246,20 @@ class PresupuestoCliente {
popSuccessAlert(response.message);
}
},
() => { $('#loader').hide(); }
() => { $('#loader').modal('hide'); }
).post();
}
catch (e) {
console.log(e);
$('#loader').hide();
$('#loader').modal('hide');
}
}
#procesarPresupuesto(response) {
$('#loader').hide();
$('#loader').modal('hide');
if (Object.values(response.errors).some((value) => value !== "")) {
popErrorAlert("No se ha podido calcular el presupuesto para los datos proporcionados. Por favor, póngase en contacto con el departamento comercial."
@ -336,8 +338,11 @@ class PresupuestoCliente {
tirada: this.datosGenerales.getTiradas(),
paginas: this.datosGenerales.paginas.val(),
paginasColor: this.datosGenerales.paginasColor.val(),
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
posPaginasColor: this.datosGenerales.posPaginasColor.val(),
paginasColorConsecutivas: this.datosGenerales.paginasColorConsecutivas.is(':checked') ? 1 : 0,
papelInteriorDiferente: this.datosGenerales.papelDiferente.is(':checked') ? 1 : 0,
$prototipo: this.datosGenerales.prototipo.is(':checked') ? 1 : 0,
paginasCuadernillo: this.datosGenerales.paginasCuadernillo.val(),
tipo: this.datosGenerales.tiposLibro.filter('.selected').attr('id'),
@ -409,7 +414,7 @@ class PresupuestoCliente {
#cargarPresupuesto() {
$('#loader').show();
$('#loader').modal('show');
let id = window.location.href.split("/").pop()
new Ajax('/presupuestocliente/cargar/' + id,
{},
@ -423,11 +428,11 @@ class PresupuestoCliente {
*/
}
console.log(response);
$('#loader').hide();
$('#loader').modal('hide');
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
},
() => {
$('#loader').hide();
$('#loader').modal('hide');
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
}
).get();

View File

@ -1,7 +1,11 @@
.image-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
margin-bottom: 20px;
position: relative;
display: inline-block;
max-height: 150px;
max-width: 200px;
}
@ -13,19 +17,19 @@
/* Pseudo-elemento que muestra el tick */
.image-container.selected::after {
content: '✔';
/* Símbolo de tick */
content: '✔'; /* Símbolo de tick */
position: absolute;
top: 90px;
right: 25px;
top: calc(50% + 5px);
left: calc(100%/2 + 65px); /* Mueve 75px a la derecha fuera del contenedor */
font-size: 50px;
font-weight: bold;
color: green;
background-color: rgba(255, 255, 255, 0);
background-color: rgba(255, 255, 255, 0); /* Fondo transparente */
border-radius: 100%;
padding: 5px;
}
.image-presupuesto {
transition: transform 1s ease;
}
@ -88,17 +92,28 @@
color: var(--fg);
font: 1em/1.5 sans-serif;
height: 100vh;
position: fixed; /* Fijo para cubrir la pantalla */
left: 50%; /* Centramos horizontalmente */
top: 50%; /* Centramos verticalmente */
transform: translate(-50%, -50%); /* Ajuste para centrar el loader */
width: auto; /* Se ajusta automáticamente */
height: auto; /* Se ajusta automáticamente */
z-index: 9999; /* Mantener por encima de otros elementos */
display: flex; /* Para centrar contenido */
justify-content: center; /* Centrar horizontalmente */
align-items: center; /* Centrar verticalmente */
background-color: rgba(255, 255, 255, 0); /* Fondo completamente transparente */
position: fixed;
/* Fijo para cubrir la pantalla */
left: 50%;
/* Centramos horizontalmente */
top: 50%;
/* Centramos verticalmente */
transform: translate(-50%, -50%);
/* Ajuste para centrar el loader */
width: auto;
/* Se ajusta automáticamente */
height: auto;
/* Se ajusta automáticamente */
z-index: 9999;
/* Mantener por encima de otros elementos */
display: flex;
/* Para centrar contenido */
justify-content: center;
/* Centrar horizontalmente */
align-items: center;
/* Centrar verticalmente */
background-color: rgba(255, 255, 255, 0);
/* Fondo completamente transparente */
}
.book,