Tema: Pdf - R&os
Ver Mensaje Individual
  #6 (permalink)  
Antiguo 13/04/2007, 04:50
sergi_climent
 
Fecha de Ingreso: enero-2005
Ubicación: Barcelona
Mensajes: 1.473
Antigüedad: 19 años, 3 meses
Puntos: 10
Re: Pdf - R&os

he copiado el codigo tal cual pero he hecho algunos cambios para adaptarlo a mi BD y a mis campos. el codigo es el siguiente:
Código PHP:
<?php 
require("../../aut_verifica.inc.php"); 
error_reporting(E_ALL);
define('FPDF_FONTPATH','../funcions/font/');
include(
'../funcions/fpdf.php'); 
class 
PDF extends FPDF
{
    function 
PDF($orientation='l',$unit='mm',$format='A4')
    {    
    
//Llama al constructor de la clase padre
    
$this->FPDF($orientation,$unit,$format);
    
//Iniciacin de variables
    
$this->B=0;
    
$this->I=0;
    
$this->U=0;
    }

    function 
Header()
    {
    
//Logo
    //$this->Image('../imagenes/logo.png',5,8,33);
    //Arial bold 15
    
$this->SetFont('Arial','B',15);
    
//Movernos a la derecha
    
$this->Cell(80);
    
//T tulo
    
$this->Cell(80,10,'Detalle de la tabla tbl_pruebas',1,0,'C');
    
//Salto de línea
    
$this->Ln(15);
    }

    
//Pie de página
    
function Footer()
    {
    
//Posicin: a 1,5 cm del final
    
$this->SetY(-15);
    
//Arial italic 8
    
$this->SetFont('Arial','I',8);
    
//Número de pgina
    
$this->Cell(0,10,'Pagina '.$this->PageNo().'/{nb}',0,0,'C');
    }

    
//colorear la tabla    y cargar datos
    
function FancyTable($header,$data)
    {
    
//Colores, ancho de línea y fuente en negrita
    
$this->SetFillColor(255,0,0);
    
$this->SetTextColor(255);
    
$this->SetDrawColor(128,0,0);
    
$this->SetLineWidth(.3);
    
$this->SetFont('','B');
    
//Cabecera
    
$w=array(20,20,20,20,20,160);    
    for(
$i=0;$i<count($header);$i++)
        
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
    
$this->Ln();
    
//Restauración de colores y fuentes
    
$this->SetFillColor(224,235,255);
    
$this->SetTextColor(0);
    
$this->SetFont('');
    
//Datos
    
$fill=0;

    
/*******************************************************************************************/
    //var per montar la clausula where segons els parametres
    
$WHEREHAN='';
    
//var per pasar les dades per la url
    
$ur='';
    function 
FWhere($w) {
        return (
$w == '') ? ' WHERE ' "$w AND ";
    }
    
/*******************************************************************************************/
    //Recollim les variables del Formulari de busqueda
    
if (isset($_GET['id_localitat']) && ($_GET['id_localitat'] != 0)) {
        
$WHEREHAN Fwhere($WHEREHAN) . " id_localitat = $_GET[id_localitat]";
    }
    if (isset(
$_GET['id_seccio']) && ($_GET['id_seccio'] != 0)) {
        
$WHEREHAN Fwhere($WHEREHAN) . " id_seccio = $_GET[id_seccio]";
    }
    if (isset(
$_GET['ref_activitat']) && ($_GET['ref_activitat'] != '')) {
        
$WHEREHAN Fwhere($WHEREHAN) . " ref_averia LIKE '$_GET[ref_activitat]%'";
    }
    if (isset(
$_GET['id_maquina']) && ($_GET['id_maquina'] != 0)) {
        
$WHEREHAN Fwhere($WHEREHAN) . " id_maquina LIKE '$_GET[id_maquina]%'";
    }
    if (isset(
$_GET['data_desde']) && ($_GET['data_desde'] != '')) {
        
$data_desde=giradata($_GET[data_desde]);
        
$WHEREHAN Fwhere($WHEREHAN) . " data_avis >= '$data_desde'";
    }
    if (isset(
$_GET['data_fins']) && ($_GET['data_fins'] != '')){ 
        
$data_fins=giradata($_GET[data_fins]);
        
$WHEREHAN Fwhere($WHEREHAN) . " data_avis <= '$data_fins'";    
    }
    if (isset(
$_GET['prioritat']) && ($_GET['prioritat'] != 0)) {
        
$WHEREHAN Fwhere($WHEREHAN) . " prioritat = '$_POST[prioritat]'";
    }
    
    if (isset(
$_GET['tipus_maquina']) && ($_GET['tipus_maquina'] != 0)) {
        
$WHEREHAN Fwhere($WHEREHAN) . " tipus_maq = '$_GET[tipus_maquina]'";
    }    
    
$Sql "SELECT id_activitat, ref_activitat, id_maquina, id_localitat, 
            id_seccio, data_avis, descripcio
            FROM activitats $WHEREHAN ORDER BY data_avis DESC
            LIMIT 0,100"
;
    
$Query mysql_query($Sql);
    
    
//Bucle para generar los datos
    
while($row mysql_fetch_row($Query))
        {
        
//$this->Cell($w[0],6,$row['1'],'LR',0,'C',$fill);
        
$this->Cell($w[1],6,$row['1'],'LR',0,'C',$fill);
        
$this->Cell($w[2],6,$row['2'],'LR',0,'C',$fill);
        
$this->Cell($w[3],6,$row['3'],'LR',0,'C',$fill);
        
$this->Cell($w[4],6,$row['4'],'LR',0,'C',$fill);
        
$this->Cell($w[5],6,$row['5'],'LR',0,'C',$fill);
        
$this->Cell($w[6],6,$row['6'],'LR',0,'L',$fill);        
        
$this->Ln();
        
$fill=!$fill;
        
        
//contador de línea para establecer líneas por página y cabecera
        
$cuenta =0;
        if(
$cuenta == 25)
            {
            
$this->Cell(array_sum($w),0,'','T');
            
$this->Ln();
            
$this->AddPage();
            
$this->SetFillColor(255,0,0);
            
$this->SetTextColor(255);
            
$this->SetDrawColor(128,0,0);
            
$this->SetLineWidth(.3);
            
$this->SetFont('','B');
            
//Cabecera
            
$w=array(20,20,20,20,20,160);    
            for(
$i=0;$i<count($header);$i++)
                 
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
                
$this->Ln();
                
$cuenta 0;
            
//Restauración de colores y fuentes
            
$this->SetFillColor(224,235,255);
            
$this->SetTextColor(0);
            
$this->SetFont('');
            }
        
        }    
    
$this->Cell(array_sum($w),0,'','T');
    }

}
//==============================================================

//Iniciar documento PDF
$pdf=new PDF();
$pdf->AliasNbPages();
//Titulos de las columnas
$header=array('Ref.Averia','Maquina','Localidd','Seccion','Fecha','Descripcion');
$pdf->SetFont('Arial','',10);
$pdf->AddPage();
$pdf->FancyTable($header,$data);
$pdf->Output();
me lanza dos errores:
Notice: Undefined variable: data in C:\Archivos de programa\Apache Group\Apache2\htdocs\CONTROLMAQUINES\maquines\acti vitat\pdf_activitats.php on line 164

donde se declara Data? donde se le asignan los valore s data? no he sido capaz de verlo/encontrarlo...

Warning: Cannot modify header information - headers already sent by (output started at C:\Archivos de programa\Apache Group\Apache2\htdocs\CONTROLMAQUINES\maquines\acti vitat\pdf_activitats.php:164) in C:\Archivos de programa\Apache Group\Apache2\htdocs\CONTROLMAQUINES\maquines\func ions\fpdf.php on line 1022
FPDF error: Some data has already been output to browser, can't send PDF file

este ya estoy al caso... a ver si areglando el 1ero se arregla el segundo... q es lo mas posible!

Gracias de antemano!

saludos
__________________
"Cada hombre es el hijo de su propio trabajo"
Miguel de Cervantes Saavedra
"La experiencia es algo que no consigues hasta justo depués de necesitarla"
Laurence Olivier

Última edición por sergi_climent; 13/04/2007 a las 05:10