From 602fb591f92ede4b8aca71cf1c41f8ca9a7a699c Mon Sep 17 00:00:00 2001 From: Ignacio Martinez Navajas Date: Thu, 5 Jun 2025 11:38:16 +0200 Subject: [PATCH 1/2] =?UTF-8?q?A=C3=B1adida=20funcionalidad=20de=20albaran?= =?UTF-8?q?=20anonimo=20y=20corregidos=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci4/app/Config/Routes.php | 1 + ci4/app/Controllers/Pdf/PrintAlbaranes.php | 51 +++++++ ci4/app/Language/es/Albaran.php | 1 + .../themes/vuexy/pdfs/albaran-anonimo.php | 137 ++++++++++++++++++ .../js/safekat/components/albaranComponent.js | 12 +- 5 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index 2b8b0b45..e6888b26 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -575,6 +575,7 @@ $routes->group( function ($routes) { $routes->get('index/(:num)', 'PrintAlbaranes::index/$1', ['as' => 'viewAlbaranPDF']); $routes->get('generar/(:num)', 'PrintAlbaranes::generar/$1', ['as' => 'albaranToPdf']); + $routes->get('generar-anonimo/(:num)', 'PrintAlbaranes::generarAnonimo/$1', ['as' => 'albaranAnonimoToPdf']); } ); diff --git a/ci4/app/Controllers/Pdf/PrintAlbaranes.php b/ci4/app/Controllers/Pdf/PrintAlbaranes.php index 4ebaeb73..56da19e5 100755 --- a/ci4/app/Controllers/Pdf/PrintAlbaranes.php +++ b/ci4/app/Controllers/Pdf/PrintAlbaranes.php @@ -71,4 +71,55 @@ class PrintAlbaranes extends BaseController ->setHeader('Content-Length', strlen($output)) ->setBody($output); } + + public function generarAnonimo($albaran_id) + { + + // Cargar modelos + $albaranModel = model('App\Models\Albaranes\AlbaranModel'); + $lineasAlbaranModel = model('App\Models\Albaranes\AlbaranLineaModel'); + + // Informacion del presupuesto + $data['albaran'] = $albaranModel->getResourceForPdf($albaran_id)->get()->getRow(); + $data['albaranLineas'] = $lineasAlbaranModel->getResourceForPdf($albaran_id)->get()->getResultObject(); + + + // Obtener contenido HTML de la vista + $html = view(getenv('theme.path') . 'pdfs/albaran-anonimo', $data); + + // Cargar CSS desde archivo local + $css = file_get_contents(FCPATH . 'themes/vuexy/css/pdf.albaran.css'); + // Combinar CSS y HTML + $html_con_css = "" . $html; + + // Crear una instancia de Dompdf + $options = new \Dompdf\Options(); + $options->set('isHtml5ParserEnabled', true); + $options->set('isPhpEnabled', true); + $options->set('isRemoteEnabled', true); + $dompdf = new \Dompdf\Dompdf($options); + + // Contenido HTML del documento + $dompdf->loadHtml($html_con_css); + + // Establecer el tamaño del papel + $dompdf->setPaper('A4', 'portrait'); + + // Renderizar el PDF + $dompdf->render(); + + // Obtener el contenido generado + $output = $dompdf->output(); + + // Establecer las cabeceras para visualizar en lugar de descargar + $file_name = "alabaran-$albaran_id.pdf"; + return $this->response + ->setStatusCode(200) + ->setHeader('Content-Type', 'application/pdf') + ->setHeader('Content-Disposition', 'inline; filename="' . $file_name . '"') + ->setHeader('Cache-Control', 'private, max-age=0, must-revalidate') + ->setHeader('Pragma', 'public') + ->setHeader('Content-Length', strlen($output)) + ->setBody($output); + } } \ No newline at end of file diff --git a/ci4/app/Language/es/Albaran.php b/ci4/app/Language/es/Albaran.php index fcfcb674..67dc8b37 100644 --- a/ci4/app/Language/es/Albaran.php +++ b/ci4/app/Language/es/Albaran.php @@ -28,6 +28,7 @@ return [ 'addIva' => 'Añadir IVA', 'nuevaLinea' => 'Nueva línea', 'imprimirAlbaran' => 'Imprimir albarán', + 'imprimirAlbaranAnonimo' => 'Imprimir albarán anónimo', 'borrarAlbaran' => 'Borrar albarán', 'borrarAlbaranConfirm' => '¿Está seguro de que desea borrar el albarán?', 'borrar' => 'Borrar', diff --git a/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php b/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php new file mode 100644 index 00000000..c7fc09eb --- /dev/null +++ b/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + +
+ mostrar_precios == 1; ?> + +
+ + + + + + + + + + + + + + + + + + + total; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Nº Unid.PedidoTítuloISBNRef. Cliente€/ud.Subtotal
+ unidades ?> + + pedido ?> + +
titulo ?>
+
+
isbn ?>
+
+
ref_cliente ?>
+
+ titulo, "IVA")): ?> +
precio_unidad, 4, ',', '.') ?>
+ +
+
total, 2, ',', '.') ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + +
+ RECIBÍ + + TOTAL + + +
+ +
+ + + \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/albaranComponent.js b/httpdocs/assets/js/safekat/components/albaranComponent.js index 12f1ac11..964a2053 100644 --- a/httpdocs/assets/js/safekat/components/albaranComponent.js +++ b/httpdocs/assets/js/safekat/components/albaranComponent.js @@ -192,6 +192,9 @@ class AlbaranComponent { + @@ -600,7 +603,14 @@ class AlbaranComponent { var albaran_id = this.id; window.open('/print-albaran/generar/'+ albaran_id , '_blank'); - }); + }); + + $('#imprimir_albaran_anonimo_' + this.id).on('click', (e) => { + + var albaran_id = this.id; + window.open('/print-albaran/generar-anonimo/'+ albaran_id , '_blank'); + + }); } _initAutoNumericInputs() { From 909228512cd22682dbd244313d2bfdee9b00ea1d Mon Sep 17 00:00:00 2001 From: Ignacio Martinez Navajas Date: Thu, 5 Jun 2025 11:45:00 +0200 Subject: [PATCH 2/2] Feedback JM --- .../themes/vuexy/pdfs/albaran-anonimo.php | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php b/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php index c7fc09eb..db93eda4 100644 --- a/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php +++ b/ci4/app/Views/themes/vuexy/pdfs/albaran-anonimo.php @@ -17,7 +17,7 @@ } .espaciado-superior { - margin-top: 80px; + margin-top: 40px; } @@ -29,6 +29,45 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Nº ALBARÁN: + + id ?> + + + + FECHA: + + fecha_albaran ? $albaran->fecha_albaran : date('d-m-Y') ?> +
Cliente: cliente ?>
Att: att ?>
direccion ?>
Cajas: cajas ?>
+