sumar registros en reportes PDF
Publicado por zendi (1058 intervenciones) el 01/10/2010 21:40:11
ESTOY DESARROLLANDO UN SCRIPT PARA UN REPORTE DE GASTOS Y QUISIERA SABER COMO PUEDO SUMAR LOS REGISTROS HE PROBADO MUCHAS MANERAS UNA DE ELLAS ES CON $totalmonto +=$monto; PERO NO LO HACE LES AGRADEZCO LA AYUDA AQUI ESTA EL CODIGO
<?php
$conexion = pg_connect("host=localhost port=5432 dbname=administracion user=postgres password=bochi");
//define('./PDF/font/');
require('WriteTag.php');
$recibos = "SELECT * FROM vrecibo";
class PDF extends PDF_WriteTag
{
//Cabecera de página
function Header()
{
$this->Image('./imagenes/dibujo.JPG',55,10,100,20);
//Select Arial bold 15
$this->SetFont('Arial','B',15);
$this->Ln(25);
//Move to the right
$this->Cell(80);
//Framed title
$this->Cell(30,10,'Rxxxxx',1,0,'C');
$this->SetFont('Arial','B',8);
$this->Cell(95, 5, 'Fecha: '.date('d/m/Y'), 0, 0, 'R');
//Line break
$this->Ln(40);
$this->SetFont('Arial','B',8);
}
//Pie de página
function Footer()
{
//Posición: a 1,5 cm del final
$this->SetY(-12);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Número de página
$this->Cell(0,10,'Pag '.$this->PageNo(),0,0,'C');
}
}//--Fin de la Clase
//Creación del objeto de la clase heredada
$pdf=new PDF('P','mm','Letter');
//$pdf->Ln(20);
$nroapto = '';
$totalmonto = 0;
$seleccionados = @pg_query($conexion,$recibos);
while($select2 = @pg_fetch_array($seleccionados)):
$nombres = $select2['nombres'];
$monto = $select2['monto'];
if ($select2['nroapto']!=$nroapto){
$pdf->AddPage();
$pdf->SetFont('Arial','B',8);
$pdf->Cell(20,4,'Cédula:');
$pdf->Cell(26,4,$select2['cedula'],0,1,'R');
$pdf->Cell(20,4,'Nombres:',0);
$pdf->Cell(26,4,$nombres,0,1,'R');
$pdf->Cell(20,4,'Apellidos:',0);
$pdf->Cell(26,4,$select2['apellidos'],0,1,'R');
$pdf->Cell(20,4,'Nro Apto:',0);
$pdf->Cell(26,4,$select2['nroapto'],0,1,'R');
$pdf->Cell(20,4,'Alícuota:',0);
$pdf->Cell(26,4,$select2['alicuota'],0,1,'R');
$pdf->Line($pdf->GetX(), $pdf->GetY(), 205, $pdf->GetY());
$pdf->Ln(8);
$pdf->Cell(45,4,'Gasto',0,'C');
$pdf->Cell(90,4,'Monto',0,1,'R');
$pdf->Ln(6);
} $nroapto = $select2['nroapto'];
$pdf->SetFont('Arial','I',8);
$pdf->Cell(47,4,$select2['descripcion'],0,0,'L');
$pdf->Cell(90,4,number_format($select2['monto'],2,',','.'),0,0,'R');
$totalmonto +=$monto;
$pdf->Cell(90,4,number_format($totalmonto,2,',','.'),0,1,'R');
endwhile;
$pdf->Output();
$pdf->Close();
?>
<?php
$conexion = pg_connect("host=localhost port=5432 dbname=administracion user=postgres password=bochi");
//define('./PDF/font/');
require('WriteTag.php');
$recibos = "SELECT * FROM vrecibo";
class PDF extends PDF_WriteTag
{
//Cabecera de página
function Header()
{
$this->Image('./imagenes/dibujo.JPG',55,10,100,20);
//Select Arial bold 15
$this->SetFont('Arial','B',15);
$this->Ln(25);
//Move to the right
$this->Cell(80);
//Framed title
$this->Cell(30,10,'Rxxxxx',1,0,'C');
$this->SetFont('Arial','B',8);
$this->Cell(95, 5, 'Fecha: '.date('d/m/Y'), 0, 0, 'R');
//Line break
$this->Ln(40);
$this->SetFont('Arial','B',8);
}
//Pie de página
function Footer()
{
//Posición: a 1,5 cm del final
$this->SetY(-12);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Número de página
$this->Cell(0,10,'Pag '.$this->PageNo(),0,0,'C');
}
}//--Fin de la Clase
//Creación del objeto de la clase heredada
$pdf=new PDF('P','mm','Letter');
//$pdf->Ln(20);
$nroapto = '';
$totalmonto = 0;
$seleccionados = @pg_query($conexion,$recibos);
while($select2 = @pg_fetch_array($seleccionados)):
$nombres = $select2['nombres'];
$monto = $select2['monto'];
if ($select2['nroapto']!=$nroapto){
$pdf->AddPage();
$pdf->SetFont('Arial','B',8);
$pdf->Cell(20,4,'Cédula:');
$pdf->Cell(26,4,$select2['cedula'],0,1,'R');
$pdf->Cell(20,4,'Nombres:',0);
$pdf->Cell(26,4,$nombres,0,1,'R');
$pdf->Cell(20,4,'Apellidos:',0);
$pdf->Cell(26,4,$select2['apellidos'],0,1,'R');
$pdf->Cell(20,4,'Nro Apto:',0);
$pdf->Cell(26,4,$select2['nroapto'],0,1,'R');
$pdf->Cell(20,4,'Alícuota:',0);
$pdf->Cell(26,4,$select2['alicuota'],0,1,'R');
$pdf->Line($pdf->GetX(), $pdf->GetY(), 205, $pdf->GetY());
$pdf->Ln(8);
$pdf->Cell(45,4,'Gasto',0,'C');
$pdf->Cell(90,4,'Monto',0,1,'R');
$pdf->Ln(6);
} $nroapto = $select2['nroapto'];
$pdf->SetFont('Arial','I',8);
$pdf->Cell(47,4,$select2['descripcion'],0,0,'L');
$pdf->Cell(90,4,number_format($select2['monto'],2,',','.'),0,0,'R');
$totalmonto +=$monto;
$pdf->Cell(90,4,number_format($totalmonto,2,',','.'),0,1,'R');
endwhile;
$pdf->Output();
$pdf->Close();
?>
Valora esta pregunta


0