Re: Pdf - R&os Cita:
Iniciado por GatorV Amigo, necesitas realmente ponerte a ver el codigo y lo que estas haciendo, necesitas incluir todo el codigo completo no solo partes, si no sabes de PHP te recomiendo que primero leas un poco el manual, y algunos tutoriales antes de ponerte a picarle.[/. solo queria una codigo de copy&paste para ver q tal generaba una consulta de bastantes resultados... la verdad q solo me conecte a la pagina de fpdf para descargarme la clase pero bueno.. ya me mirare esta clase cuando tenga tiempo.
Yo he usado la de R&OS como he puesto en el titulo... pero me he encontrado con alguna limitacion y queria probar con otra a ver q tal iba.
se agradece igualmente!
PD. llevo 2 años aficionandome al PHP, pero por falta de tiempo no he podido ponerme al 100% con los manuales, y tal pero ya tengo hecho mis pinitos... etc etc etc
con un poco de lectura y tiempo se conseigue.
x si alguien le sirve... Código PHP: <?php
require("../../aut_verifica.inc.php");
error_reporting(E_ALL);
define('FPDF_FONTPATH','../funcions/font/');
include('../funcions/fpdf.php');
/*******************************************************************************************/
//var per montar la clausula where segons els parametres
$WHEREHAN='';
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,1000";
$result = mysql_query($sql);
$data=array();
//Bucle para generar los datos
while($row = mysql_fetch_row($result))
{
$data[] = $row;
}
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='';
/*******************************************************************************************/
//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,1000";
$result = mysql_query($sql);
$data=array();
//Bucle para generar los datos
while($row = mysql_fetch_row($result))
{
//$data[] = $row;
//$this->Cell($w[0],6,$row['1'],'LR',0,'C',$fill);
$this->Cell($w[0],6,$row['1'],'LR',0,'C',$fill);
$this->Cell($w[1],6,$row['2'],'LR',0,'C',$fill);
$this->Cell($w[2],6,$row['3'],'LR',0,'C',$fill);
$this->Cell($w[3],6,$row['4'],'LR',0,'C',$fill);
$this->Cell($w[4],6,$row['5'],'LR',0,'C',$fill);
$this->Cell($w[5],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();
?> saludos y gracias por vuestra paciencia para uno sin tiempo
__________________ "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; 18/04/2007 a las 01:08 |