Merge branch 'main' into 'mod/presupuesto_admin'

Main

See merge request jjimenez/safekat!456
This commit is contained in:
2024-12-27 09:49:48 +00:00
12 changed files with 195 additions and 78 deletions

View File

@ -74,6 +74,8 @@ class DatosGenerales {
this.rl_retractilado = $("#rl_retractilado");
this.rl_retractilado5 = $("#rl_retractilado5");
this.cargando = false;
this.initValidation();
}
@ -534,6 +536,8 @@ class DatosGenerales {
cargarDatos(datos) {
this.cargando = true;
this.titulo.val(datos.titulo);
this.autor.val(datos.autor);
this.isbn.val(datos.isbn);
@ -600,6 +604,8 @@ class DatosGenerales {
this.retractilado5.prop('checked', datos.retractilado5);
this.ivaReducido.val(datos.ivaReducido ? 1 : 0).trigger('change');
this.cargando = false;
}
getCliente() {
@ -736,8 +742,6 @@ class DatosGenerales {
this.checkPaginasMultiplo4();
// Para recalcular el presupuesto
$('#divGramajeInterior').empty();
$('#divGramajeInteriorColor').empty();
element.trigger('change');
}
@ -782,6 +786,7 @@ class DatosGenerales {
this.formValidation.revalidateField('paginas');
// Se configura dependiento si hay color o no
const lastLayoutColor = $('#negroEstandar').hasClass('d-none');
if (paginasColor == 0) {
this.#handleInteriorLayout('negro');
@ -789,6 +794,13 @@ class DatosGenerales {
this.divPosPaginasColor.addClass('d-none');
this.posPaginasColor.val("");
this.pagColorConsecutivas.prop('checked', false);
if(lastLayoutColor && !this.cargando){
$('#divPapelInterior').empty();
$('#divGramajeInterior').empty();
$('#negroEstandar').trigger('click');
}
}
else {
if (this.papelDiferente.is(":checked"))
@ -797,8 +809,17 @@ class DatosGenerales {
this.#handleInteriorLayout('color');
this.divPaginasColorConsecutivas.removeClass('d-none');
this.divPosPaginasColor.removeClass('d-none');
if(!lastLayoutColor && !this.cargando){
$('#divPapelInterior').empty();
$('#divGramajeInterior').empty();
$('#colorEstandar').trigger('click');
}
}
$('.calcular-lomo').trigger('change');
this.checkPaginasMultiplo4();
}

View File

@ -105,8 +105,6 @@ class DisenioInterior {
}
updatePapeles(papeles = null) {
const context = this;
@ -1034,6 +1032,7 @@ class DisenioInterior {
const gramaje = element[0].id;
this.presupuestoCliente.calcularSolapas(event);
this.presupuestoCliente.checkLomoInterior(event);
this.presupuestoCliente.checkForm(event);
});

View File

@ -113,6 +113,7 @@ class PresupuestoCliente {
$(".calcular-presupuesto").on('change', this.checkForm.bind(this));
$(".calcular-solapas").on('change', this.calcularSolapas.bind(this));
$(".calcular-lomo").on('change', this.checkLomoInterior.bind(this));
}
@ -180,6 +181,31 @@ class PresupuestoCliente {
}
}
checkLomoInterior() {
/* Limites lomo */
this.#getDatos(false, true);
if (Object.values(this.datos).every(this.#isValidDataForm)) {
new Ajax('/presupuestocliente/checklomo',
this.datos,
{},
(response) => {
if (response === null || response === undefined || response === "") {
console.log("Error en el calculo del lomo interior.");
return;
}
if(response.errors.status == 1){
popErrorAlert('' + response.errors.value, "sk-alert", false);
}
else{
popAlert2Hide('sk-alert');
}
},
() => { }
).post();
}
}
checkForm(event) {
this.#processResumenLateral();
@ -526,9 +552,6 @@ class PresupuestoCliente {
}
}
popAlert2Hide();
if (response.tiradas && response.tiradas.length) {
let tiradas = { ...response.tiradas };
@ -536,6 +559,8 @@ class PresupuestoCliente {
tiradas.sort((a, b) => a - b);
this.divTiradasPrecios.empty();
popAlert2Hide();
for (let i = 0; i < tiradas.length; i++) {
new tarjetaTiradasPrecio(
this.divTiradasPrecios,
@ -550,7 +575,7 @@ class PresupuestoCliente {
}
}
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
setTimeout(() => {