mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminada validación de cubierta
This commit is contained in:
@ -405,12 +405,24 @@ return [
|
|||||||
'papel_interior_especial' => 'Seleccione el papel especial en el desplegable para el interior',
|
'papel_interior_especial' => 'Seleccione el papel especial en el desplegable para el interior',
|
||||||
'gramaje_interior' => 'Seleccione el gramaje para el interior',
|
'gramaje_interior' => 'Seleccione el gramaje para el interior',
|
||||||
|
|
||||||
|
'tipo_cubierta' => 'Seleccione el tipo de cubierta',
|
||||||
|
'papel_guardas' => 'Seleccione el tipo de papel para las guardas',
|
||||||
|
'gramaje_guardas' => 'Seleccione el gramaje para las guardas',
|
||||||
|
'papel_cubierta' => 'Seleccione el tipo de papel para la cubierta',
|
||||||
|
'papel_cubierta_especial' => 'Seleccione el papel especial en el desplegable para la cubierta',
|
||||||
|
'gramaje_cubierta' => 'Seleccione el gramaje para la cubierta',
|
||||||
|
|
||||||
|
'papel_sobrecubierta' => 'Seleccione el tipo de papel para la sobrecubierta',
|
||||||
|
'gramaje_sobrecubierta' => 'Seleccione el gramaje para la sobrecubierta',
|
||||||
|
'papel_faja' => 'Seleccione el tipo de papel para la faja',
|
||||||
|
'gramaje_faja' => 'Seleccione el gramaje para la faja',
|
||||||
|
|
||||||
'pais' => 'Debe seleccionar un país',
|
'pais' => 'Debe seleccionar un país',
|
||||||
'integer_greatherThan_0' => 'Número entero > 0 requerido',
|
'integer_greatherThan_0' => 'Número entero > 0 requerido',
|
||||||
'greater_than_0' => 'El campo {field} debe ser mayor que 0',
|
'greater_than_0' => 'El campo {field} debe ser mayor que 0',
|
||||||
'tirada_no_valida' => "Tirada no valida",
|
'tirada_no_valida' => "Tirada no valida",
|
||||||
'sin_gramaje' => "Seleccione gramaje",
|
'sin_gramaje' => "Seleccione gramaje",
|
||||||
'tipo_cubierta' => 'Seleccione tipo de cubierta',
|
|
||||||
'opcion_solapas' => 'Seleccione la opción para las solapas',
|
'opcion_solapas' => 'Seleccione la opción para las solapas',
|
||||||
'paginas_multiplo_4' => 'El número total de páginas para <b>cosido</b> y <b>grapado</b> debe ser múltiplo de 4',
|
'paginas_multiplo_4' => 'El número total de páginas para <b>cosido</b> y <b>grapado</b> debe ser múltiplo de 4',
|
||||||
'paginas_pares' => 'El número de páginas debe ser par',
|
'paginas_pares' => 'El número de páginas debe ser par',
|
||||||
|
|||||||
@ -237,7 +237,6 @@ class DisenioCubierta {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.initValidation();
|
|
||||||
|
|
||||||
// Creamos un nuevo observador que detecta cambios en los atributos
|
// Creamos un nuevo observador que detecta cambios en los atributos
|
||||||
this.observer = new MutationObserver(mutations => {
|
this.observer = new MutationObserver(mutations => {
|
||||||
@ -355,7 +354,7 @@ class DisenioCubierta {
|
|||||||
this.sinSolapas.trigger('click');
|
this.sinSolapas.trigger('click');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
this.divPapelCubierta.find(`[cod="${datosCubierta.papel.code}"]`).addClass('selected');
|
this.divPapelCubierta.find(`[cod="${datosCubierta.papel.code}"]`).addClass('selected');
|
||||||
|
|
||||||
@ -385,244 +384,114 @@ class DisenioCubierta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
initValidation() {
|
validate(goToNext = true) {
|
||||||
|
|
||||||
const stepper = this.validatorStepper;
|
let errores = [];
|
||||||
|
|
||||||
this.formValidation = FormValidation.formValidation(this.wizardStep, {
|
let continueCheck = true;
|
||||||
fields: {
|
|
||||||
div_tipo_cubierta: {
|
|
||||||
validators: {
|
|
||||||
callback: {
|
|
||||||
callback: function (input) {
|
|
||||||
const div = $('#divTipoCubierta'); // Selecciona el div
|
|
||||||
|
|
||||||
div.find('.fv-plugins-message-container').remove();
|
// diseño cubierta
|
||||||
if ($('.tipo-cubierta.selected').length > 0) {
|
$('#divTipoCubierta').removeClass('is-invalid');
|
||||||
return true;
|
if ($('.tipo-cubierta.selected').length == 0) {
|
||||||
}
|
$('#divTipoCubierta').addClass('is-invalid');
|
||||||
else {
|
errores.push(window.translations["validation"].tipo_cubierta);
|
||||||
div.append(`
|
continueCheck = false;
|
||||||
<div class="fv-plugins-message-container invalid-feedback">
|
}
|
||||||
<div data-field="div_tipo_cubierta" data-validator="callback" style="margin-top: 50px;">
|
|
||||||
${window.translations["validation"].tipo_cubierta}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
div_solapas_cubierta: {
|
|
||||||
validators: {
|
|
||||||
callback: {
|
|
||||||
callback: function (input) {
|
|
||||||
const div = $('#divSolapasCubierta');
|
|
||||||
if (div.hasClass("d-none")) return true;
|
|
||||||
|
|
||||||
div.find('.fv-plugins-message-container').remove();
|
// solapas cubierta
|
||||||
if ($('.solapas-cubierta.selected').length > 0) {
|
$('#divSolapasCubierta').removeClass('is-invalid');
|
||||||
return true;
|
if (!$('#divSolapasCubierta').hasClass("d-none") && $('.solapas-cubierta.selected').length == 0 && continueCheck) {
|
||||||
}
|
$('#divSolapasCubierta').addClass('is-invalid');
|
||||||
else {
|
errores.push(window.translations["validation"].opcion_solapas);
|
||||||
div.append(`
|
}
|
||||||
<div class="fv-plugins-message-container invalid-feedback">
|
|
||||||
<div data-field="div_solapas_cubierta" data-validator="callback" style="margin-top: 50px;">
|
|
||||||
${window.translations["validation"].opcion_solapas}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
div_papel_cubierta: {
|
|
||||||
validators: {
|
|
||||||
callback: {
|
|
||||||
callback: function (input) {
|
|
||||||
|
|
||||||
$('#divPapelCubierta').find('.fv-plugins-message-container').remove();
|
// opciones tapa dura y lomo redondo
|
||||||
$('#divPapelEspecialCubierta').find('.fv-plugins-message-container').remove();
|
$('#papelGuardas').removeClass('is-invalid');
|
||||||
|
$('#gramajeGuardas').removeClass('is-invalid');
|
||||||
const papelSeleccionado = $('.custom-selector-papel-cubierta input[type="radio"]:checked');
|
if (!$('#divConfigTapaDura').hasClass('d-none') && continueCheck) {
|
||||||
if (papelSeleccionado.length > 0) {
|
if ($('#papelGuardas').select2('data').length == 0) {
|
||||||
return true;
|
$('#papelGuardas').addClass('is-invalid');
|
||||||
|
errores.push(window.translations["validation"].papel_guardas);
|
||||||
}
|
|
||||||
else {
|
|
||||||
$('#divPapelCubierta').append(`
|
|
||||||
<div class="fv-plugins-message-container invalid-feedback">
|
|
||||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
|
||||||
${window.translations["validation"].papel_interior}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
div_papel_especial_cubierta: {
|
|
||||||
validators: {
|
|
||||||
callback: {
|
|
||||||
callback: function (input) {
|
|
||||||
|
|
||||||
$('#divPapelEspecialCubierta').find('.fv-plugins-message-container').remove();
|
|
||||||
if ($('#divPapelEspecialCubierta').hasClass("d-none")) return true;
|
|
||||||
|
|
||||||
if ($('#papelEspecialCubiertaSel').select2('data').length > 0)
|
|
||||||
return true;
|
|
||||||
else {
|
|
||||||
$('#divPapelEspecialCubierta').append(`
|
|
||||||
<div class="fv-plugins-message-container invalid-feedback">
|
|
||||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
|
||||||
${window.translations["validation"].papel_interior}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
div_gramaje_cubierta: {
|
|
||||||
validators: {
|
|
||||||
callback: {
|
|
||||||
callback: function (input) {
|
|
||||||
|
|
||||||
const divGramajeInterior = $('#divGramajeCubierta'); // Selecciona el div
|
|
||||||
divGramajeInterior.find('.fv-plugins-message-container').remove();
|
|
||||||
|
|
||||||
const gramajeSeleccionado = $('.custom-selector-gramaje-cubierta input[type="radio"]:checked');
|
|
||||||
if (gramajeSeleccionado.length > 0) {
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
divGramajeInterior.append(`
|
|
||||||
<div class="fv-plugins-message-container invalid-feedback">
|
|
||||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
|
||||||
${window.translations["validation"].gramaje_interior}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
div_config_tapa_dura: {
|
|
||||||
validators: {
|
|
||||||
callback: {
|
|
||||||
callback: function (input) {
|
|
||||||
|
|
||||||
const div = $('#divConfigTapaDura'); // Selecciona el div
|
|
||||||
div.find('.fv-plugins-message-container').remove();
|
|
||||||
|
|
||||||
if ($('divConfigTapaDura').hasClass('d-none'))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
const papelGuardas = $('#papelGuardas').select2('data').length > 0;
|
|
||||||
const gramajeGuardas = $('#gramajeGuardas').select2('data').length > 0;
|
|
||||||
if (papelGuardas && gramajeGuardas) {
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
div.append(`
|
|
||||||
<div class="fv-plugins-message-container invalid-feedback">
|
|
||||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
|
||||||
${window.translations["validation"].extras_cubierta}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
div_extras: {
|
|
||||||
validators: {
|
|
||||||
callback: {
|
|
||||||
callback: function (input) {
|
|
||||||
|
|
||||||
const div = $('#divExtras'); // Selecciona el div
|
|
||||||
div.find('.fv-plugins-message-container').remove();
|
|
||||||
|
|
||||||
let error = false;
|
|
||||||
|
|
||||||
if ($("#addFaja").prop("checked") == true) {
|
|
||||||
const papelFaja = $('#papelFaja').select2('data').length > 0;
|
|
||||||
const gramajeFaja = $('#gramajeFaja').select2('data').length > 0;
|
|
||||||
if (!papelFaja || !gramajeFaja) {
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($("#addSobrecubierta").prop("checked") == true) {
|
|
||||||
const papelSobrecubierta = $('#papelSobrecubierta').select2('data').length > 0;
|
|
||||||
const gramajeSobrecubierta = $('#gramajeSobrecubierta').select2('data').length > 0;
|
|
||||||
if (!papelSobrecubierta || !gramajeSobrecubierta) {
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
div.append(`
|
|
||||||
<div class="fv-plugins-message-container invalid-feedback">
|
|
||||||
<div data-field="div_impresion_interior" data-validator="callback" style="margin-top: 50px;">
|
|
||||||
${window.translations["validation"].extras_cubierta}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: {
|
|
||||||
trigger: new FormValidation.plugins.Trigger(),
|
|
||||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
|
||||||
// Use this for enabling/changing valid/invalid class
|
|
||||||
// eleInvalidClass: '',
|
|
||||||
eleValidClass: '',
|
|
||||||
rowSelector: function (field, ele) {
|
|
||||||
// field is the field name
|
|
||||||
// ele is the field element
|
|
||||||
switch (field) {
|
|
||||||
case 'div_tipo_cubierta':
|
|
||||||
case 'div_solapas_cubierta':
|
|
||||||
case 'div_papel_cubierta':
|
|
||||||
case 'div_gramaje_cubierta':
|
|
||||||
case 'div_papel_especial_cubierta':
|
|
||||||
case 'div_config_tapa_dura':
|
|
||||||
return '.col-sm-10';
|
|
||||||
case 'div_extras':
|
|
||||||
return '.col-sm-12';
|
|
||||||
default:
|
|
||||||
return '.col-sm-3';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
|
||||||
submitButton: new FormValidation.plugins.SubmitButton()
|
|
||||||
}
|
}
|
||||||
}).on('core.form.valid', () => {
|
if ($('#gramajeGuardas').select2('data').length == 0) {
|
||||||
if (this.allowNext)
|
$('#gramajeGuardas').addClass('is-invalid');
|
||||||
stepper.next();
|
errores.push(window.translations["validation"].gramaje_guardas);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// papel
|
||||||
|
$('#divPapelCubierta').removeClass('is-invalid');
|
||||||
|
if ($('.custom-selector-papel-cubierta input[type="radio"]:checked').length == 0 && continueCheck) {
|
||||||
|
|
||||||
|
$('#divPapelCubierta').addClass('is-invalid');
|
||||||
|
errores.push(window.translations["validation"].papel_cubierta);
|
||||||
|
continueCheck = false;
|
||||||
|
}
|
||||||
|
else if (!$('#divPapelEspecialCubierta').hasClass("d-none")) {
|
||||||
|
if ($('#papelEspecialCubiertaSel').select2('data').length == 0 && continueCheck) {
|
||||||
|
$('#divPapelEspecialCubierta').addClass('is-invalid');
|
||||||
|
errores.push(window.translations["validation"].papel_cubierta_especial);
|
||||||
|
continueCheck = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// gramaje
|
||||||
|
$('#divGramajeCubierta').removeClass('is-invalid');
|
||||||
|
if ($('.custom-selector-gramaje-cubierta input[type="radio"]:checked').length == 0 && continueCheck) {
|
||||||
|
$('#divGramajeCubierta').addClass('is-invalid');
|
||||||
|
errores.push(window.translations["validation"].gramaje_cubierta);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sobrecubierta
|
||||||
|
$('#papelSobrecubierta').removeClass('is-invalid');
|
||||||
|
$('#gramajeSobrecubierta').removeClass('is-invalid');
|
||||||
|
if ($("#addSobrecubierta").prop("checked") == true) {
|
||||||
|
if($('#papelSobrecubierta').select2('data').length == 0){
|
||||||
|
$('#papelSobrecubierta').addClass('is-invalid');
|
||||||
|
errores.push(window.translations["validation"].papel_sobrecubierta);
|
||||||
|
}
|
||||||
|
if($('#gramajeSobrecubierta').select2('data').length == 0){
|
||||||
|
$('#gramajeSobrecubierta').addClass('is-invalid');
|
||||||
|
errores.push(window.translations["validation"].gramaje_sobrecubierta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// faja
|
||||||
|
$('#papelFaja').removeClass('is-invalid');
|
||||||
|
$('#gramajeFaja').removeClass('is-invalid');
|
||||||
|
if ($("#addFaja").prop("checked") == true) {
|
||||||
|
if($('#papelFaja').select2('data').length == 0){
|
||||||
|
$('#papelFaja').addClass('is-invalid');
|
||||||
|
errores.push(window.translations["validation"].papel_faja);
|
||||||
|
}
|
||||||
|
if($('#gramajeFaja').select2('data').length == 0){
|
||||||
|
$('#gramajeFaja').addClass('is-invalid');
|
||||||
|
errores.push(window.translations["validation"].gramaje_faja);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const skAlert = document.getElementById('sk-alert');
|
||||||
|
skAlert.innerHTML = '';
|
||||||
|
const uniqueErrors = [...new Set(errores)];
|
||||||
|
|
||||||
|
if (uniqueErrors.length > 0) {
|
||||||
|
const message = window.translations["validation"].fix_errors +
|
||||||
|
`<ul class="mb-0">
|
||||||
|
${uniqueErrors.map(err => `<li>${err}</li>`).join('')}
|
||||||
|
</ul>`;
|
||||||
|
popErrorAlert(message, 'sk-alert', false);
|
||||||
|
errores = [];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.getElementById('sk-alert').innerHTML = '';
|
||||||
|
errores = [];
|
||||||
|
if (goToNext)
|
||||||
|
this.validatorStepper.next();
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLomoCubierta() {
|
getLomoCubierta() {
|
||||||
@ -903,6 +772,14 @@ class DisenioCubierta {
|
|||||||
// Accede al ID del elemento que disparó el evento
|
// Accede al ID del elemento que disparó el evento
|
||||||
const element = $(event.target);
|
const element = $(event.target);
|
||||||
|
|
||||||
|
this.divPapelCubierta.removeClass('is-invalid');
|
||||||
|
this.divGramajeCubierta.removeClass('is-invalid');
|
||||||
|
|
||||||
|
this.divGramajeCubierta.empty();
|
||||||
|
this.divPapelCubierta.empty();
|
||||||
|
|
||||||
|
this.textoPapelCubierta.addClass('d-none');
|
||||||
|
|
||||||
let class2Find = '.tipo-cubierta';
|
let class2Find = '.tipo-cubierta';
|
||||||
|
|
||||||
let containers = element.closest(class2Find).parent().find(class2Find);
|
let containers = element.closest(class2Find).parent().find(class2Find);
|
||||||
@ -987,23 +864,26 @@ class DisenioCubierta {
|
|||||||
#handleMenuPapel() {
|
#handleMenuPapel() {
|
||||||
|
|
||||||
this.divGramajeCubierta.empty();
|
this.divGramajeCubierta.empty();
|
||||||
const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1;
|
this.divGramajeCubierta.removeClass("is-invalid");
|
||||||
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
|
if ($('.tipo-cubierta.selected').length > 0) {
|
||||||
{
|
const tapa_dura = this.tapaBlanda.hasClass("selected") ? 0 : 1;
|
||||||
[this.csrf_token]: this.csrf_hash,
|
new Ajax('/configuracion/papelesgenericos/getpapelcliente',
|
||||||
tipo: 'colorhq',
|
{
|
||||||
cubierta: 1,
|
[this.csrf_token]: this.csrf_hash,
|
||||||
ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho,
|
tipo: 'colorhq',
|
||||||
alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto,
|
cubierta: 1,
|
||||||
solapas: $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val(),
|
ancho: this.presupuestoCliente.datosGenerales.getDimensionLibro().ancho,
|
||||||
lomo: $('#lc').val(),
|
alto: this.presupuestoCliente.datosGenerales.getDimensionLibro().alto,
|
||||||
tapa_dura: tapa_dura,
|
solapas: $('#solapas_cubierta').hasClass("d-none") ? 0 : $('#solapas_cubierta').val(),
|
||||||
tirada: this.presupuestoCliente.datosGenerales.getTiradas()[0],
|
lomo: $('#lc').val(),
|
||||||
},
|
tapa_dura: tapa_dura,
|
||||||
{},
|
tirada: this.presupuestoCliente.datosGenerales.getTiradas()[0],
|
||||||
(response) => { this.fillPapeles(response); },
|
},
|
||||||
(response) => { console.log(response); }
|
{},
|
||||||
).get();
|
(response) => { this.fillPapeles(response); },
|
||||||
|
(response) => { console.log(response); }
|
||||||
|
).get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -682,6 +682,10 @@ class DisenioInterior {
|
|||||||
// Accede al ID del elemento que disparó el evento
|
// Accede al ID del elemento que disparó el evento
|
||||||
const element = $(event.target);
|
const element = $(event.target);
|
||||||
|
|
||||||
|
$('#divImpresionInterior').removeClass('is-invalid');
|
||||||
|
$('#divPapelInterior').removeClass('is-invalid');
|
||||||
|
$('#divGramajeInterior').removeClass('is-invalid');
|
||||||
|
|
||||||
let class2Find = '.disenio-interior';
|
let class2Find = '.disenio-interior';
|
||||||
if (element[0].closest('.image-container').id.includes('Color')) {
|
if (element[0].closest('.image-container').id.includes('Color')) {
|
||||||
this.divGramajeInteriorColor.empty();
|
this.divGramajeInteriorColor.empty();
|
||||||
@ -692,6 +696,8 @@ class DisenioInterior {
|
|||||||
this.papelInteriorColor = null;
|
this.papelInteriorColor = null;
|
||||||
this.gramajeColor = null;
|
this.gramajeColor = null;
|
||||||
class2Find = '.disenio-interior-color';
|
class2Find = '.disenio-interior-color';
|
||||||
|
this.divPapelInteriorColor.empty();
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.divGramajeInterior.empty();
|
this.divGramajeInterior.empty();
|
||||||
@ -701,6 +707,7 @@ class DisenioInterior {
|
|||||||
$('#papelEspecialInterior').on("change", this.#handlePapelInteriorEspecial.bind(this));
|
$('#papelEspecialInterior').on("change", this.#handlePapelInteriorEspecial.bind(this));
|
||||||
this.papelInterior = null;
|
this.papelInterior = null;
|
||||||
this.gramaje = null;
|
this.gramaje = null;
|
||||||
|
this.divPapelInterior.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
let containers = element.closest(class2Find).parent().find(class2Find);
|
let containers = element.closest(class2Find).parent().find(class2Find);
|
||||||
@ -717,10 +724,12 @@ class DisenioInterior {
|
|||||||
// Para recalcular el presupuesto
|
// Para recalcular el presupuesto
|
||||||
element.trigger('change');
|
element.trigger('change');
|
||||||
|
|
||||||
if (class2Find == '.disenio-interior-color')
|
if ($('.disenio-interior.selected').length != 0) {
|
||||||
this.updatePapeles('color');
|
if (class2Find == '.disenio-interior-color')
|
||||||
else
|
this.updatePapeles('color');
|
||||||
this.updatePapeles();
|
else
|
||||||
|
this.updatePapeles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -728,6 +737,9 @@ class DisenioInterior {
|
|||||||
|
|
||||||
const context = this;
|
const context = this;
|
||||||
|
|
||||||
|
$('#divPapelInterior').removeClass('is-invalid');
|
||||||
|
$('#divGramajeInterior').removeClass('is-invalid');
|
||||||
|
|
||||||
// Accede al ID del elemento que disparó el evento
|
// Accede al ID del elemento que disparó el evento
|
||||||
const element = $(event.target);
|
const element = $(event.target);
|
||||||
const papel = element[0].id.split('_')[1];
|
const papel = element[0].id.split('_')[1];
|
||||||
@ -779,6 +791,9 @@ class DisenioInterior {
|
|||||||
|
|
||||||
const context = this;
|
const context = this;
|
||||||
|
|
||||||
|
$('#divPapelInterior').removeClass('is-invalid');
|
||||||
|
$('#divGramajeInterior').removeClass('is-invalid');
|
||||||
|
|
||||||
this.papelInterior = this.papelEspecial.getVal();
|
this.papelInterior = this.papelEspecial.getVal();
|
||||||
|
|
||||||
let tipo = this.getTipoImpresion();
|
let tipo = this.getTipoImpresion();
|
||||||
@ -806,6 +821,9 @@ class DisenioInterior {
|
|||||||
|
|
||||||
const context = this;
|
const context = this;
|
||||||
|
|
||||||
|
$('#divPapelInterior').removeClass('is-invalid');
|
||||||
|
$('#divGramajeInterior').removeClass('is-invalid');
|
||||||
|
|
||||||
// Accede al ID del elemento que disparó el evento
|
// Accede al ID del elemento que disparó el evento
|
||||||
const element = $(event.target);
|
const element = $(event.target);
|
||||||
const papel = element[0].id.split('_')[1];
|
const papel = element[0].id.split('_')[1];
|
||||||
@ -857,6 +875,9 @@ class DisenioInterior {
|
|||||||
|
|
||||||
const context = this;
|
const context = this;
|
||||||
|
|
||||||
|
$('#divPapelInterior').removeClass('is-invalid');
|
||||||
|
$('#divGramajeInterior').removeClass('is-invalid');
|
||||||
|
|
||||||
this.papelInteriorColor = this.papelEspecialColor.getVal();
|
this.papelInteriorColor = this.papelEspecialColor.getVal();
|
||||||
|
|
||||||
let tipo = this.getTipoImpresionColor();
|
let tipo = this.getTipoImpresionColor();
|
||||||
@ -883,6 +904,7 @@ class DisenioInterior {
|
|||||||
|
|
||||||
fillGramajes(response) {
|
fillGramajes(response) {
|
||||||
|
|
||||||
|
$('#divGramajeInterior').removeClass('is-invalid');
|
||||||
|
|
||||||
this.divGramajeInterior.empty()
|
this.divGramajeInterior.empty()
|
||||||
let showGramaje = false;
|
let showGramaje = false;
|
||||||
@ -945,6 +967,7 @@ class DisenioInterior {
|
|||||||
|
|
||||||
fillGramajesColor(response) {
|
fillGramajesColor(response) {
|
||||||
|
|
||||||
|
$('#divGramajeInterior').removeClass('is-invalid');
|
||||||
|
|
||||||
this.divGramajeInteriorColor.empty()
|
this.divGramajeInteriorColor.empty()
|
||||||
let showGramaje = false;
|
let showGramaje = false;
|
||||||
|
|||||||
@ -130,39 +130,6 @@ class PresupuestoCliente {
|
|||||||
this.disenioCubierta.processMenuLateral();
|
this.disenioCubierta.processMenuLateral();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
#checkTiradas() {
|
|
||||||
|
|
||||||
let tiradas = [parseInt(this.datosGenerales.tirada1.val())];
|
|
||||||
|
|
||||||
if (this.datosGenerales.tirada2.val().length > 0 &&
|
|
||||||
Number.isInteger(parseInt(this.datosGenerales.tirada2.val())) &&
|
|
||||||
parseInt(this.datosGenerales.tirada2.val()) > 0 &&
|
|
||||||
this.datosGenerales.tirada2.val() != "") {
|
|
||||||
|
|
||||||
tiradas.push(parseInt(this.datosGenerales.tirada2.val()));
|
|
||||||
}
|
|
||||||
if (this.datosGenerales.tirada3.val().length > 0 &&
|
|
||||||
Number.isInteger(parseInt(this.datosGenerales.tirada3.val())) &&
|
|
||||||
parseInt(this.datosGenerales.tirada3.val()) > 0 &&
|
|
||||||
this.datosGenerales.tirada3.val() != "") {
|
|
||||||
|
|
||||||
tiradas.push(parseInt(this.datosGenerales.tirada3.val()));
|
|
||||||
}
|
|
||||||
if (this.datosGenerales.tirada4.val().length > 0 &&
|
|
||||||
Number.isInteger(parseInt(this.datosGenerales.tirada4.val())) &&
|
|
||||||
parseInt(this.datosGenerales.tirada4.val()) > 0 &&
|
|
||||||
this.datosGenerales.tirada4.val() != "") {
|
|
||||||
|
|
||||||
tiradas.push(parseInt(this.datosGenerales.tirada4.val()));
|
|
||||||
}
|
|
||||||
|
|
||||||
const noPOD = (tiradas.some(tirada => parseInt(tirada) > 30));
|
|
||||||
const siPOD = (tiradas.some(tirada => parseInt(tirada) <= 30));
|
|
||||||
|
|
||||||
this.datosGenerales.formValidation.validateField('tirada');
|
|
||||||
return !(noPOD && siPOD);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
calcularSolapas() {
|
calcularSolapas() {
|
||||||
|
|
||||||
@ -241,10 +208,6 @@ class PresupuestoCliente {
|
|||||||
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
|
if (Object.values(datos_to_check).every(this.#isValidDataForm)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!this.datosGenerales.checkPaginasMultiplo4()) {
|
|
||||||
popErrorAlert("Compruebe que todos los campos son correctos.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$('#loader').modal('show');
|
$('#loader').modal('show');
|
||||||
@ -334,31 +297,18 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
switch (form) {
|
switch (form) {
|
||||||
case 'datos-generales':
|
case 'datos-generales':
|
||||||
if(this.datosGenerales.validate(false))
|
if (this.datosGenerales.validate(false))
|
||||||
this.#goToForm(nextForm);
|
this.#goToForm(nextForm);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'interior-libro':
|
case 'interior-libro':
|
||||||
if(this.disenioInterior.validate(false))
|
if (this.disenioInterior.validate(false))
|
||||||
this.#goToForm(nextForm);
|
this.#goToForm(nextForm);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cubierta-libro':
|
case 'cubierta-libro':
|
||||||
this.disenioCubierta.allowNext = false;
|
if (this.disenioCubierta.validate(false))
|
||||||
validateForm(this.disenioCubierta.formValidation).then((status) => {
|
|
||||||
if (status !== 'Valid') {
|
|
||||||
this.disenioCubierta.allowNext = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.#goToForm(nextForm);
|
this.#goToForm(nextForm);
|
||||||
this.disenioCubierta.allowNext = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
).catch(error => {
|
|
||||||
this.disenioCubierta.allowNext = true;
|
|
||||||
console.error('Error al validar:', error);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'direcciones-libro':
|
case 'direcciones-libro':
|
||||||
@ -505,12 +455,6 @@ class PresupuestoCliente {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.datosGenerales.checkPaginasMultiplo4()) {
|
|
||||||
popErrorAlert("Compruebe que todos los campos son correctos.");
|
|
||||||
$('#loader').modal('hide');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.#getDatos(true);
|
this.#getDatos(true);
|
||||||
|
|
||||||
if (confirmar) {
|
if (confirmar) {
|
||||||
@ -538,8 +482,13 @@ class PresupuestoCliente {
|
|||||||
if (response.error) {
|
if (response.error) {
|
||||||
popErrorAlert("Presupuesto no válido, corrija los errores antes de guardar.");
|
popErrorAlert("Presupuesto no válido, corrija los errores antes de guardar.");
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
popSuccessAlert(response.message);
|
popSuccessAlert(response.message);
|
||||||
|
$('.is-invalid').removeClass('is-invalid');
|
||||||
|
const skAlert = document.getElementById('sk-alert');
|
||||||
|
skAlert.innerHTML = '';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() => { $('#loader').modal('hide'); }
|
() => { $('#loader').modal('hide'); }
|
||||||
@ -607,6 +556,9 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
|
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
|
||||||
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
|
this.lsc.val(parseFloat(response.info.lomo_sobrecubierta).toFixed(2));
|
||||||
|
$('.is-invalid').removeClass('is-invalid');
|
||||||
|
const skAlert = document.getElementById('sk-alert');
|
||||||
|
skAlert.innerHTML = '';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$(`#containerTiradasEnvios .tirada-envio input[tirada="${this.direcciones.tiradaSeleccionada}"]`).trigger('click');
|
$(`#containerTiradasEnvios .tirada-envio input[tirada="${this.direcciones.tiradaSeleccionada}"]`).trigger('click');
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -630,10 +582,7 @@ class PresupuestoCliente {
|
|||||||
|
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (this.disenioCubierta.acabadoCubierta.getVal() == 0) {
|
this.disenioCubierta.validate();
|
||||||
alertWarningMessage(window.translations.cubiertaSinAcabado, window.translations.cubiertaSinAcabadoText);
|
|
||||||
}
|
|
||||||
this.disenioCubierta.formValidation.validate();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
@ -866,8 +815,8 @@ class PresupuestoCliente {
|
|||||||
$('#menu_resumen_button').trigger('click');
|
$('#menu_resumen_button').trigger('click');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
self.resumen.init_dropzone();
|
self.resumen.init_dropzone();
|
||||||
self.resumen.generate_total(response.data.resumen.base,
|
self.resumen.generate_total(response.data.resumen.base,
|
||||||
response.data.resumen.precio_unidad,
|
response.data.resumen.precio_unidad,
|
||||||
response.data.resumen.total_envio,
|
response.data.resumen.total_envio,
|
||||||
response.data.datosGenerales.ivaReducido);
|
response.data.datosGenerales.ivaReducido);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user