Solo se generan pdfs de pedidos aprobados. Los pdfs ahora incluyen bonos

This commit is contained in:
Ale 2022-11-12 18:44:22 -03:00
parent f67232f55c
commit cf82e1e21e
3 changed files with 37 additions and 4 deletions

View File

@ -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

21
public/js/app.js vendored
View File

@ -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", [

View File

@ -37,4 +37,16 @@
</tr>
@endif
@endforeach
@foreach($subpedido->productos as $producto)
@if($producto->bono)
<tr>
<td>
{{ $producto->nombre }}
</td>
<td style="text-align: center">
{{ $producto->pivot->cantidad }}
</td>
</tr>
@endif
@endforeach
</table>