mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
corregidos varios fallos en el importador. Añadidos avisos de error y success al importar
This commit is contained in:
@ -70,7 +70,7 @@ class Importador {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
this.openBtn = $('#openOld');
|
||||
this.initImport = $('#initImport');
|
||||
this.makeImport = $('#makeImport');
|
||||
@ -83,7 +83,7 @@ class Importador {
|
||||
$(document).on('select2:open', () => {
|
||||
document.querySelector('.select2-search__field').focus();
|
||||
});
|
||||
|
||||
|
||||
this.cliente.init();
|
||||
this.presupuesto.init();
|
||||
this.encuadernacion.init();
|
||||
@ -126,7 +126,7 @@ class Importador {
|
||||
this.makeImport.on('click', this.importPresupuesto.bind(this));
|
||||
}
|
||||
|
||||
importPresupuesto(){
|
||||
importPresupuesto() {
|
||||
|
||||
if ($("#clienteId").val() != '' && $("#presupuesto").val() != '') {
|
||||
let data = this.collectData();
|
||||
@ -137,11 +137,45 @@ class Importador {
|
||||
(response) => {
|
||||
if (response.success) {
|
||||
const urlObj = new URL(window.location.href);
|
||||
window.open(`${urlObj.origin}` + '/presupuestoadmin/edit/' + response.id);
|
||||
Swal.fire({
|
||||
title: 'Atención!',
|
||||
text: 'Esto es una importación básica, por favor revisa los datos para comprobar que no hay errores. ' +
|
||||
'Tenga en cuenta que no todos los servicios se pueden importar.',
|
||||
icon: 'warning',
|
||||
showCancelButton: false,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then(() => {
|
||||
window.open(`${urlObj.origin}` + '/presupuestoadmin/edit/' + response.id);
|
||||
});
|
||||
}
|
||||
else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No ha sido posible importar el presupuesto. Póngase en contacto con el administrador.',
|
||||
icon: 'error',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.error(error);
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'Ha habido un error al intentar importar el presupuesto. Asegúrese de que están todos los campos rellenos.',
|
||||
icon: 'error',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
}
|
||||
).post();
|
||||
}
|
||||
@ -154,11 +188,11 @@ class Importador {
|
||||
|
||||
data.id = $("#presupuesto").val();
|
||||
data.cliente_id = $("#clienteId").val();
|
||||
|
||||
|
||||
data.paginas = $('#paginas').val();
|
||||
data.tirada = $('#tirada').val();
|
||||
data.papel_formato_id = $('#tamanio').val();
|
||||
data.papel_formato_personalizado = $('#papelFormatoPersonalizado').prop('checked')?1:0;
|
||||
data.papel_formato_personalizado = $('#papelFormatoPersonalizado').prop('checked') ? 1 : 0;
|
||||
data.papel_formato_ancho = $('#papelFormatoAncho').val();
|
||||
data.papel_formato_alto = $('#papelFormatoAlto').val();
|
||||
|
||||
@ -166,9 +200,9 @@ class Importador {
|
||||
data.isHq = $('#hq').val();
|
||||
|
||||
data.paginas_bn = $('#compPaginasNegro').val();
|
||||
data.papel_bn = this.compPapelNegroSelected.getVal();
|
||||
data.papel_bn = this.compPapelNegroSelected.getVal();
|
||||
data.gramaje_bn = $('#compGramajeNegro').val();
|
||||
|
||||
|
||||
data.paginas_color = $('#compPaginasColor').val();
|
||||
data.papel_color = this.compPapelColorSelected.getVal();
|
||||
data.gramaje_color = $('#compGramajeColor').val();
|
||||
@ -186,20 +220,20 @@ class Importador {
|
||||
data.acabado_sobrecubierta = this.acabadosSobrecubierta.getVal();
|
||||
|
||||
data.servicios = {
|
||||
marcapaginas: $('#marcapaginas').prop('checked')?1:0,
|
||||
marcapaginas: $('#marcapaginas').prop('checked') ? 1 : 0,
|
||||
serviciosExtra: []
|
||||
};
|
||||
|
||||
if($('#ferro').prop('checked')){
|
||||
|
||||
if ($('#ferro').prop('checked')) {
|
||||
data.servicios.serviciosExtra.push(30);
|
||||
}
|
||||
if($('#ferroDigital').prop('checked')){
|
||||
if ($('#ferroDigital').prop('checked')) {
|
||||
data.servicios.serviciosExtra.push(29);
|
||||
}
|
||||
if($('#prototipo').prop('checked')){
|
||||
if ($('#prototipo').prop('checked')) {
|
||||
data.servicios.serviciosExtra.push(9);
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -242,7 +276,6 @@ class Importador {
|
||||
|
||||
fillInitialData(data) {
|
||||
|
||||
console.log(data);
|
||||
$('#paginas').val(data.datosGenerales.paginas);
|
||||
$('#tirada').val(data.datosGenerales.tirada);
|
||||
if (data.datosGenerales.papel_formato_personalizado) {
|
||||
@ -386,8 +419,8 @@ class Importador {
|
||||
$('#prototipo').prop('checked', false);
|
||||
}
|
||||
}
|
||||
this.makeImport.prop('disabled', false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
Reference in New Issue
Block a user