From cf82e1e21e46d004d69791400a64e8ab6f990dd8 Mon Sep 17 00:00:00 2001 From: Ale Date: Sat, 12 Nov 2022 18:44:22 -0300 Subject: [PATCH] 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