Ver Mensaje Individual
  #8 (permalink)  
Antiguo 24/01/2013, 13:37
Avatar de RastaMart
RastaMart
 
Fecha de Ingreso: noviembre-2006
Mensajes: 91
Antigüedad: 17 años, 5 meses
Puntos: 3
Respuesta: Como hacer un reporte fpdf

Sabes, sinceramente no me hadia dado cuenta que estas usando postgresql.

Mira yo uso mysql en mis reportes, tmb estoy usando postgresql pero para otras cosas..

Lo adecue al que tengo de reporte usando postgresql.

Trata de echarlo andar y me platicas.

Código PHP:

<?php
require('fpdf.php');
    
class 
PDF extends FPDF
{
  public 
$sucursal;
  public 
$f_ini;
  public 
$f_fin;
  
//Cabecera de página
    
function Header()
    {
       
       
$this->Rect(1,1,213,31);
       
$this->Rect(1,31,213,1,'DF');
        
//Logo
        
$this->Image('../css/images/Logog.jpg',13,2,25,27);
        
//Arial bold 15
        
$this->SetFont('Arial','B',14);
        
//Movernos a la derecha
        
$this->Cell(30);
        
//Título
        
$this->Cell(170,4,'TITULO',0,0,'C');
        
$this->Ln(2);
        
$this->SetFont('Arial','B',10);
        
$this->Cell(36);
        
$this->MultiCell(170,5,'algun otro mensaje:');
        
//$this->SetFont('Arial','',6);
    
        
$this->SetFont('Arial','',7);
        
$this->Line(1,32,214,32);
        
        
$this->Text(12,36,'No.');
        
$this->Text(22,36,'Nombre');
        
$this->Text(40,36,'Apellidos');
        
$this->Text(80,36,'Gerencia');     
             
$this->Text(120,36,'Cargo');   
        
$this->Line(1,38,214,38);
        
$this->Line(1,39,214,39);
        
//Salto de línea
        
$this->Ln(10);
        
$this->SetY(45);
    }

    
//Pie de página
    
function Footer()
    {
      
      
//Posición: a 1,5 cm del final
        
$this->SetY(-15);
        
//Arial italic 8
        
$this->SetFont('Arial','I',7);
        
//Número de página
        
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
      
$fechadate("Y-m-d");
       
$hora=date("H:i:s");
      
$this->Line(1,266,214,266);
      
$this->Line(1,273,214,273);
      
$fechadate("Y-m-d");
       
$hora=date("H:i:s");
       
$this->Text(10,270.5,$fecha);
        
$this->Text(30,270.5,$hora);
        
$this->Text(148,270.5,$this->f_ini);
        
$this->Text(180,270.5,$this->f_fin);
    }

    function 
__construct()
    {       
        
//Llama al constructor de su clase Padre.
        //Modificar aka segun la forma del papel del reporte
        
parent::__construct('P','mm','Letter');
    }
}

    
//Creación del objeto de la clase heredada
    
$pdf=new PDF();
    
$pdf->SetTopMargin(5.4);
    
$pdf->SetLeftMargin(4.5);    
    
$pdf->AliasNbPages();
    
$pdf->SetFont('Times','',7);

$cadconex="dbname=sspa host=localhost port=5432 user=postgres password=0000";
$conexion pg_connect($cadconex);
 


        
$cadbusca "select nombre, apellido, gerencia, cargo from empleados";
            
$result=pg_query($cadbusca) or die('La consulta fallo: ' pg_last_error());

        
$j=1;
    
$pdf->AddPage();    
        
         while(
$row pg_fetch_array($result))
        {
          
$name $row["nombre"];            
          
$apellidos $row["apellidos"];
          
$gerencia $row["gerencia"];
          
$cargo $row["cargo"];

          
$pdf->Text(12,$pdf->GetY(),($j));
          
$pdf->Text(22,$pdf->GetY(),$name);
          
$pdf->Text(40,$pdf->GetY(),$apellidos);
          
$pdf->Text(80,$pdf->GetY(),$gerencia);
          
$pdf->Text(120,$pdf->GetY(),$cargo);
          
$pdf->cell(0,5.5,'',0,1);
        
$j=$j+1;
        }
           
$pdf->cell(0,8,'',0,1);
                 
$pdf->Text(30,$pdf->GetY(),'Nombre');
           
$pdf->Text(115,$pdf->GetY(),'Fecha');
           
$pdf->Text(160,$pdf->GetY(),'Firma');
           
$pdf->cell(0,5,'',0,1);
           
$pdf->Text(15,$pdf->GetY(),'_________________________________________');
           
$pdf->Text(100,$pdf->GetY(),'________________________');
           
$pdf->Text(145,$pdf->GetY(),'________________________');
    
$pdf->Output();    
?>