-
Notifications
You must be signed in to change notification settings - Fork 1
/
newpdf.php
103 lines (83 loc) · 3.19 KB
/
newpdf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
ob_end_clean();
require('fpdf/fpdf.php');
require("Config/connect.php");
$fecha = date(d)."/".date(m)."/".date(Y);
$hora = date(H).":".date(i).":".date(s);
$transaccion=1;//$_REQUEST[transaccion];
$registrosX=mysql_query("select * from parametros") or die("Error:1".mysql_error());
while ($regX=mysql_fetch_array($registrosX))
{
$razon = utf8_decode($regX['razon_social']);
//$rfc = $regX['rfc'];
$domicilio = utf8_decode($regX['domicilio']);
//$iva = $regX['iva'];
$moneda = $regX['moneda'];
$ancho_celda = $regX['papel_ancho'];
$ancho_celda=$ancho_celda/10;
$ancho_papel = $ancho_celda+20;
$alto_papel = $ancho_papel*3;
$pos_x = $ancho_papel/3.6;
$tamaño = $ancho_papel/2.3;
}
//$iva = $iva/100;
class PDF extends FPDF
{
//Encabezado de página
function Header()
{
}
}
$pdf=new PDF('P','mm',array($ancho_papel,$alto_papel));
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->Image('images/Logo.png',$pos_x,10,$tamaño);
$pdf->setY($tamaño+15);
$pdf->MultiCell($ancho_celda,5,$razon,0,'C');
$pdf->MultiCell($ancho_celda,5,$domicilio,0,'C');
//$pdf->MultiCell($ancho_celda,5,$rfc,0,'C');
$pdf->Ln(10);
$pdf->MultiCell($ancho_celda,5,$fecha." ".$hora,0,'C');
$pdf->Ln(10);
$registros=mysql_query("select * from Venta where ID_Venta = '5'") or die("Error:2".mysql_error());
while ($reg=mysql_fetch_array($registros))
{
$precio = $reg['Total'];
//$cantidad = $reg['Cantidad'];
$registros2=mysql_query("select ID_Producto from Producto_venta where ID_venta =5") or die("Error:3".mysql_error());
while ($reg2=mysql_fetch_array($registros2)){$descripcion = utf8_decode($reg2['ID_Producto']);}
$ancho_cantidad=$ancho_celda/7;
$ancho_descripcion=$ancho_celda/2;
$ancho_precio=$ancho_celda/5;
$chars_max = $ancho_precio+10;
$pdf->SetFont('Arial','',7);
$descripcion = substr($descripcion, 0, $chars_max);
$pdf->Cell($ancho_cantidad,5,$cantidad,0,0,'C');
$pdf->Cell($ancho_descripcion,5,$descripcion,0,0,'L');
$pdf->Cell($ancho_precio,5,$moneda.number_format($precio,2,".",","),0,0,'R');
$pdf->Cell($ancho_precio,5,$moneda.number_format($monto,2,".",","),0,1,'R');
}
$pdf->Ln(5);
$pdf->Cell($ancho_cantidad,5,"",0,0,'C');
$pdf->Cell($ancho_descripcion,5,"",0,0,'L');
$pdf->Cell($ancho_precio,5,"Subtotal:",0,0,'R');
$pdf->Cell($ancho_precio,5,$moneda.number_format(($total/($iva+1)),2,".",","),0,1,'R');
$pdf->Cell($ancho_cantidad,5,"",0,0,'C');
$pdf->Cell($ancho_descripcion,5,"",0,0,'L');
$pdf->Cell($ancho_precio,5,"IVA:",0,0,'R');
$pdf->Cell($ancho_precio,5,$moneda.number_format(($iva*$total),2,".",","),0,1,'R');
$pdf->Cell($ancho_cantidad,5,"",0,0,'C');
$pdf->Cell($ancho_descripcion,5,"",0,0,'L');
$pdf->Cell($ancho_precio,5,"Total:",0,0,'R');
$pdf->Cell($ancho_precio,5,$moneda.number_format($total,2,".",","),0,1,'R');
$pdf->Ln(5);
$pdf->Cell($ancho_celda,5,"#TR: ".$transaccion,0,1,'C');
$pdf->Ln(5);
$pdf->Cell($ancho_celda,5,"Gracias por su compra!",0,1,'C');
$pdf->Ln(10);
$pdf->Cell($ancho_celda,5,".",0,1,'C');
mysql_close($conexion);
$pdf->Output();//muestro el pdf
?>
?>