Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/12/2015, 21:18
Avatar de detective_jd
detective_jd
 
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
problema al cargar FPDF con MVC

Hola a todos, acá tengo con una consulta es la sgte: resulta que estoy probando fpdf y cuando quiero crear el pdf desde el controlador no hay problemas y funciona, pero cuando quiero crear las variables desde el controlador y pasarlas a la vista no anda, mostrando un mensaje diciendo: "No se pudo cargar el documento PDF", pongo el código:

VehiculosController.php:

Código PHP:
Ver original
  1. require_once './Lib/fpdf/fpdf.php';
  2.  
  3. function __construct() {
  4. parent::__construct();
  5. $this->pdf= new FPDF();
  6. $this->mod_m= new ModeloModel();
  7. $this->mod_tv=new TipovehModel();
  8. $this->mod_v= new VehiculoModel();
  9. }
  10.  
  11. public function reporte(){
  12. if(Session::get("tipo") == "admin"){
  13. Session::set('pdf', $this->getPDF());
  14. Session::set('vehiculos', $this->mod_v->obtenerTodos());
  15. $this->redirect(array('reporte.php'));
  16. /*
  17. $this->getPDF()->AddPage();
  18. $this->getPDF()->SetFont('Arial','B',16);
  19. $this->getPDF()->Cell(40,10,utf8_decode('Reporte de Vehículos'));
  20. $this->getPDF()->Ln(15);
  21. $this->getPDF()->SetFont('Arial','B',12);
  22. $this->getPDF()->Cell(30,5,utf8_decode('Vehículo'),1);
  23. $this->getPDF()->Cell(30,5,utf8_decode('Matrícula'),1);
  24. $this->getPDF()->Cell(30,5,'Cantidad',1);
  25. $this->getPDF()->Cell(30,5,utf8_decode('Descripción'),1);
  26. $this->getPDF()->Cell(40,5,'Modelo',1);
  27. $this->getPDF()->Cell(30,5,'Tipo',1);
  28. $this->getPDF()->Ln(8);
  29. foreach ($this->mod_v->obtenerTodos() as $vehiculo){
  30. $this->getPDF()->Cell(30,5,$vehiculo['id'],1);
  31. $this->getPDF()->Cell(30,5,$vehiculo['mat'],1);
  32. $this->getPDF()->Cell(30,5,$vehiculo['cant'],1);
  33. $this->getPDF()->Cell(30,5,$vehiculo['des'],1);
  34. $this->getPDF()->Cell(40,5,$vehiculo['modelo'],1);
  35. $this->getPDF()->Cell(30,5,utf8_decode($vehiculo['tipov']),1);
  36. $this->getPDF()->Ln(5);
  37. }
  38. $this->getPDF()->Output();*/
  39. }
  40. else {
  41. Session::set("msg","Debe ser administrador para acceder.");
  42. $this->redirect(array('Main','index.php'));
  43. }
  44. }
  45. private function getPDF(){
  46. return $this->pdf;
  47. }

View/Vehiculos/reporte.php:

Código PHP:
Ver original
  1. <?php
  2. Session::get('pdf')->AddPage();
  3. Session::get('pdf')->SetFont('Arial','B',16);
  4. Session::get('pdf')->Cell(40,10,utf8_decode('Reporte de Vehículos'));
  5. Session::get('pdf')->Ln(15);
  6. Session::get('pdf')->SetFont('Arial','B',12);
  7. Session::get('pdf')->Cell(30,5,utf8_decode('Vehículo'),1);
  8. Session::get('pdf')->Cell(30,5,utf8_decode('Matrícula'),1);
  9. Session::get('pdf')->Cell(30,5,'Cantidad',1);
  10. Session::get('pdf')->Cell(30,5,utf8_decode('Descripción'),1);
  11. Session::get('pdf')->Cell(40,5,'Modelo',1);
  12. Session::get('pdf')->Cell(30,5,'Tipo',1);
  13. Session::get('pdf')->Ln(8);
  14. foreach (Session::get('vehiculos') as $vehiculo){
  15. Session::get('pdf')->Cell(30,5,$vehiculo['id'],1);
  16. Session::get('pdf')->Cell(30,5,$vehiculo['mat'],1);
  17. Session::get('pdf')->Cell(30,5,$vehiculo['cant'],1);
  18. Session::get('pdf')->Cell(30,5,$vehiculo['des'],1);
  19. Session::get('pdf')->Cell(40,5,$vehiculo['modelo'],1);
  20. Session::get('pdf')->Cell(30,5,utf8_decode($vehiculo['tipov']),1);
  21. Session::get('pdf')->Ln(5);
  22. }
  23. Session::get('pdf')->Output();

No entiendo porque no carga el pdf que creo, espero sus respuestas.

Saludos.