Os incluyo el script que trasnforma en pdf para que le echeis un vistazo:
Código php:
El script funciona bien, por lo que le puede servir a alguno de vosotros tenga un pequeño negocio y pueda sacar las facturas una a una.Ver original
<?php require_once('clases/fpdf.php'); require_once("conectar.php"); require_once("comunes.php"); $pdf=new PDF(); $pdf->Open(); $pdf->AddPage(); $pdf->Ln(60); $consulta = "Select * from factura2,empresas where id_factura between '$id_factura' and '$id_factura2' and factura2.id_empresas=empresas.id_empresas"; $contador=0; $contador++; $pdf->Cell(110); $pdf->Cell(80,4,"",'',0,'C'); $pdf->Ln(4); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',8); $pdf->Cell(110); $pdf->Cell(80,4,"",'LRT',0,'L',1); $pdf->Ln(4); $pdf->Cell(110); $pdf->Cell(80,4,$row["nombre"],'LR',0,'L',1); $pdf->Ln(4); $pdf->Cell(110); $pdf->Cell(80,4,$row["domicilio"],'LR',0,'L',1); $pdf->Ln(4); $pdf->Cell(110); $pdf->Cell(80,4,$row["cp"] . " " . $row["poblacion"] . " (" . $row["provincia"] . ")",'LR',0,'L',1); $pdf->Ln(4); $pdf->Cell(110); $pdf->Cell(80,4,"",'LRB',0,'L',1); $pdf->Ln(10); $pdf->SetFillColor(255,191,116); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->Cell(80); $pdf->Cell(30,4,"CIF",1,0,'C',1); $pdf->Cell(30,4,"Cod. Cliente",1,0,'C',1); $pdf->Cell(30,4,"Fecha",1,0,'C',1); $pdf->Cell(20,4,"Núm. Factura",1,0,'C',1); $pdf->Ln(4); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','',6); $pdf->Cell(80); $pdf->Cell(30,4,$row["cif"],1,0,'C',1); $pdf->Cell(30,4,$row["id_empresas"],1,0,'C',1); $pdf->Cell(30,4,$row["fecha"],1,0,'C',1); $pdf->Cell(20,4,$row["id_factura"],1,0,'C',1); $pdf->Ln(10); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->Cell(80); $pdf->Cell(30,4,"DATOS DEL CURSO",1,0,'C',1); $pdf->Ln(10); $pdf->SetFillColor(255,191,116); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->Cell(31); $pdf->Cell(20,4, "Acción",1,0,'C',1); $pdf->Cell(50,4,"Nombre del curso",1,0,'C',1); $pdf->Cell(20,4,"Tipo de curso",1,0,'C',1); $pdf->Cell(25,4,"Fecha de inicio",1,0,'C',1); $pdf->Cell(30,4, "Fecha de finalizacion",1,0,'C',1); $pdf->Cell(15,4, "Alumnos",1,0,'C',1); $pdf->Ln(4); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','',6); $pdf->Cell(31); $pdf->Cell(20,4,$row["accion"],1,0,'C',1); $pdf->Cell(50,4,$row["nombrecur"],1,0,'C',1); $pdf->Cell(20,4,$row["tipo"],1,0,'C',1); $pdf->Cell(25,4,$row["inicio"],1,0,'C',1); $pdf->Cell(30,4,$row["finalizacion"],1,0,'C',1); $pdf->Cell(15,4,$row["alumnos"],1,0,'C',1); //ahora mostramos las lneas de la factura $pdf->Ln(15); $pdf->SetFillColor(255,191,116); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->Cell(30); $pdf->Cell(160,4,"Factura",1,0,'C',1); $pdf->Ln(4); $pdf->Cell(30); $pdf->SetFillColor(255,191,116); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->Cell(20,4, "Acción",1,0,'C',1); $pdf->Cell(70,4,"Descripción",1,0,'C',1); $pdf->Cell(70,4, "Importe",1,0,'C',1); $pdf->Ln(4); $pdf->Cell(30); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->cell(20,4,$row["accion"],1,0,'L',1); $pdf->cell(70,4,'Costes de impartición',1,0,'L'); $pdf->Cell(70,4,$row["imparticion"],1,0,'C'); $pdf->Ln(4); $pdf->Cell(30); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->cell(20,4,'',1,0,'L',1); $pdf->cell(70,4,'Costes asociados',1,0,'L'); $pdf->Cell(70,4,$row["asociados"],1,0,'C'); $pdf->Ln(4); $pdf->Cell(30,30); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->cell(20,4,'',1,0,'L',1); $pdf->cell(70,4,'',1,0,'L'); $pdf->Cell(70,4,'',1,0,'C'); $pdf->Ln(4); $pdf->Cell(30); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->cell(20,4,'',1,0,'L',1); $pdf->cell(70,4,'Importe total',1,0,'L'); $pdf->Cell(70,4,$row["bonificar"],1,0,'C'); $pdf->Ln(4); $pdf->Cell(120); $pdf->SetFillColor(255,191,116); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',6); $pdf->Cell(70,4, "Importe a bonificar",1,0,'C',1); $pdf->Ln(4); $pdf->Cell(120); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','',6); $pdf->Cell(70,4,$row["bonificar"],1,0,'C'); $pdf->Ln(4); $pdf->Ln(20); $pdf->Cell(66); $pdf->SetFillColor(255,191,116); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','B',8); $pdf->Cell(30,4,"Base imponible",1,0,'C',1); $pdf->Cell(30,4,"Cuota IVA",1,0,'C',1); $pdf->Cell(30,4,"IVA",1,0,'C',1); $pdf->Cell(35,4,"TOTAL EUROS",1,0,'C',1); $pdf->SetFillColor(255,255,255); $pdf->SetTextColor(0); $pdf->SetDrawColor(0,0,0); $pdf->SetLineWidth(.2); $pdf->SetFont('Arial','',6); $pdf->Ln(4); $pdf->Cell(66); $pdf->Cell(30,4,$row["bonificar"],1,0,'C',1); $pdf->Cell(30,4,'16%',1,0,'C',1); $pdf->Cell(30,4,'0.00',1,0,'C',1); $pdf->Cell(35,4,$row["bonificar"],1,0,'C',1); $pdf->Ln(4); $pdf->Cell(110); $pdf->Ln(10); $pdf->Output(); } ?>
Sé que es un poco largo, pero espero que podais darme alguna solución.-
Muchas gracias