mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
finalizar envio ok
This commit is contained in:
@ -28,9 +28,18 @@ class EnvioEdit {
|
||||
this.btnGenerarAlbaran = $("#btnGenerarAlbaran");
|
||||
this.btnbtnSelectAll = $("#btnSelectAll");
|
||||
this.cajas = $("#cajas");
|
||||
this.codigoSeguimiento = $("#codigoSeguimiento");
|
||||
if($("#empresaMensajeriaInput").length) {
|
||||
this.proveedor = new ClassSelect($("#empresaMensajeria"), '/compras/proveedores/getProveedores', "", true, { 'tipo_id': 2 });
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
if($("#empresaMensajeriaInput").length) {
|
||||
this.proveedor.init();
|
||||
}
|
||||
|
||||
this.table = $('#tableLineasEnvio').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
@ -205,8 +214,158 @@ class EnvioEdit {
|
||||
const checkboxes = this.table.$('input[type="checkbox"]');
|
||||
const allChecked = checkboxes.length === checkboxes.filter(':checked').length;
|
||||
checkboxes.prop('checked', !allChecked);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
this.codigoSeguimiento.on('change', (e) => {
|
||||
const value = $(e.currentTarget).val();
|
||||
|
||||
$.post('/logistica/updateCodigoSeguimiento', {
|
||||
id: $('#id').val(),
|
||||
codigo_seguimiento: value
|
||||
}, function (response) {
|
||||
if (!response.status) {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
$(e.currentTarget).val(value.substring(0, 100));
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo actualizar el código de seguimiento.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
$(e.currentTarget).val(value.substring(0, 100));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
this.proveedor.onChange((e) => {
|
||||
|
||||
const value = this.proveedor.getVal();
|
||||
$.post('/logistica/updateProveedorEnvio', {
|
||||
id: $('#id').val(),
|
||||
proveedor_id: value
|
||||
}, function (response) {
|
||||
if (!response.status) {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
this.proveedor.setVal(0);
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo actualizar el proveedor.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
this.proveedor.setVal(0);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$('#finalizarEnvio').on('click', () => {
|
||||
|
||||
if(this.codigoSeguimiento.val().length <= 0 || this.proveedor.getVal() <= 0) {
|
||||
Swal.fire({
|
||||
title: 'Atención!',
|
||||
text: 'Debe seleccionar un proveedor y un código de seguimiento antes de finalizar el envío.',
|
||||
icon: 'info',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Finalizar envío',
|
||||
text: '¿Está seguro de que desea finalizar el envío?',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí',
|
||||
cancelButtonText: 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-danger me-1',
|
||||
cancelButton: 'btn btn-secondary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.post('/logistica/finalizarEnvio', {
|
||||
id: $('#id').val()
|
||||
}, function (response) {
|
||||
if (response.status) {
|
||||
Swal.fire({
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo finalizar el envío.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this._getAlbaranes();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user