mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'fix/pdf_ot_albaranes' into 'main'
arreglado albaranes para que muestren las cajas. tambien se ha actualizado... See merge request jjimenez/safekat!850
This commit is contained in:
@ -476,10 +476,29 @@ class Albaran extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$model_linea->update($id, $linea->toArray());
|
$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 = [
|
$data = [
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.',
|
'message' => lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.',
|
||||||
];
|
];
|
||||||
|
if($fieldName == 'cajas') {
|
||||||
|
$data['cajas'] = $cajas->getRow()->total_cajas;
|
||||||
|
};
|
||||||
return $this->respond($data);
|
return $this->respond($data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class AlbaranLineaModel extends \App\Models\BaseModel
|
|||||||
->select(
|
->select(
|
||||||
"t1.id, t1.titulo as titulo, t1.isbn as isbn, t1.ref_cliente as ref_cliente,
|
"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.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_linea", "t1.pedido_linea_id = pedidos_linea.id", "left")
|
||||||
->join("pedidos", "pedidos_linea.pedido_id = pedidos.id", "left");
|
->join("pedidos", "pedidos_linea.pedido_id = pedidos.id", "left");
|
||||||
|
|||||||
@ -63,7 +63,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6">Cajas: <?= $albaran->cajas ?></td>
|
<td colspan="6">Total cajas: <?= $albaran->cajas ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@ -76,6 +76,8 @@
|
|||||||
<th class="concepto">Título</th>
|
<th class="concepto">Título</th>
|
||||||
<th class="concepto">ISBN</th>
|
<th class="concepto">ISBN</th>
|
||||||
<th class="concepto">Ref. Cliente</th>
|
<th class="concepto">Ref. Cliente</th>
|
||||||
|
<th class="concepto">Cajas</th>
|
||||||
|
<th class="concepto">Unidades/Caja</th>
|
||||||
<?php if ($mostrarPrecios): ?>
|
<?php if ($mostrarPrecios): ?>
|
||||||
<th class="precio_unidad">€/ud.</th>
|
<th class="precio_unidad">€/ud.</th>
|
||||||
<th class="subtotal">Subtotal</th>
|
<th class="subtotal">Subtotal</th>
|
||||||
@ -109,6 +111,12 @@
|
|||||||
<td>
|
<td>
|
||||||
<div><?= $linea->ref_cliente ?></div>
|
<div><?= $linea->ref_cliente ?></div>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<div><?= $linea->cajas ?></div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div><?= $linea->unidades_cajas ?></div>
|
||||||
|
</td>
|
||||||
<?php if ($mostrarPrecios): ?>
|
<?php if ($mostrarPrecios): ?>
|
||||||
<td class="precio_unidad">
|
<td class="precio_unidad">
|
||||||
<?php if (!str_contains($linea->titulo, "IVA")): ?>
|
<?php if (!str_contains($linea->titulo, "IVA")): ?>
|
||||||
@ -140,6 +148,12 @@
|
|||||||
<td>
|
<td>
|
||||||
<div></div>
|
<div></div>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<div></div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div></div>
|
||||||
|
</td>
|
||||||
<?php if ($mostrarPrecios): ?>
|
<?php if ($mostrarPrecios): ?>
|
||||||
<td class="precio_unidad">
|
<td class="precio_unidad">
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6">Cajas: <?= $albaran->cajas ?></td>
|
<td colspan="6">Total cajas: <?= $albaran->cajas ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@ -82,6 +82,8 @@
|
|||||||
<th class="concepto">Título</th>
|
<th class="concepto">Título</th>
|
||||||
<th class="concepto">ISBN</th>
|
<th class="concepto">ISBN</th>
|
||||||
<th class="concepto">Ref. Cliente</th>
|
<th class="concepto">Ref. Cliente</th>
|
||||||
|
<th class="concepto">Cajas</th>
|
||||||
|
<th class="concepto">Unidades/Caja</th>
|
||||||
<?php if ($mostrarPrecios): ?>
|
<?php if ($mostrarPrecios): ?>
|
||||||
<th class="precio_unidad">€/ud.</th>
|
<th class="precio_unidad">€/ud.</th>
|
||||||
<th class="subtotal">Subtotal</th>
|
<th class="subtotal">Subtotal</th>
|
||||||
@ -115,6 +117,12 @@
|
|||||||
<td>
|
<td>
|
||||||
<div><?= $linea->ref_cliente ?></div>
|
<div><?= $linea->ref_cliente ?></div>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<div><?= $linea->cajas ?></div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div><?= $linea->unidades_cajas ?></div>
|
||||||
|
</td>
|
||||||
<?php if ($mostrarPrecios): ?>
|
<?php if ($mostrarPrecios): ?>
|
||||||
<td class="precio_unidad">
|
<td class="precio_unidad">
|
||||||
<?php if (!str_contains($linea->titulo, "IVA")): ?>
|
<?php if (!str_contains($linea->titulo, "IVA")): ?>
|
||||||
@ -146,6 +154,12 @@
|
|||||||
<td>
|
<td>
|
||||||
<div></div>
|
<div></div>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<div></div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div></div>
|
||||||
|
</td>
|
||||||
<?php if ($mostrarPrecios): ?>
|
<?php if ($mostrarPrecios): ?>
|
||||||
<td class="precio_unidad">
|
<td class="precio_unidad">
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|||||||
@ -511,6 +511,9 @@ class AlbaranComponent {
|
|||||||
}, (response) => {
|
}, (response) => {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
this.table.ajax.reload(null, false);
|
this.table.ajax.reload(null, false);
|
||||||
|
if(response.cajas != null){
|
||||||
|
$('#cajas_albaran_' + this.id).val(response.cajas);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
|
|||||||
@ -1,11 +1,24 @@
|
|||||||
$(() => {
|
$(() => {
|
||||||
var opt = {
|
const elementToPdf = document.querySelector('body'); // o .pdf-wrapper si quieres acotar
|
||||||
margin: 2,
|
|
||||||
|
const opt = {
|
||||||
|
margin: 2, // un margen decente
|
||||||
filename: $(".pdf-wrapper").data("id") + ".pdf",
|
filename: $(".pdf-wrapper").data("id") + ".pdf",
|
||||||
image: { type: 'jpeg', quality: 1 },
|
image: { type: 'jpeg', quality: 0.98 },
|
||||||
html2canvas: { scale: 4 },
|
html2canvas: {
|
||||||
|
scale: 4,
|
||||||
|
useCORS: true,
|
||||||
|
scrollY: -window.scrollY, // importante
|
||||||
|
//windowWidth: document.body.scrollWidth,
|
||||||
|
//windowHeight: document.body.scrollHeight
|
||||||
|
},
|
||||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
|
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
|
||||||
|
pagebreak: {
|
||||||
|
mode: ['css', 'legacy'], // intenta usar los saltos naturales
|
||||||
|
before: '.page-break', // puedes insertar <div class="page-break"></div> si lo necesitas
|
||||||
|
avoid: ['table', 'tr', '.row'] // evita cortar tablas
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let elementToPdf = $('body')[0]
|
|
||||||
html2pdf().set(opt).from(elementToPdf).save()
|
html2pdf().set(opt).from(elementToPdf).toPdf().get('pdf').save();
|
||||||
})
|
});
|
||||||
@ -13,24 +13,38 @@
|
|||||||
|
|
||||||
/* ... the rest of the rules ... */
|
/* ... the rest of the rules ... */
|
||||||
}
|
}
|
||||||
html,body {
|
html, body {
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
width: 210mm;
|
width: 210mm;
|
||||||
height: 297mm;
|
|
||||||
max-width: 210mm;
|
max-width: 210mm;
|
||||||
width: 100%;
|
margin: 0 auto;
|
||||||
|
padding: 0;
|
||||||
|
background: white;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
max-height: 297mm;
|
box-sizing: border-box;
|
||||||
background-color: white;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pdf-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Opcional: ayuda a evitar cortes raros en tablas o secciones */
|
||||||
|
.page-break {
|
||||||
|
page-break-before: always;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
border: 0px solid;
|
border: 0px solid;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 210mm;
|
max-width: 210mm;
|
||||||
max-height: 297mm;
|
height: auto !important;
|
||||||
|
max-height: none !important;
|
||||||
|
/*max-height: 297mm;*/
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
.portada-img {
|
.portada-img {
|
||||||
@ -189,8 +203,15 @@ table th {
|
|||||||
width: 50px;
|
width: 50px;
|
||||||
}
|
}
|
||||||
.ot-code {
|
.ot-code {
|
||||||
font-size: 4em;
|
font-size: 3.5em;
|
||||||
}
|
}
|
||||||
.code-title {
|
.code-title {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body, html, .pdf-wrapper, .page, div {
|
||||||
|
box-sizing: border-box;
|
||||||
|
max-width: 210mm;
|
||||||
|
overflow-x: hidden;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user