mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminados albaranes
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import DatePicker from "./datepicker.js";
|
||||
class AlbaranComponent {
|
||||
|
||||
constructor(item) {
|
||||
@ -8,9 +9,15 @@ class AlbaranComponent {
|
||||
this.att = item.att;
|
||||
this.direccion = item.direccion;
|
||||
this.envio_id = item.envio_id;
|
||||
this.fecha = null;
|
||||
if(this.item.fecha_albaran != null){
|
||||
const [dia, mes, anio] = item.fecha_albaran.split('/');
|
||||
this.fecha = `${anio}-${mes.padStart(2, '0')}-${dia.padStart(2, '0')}`;
|
||||
}
|
||||
this.selectorTabla = `#tablaAlbaran${this.id}`;
|
||||
|
||||
this.table = null;
|
||||
this.fechaAlbaran = null;
|
||||
}
|
||||
|
||||
mount(selector) {
|
||||
@ -257,6 +264,15 @@ class AlbaranComponent {
|
||||
}
|
||||
});
|
||||
|
||||
const option = {
|
||||
altInput: true,
|
||||
altFormat: "d/m/Y",
|
||||
dateFormat: "Y-m-d",
|
||||
allowInput: true,
|
||||
}
|
||||
this.fechaAlbaran = new DatePicker($('#fecha_albaran_' + this.id), option);
|
||||
this.fechaAlbaran.setDate(this.fecha);
|
||||
|
||||
$('#tablaAlbaran' + this.id).on('click', '.btn-delete-albaran-lineas', (e) => {
|
||||
e.preventDefault();
|
||||
const table = $('#tablaAlbaran' + this.id).DataTable();
|
||||
@ -386,6 +402,33 @@ class AlbaranComponent {
|
||||
});
|
||||
});
|
||||
|
||||
$('#fecha_albaran_' + this.item.id).on('change', (e) => {
|
||||
const value = $(e.currentTarget).val();
|
||||
const albaranId = this.id;
|
||||
|
||||
$.post('/albaranes/updateAlbaran', {
|
||||
albaranId: albaranId,
|
||||
fieldName: 'fecha_albaran',
|
||||
fieldValue: value
|
||||
}, (response) => {
|
||||
if (response.success) {
|
||||
this.table.ajax.reload(null, false);
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se ha podido actualizar el albarán',
|
||||
icon: 'error',
|
||||
showCancelButton: false,
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#borrar_albaran_" + this.item.id).on('click', (e) => {
|
||||
e.preventDefault();
|
||||
@ -547,7 +590,7 @@ class AlbaranComponent {
|
||||
var albaran_id = this.id;
|
||||
window.open('/print-albaran/generar/'+ albaran_id , '_blank');
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_initAutoNumericInputs() {
|
||||
|
||||
Reference in New Issue
Block a user