Foros del Web » Programando para Internet » PHP »

No muestra primer producto en factura

Estas en el tema de No muestra primer producto en factura en el foro de PHP en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 11/03/2012, 18:52
 
Fecha de Ingreso: noviembre-2010
Ubicación: Concordia
Mensajes: 95
Antigüedad: 13 años, 4 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);
  #2 (permalink)  
Antiguo 12/03/2012, 03:09
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: No muestra primer producto en factura

Postea sólo el código que te da problemas y utiliza las etiquetas de formato, saludos.
__________________
Fere libenter homines, id quod volunt, credunt.
  #3 (permalink)  
Antiguo 12/03/2012, 03:37
 
Fecha de Ingreso: noviembre-2010
Ubicación: Concordia
Mensajes: 95
Antigüedad: 13 años, 4 meses
Puntos: 6
Respuesta: No muestra primer producto en factura

Ese es el tema, funcionar anda lo mas bien, no me da error, ni muestra fallas, pero si la factura incluye 2 elementos, solo muestra uno y si es solo uno, no muestra nada

saludos
  #4 (permalink)  
Antiguo 12/03/2012, 03:50
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: No muestra primer producto en factura

Utiliza

error_reporting(E_ALL);
ini_set("display_errors", 1);

para ver los errores y quita la @ de la última linea a ver si te salen los errores. En cualquier caso el problema está en la select que no posteas.
__________________
Fere libenter homines, id quod volunt, credunt.
  #5 (permalink)  
Antiguo 12/03/2012, 07:07
 
Fecha de Ingreso: noviembre-2010
Ubicación: Concordia
Mensajes: 95
Antigüedad: 13 años, 4 meses
Puntos: 6
Respuesta: No muestra primer producto en factura

no muestra ningun tipo de error, esta es la consulta que muestra los datos del usuario y los productos:

SELECT tblproducto.strNombre, tblproducto.dblPrecio, tblcarrito.intCantidad FROM tblcarrito Inner Join tblproducto ON tblcarrito.idProducto = tblproducto.idProducto WHERE tblcarrito.intTransaccionEfectuada = %s AND tblcarrito.idUsuario = %s

en un reporte comun con php, muestra todo sin problema, podria ser la matriz definida en la funcion function Row($data)??
  #6 (permalink)  
Antiguo 12/03/2012, 07:12
Avatar de Nano_  
Fecha de Ingreso: febrero-2006
Ubicación: Bogotá, Colombia
Mensajes: 1.866
Antigüedad: 18 años, 2 meses
Puntos: 96
Respuesta: No muestra primer producto en factura

Saludos!

Que es $ProductosCompra?
__________________
:.:Nano.:: @nano_hard - Retornando al foro
  #7 (permalink)  
Antiguo 12/03/2012, 07:15
 
Fecha de Ingreso: noviembre-2010
Ubicación: Concordia
Mensajes: 95
Antigüedad: 13 años, 4 meses
Puntos: 6
Respuesta: No muestra primer producto en factura

es la consulta que me muestra la cantidad de productos, nombre y precio
  #8 (permalink)  
Antiguo 12/03/2012, 07:33
 
Fecha de Ingreso: noviembre-2010
Ubicación: Concordia
Mensajes: 95
Antigüedad: 13 años, 4 meses
Puntos: 6
Respuesta: No muestra primer producto en factura

puede ser que el problema este el el while? porque se lo quite y ahi si me muestra ese primer producto
  #9 (permalink)  
Antiguo 12/03/2012, 07:48
 
Fecha de Ingreso: noviembre-2010
Ubicación: Concordia
Mensajes: 95
Antigüedad: 13 años, 4 meses
Puntos: 6
Respuesta: No muestra primer producto en factura

Amigos ya encontre el problema, no era un while, era un do-while, saludos y gracias

Etiquetas: factura, muestra, mysql, primer, producto, registro
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 13:56.