Merge pull request 'Fix-ExportarPedido' (#13) from Fix-ExportarPedido into master

Reviewed-on: nathalie/pedi2#13
This commit is contained in:
Alejandro Tasistro 2022-11-13 21:22:01 -03:00
commit aa70fa1c8d
3 changed files with 39 additions and 5 deletions

View File

@ -21,18 +21,23 @@ 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
$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

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>