mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando
This commit is contained in:
@ -339,16 +339,19 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
return '<a href="' . base_url('pedidos/edit/' . $q->pedido) . '" target="_blank">' . $q->pedido . '</a>';
|
||||
})
|
||||
->edit('unidades', function ($q) {
|
||||
return '<input type="number" class="form-control form-control-sm text-center" value="' . $q->unidades . '" data-id="' . $q->id . '" data-field="cantidad" />';
|
||||
return '<input type="number" class="form-control form-control-sm input-albaran-linea text-center"
|
||||
value="' . $q->unidades . '" data-id="' . $q->id . '" data-field="cantidad" />';
|
||||
})
|
||||
->edit('titulo', function ($q) {
|
||||
return '<input type="text" class="form-control form-control-sm" value="' . $q->titulo . '" data-id="' . $q->id . '" data-field="titulo" />';
|
||||
return '<input type="text" class="form-control form-control-sm input-albaran-linea" value="' . $q->titulo .
|
||||
'" data-id="' . $q->id . '" data-field="titulo" />';
|
||||
})
|
||||
->edit('total', function ($q) {
|
||||
return '<input class="form-control autonumeric-2 form-control-sm text-center" value="' . $q->total . '" data-id="' . $q->id . '" data-field="total" />';
|
||||
return '<input class="form-control autonumeric-2 input-albaran-linea
|
||||
form-control-sm text-center" value="' . $q->total . '" data-id="' . $q->id . '" data-field="total" />';
|
||||
})
|
||||
->edit('precio_unidad', function ($q) {
|
||||
return '<input class="form-control autonumeric-4 form-control-sm text-center" value="' .
|
||||
return '<input class="form-control autonumeric-4 form-control-sm text-center input-albaran-linea" value="' .
|
||||
number_format((float) $q->precio_unidad, 4, ',', '') .
|
||||
'" data-id="' . $q->id . '" data-field="precio_unidad" />';
|
||||
});
|
||||
@ -357,6 +360,37 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
return $result->toJson(returnAsObject: true);
|
||||
}
|
||||
|
||||
public function updateAlbaranLinea(){
|
||||
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$fieldName = $this->request->getPost('fieldName');
|
||||
$fieldValue = $this->request->getPost('fieldValue');
|
||||
$id = $this->request->getPost('lineaId');
|
||||
|
||||
if ($id == null) {
|
||||
$data = [
|
||||
'success' => false,
|
||||
'message' => lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]),
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
$albaranEntity = model('App\Models\Albaranes\AlbaranLineaModel')->find($id);
|
||||
|
||||
if ($albaranEntity == false) {
|
||||
$data = [
|
||||
'success' => false,
|
||||
'message' => lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Pedidos.albaran')), $id]),
|
||||
];
|
||||
return $this->respond($data);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function borrarLinea()
|
||||
{
|
||||
|
||||
|
||||
@ -440,6 +440,37 @@ class AlbaranComponent {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('#tablaAlbaran' + this.id).on('change', '.input-albaran-linea', (e) => {
|
||||
|
||||
const fieldName = $(e.currentTarget).attr('data-field');
|
||||
const fieldValue = $(e.currentTarget).val();
|
||||
const albaranId = this.id;
|
||||
const lineaId = $(e.currentTarget).attr('data-id');
|
||||
|
||||
$.post('/albaranes/updateAlbaranLinea', {
|
||||
fieldName: fieldName,
|
||||
fieldValue: fieldValue,
|
||||
lineaId: lineaId
|
||||
}, (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
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_initAutoNumericInputs() {
|
||||
|
||||
Reference in New Issue
Block a user