Foros del Web » Programando para Internet » PHP »

problemas con reportes en pdf

Estas en el tema de problemas con reportes en pdf en el foro de PHP en Foros del Web. Bueno de nuevo yo otra vez por acá, mi duda es la sgt: yo realizo la consulta y hago un reporte(pdf), el cual queda de ...
  #1 (permalink)  
Antiguo 19/08/2011, 12:48
 
Fecha de Ingreso: agosto-2006
Mensajes: 56
Antigüedad: 17 años, 7 meses
Puntos: 0
Información problemas con reportes en pdf

Bueno de nuevo yo otra vez por acá, mi duda es la sgt:
yo realizo la consulta y hago un reporte(pdf), el cual queda de la sgt manera:CODIGO NIV PNom P ape S APE Concepto
20032042 1 MATEO RODRIGUEZ DEL VALLE actividades bachillerato 500000
20032042 1 MATEO RODRIGUEZ DEL VALLE Pension 1000000
20032042 1 MATEO RODRIGUEZ DEL VALLE otros 1050000
20042089 1 DANIEL OTERO GOMEZ actividades bachillerato 500000
20042089 1 DANIEL OTERO GOMEZ Pension 1000000 20042089 1 DANIEL OTERO GOMEZ otros 1050000
20052015 1 JORGE LUIS GUTIERREZ TRONCOSO actividades bachil 500000
20052015 1 JORGE LUIS GUTIERREZ TRONCOSO Pension 1000000
20052015 1 JORGE LUIS GUTIERREZ TRONCOSO otros 1050000

entonces lo que yo quiero es hacer lo sgt:
CODIGO NIV PNom P ape S APE Concepto
20032042 1 MATEO RODRIGUEZ DEL VALLE actividades bachillerato 500000
20032042 1 MATEO RODRIGUEZ DEL VALLE Pension 1000000
20032042 1 MATEO RODRIGUEZ DEL VALLE otros 1050000
subtotal****************************************** ******* 2550000

20042089 1 DANIEL OTERO GOMEZ actividades bachillerato 500000
20042089 1 DANIEL OTERO GOMEZ Pension 1000000 20042089 1 DANIEL OTERO GOMEZ otros 1050000
subtotal****************************************** ******* 2550000

20052015 1 JORGE LUIS GUTIERREZ TRONCOSO actividades bachil 500000
20052015 1 JORGE LUIS GUTIERREZ TRONCOSO Pension 1000000
20052015 1 JORGE LUIS GUTIERREZ TRONCOSO otros 1050000
subtotal****************************************** ******* 2550000

total pension******************************************* ** 3000000

total actividades bachillerato*********************************15000 00

total otros********************************************* **3150000

total********************************************* *******7650000

lo debo hacer en php, el código que tengo hasta ahora es este
$sql="SELECT facPreli.preCodEst, facPreli.preValor, nucEstu.estPriNom, nucEstu.estSegNom, nucEstu.estPriApe, nucEstu.estSegApe, facConcep.conDescrip,
facPreli.prePerCau



FROM facPreli INNER JOIN
nucEstu ON facPreli.preCodEst = nucEstu.estCod INNER JOIN
facConcep ON facPreli.preCodCon = facConcep.conCodigo
GROUP BY nucEstu.estSegNom, facPreli.preCodEst, facPreli.preValor, nucEstu.estPriNom, nucEstu.estPriApe, nucEstu.estSegApe, facConcep.conDescrip, facPreli.prePerCau"; //realiza la busqueda en la b.d
// ejecutamos la consulta
$rs = odbc_exec( $conexion, $sql ) or die ( "Error en la consulta SQL" );
//initialize counter
$i = 0;

//Set maximum rows per page
$max = 75;

//Set Row Height
//$row_height = 1;

while($row =odbc_fetch_array($rs))
{


//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
$y_axis=40;

//print column titles for the current page
$pdf->SetY($y_axis_initial);
$pdf->SetX(8);
$pdf->Cell(12,3,'CODIGO',1,0,'C',1);
$pdf->Cell(30,3,'PRIMER_NOMBRE',1,0,'C',1);
$pdf->Cell(30,3,'SEGUNDO_NOMBRE',1,0,'C',1);
$pdf->Cell(30,3,'PRIMER_APELLIDO',1,0,'C',1);
$pdf->Cell(30,3,'SEGUNDO_APELLIDO',1,0,'C',1);
$pdf->Cell(25,3,'PERIODO',1,0,'C',1);
$pdf->Cell(25,3,'CONCEPTO',1,0,'C',1);
$pdf->Cell(15,3,'VALOR',1,0,'C',1);


//Go to next row
$y_axis = $y_axis + $row_height;

//Set $i variable to 0 (first row)
$i = 0;
}
$Codigo=$row['preCodEst'];
$PriNomb=$row['estPriNom'];
$SegNomb=$row['estSegNom'];
$PriApe=$row['estPriApe'];
$SegApe=$row['estSegApe'];
$Periodo=$row['prePerCau'];
$Concep=$row['conDescrip'];
$Valor=$row['preValor'];


$pdf->SetY($y_axis);
$pdf->SetX(8);
$pdf->Cell(12,3,$Codigo,1,0,'L');
$pdf->Cell(30,3,$PriNomb,1,0,'L');
$pdf->Cell(30,3,$SegNomb,1,0,'L');
$pdf->Cell(30,3,$PriApe,1,0,'L');
$pdf->Cell(30,3,$SegApe,1,0,'L');
$pdf->Cell(25,3,$Periodo,1,0,'C');
$pdf->Cell(25,3,$Concep,1,0,'C');
$pdf->Cell(15,3,$Valor,1,0,'R');

//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
  #2 (permalink)  
Antiguo 23/08/2011, 06:47
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: problemas con reportes en pdf

Antes de entrar en en while, inicializas unos contadores a 0, por cada concepto que quieras sumar:
Código PHP:
Ver original
  1. $total_bachillerato = 0;
  2. $total_pension = 0;
  3. $total_otros = 0;
etc..
Dentro del While, si concepto = "otros", entonces acumulas el valor de la variable $valor:

Código PHP:
Ver original
  1. $total_otros += $valor;

Saludos,
__________________
Fere libenter homines, id quod volunt, credunt.

Etiquetas: pdf, reportes, sql, variables
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 19:17.