Foros del Web » Programando para Internet » PHP »

FPDF mysql php

Estas en el tema de FPDF mysql php en el foro de PHP en Foros del Web. Saludos, tengo una duda estoy realizando un reporte don los datos deben estar agrupados y ni idea Este es mi Query SELECT clientes.nombre_fantasia, contactos.nombre FROM ...
  #1 (permalink)  
Antiguo 12/01/2016, 14:55
 
Fecha de Ingreso: agosto-2012
Ubicación: Caracas
Mensajes: 14
Antigüedad: 11 años, 8 meses
Puntos: 0
FPDF mysql php

Saludos, tengo una duda estoy realizando un reporte don los datos deben estar agrupados
y ni idea

Este es mi Query

SELECT
clientes.nombre_fantasia,
contactos.nombre
FROM
clientes
INNER JOIN contactos ON contactos.cliente_rut = clientes.rut
GROUP BY
clientes.rut,
contactos.nombre
ORDER BY nombre_fantasia

Mi salida

ACHX Laura
ACHX Jose
Adidas Andres

Que Necesito hacer

Nombre Empresa: ACHX
Laura
Jose
Nombre Empresa: Adidas
Andres

Código PHP:
<?php
require('fpdf/fpdf.php');

class 
PDF extends FPDF
{

    function 
cabeceraHorizontal($cabecera)
    {
        
$this->SetXY(1010);
        
$this->SetFont('Arial','B',10);
        
$this->SetFillColor(0,102,204);//Fondo verde de celda
        
$this->SetTextColor(240255240); //Letra color blanco
        
$ejeX 10;
        foreach(
$cabecera as $fila)
        {
            
$this->RoundedRect($ejeX104072'FD');
            
$this->CellFitSpace(40,7utf8_decode($fila),0'C');
            
$ejeX $ejeX 40;
        }
    }

    function 
datosHorizontal($datos)
    {
        
$this->SetXY(10,17);
        
$this->SetFont('Arial','',10);
        
$this->SetFillColor(229229229); //Gris tenue de cada fila
        
$this->SetTextColor(333); //Color del texto: Negro
        
$bandera false//Para alternar el relleno
        
$ejeY 17//AquÃ* se encuentra la primer CellFitSpace e irá incrementando
        
$letra 'D'//'D' Dibuja borde de cada CellFitSpace -- 'FD' Dibuja borde y rellena
        
foreach($datos as $fila)
        {
            
//Por cada 3 CellFitSpace se crea un RoundedRect encimado
            //El parámetro $letra de RoundedRect cambiará en cada iteración
            //para colocar FD y D, la primera iteración es D
            //Solo la celda de enmedio llevará bordes, izquierda y derecha
            //Las celdas laterales colocarlas sin borde

            //$this->CellFitSpace(40,7, utf8_decode($fila['id_user']),0, 0 , 'L' );
            
$this->CellFitSpace(40,7utf8_decode($fila['nombre_fantasia']),0'L' );
            
$this->CellFitSpace(40,7utf8_decode($fila['nombre']),'LR''L' );
                      
            
$this->Ln();
            
//Condición ternaria que cambia el valor de $letra
            
($letra == 'D') ? $letra 'FD' $letra 'D';
            
//Aumenta la siguiente posición de Y (recordar que X es fijo)
            //Se suma 7 porque cada celda tiene esa altura
            
$ejeY $ejeY 7;
        }
    }

    function 
tablaHorizontal($cabeceraHorizontal$datosHorizontal)
    {
        
$this->cabeceraHorizontal($cabeceraHorizontal);
        
$this->datosHorizontal($datosHorizontal);
    }

    
//**************************************************************************************************************
    
function CellFit($w$h=0$txt=''$border=0$ln=0$align=''$fill=false$link=''$scale=false$force=true)
    {
        
//Get string width
        
$str_width=$this->GetStringWidth($txt);

        
//Calculate ratio to fit cell
        
if($w==0)
            
$w $this->w-$this->rMargin-$this->x;
        
$ratio = ($w-$this->cMargin*2)/$str_width;

        
$fit = ($ratio || ($ratio && $force));
        if (
$fit)
        {
            if (
$scale)
            {
                
//Calculate horizontal scaling
                
$horiz_scale=$ratio*100.0;
                
//Set horizontal scaling
                
$this->_out(sprintf('BT %.2F Tz ET',$horiz_scale));
            }
            else
            {
                
//Calculate character spacing in points
                
$char_space=($w-$this->cMargin*2-$str_width)/max($this->MBGetStringLength($txt)-1,1)*$this->k;
                
//Set character spacing
                
$this->_out(sprintf('BT %.2F Tc ET',$char_space));
            }
            
//Override user alignment (since text will fill up cell)
            
$align='';
        }

        
//Pass on to Cell method
        
$this->Cell($w,$h,$txt,$border,$ln,$align,$fill,$link);

        
//Reset character spacing/horizontal scaling
        
if ($fit)
            
$this->_out('BT '.($scale '100 Tz' '0 Tc').' ET');
    }

    function 
CellFitSpace($w$h=0$txt=''$border=0$ln=0$align=''$fill=false$link='')
    {
        
$this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,false,false);
    }

    
//Patch to also work with CJK double-byte text
    
function MBGetStringLength($s)
    {
        if(
$this->CurrentFont['type']=='Type0')
        {
            
$len 0;
            
$nbbytes strlen($s);
            for (
$i 0$i $nbbytes$i++)
            {
                if (
ord($s[$i])<128)
                    
$len++;
                else
                {
                    
$len++;
                    
$i++;
                }
            }
            return 
$len;
        }
        else
            return 
strlen($s);
    }
//**********************************************************************************************

 
function RoundedRect($x$y$w$h$r$style ''$angle '1234')
    {
        
$k $this->k;
        
$hp $this->h;
        if(
$style=='F')
            
$op='f';
        elseif(
$style=='FD' or $style=='DF')
            
$op='B';
        else
            
$op='S';
        
$MyArc 4/* (sqrt(2) - 1);
        
$this->_out(sprintf('%.2f %.2f m', ($x+$r)*$k, ($hp-$y)*$k ));

        
$xc $x+$w-$r;
        
$yc $y+$r;
        
$this->_out(sprintf('%.2f %.2f l'$xc*$k, ($hp-$y)*$k ));
        if (
strpos($angle'2')===false)
            
$this->_out(sprintf('%.2f %.2f l', ($x+$w)*$k, ($hp-$y)*$k ));
        else
            
$this->_Arc($xc $r*$MyArc$yc $r$xc $r$yc $r*$MyArc$xc $r$yc);

        
$xc $x+$w-$r;
        
$yc $y+$h-$r;
        
$this->_out(sprintf('%.2f %.2f l', ($x+$w)*$k, ($hp-$yc)*$k));
        if (
strpos($angle'3')===false)
            
$this->_out(sprintf('%.2f %.2f l', ($x+$w)*$k, ($hp-($y+$h))*$k));
        else
            
$this->_Arc($xc $r$yc $r*$MyArc$xc $r*$MyArc$yc $r$xc$yc $r);

        
$xc $x+$r;
        
$yc $y+$h-$r;
        
$this->_out(sprintf('%.2f %.2f l'$xc*$k, ($hp-($y+$h))*$k));
        if (
strpos($angle'4')===false)
            
$this->_out(sprintf('%.2f %.2f l', ($x)*$k, ($hp-($y+$h))*$k));
        else
            
$this->_Arc($xc $r*$MyArc$yc $r$xc $r$yc $r*$MyArc$xc $r$yc);

        
$xc $x+$r ;
        
$yc $y+$r;
        
$this->_out(sprintf('%.2f %.2f l', ($x)*$k, ($hp-$yc)*$k ));
        if (
strpos($angle'1')===false)
        {
            
$this->_out(sprintf('%.2f %.2f l', ($x)*$k, ($hp-$y)*$k ));
            
$this->_out(sprintf('%.2f %.2f l', ($x+$r)*$k, ($hp-$y)*$k ));
        }
        else
            
$this->_Arc($xc $r$yc $r*$MyArc$xc $r*$MyArc$yc $r$xc$yc $r);
        
$this->_out($op);
    }

    function 
_Arc($x1$y1$x2$y2$x3$y3)
    {
        
$h $this->h;
        
$this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c '$x1*$this->k, ($h-$y1)*$this->k,
            
$x2*$this->k, ($h-$y2)*$this->k$x3*$this->k, ($h-$y3)*$this->k));
    }
// FIN Class PDF
?>
agradezco su ayuda
  #2 (permalink)  
Antiguo 03/05/2016, 12:44
 
Fecha de Ingreso: abril-2016
Mensajes: 65
Antigüedad: 8 años
Puntos: 4
Respuesta: FPDF mysql php

Amigo pudiste resolver este tema?

Etiquetas: fpdf, mysql, select, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:44.