-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice_db.php
170 lines (120 loc) · 4.32 KB
/
invoice_db.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
// call the pdf library
require('fpdf/fpdf.php');
include 'connectdb.php';
$id = $_GET['view_btn'];
// echo $id;
$select=$pdo->prepare("select * from tbl_invoice where in_id=$id");
$select->execute();
$row=$select->fetch(PDO::FETCH_OBJ);
// print_r($row);
// A4 width : 219mm
// default margin : 10mm each side
// writable horiZontal : 219 - (10*2) = 190times
// create pdf is_object
$pdf = new FPDF('P','mm','A4');
// String orientation(P or L)- portrait or landscape
// String unit (pt,mm,cm,and in) - measure unit
// Mixed format (A3,A4,A5,Letter and Legal) - format of pages
// add a new page
$pdf->AddPage();
// First set a font for a doc.
// $pdf->SetFont("Font","B I U","Size");
// B->Bold , I->Italic , U->Underline;
$pdf->SetFont('Arial','BIU',14);
// Then create a cell
// $pdf->Cell(width,height,"text",border,PostionAfterCell,Align,BackgroundFill,"link");
// border:0 (No) / 1 (Yes);
// PositionAfterCell: 0 (To Right), 1 (Start of next line), 2 (Below);
// Align: L (Left) , C (Center) , R (Right) ;
// BackgroundFill: true / false(default);
// to fill color in cell if true
// $pdf->SetFillcolor(200,145,133);
// $pdf->Cell(60,10,'hello world 1',1,1,'C',true,"google.com");
// $pdf->Cell(60,10,'hello world 2',1,2,'C',true,"google.com");
// $pdf->Cell(60,10,'hello world 3',1,0,'C',true,"google.com");
$pdf->SetFont('Arial','B',16);
$pdf->Cell(80,10,'Prasher Electronics',0,0,'');
$pdf->SetFont('Arial','B',13);
$pdf->Cell(112,10,'INVOICE',0,1,'C');
$pdf->SetFont('Arial','',8);
$pdf->Cell(80,5,'Address : Arya samaj road , Uttam nagar New delhi - 110056',0,0,'');
$pdf->Setfont('Arial','',10);
$pdf->Cell(112,5,'Invoice :'.$row->in_id,0,1,'C');
$pdf->SetFont('Arial','',8);
$pdf->Cell(80,5,'Phone Number : +91 7665464434',0,0,'');
$pdf->Setfont('Arial','',10);
$pdf->Cell(112,5,'Date :'.$row->date,0,1,'C');
$pdf->Setfont('Arial','',8);
$pdf->Cell(80,5,'E-mail Address : [email protected]',0,1,'');
$pdf->Cell(80,5,'Website : www.Prasherelectronics.com',0,1,'');
// Line(x1,y1,x2,y2);
$pdf->Line(5,45,205,45);
$pdf->Line(5,46,205,46);
// line break
$pdf->Ln(10);
$pdf->Setfont('Arial','BI',12);
$pdf->Cell(20,10,'Bill To :',0,0,'');
$pdf->Setfont('Courier','BI',14);
$pdf->Cell(50,10,$row->cust_name,0,1,'');
$pdf->Cell(50,5,'',0,1,'');
// 190 divides cells
$pdf->Setfont('Arial','BI',12);
$pdf->SetFillcolor(208,208,208);
$pdf->Cell(100,8,'PRODUCT',1,0,'C',true);
$pdf->Cell(20,8,'QTY',1,0,'C',true);
$pdf->Cell(30,8,'PRICE',1,0,'C',true);
$pdf->Cell(40,8,'TOTAL',1,1,'C',true);
$select=$pdo->prepare("select * from tbl_invoice_details where in_id=$id");
$select->execute();
// print_r($item);
while($item=$select->fetch(PDO::FETCH_OBJ)){
$pdf->Setfont('Arial','B',12);
$pdf->Cell(100,8,$item->p_name,1,0,'L');
$pdf->Cell(20,8,$item->qty,1,0,'C');
$pdf->Cell(30,8,$item->price,1,0,'C');
$pdf->Cell(40,8,$item->price*$item->qty,1,1,'C');
}
$pdf->Setfont('Arial','B',12);
$pdf->Cell(100,8,'',0,0,'L');
$pdf->Cell(20,8,'',0,0,'C');
$pdf->Cell(30,8,'Subtotal',1,0,'C',true);
$pdf->Cell(40,8,$row->sub_total,1,1,'C');
$pdf->Setfont('Arial','B',12);
$pdf->Cell(100,8,'',0,0,'L');
$pdf->Cell(20,8,'',0,0,'C');
$pdf->Cell(30,8,'Tax',1,0,'C',true);
$pdf->Cell(40,8,$row->tax,1,1,'C');
$pdf->Setfont('Arial','B',12);
$pdf->Cell(100,8,'',0,0,'L');
$pdf->Cell(20,8,'',0,0,'C');
$pdf->Cell(30,8,'Discount',1,0,'C',true);
$pdf->Cell(40,8,$row->discount,1,1,'C');
$pdf->Setfont('Arial','B',12);
$pdf->Cell(100,8,'',0,0,'L');
$pdf->Cell(20,8,'',0,0,'C');
$pdf->Cell(30,8,'Grand Total',1,0,'C',true);
$pdf->Cell(40,8,$row->total,1,1,'C');
$pdf->Setfont('Arial','B',12);
$pdf->Cell(100,8,'',0,0,'L');
$pdf->Cell(20,8,'',0,0,'C');
$pdf->Cell(30,8,'Paid',1,0,'C',true);
$pdf->Cell(40,8,$row->paid,1,1,'C');
$pdf->Setfont('Arial','B',12);
$pdf->Cell(100,8,'',0,0,'L');
$pdf->Cell(20,8,'',0,0,'C');
$pdf->Cell(30,8,'Due',1,0,'C',true);
$pdf->Cell(40,8,$row->due,1,1,'C');
$pdf->Setfont('Arial','B',10);
$pdf->Cell(100,8,'',0,0,'L');
$pdf->Cell(20,8,'',0,0,'C');
$pdf->Cell(30,8,'Payment Method',1,0,'C',true);
$pdf->Cell(40,8,$row->pay_type,1,1,'C');
$pdf->Cell(50,10,'',0,1,'');
$pdf->Setfont('Arial','B',10);
$pdf->Cell(32,10,"Important Notice :",0,0,'',true);
$pdf->Setfont('Arial','',8);
$pdf->Cell(148,10,'No item will be replaced or refunded if you dont have the invoice with you. You can refund within 2 days of purchase.',0,0,'');
// output the result
$pdf->Output();
?>