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 {
|
||||
|
||||
@ -54,7 +54,7 @@ class AlbaranLineaModel extends \App\Models\BaseModel
|
||||
->select(
|
||||
"t1.id, t1.titulo as titulo, t1.isbn as isbn, t1.ref_cliente as ref_cliente,
|
||||
t1.cantidad as unidades, t1.precio_unidad as precio_unidad, t1.iva_reducido as iva_reducido,
|
||||
t1.total as total, pedidos.id AS pedido"
|
||||
t1.total as total, pedidos.id AS pedido, t1.cajas, t1.unidades_cajas"
|
||||
)
|
||||
->join("pedidos_linea", "t1.pedido_linea_id = pedidos_linea.id", "left")
|
||||
->join("pedidos", "pedidos_linea.pedido_id = pedidos.id", "left");
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
<tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">Cajas: <?= $albaran->cajas ?></td>
|
||||
<td colspan="6">Total cajas: <?= $albaran->cajas ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -76,6 +76,8 @@
|
||||
<th class="concepto">Título</th>
|
||||
<th class="concepto">ISBN</th>
|
||||
<th class="concepto">Ref. Cliente</th>
|
||||
<th class="concepto">Cajas</th>
|
||||
<th class="concepto">Unidades/Caja</th>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<th class="precio_unidad">€/ud.</th>
|
||||
<th class="subtotal">Subtotal</th>
|
||||
@ -109,6 +111,12 @@
|
||||
<td>
|
||||
<div><?= $linea->ref_cliente ?></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><?= $linea->cajas ?></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><?= $linea->unidades_cajas ?></div>
|
||||
</td>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<td class="precio_unidad">
|
||||
<?php if (!str_contains($linea->titulo, "IVA")): ?>
|
||||
@ -140,6 +148,12 @@
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<td class="precio_unidad">
|
||||
<div></div>
|
||||
|
||||
@ -69,7 +69,7 @@
|
||||
<tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6">Cajas: <?= $albaran->cajas ?></td>
|
||||
<td colspan="6">Total cajas: <?= $albaran->cajas ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -82,6 +82,8 @@
|
||||
<th class="concepto">Título</th>
|
||||
<th class="concepto">ISBN</th>
|
||||
<th class="concepto">Ref. Cliente</th>
|
||||
<th class="concepto">Cajas</th>
|
||||
<th class="concepto">Unidades/Caja</th>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<th class="precio_unidad">€/ud.</th>
|
||||
<th class="subtotal">Subtotal</th>
|
||||
@ -115,6 +117,12 @@
|
||||
<td>
|
||||
<div><?= $linea->ref_cliente ?></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><?= $linea->cajas ?></div>
|
||||
</td>
|
||||
<td>
|
||||
<div><?= $linea->unidades_cajas ?></div>
|
||||
</td>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<td class="precio_unidad">
|
||||
<?php if (!str_contains($linea->titulo, "IVA")): ?>
|
||||
@ -146,6 +154,12 @@
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<td>
|
||||
<div></div>
|
||||
</td>
|
||||
<?php if ($mostrarPrecios): ?>
|
||||
<td class="precio_unidad">
|
||||
<div></div>
|
||||
|
||||
@ -511,6 +511,9 @@ class AlbaranComponent {
|
||||
}, (response) => {
|
||||
if (response.success) {
|
||||
this.table.ajax.reload(null, false);
|
||||
if(response.cajas != null){
|
||||
$('#cajas_albaran_' + this.id).val(response.cajas);
|
||||
}
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
|
||||
Reference in New Issue
Block a user