VehiculosController.php:
Código PHP:
Ver original
require_once './Lib/fpdf/fpdf.php'; function __construct() { parent::__construct(); $this->pdf= new FPDF(); $this->mod_m= new ModeloModel(); $this->mod_tv=new TipovehModel(); $this->mod_v= new VehiculoModel(); } public function reporte(){ if(Session::get("tipo") == "admin"){ Session::set('pdf', $this->getPDF()); Session::set('vehiculos', $this->mod_v->obtenerTodos()); /* $this->getPDF()->AddPage(); $this->getPDF()->SetFont('Arial','B',16); $this->getPDF()->Cell(40,10,utf8_decode('Reporte de Vehículos')); $this->getPDF()->Ln(15); $this->getPDF()->SetFont('Arial','B',12); $this->getPDF()->Cell(30,5,utf8_decode('Vehículo'),1); $this->getPDF()->Cell(30,5,utf8_decode('Matrícula'),1); $this->getPDF()->Cell(30,5,'Cantidad',1); $this->getPDF()->Cell(30,5,utf8_decode('Descripción'),1); $this->getPDF()->Cell(40,5,'Modelo',1); $this->getPDF()->Cell(30,5,'Tipo',1); $this->getPDF()->Ln(8); foreach ($this->mod_v->obtenerTodos() as $vehiculo){ $this->getPDF()->Cell(30,5,$vehiculo['id'],1); $this->getPDF()->Cell(30,5,$vehiculo['mat'],1); $this->getPDF()->Cell(30,5,$vehiculo['cant'],1); $this->getPDF()->Cell(30,5,$vehiculo['des'],1); $this->getPDF()->Cell(40,5,$vehiculo['modelo'],1); $this->getPDF()->Cell(30,5,utf8_decode($vehiculo['tipov']),1); $this->getPDF()->Ln(5); } $this->getPDF()->Output();*/ } else { Session::set("msg","Debe ser administrador para acceder."); } } private function getPDF(){ return $this->pdf; }
View/Vehiculos/reporte.php:
Código PHP:
Ver original
<?php Session::get('pdf')->AddPage(); Session::get('pdf')->SetFont('Arial','B',16); Session::get('pdf')->Ln(15); Session::get('pdf')->SetFont('Arial','B',12); Session::get('pdf')->Cell(30,5,'Cantidad',1); Session::get('pdf')->Cell(40,5,'Modelo',1); Session::get('pdf')->Cell(30,5,'Tipo',1); Session::get('pdf')->Ln(8); foreach (Session::get('vehiculos') as $vehiculo){ Session::get('pdf')->Cell(30,5,$vehiculo['id'],1); Session::get('pdf')->Cell(30,5,$vehiculo['mat'],1); Session::get('pdf')->Cell(30,5,$vehiculo['cant'],1); Session::get('pdf')->Cell(30,5,$vehiculo['des'],1); Session::get('pdf')->Cell(40,5,$vehiculo['modelo'],1); Session::get('pdf')->Ln(5); } Session::get('pdf')->Output();
No entiendo porque no carga el pdf que creo, espero sus respuestas.
Saludos.