forked from nathalie/pedi2
		
	Merge pull request 'Fix-ExportarPedido' (#13) from Fix-ExportarPedido into master
Reviewed-on: nathalie/pedi2#13
This commit is contained in:
		
						commit
						aa70fa1c8d
					
				
					 3 changed files with 39 additions and 5 deletions
				
			
		| 
						 | 
					@ -21,18 +21,23 @@ class GrupoDeCompra extends Model
 | 
				
			||||||
  	return $this->hasMany('App\Subpedido');
 | 
					  	return $this->hasMany('App\Subpedido');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function pedidosAprobados() {
 | 
				
			||||||
 | 
					    return $this->subpedidos->where('aprobado',1);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public function exportarPlanillasAPdf() {
 | 
					  public function exportarPlanillasAPdf() {
 | 
				
			||||||
      $subpedidos = $this->subpedidos;
 | 
					      $subpedidos = $this->pedidosAprobados();
 | 
				
			||||||
      //generar pdf
 | 
					      //generar pdf
 | 
				
			||||||
      $mpdf = new Mpdf();;
 | 
					      $mpdf = new Mpdf();
 | 
				
			||||||
      foreach ($subpedidos as $subpedido) {
 | 
					      foreach ($subpedidos as $subpedido) {
 | 
				
			||||||
          $tabla = $subpedido->generarHTML();
 | 
					          $tabla = $subpedido->generarHTML();
 | 
				
			||||||
          // agregar la tabla al pdf en una nueva página
 | 
					          // agregar la tabla al pdf en una nueva página
 | 
				
			||||||
          $mpdf->WriteHTML($tabla);
 | 
					          $mpdf->WriteHTML($tabla);
 | 
				
			||||||
          $mpdf->AddPage();
 | 
					          $mpdf->AddPage();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      $filename = $this->nombre . '.pdf';
 | 
				
			||||||
      // imprimir el pdf
 | 
					      // imprimir el pdf
 | 
				
			||||||
      $mpdf->Output();
 | 
					      $mpdf->Output($filename, "D");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //Asume que los productos están gruadados en orden de fila
 | 
					  //Asume que los productos están gruadados en orden de fila
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										21
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								public/js/app.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -3021,6 +3021,13 @@ __webpack_require__.r(__webpack_exports__);
 | 
				
			||||||
      subpedidos: []
 | 
					      subpedidos: []
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  computed: {
 | 
				
			||||||
 | 
					    hayAprobados: function hayAprobados() {
 | 
				
			||||||
 | 
					      return this.subpedidos.filter(function (sp) {
 | 
				
			||||||
 | 
					        return sp.aprobado;
 | 
				
			||||||
 | 
					      }).length > 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  beforeCreate: function beforeCreate() {
 | 
					  beforeCreate: function beforeCreate() {
 | 
				
			||||||
    var _this = this;
 | 
					    var _this = this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6024,7 +6031,12 @@ var render = function () {
 | 
				
			||||||
          "a",
 | 
					          "a",
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
            staticClass: "button is-success",
 | 
					            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", [
 | 
					            _c("span", [
 | 
				
			||||||
| 
						 | 
					@ -6039,7 +6051,12 @@ var render = function () {
 | 
				
			||||||
          "a",
 | 
					          "a",
 | 
				
			||||||
          {
 | 
					          {
 | 
				
			||||||
            staticClass: "button is-info",
 | 
					            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", [
 | 
					            _c("span", [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,4 +37,16 @@
 | 
				
			||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
        @endif
 | 
					        @endif
 | 
				
			||||||
    @endforeach
 | 
					    @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>
 | 
					</table>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue