mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
reparados bugs
This commit is contained in:
@ -13,8 +13,7 @@
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
const clientePresupuestoWizard = document.querySelector('#wizard-presupuesto-cliente');
|
||||
if (typeof clientePresupuestoWizard !== undefined && clientePresupuestoWizard !== null &&
|
||||
clientePresupuestoWizard.querySelector('#presupuesto-cliente-form').querySelector('#tipo-libro') !== null ) {
|
||||
if (typeof clientePresupuestoWizard !== undefined && clientePresupuestoWizard !== null ) {
|
||||
// Wizard form
|
||||
const clientePresupuestoWizardForm = clientePresupuestoWizard.querySelector('#presupuesto-cliente-form');
|
||||
// Wizard steps
|
||||
@ -26,235 +25,241 @@
|
||||
const clientePresupuestoWizardNext = [].slice.call(clientePresupuestoWizardForm.querySelectorAll('.btn-next'));
|
||||
const clientePresupuestoWizardPrev = [].slice.call(clientePresupuestoWizardForm.querySelectorAll('.btn-prev'));
|
||||
|
||||
let FormValidation2;
|
||||
let FormValidation3;
|
||||
let FormValidation4;
|
||||
let FormValidation5;
|
||||
|
||||
let validationStepper = new Stepper(clientePresupuestoWizard, {
|
||||
linear: true
|
||||
});
|
||||
|
||||
// select2 (clienteId)
|
||||
const clienteId = $('#clienteId');
|
||||
if(clientePresupuestoWizardFormStep2 != null) {
|
||||
// select2 (clienteId)
|
||||
const clienteId = $('#clienteId');
|
||||
|
||||
clienteId.on('change.select2', function () {
|
||||
// Revalidate the clienteId field when an option is chosen
|
||||
FormValidation2.revalidateField('clienteId');
|
||||
});
|
||||
clienteId.on('change.select2', function () {
|
||||
// Revalidate the clienteId field when an option is chosen
|
||||
FormValidation2.revalidateField('clienteId');
|
||||
});
|
||||
|
||||
// Deal Details
|
||||
const FormValidation2 = FormValidation.formValidation(clientePresupuestoWizardFormStep2, {
|
||||
fields: {
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-sm-3'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
// Jump to the next step when all fields in the current step are valid
|
||||
validationStepper.next();
|
||||
});
|
||||
|
||||
|
||||
// Deal Usage
|
||||
const FormValidation3 = FormValidation.formValidation(clientePresupuestoWizardFormStep3, {
|
||||
fields: {
|
||||
titulo: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: window.Presupuestos.validation.requerido_short
|
||||
},
|
||||
}
|
||||
// Deal Details
|
||||
FormValidation2 = FormValidation.formValidation(clientePresupuestoWizardFormStep2, {
|
||||
fields: {
|
||||
},
|
||||
clienteId: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.cliente,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const options = $("#clienteId").select2('data');
|
||||
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
||||
return options !== null && options.length > 0 && hasValidOption;
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-sm-3'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
// Jump to the next step when all fields in the current step are valid
|
||||
validationStepper.next();
|
||||
});
|
||||
|
||||
|
||||
// Deal Usage
|
||||
FormValidation3 = FormValidation.formValidation(clientePresupuestoWizardFormStep3, {
|
||||
fields: {
|
||||
titulo: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: window.Presupuestos.validation.requerido_short
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
tirada: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
},
|
||||
clienteId: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.cliente,
|
||||
callback: function (input) {
|
||||
// Get the selected options
|
||||
const options = $("#clienteId").select2('data');
|
||||
const hasValidOption = options.some(option => parseInt(option.id) > 0);
|
||||
return options !== null && options.length > 0 && hasValidOption;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
paginas: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#paginas").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginasColor: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
if ($('#pagColorDiv').is(':hidden'))
|
||||
return true;
|
||||
else {
|
||||
const value = $("#paginasColor").val();
|
||||
},
|
||||
tirada: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
gramajeInterior: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeInterior option:selected').text().length == 0) {
|
||||
if(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0){
|
||||
return {
|
||||
valid: false,
|
||||
message: window.Presupuestos.validation.sin_gramaje,
|
||||
},
|
||||
paginas: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
const value = $("#paginas").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
paginasColor: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.integer_greatherThan_0,
|
||||
callback: function (input) {
|
||||
if ($('#pagColorDiv').is(':hidden'))
|
||||
return true;
|
||||
else {
|
||||
const value = $("#paginasColor").val();
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
gramajeInterior: {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeInterior option:selected').text().length == 0) {
|
||||
if(value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0){
|
||||
return {
|
||||
valid: false,
|
||||
message: window.Presupuestos.validation.sin_gramaje,
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0,
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid: value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0,
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
return true;
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
gramajeCubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeCubierta option:selected').text().length == 0) {
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
gramajeCubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeCubierta option:selected').text().length == 0) {
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.sin_gramaje,
|
||||
callback: function (input) {
|
||||
if ($('#gramajeCubierta option:selected').text().length == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
},
|
||||
},
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.sin_gramaje,
|
||||
callback: function (input) {
|
||||
if ($('#gramajeCubierta option:selected').text().length == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
gramajeSobrecubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeSobrecubierta option:selected').text().length == 0) {
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
gramajeSobrecubierta: {
|
||||
validators: {
|
||||
callback: {
|
||||
message: window.Presupuestos.validation.tirada_no_valida,
|
||||
callback: function (input) {
|
||||
const value = $("#tirada").val();
|
||||
if ($('#gramajeSobrecubierta option:selected').text().length == 0) {
|
||||
return value.length > 0 && Number.isInteger(parseInt(value)) && parseInt(value) > 0;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
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 'gramajeInterior':
|
||||
case 'gramajeCubierta':
|
||||
case 'gramajeSobrecubierta':
|
||||
return '.col-sm-2';
|
||||
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 'gramajeInterior':
|
||||
case 'gramajeCubierta':
|
||||
case 'gramajeSobrecubierta':
|
||||
return '.col-sm-2';
|
||||
|
||||
case 'titulo':
|
||||
return '.col-sm-12';
|
||||
case 'titulo':
|
||||
return '.col-sm-12';
|
||||
|
||||
case 'clienteId':
|
||||
return '.col-sm-6';
|
||||
case 'clienteId':
|
||||
return '.col-sm-6';
|
||||
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
default:
|
||||
return '.col-sm-3';
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
validationStepper.next();
|
||||
initDirecciones();
|
||||
initTiradasDirecciones();
|
||||
});
|
||||
|
||||
const tirada = $('#tirada');
|
||||
tirada.on('change', function () {
|
||||
// Revalidate the clienteId field when an option is chosen
|
||||
FormValidation2.revalidateField('gramajeInterior');
|
||||
FormValidation2.revalidateField('gramajeCubierta');
|
||||
FormValidation2.revalidateField('gramajeSobrecubierta');
|
||||
});
|
||||
|
||||
// Direcciones
|
||||
const FormValidation4 = FormValidation.formValidation(clientePresupuestoWizardFormStep4, {
|
||||
fields: {
|
||||
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-md-12'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
if(validarEnvio()){
|
||||
generarResumen();
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
validationStepper.next();
|
||||
}
|
||||
else{
|
||||
let text = "El número de unidades enviadas no coincie con la tirada seleccionada.";
|
||||
if($('#prototipo').is(':checked')) {
|
||||
text += "<br>(Tenga en cuenta que se ha seleccionado la opción de prototipo)";
|
||||
}
|
||||
$('#errorDirecciones').text(text);
|
||||
$('#errorDirecciones').show();
|
||||
}
|
||||
});
|
||||
initDirecciones();
|
||||
initTiradasDirecciones();
|
||||
});
|
||||
|
||||
const tirada = $('#tirada');
|
||||
tirada.on('change', function () {
|
||||
// Revalidate the clienteId field when an option is chosen
|
||||
FormValidation2.revalidateField('gramajeInterior');
|
||||
FormValidation2.revalidateField('gramajeCubierta');
|
||||
FormValidation2.revalidateField('gramajeSobrecubierta');
|
||||
});
|
||||
|
||||
// Direcciones
|
||||
FormValidation4 = FormValidation.formValidation(clientePresupuestoWizardFormStep4, {
|
||||
fields: {
|
||||
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||
// Use this for enabling/changing valid/invalid class
|
||||
// eleInvalidClass: '',
|
||||
eleValidClass: '',
|
||||
rowSelector: '.col-md-12'
|
||||
}),
|
||||
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||
submitButton: new FormValidation.plugins.SubmitButton()
|
||||
}
|
||||
}).on('core.form.valid', function () {
|
||||
if(validarEnvio()){
|
||||
generarResumen();
|
||||
validationStepper.next();
|
||||
}
|
||||
else{
|
||||
let text = "El número de unidades enviadas no coincie con la tirada seleccionada.";
|
||||
if($('#prototipo').is(':checked')) {
|
||||
text += "<br>(Tenga en cuenta que se ha seleccionado la opción de prototipo)";
|
||||
}
|
||||
$('#errorDirecciones').text(text);
|
||||
$('#errorDirecciones').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Deal Usage
|
||||
const FormValidation5 = FormValidation.formValidation(clientePresupuestoWizardFormStep5, {
|
||||
FormValidation5 = FormValidation.formValidation(clientePresupuestoWizardFormStep5, {
|
||||
fields: {
|
||||
// * Validate the fields here based on your requirements
|
||||
},
|
||||
|
||||
2536
xdebug.log
2536
xdebug.log
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user