From 6a9331747e2bf23e16fc659f75c4197b95be5a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 5 Jun 2025 18:57:03 +0200 Subject: [PATCH 1/2] solucionado el problema de la impresion de las ots --- .../assets/js/safekat/pages/pdf/otDownload.js | 27 ++++++++++---- httpdocs/themes/vuexy/css/pdf.ot.css | 37 +++++++++++++++---- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/pdf/otDownload.js b/httpdocs/assets/js/safekat/pages/pdf/otDownload.js index c666e800..1652920a 100644 --- a/httpdocs/assets/js/safekat/pages/pdf/otDownload.js +++ b/httpdocs/assets/js/safekat/pages/pdf/otDownload.js @@ -1,11 +1,24 @@ $(() => { - var opt = { - margin: 2, + const elementToPdf = document.querySelector('body'); // o .pdf-wrapper si quieres acotar + + const opt = { + margin: 2, // un margen decente filename: $(".pdf-wrapper").data("id") + ".pdf", - image: { type: 'jpeg', quality: 1 }, - html2canvas: { scale: 4 }, + image: { type: 'jpeg', quality: 0.98 }, + html2canvas: { + scale: 4, + useCORS: true, + scrollY: -window.scrollY, // importante + //windowWidth: document.body.scrollWidth, + //windowHeight: document.body.scrollHeight + }, jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }, + pagebreak: { + mode: ['css', 'legacy'], // intenta usar los saltos naturales + before: '.page-break', // puedes insertar
si lo necesitas + avoid: ['table', 'tr', '.row'] // evita cortar tablas + } }; - let elementToPdf = $('body')[0] - html2pdf().set(opt).from(elementToPdf).save() -}) \ No newline at end of file + + html2pdf().set(opt).from(elementToPdf).toPdf().get('pdf').save(); +}); \ No newline at end of file diff --git a/httpdocs/themes/vuexy/css/pdf.ot.css b/httpdocs/themes/vuexy/css/pdf.ot.css index e773c58e..c0c29e2e 100644 --- a/httpdocs/themes/vuexy/css/pdf.ot.css +++ b/httpdocs/themes/vuexy/css/pdf.ot.css @@ -13,24 +13,38 @@ /* ... the rest of the rules ... */ } -html,body { - font-family: Arial, sans-serif; +html, body { width: 210mm; - height: 297mm; max-width: 210mm; - width: 100%; + margin: 0 auto; + padding: 0; + background: white; + font-family: Arial, sans-serif; font-size: 14px; - max-height: 297mm; - background-color: white; + box-sizing: border-box; + 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 { border: 0px solid; padding: 10px; margin: 10px; width: 100%; max-width: 210mm; - max-height: 297mm; + height: auto !important; + max-height: none !important; + /*max-height: 297mm;*/ background-color: white; } .portada-img { @@ -189,8 +203,15 @@ table th { width: 50px; } .ot-code { - font-size: 4em; + font-size: 3.5em; } .code-title { font-size: 1.5em; } + +body, html, .pdf-wrapper, .page, div { + box-sizing: border-box; + max-width: 210mm; + overflow-x: hidden; + word-wrap: break-word; +} \ No newline at end of file From 49140cea40c7990c217bf36000caeef23b7f4979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Thu, 5 Jun 2025 21:25:48 +0200 Subject: [PATCH 2/2] =?UTF-8?q?arreglado=20albaranes=20para=20que=20muestr?= =?UTF-8?q?en=20las=20cajas.=20tambien=20se=20ha=20actualizado=20para=20qu?= =?UTF-8?q?e=20cuando=20se=20modifiquen=20las=20cajas=20de=20la=20linea=20?= =?UTF-8?q?se=20modifiquen=20el=20total=20del=20albar=C3=A1n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Controllers/Albaranes/Albaran.php | 19 +++++++++++++++++++ .../Models/Albaranes/AlbaranLineaModel.php | 2 +- .../themes/vuexy/pdfs/albaran-anonimo.php | 16 +++++++++++++++- ci4/app/Views/themes/vuexy/pdfs/albaran.php | 16 +++++++++++++++- .../js/safekat/components/albaranComponent.js | 3 +++ 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/ci4/app/Controllers/Albaranes/Albaran.php b/ci4/app/Controllers/Albaranes/Albaran.php index 99eda620..91915ead 100755 --- a/ci4/app/Controllers/Albaranes/Albaran.php +++ b/ci4/app/Controllers/Albaranes/Albaran.php @@ -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 { diff --git a/ci4/app/Models/Albaranes/AlbaranLineaModel.php b/ci4/app/Models/Albaranes/AlbaranLineaModel.php index 6467be3c..9d49cd06 100755 --- a/ci4/app/Models/Albaranes/AlbaranLineaModel.php +++ b/ci4/app/Models/Albaranes/AlbaranLineaModel.php @@ -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"); diff --git a/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php b/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php index db93eda4..7e7fed67 100644 --- a/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php +++ b/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php @@ -63,7 +63,7 @@ - Cajas: cajas ?> + Total cajas: cajas ?> @@ -76,6 +76,8 @@ Título ISBN Ref. Cliente + Cajas + Unidades/Caja €/ud. Subtotal @@ -109,6 +111,12 @@
ref_cliente ?>
+ +
cajas ?>
+ + +
unidades_cajas ?>
+ titulo, "IVA")): ?> @@ -140,6 +148,12 @@
+ +
+ + +
+
diff --git a/ci4/app/Views/themes/vuexy/pdfs/albaran.php b/ci4/app/Views/themes/vuexy/pdfs/albaran.php index 00ebc343..07e61438 100755 --- a/ci4/app/Views/themes/vuexy/pdfs/albaran.php +++ b/ci4/app/Views/themes/vuexy/pdfs/albaran.php @@ -69,7 +69,7 @@ - Cajas: cajas ?> + Total cajas: cajas ?> @@ -82,6 +82,8 @@ Título ISBN Ref. Cliente + Cajas + Unidades/Caja €/ud. Subtotal @@ -115,6 +117,12 @@
ref_cliente ?>
+ +
cajas ?>
+ + +
unidades_cajas ?>
+ titulo, "IVA")): ?> @@ -146,6 +154,12 @@
+ +
+ + +
+
diff --git a/httpdocs/assets/js/safekat/components/albaranComponent.js b/httpdocs/assets/js/safekat/components/albaranComponent.js index 964a2053..598c96a7 100644 --- a/httpdocs/assets/js/safekat/components/albaranComponent.js +++ b/httpdocs/assets/js/safekat/components/albaranComponent.js @@ -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',