mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
arreglado albaranes para que muestren las cajas. tambien se ha actualizado para que cuando se modifiquen las cajas de la linea se modifiquen el total del albarán
This commit is contained in:
@ -476,10 +476,29 @@ class Albaran extends \App\Controllers\BaseResourceController
|
||||
|
||||
$model_linea->update($id, $linea->toArray());
|
||||
|
||||
if($fieldName == 'cajas'){
|
||||
$cajas = $model_linea->where('albaran_id', $linea->albaran_id)
|
||||
->where('cajas > 0')
|
||||
->select('SUM(cajas) as total_cajas')
|
||||
->get();
|
||||
|
||||
$albaranModel = model('App\Models\Albaranes\AlbaranModel');
|
||||
$albaran = $albaranModel->find($linea->albaran_id);
|
||||
if($albaran != false) {
|
||||
$albaran->cajas = $cajas->getRow()->total_cajas;
|
||||
$albaran->user_updated_id = auth()->user()->id;
|
||||
$albaran->updated_at = date('Y-m-d H:i:s');
|
||||
$albaranModel->update($linea->albaran_id, $albaran->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'success' => true,
|
||||
'message' => lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.',
|
||||
];
|
||||
if($fieldName == 'cajas') {
|
||||
$data['cajas'] = $cajas->getRow()->total_cajas;
|
||||
};
|
||||
return $this->respond($data);
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user