• Martes 16 de Abril de 2024, 07:34

Autor Tema:  FPDF y registros (tipo factura) en una sola hoja  (Leído 4649 veces)

Richardtextex

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
FPDF y registros (tipo factura) en una sola hoja
« en: Sábado 18 de Noviembre de 2017, 23:40 »
0
Hola a todos. Estoy desarrollando un sistema de ventas para una empresa de venta de confites. Lo que busco es que el reporte que sale en una impresora termica (tipo ticket) sea en una sola hoja. Al imprimir muchos productos estos me salen en varias hojas y yo quiero que salgan en una sola. como se hace esto, alguna ayuda porfis ya que he perdido un mes con este problema.

este es mi codigo:

<?php
require('../ventas/fpdf/fpdf.php');


$pdf = new fpdf();
//$pdf = new PDF_AutoPrint();
$pdf->AddPage();
$pdf->SetFont('Arial','B',28);


$meses = array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
$fecha = date('d')." de ".$meses[date('n')-1]. " del ".date('Y');
                     session_start();
                  $paso=$_SESSION['nboleta'];
                  $a=$_SESSION['usuario'];
                        $b=$_SESSION['clave'];

$link = mysql_connect("localhost", "exgolosi_rcp", "Richard7133");
mysql_select_db("exgolosi_exgolosin",$link);


$vendedor=mysql_query("select * from empleados where rut=$a  and claveacceso = $b",$link);
if ($fila=mysql_fetch_array($vendedor))
            {
            $usuario=$fila["nombres"];
                }


$resultado2 = mysql_query("select clientes.rutcli, clientes.nombres, clientes.giro, clientes.direccion, clientes.telefonofijo, productos.codprod, detalle, cantidad, precioventa, nota_venta.neto, impuesto_adicional, notaventa_producto.descuento, notaventa_producto.total FROM boleta, clientes_boleta, clientes, nos_boletaventa, nota_venta, notaventa_producto, productos WHERE clientes.rutcli=clientes_boleta.rutcli AND clientes_boleta.n_boleta=boleta.n_boleta AND boleta.n_boleta=nos_boletaventa.n_boleta AND nos_boletaventa.n_nota=nota_venta.n_nota AND nota_venta.n_nota=notaventa_producto.n_nota AND notaventa_producto.codprod=productos.codprod AND boleta.n_boleta=$paso",$link);


//$row2=mysql_fetch_array($resultado2)


if ($row2=mysql_fetch_array($resultado2))

{


// 1º Datos del cliente
$texto2="COMERCIALIZADORA EX-GOLOSIN LTDA \nCasa Matriz: Tucapel 152, Los Angeles\nSucursal Tucapel 500, Los Angeles\nTelefonos 432555555\nCorreo electronico exgolosin@exgolosin.cl\nVendedor: $usuario\nFecha venta: $fecha";
$pdf->SetXY(12, 10);
$pdf->MultiCell(180,10,$texto2,1,"L");
$pdf->Ln(14);
$pdf->Cell(140,10,"Orden de Venta Nro: $paso",0,"L");

// 2º Una tabla con los articulos comprados

// La cabecera de la tabla (en azulito sobre fondo rojo)
$pdf->SetXY(12, 150);
$pdf->SetFillColor(250,250,250);
$pdf->SetTextColor(0,0,0);
$pdf->Cell(180,10,"LISTADO DE ARTICULOS",1,1,"C");
$pdf->SetXY(12, 160);
$pdf->SetFont('Arial','B',26);
$pdf->Cell(12,15,"U",1,0,"L");
$pdf->Cell(140,15,"Detalle",1,0,"L");
$pdf->Cell(28,15,"Valor",1,0,"L");



$total=0;

// Los datos (en negro)
$pdf->SetTextColor(0,0,0);
$resultado2 = mysql_query("select clientes.rutcli, clientes.nombres, clientes.giro, clientes.direccion, clientes.telefonofijo, productos.codprod, detalle, cantidad, precioventa, nota_venta.neto, impuesto_adicional, notaventa_producto.descuento, notaventa_producto.total FROM boleta, clientes_boleta, clientes, nos_boletaventa, nota_venta, notaventa_producto, productos WHERE clientes.rutcli=clientes_boleta.rutcli AND clientes_boleta.n_boleta=boleta.n_boleta AND boleta.n_boleta=nos_boletaventa.n_boleta AND nos_boletaventa.n_nota=nota_venta.n_nota AND nota_venta.n_nota=notaventa_producto.n_nota AND notaventa_producto.codprod=productos.codprod AND boleta.n_boleta=$paso",$link);

$pdf->SetXY(12,190);
$pdf->SetFont('Arial','B',24);
$contador=1;
while($row2=mysql_fetch_array($resultado2))
{
$suma=$row2[7]*$row2[8];
$suma="$".number_format($suma);
$pdf->Cell(14,1,"(".$contador.")       ",0,"L");
$pdf->Cell(140,1,$row2[6],0,"L");
$pdf->Cell(100,1,$suma,0,"R");
$pdf->Ln(8);
if ($row2[11]>0)
{
$detalle="$".$row2[8].".- x".$row2[7]."  Desc oferta -$".$row2[11].".-";
$pdf->Cell(90,10,"          ".$detalle,0,"L");   
}
else
{
$detalle="$".$row2[8].".- x".$row2[7];
$pdf->Cell(90,10,"     ".$detalle,0,"L");     
}
$pdf->Ln(15);
//$pdf->Cell(25,10,"---------------------------------------------------------------------",0,"L");

$total+=(($row2[7]*$row2[8])-$row2[11]);
$contador = $contador + 1;

   
}

// El documento enviado al navegador

}
else
{
    echo"no encuentro datos en $paso";
}

//$pdf->AutoPrint();
//$nombrefact="$paso.pdf";
$total="$".number_format($total);
$pdf->MultiCell(182,20,"Total: $total",1,0,"R");

//$pdf->multiCell(30,20,$total,1,1,"R");
$pdf->Output();
?>
<html><body>
    <?php
    echo "<script>window.close('notaimpresion.php'); </script>";
?>