From cf82e1e21e46d004d69791400a64e8ab6f990dd8 Mon Sep 17 00:00:00 2001 From: Ale Date: Sat, 12 Nov 2022 18:44:22 -0300 Subject: [PATCH 1/2] Solo se generan pdfs de pedidos aprobados. Los pdfs ahora incluyen bonos --- app/GrupoDeCompra.php | 8 +++++-- public/js/app.js | 21 +++++++++++++++++-- .../views/pdfgen/subpedido_tabla.blade.php | 12 +++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/GrupoDeCompra.php b/app/GrupoDeCompra.php index 9147fbb..dfdd3d7 100644 --- a/app/GrupoDeCompra.php +++ b/app/GrupoDeCompra.php @@ -21,10 +21,14 @@ class GrupoDeCompra extends Model return $this->hasMany('App\Subpedido'); } + public function pedidosAprobados() { + return $this->subpedidos->where('aprobado',1); + } + public function exportarPlanillasAPdf() { - $subpedidos = $this->subpedidos; + $subpedidos = $this->pedidosAprobados(); //generar pdf - $mpdf = new Mpdf();; + $mpdf = new Mpdf(); foreach ($subpedidos as $subpedido) { $tabla = $subpedido->generarHTML(); // agregar la tabla al pdf en una nueva página diff --git a/public/js/app.js b/public/js/app.js index a0dba5b..b959090 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -3021,6 +3021,13 @@ __webpack_require__.r(__webpack_exports__); subpedidos: [] }; }, + computed: { + hayAprobados: function hayAprobados() { + return this.subpedidos.filter(function (sp) { + return sp.aprobado; + }).length > 0; + } + }, beforeCreate: function beforeCreate() { var _this = this; @@ -6024,7 +6031,12 @@ var render = function () { "a", { staticClass: "button is-success", - attrs: { href: "/admin/exportar-pedido-a-csv/" + _vm.gdc }, + attrs: { + href: _vm.hayAprobados + ? "/admin/exportar-pedido-a-csv/" + _vm.gdc + : "#", + disabled: !_vm.hayAprobados, + }, }, [ _c("span", [ @@ -6039,7 +6051,12 @@ var render = function () { "a", { staticClass: "button is-info", - attrs: { href: "/admin/exportar-planillas-a-pdf/" + _vm.gdc }, + attrs: { + href: _vm.hayAprobados + ? "/admin/exportar-planillas-a-pdf/" + _vm.gdc + : "#", + disabled: !_vm.hayAprobados, + }, }, [ _c("span", [ diff --git a/resources/views/pdfgen/subpedido_tabla.blade.php b/resources/views/pdfgen/subpedido_tabla.blade.php index 41e1173..edc4c3a 100644 --- a/resources/views/pdfgen/subpedido_tabla.blade.php +++ b/resources/views/pdfgen/subpedido_tabla.blade.php @@ -37,4 +37,16 @@ @endif @endforeach + @foreach($subpedido->productos as $producto) + @if($producto->bono) + + + {{ $producto->nombre }} + + + {{ $producto->pivot->cantidad }} + + + @endif +@endforeach From f8484959d663b6c6248810502d7ebfb83e01a385 Mon Sep 17 00:00:00 2001 From: Ale Date: Sat, 12 Nov 2022 18:53:06 -0300 Subject: [PATCH 2/2] =?UTF-8?q?Las=20planillas=20se=20descargan=20autom?= =?UTF-8?q?=C3=A1ticamente=20y=20tienen=20el=20nombre=20del=20barrio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/GrupoDeCompra.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/GrupoDeCompra.php b/app/GrupoDeCompra.php index dfdd3d7..39e8376 100644 --- a/app/GrupoDeCompra.php +++ b/app/GrupoDeCompra.php @@ -35,8 +35,9 @@ class GrupoDeCompra extends Model $mpdf->WriteHTML($tabla); $mpdf->AddPage(); } + $filename = $this->nombre . '.pdf'; // imprimir el pdf - $mpdf->Output(); + $mpdf->Output($filename, "D"); } //Asume que los productos están gruadados en orden de fila