Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/03/2012, 18:52
pereza_2008
 
Fecha de Ingreso: noviembre-2010
Ubicación: Concordia
Mensajes: 95
Antigüedad: 13 años, 5 meses
Puntos: 6
Exclamación No muestra primer producto en factura

Hola gente, mi problema es el siguiente, cuando genero el pdf desde base de datos, no muestra el primer registro, si los demas o sea que si tengo 2 productos que facturar, solo me muestra el segundo que agregue en la venta, este es mi codigo:

class PDF extends FPDF
{
var $widths;
var $aligns;
var $height;

function SetWidths($w)
{
//Set the array of column widths
$this->widths=$w;
}
function SetHeight($w)
{
//Set the array of column widths
$this->height(90);
}
function SetAligns($a)

{

//Set the array of column alignments

$this->aligns=$a;

}
// Cabecera de página
function Header()
{
global $row_Datoscompra;
// Logo
$this->Rect(10, 15, 190, 265, "I");
$this->Image('images/logo.png',15,18,75);
$this->AddFont('Lucida',"B",'LucidaSansUnicode.php');
$this->SetFont('Lucida','B',10);
$this->Text(14,47, "Cliente: ");
$this->Text(14,53, "Domicilio: ");
$this->Text(14,59, utf8_decode("Teléfono: "));

$this->Text(152, 33, "Concordia, ");
$this->Text (155, 28, utf8_decode("Comprobante Nº"));

$this->Text(12, 72, "Cantidad");
$this->Text(33, 72, "Producto");
$this->Text(151, 72, "Precio Unit.");
$this->Text(185, 72, "Total");


$this->Line(10, 37, 200,37);//linea abajo de logo
$this->Line(10, 65, 200,65);//linea abajo de datos del cliente

$this->SetFont('Lucida','B',10);
$this->Text(32, 47, utf8_decode(ObtenerNombreCliente($row_Datoscompra['idCliente'])));
$this->Text(32, 53, ObtenerDireccionCliente($row_Datoscompra['idCliente']));
$this->Text(32, 59, ObtenerTelefonoCliente($row_Datoscompra['idCliente']));


$this->Text(171, 33, strftime("%d / %m / %Y", strtotime($row_Datoscompra['fchCompra'])));
$this->Text(190, 28, $row_Datoscompra['idCompra']);

}

function Footer()
{
global $row_Datoscompra;
global $saldo;
// Pie de página
$this->AddFont('Lucida',"B",'LucidaSansUnicode.php');
$this->Line(10, 222, 200,222);//linea del total
$this->SetFont('Lucida','B',10);

$this->Text(177,228, "$".number_format($row_Datoscompra['dblTotal'], 2, ',', '.'));
$this->AddFont('Lucida',"B",'LucidaSansUnicode.php');
$this->SetFont('Lucida','B',10);
$this->Text (155, 228, "Total: ");
$saldo=$row_Datoscompra['dblPago']-$row_Datoscompra['dblTotal'];

$this->Line(10, 252, 200,252);//linea arriba de el footer
$this->AddFont('Lucida',"I",'LucidaSansUnicode.php');
$this->SetFont('Lucida','I',10);
$this->Text (12, 228, "Forma de Pago: ");
$this->Text(43, 228, TextoFormaPago($row_Datoscompra['intTipopago']));

$this->Line(10, 230, 200,230);//linea del total

$this->Text (12, 235, "Detalle de Pago: ");
$this->Text (43, 242, "SALDO: $");
$this->Text (59, 242, $saldo);

$this->Text(43, 235, strftime("%d/%m/%Y", strtotime($row_Datoscompra['fchCompra'])));
$this->Text (67, 235, "$");
$this->Text(70, 235, number_format($row_Datoscompra['dblPago'], 2, ',', '.'));


$this->SetY(-45);
$this->AddFont('Lucida',"B",'LucidaSansUnicode.php');
$this->SetFont('Lucida','B',10);
$this->SetTextColor(0);
$this->Cell(0,10,'Avellaneda 968 - Concordia - Entre Rios - Argentina',0,0,'C');$this->SetY(-40);
$this->SetFont('Lucida','',10);
$this->SetTextColor(0);
$this->Cell(0,10,'Tel.: (0345) 421 - 6628 / (0345) 154-175286',0,0,'C');
$this->SetY(-35);
$this->SetFont('Lucida','',10);
$this->SetTextColor(0);
$this->Cell(0,10,'Email.: [email protected] / MSN: [email protected]',0,0,'C');
$this->SetY(-30);
$this->SetFont('Lucida','B',13);
$this->SetTextColor(0);
$this->Cell(0,10,'www.eluniversopc.com.ar',0,0,'C');
}

function Row($data)
{
//Calculate the height of the row
$nb=0;
for($i=0;$i<count($data);$i++)
$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
$h=5*$nb;
//Issue a page break first if needed
$this->CheckPageBreak($h);
//Draw the cells of the row
for($i=0;$i<count($data);$i++)
{
$w=$this->widths[$i];

$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
//Save the current position
$x=$this->GetX();
$y=$this->GetY();
//Draw the border

$this->Rect($x,$y,0,0);

$this->MultiCell($w,5,$data[$i],0,$a,'true');
//Put the position to the right of the cell
$this->SetXY($x+$w,$y);
}
//Go to the next line
$this->Ln($h);
}
function NbLines($w,$txt)
{
//Computes the number of lines a MultiCell of width w will take
$cw=&$this->CurrentFont['cw'];
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
$s=str_replace("\r",'',$txt);
$nb=strlen($s);
if($nb>0 and $s[$nb-1]=="\n")
$nb--;
$sep=-1;
$i=0;
$j=0;
$l=0;
$nl=1;
while($i<$nb)
{
$c=$s[$i];
if($c=="\n")
{
$i++;
$sep=-1;
$j=$i;
$l=0;
$nl++;
continue;
}
if($c==' ')
$sep=$i;
$l+=$cw[$c];
if($l>$wmax)
{
if($sep==-1)
{
if($i==$j)
$i++;
}
else
$i=$sep+1;
$sep=-1;
$j=$i;
$l=0;
$nl++;
}
else
$i++;
}
return $nl;
}
function CheckPageBreak($h)
{
//If the height h would cause an overflow, add a new page immediately
if($this->GetY()+$h>$this->PageBreakTrigger)
$this->AddPage($this->CurOrientation);
}

}
$pdf=new PDF('P','mm','A4');

//require('fpdf/makefont/makefont.php');

//MakeFont('c:\\xampp\\htdocs\\sistema\\fpdf\\font\\ l_10646.ttf','cp1252');


$pdf->AddPage();
$pdf->SetLeftMargin(17);
$pdf->SetRightMargin(20);
$pdf->SetTopMargin (75);
$pdf->SetAutoPageBreak(0, 75);
$pdf->AddFont('Lucida',"",'LucidaSansUnicode.php');
// title and logo
$pdf->SetFont('Lucida','',30);
$pdf->Text(70,16,'');
$pdf->SetFont('Lucida','B',60);
$pdf->Text(70,40,'');

// draws the box and labels
$pdf->SetFillColor(204, 204, 204);
$box_top = 15; // the Y parameter of the top of the grey box

$pdf->SetFont('Lucida','',10);

$pdf->SetY(75);
while ($row_ProductosCompra = mysql_fetch_assoc($ProductosCompra))
{

$pdf->SetX(17);
$pdf->AddFont('Lucida',"",'LucidaSansUnicode.php');
$pdf->SetFillColor(255,255,255);
$total=number_format($row_ProductosCompra['intCantidad']*$row_ProductosCompra['dblPrecio'], 2, ',', '.');
$pdf->SetFont('Lucida','',9);
$pdf->SetAligns(array('L','L','R','R'));
$pdf->SetWidths(array(15, 119, 19,24));

$pdf->Row(array($row_ProductosCompra['intCantidad'], $row_ProductosCompra['strNombre'], number_format($row_ProductosCompra['dblPrecio'], 2, ',', '.'), $total));

}
@mysql_free_result($ProductosCompra);