-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdf_invoices.php
168 lines (124 loc) · 4.5 KB
/
pdf_invoices.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
<?php
require('fpdf.php');
class PeoplePDF extends FPDF {
//Page header
function Header() {
$num = 0;
$fill = 0;
include('dao/connect.php');
$result = $db->query("select * from institution_details");
while ($de = $result->fetch_assoc()) {
$name = $de['institution_name'];
$name2 = $de['name_part2'];
$address = $de['box'] . " , " . $de['place'] . " Tel: " . $de['telphone'];
//$logref=$de['logref'];
$phone = $de['telphone'];
$headoffice = $de['head_office'];
$email = $de['email'];
$web = $de['website'];
}
$logo = "images/logo.png";
$date = date("Y-m-d H:i:s");
$y = date("Y");
$m = date("m");
$d = date("d");
$hr = date("H");
$min = date("i");
$sec = date("s");
$hcodes = $y . $m . $d . $hr;
$mins = $min . $sec;
$hcode = $hcodes . $mins;
$barcode = "images/barcode.PNG";
$this->SetFont('times', '', 8);
$this->Image($logo, 15, 10, 20, 20);
$this->Image($barcode, 165, 10, 0, 0);
$this->Text(175, 25, $hcode);
$this->SetFont('times', '', 8);
//$this->Image($barcode,150,10,0,0);
//$this->Text(151, 25, $hcode);
$this->SetFont('times', 'B', 28);
$this->Cell(195, 7, $name, 0, 0, "C", 0);
$this->Ln();
$this->SetFont('times', 'B', 14);
$this->Cell(195, 6, $name2, 0, 0, "C", 0);
$this->Ln();
$this->SetFont('times', '', 12);
$this->Cell(195, 6, "Office: $headoffice, Email: $email", 0, 0, "C", 0);
$this->Ln();
$this->Cell(195, 6, "Unpaid Invoices" , 0, 0, "C", 0);
$this->Line(10, 36, 200, 36);
$this->Ln();
$this->Ln(20);
}
//Page footer
function Footer() {
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial', 'I', 9);
//Page number
$this->Cell(0, 10, 'Page ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
}
}
$pdf = new FPDF();
$pdf = new PeoplePDF();
$pdf->AliasNbPages(); //for page numbers
//$pdf->open();
$pdf->addPage();
$pdf->SetAutoPageBreak(false);
$pdf->SetFillColor(0, 0, 0); //black
$pdf->SetDrawColor(0, 0, 0); //black
//table header
$pdf->SetFillColor(128, 128, 128); //gray
$pdf->setFont("times", "", "11");
$pdf->setXY(10, 40);
$pdf->Cell(10, 7, "#", 1, 0, "L", 1);
$pdf->Cell(50, 7, "Supplier", 1, 0, "C", 1);
$pdf->Cell(50, 7, "Contact Person", 1, 0, "C", 1);
$pdf->Cell(30, 7, "Invoice Date", 1, 0, "C", 1);
$pdf->Cell(30, 7, "Amount", 1, 0, "C", 1);
$pdf->Cell(20, 7, "Status", 1, 0, "C", 1);
$pdf->Ln();
//gegevens van database
$y = $pdf->GetY();
$x = 10;
$pdf->setXY($x, $y);
$statement = "SELECT `company_name`,`contact_person`, invoice.* FROM invoice JOIN `suppliers` ON invoice.`supplier_id` = suppliers.`supplier_id` where pay_status='Unpaid' ORDER BY `invoice_date` DESC ";
include('dao/connect.php');
$result = $db->query($statement);
$num = 0;
$fill = 0;
$purchase_total = 0;
$wholesale_total = 0;
$totalunits = 0;
$retail_total = 0;
while ($row = $result->fetch_assoc()) {
$num++;
$pdf->SetFillColor(224, 235, 255);
$pdf->setFont("times", "", "11");
$pdf->Cell(10, 7, $num, 1, 0, "L", $fill);
$pdf->Cell(50, 7, $row['company_name'], 1, 0, "L", $fill);
$pdf->Cell(50, 7, $row['contact_person'], 1, 0, "L", $fill);
$pdf->Cell(30, 7, $row['invoice_date'], 1, 0, "R", $fill);
$pdf->Cell(30, 7, $row['amount'], 1, 0, "R", $fill);
$pdf->Cell(20, 7, $row['pay_status'], 1, 0, "R", $fill);
$y += 7;
$fill = !$fill;
if ($y > 275) {
$pdf->AddPage();
$pdf->SetFillColor(128, 128, 128); //gray
$pdf->setFont("times", "", "11");
$pdf->setXY(20, 40);
$pdf->Cell(10, 7, "#", 1, 0, "L", 1);
$pdf->Cell(50, 7, "Supplier", 1, 0, "C", 1);
$pdf->Cell(50, 7, "Contact Person", 1, 0, "C", 1);
$pdf->Cell(30, 7, "Invoice Date", 1, 0, "C", 1);
$pdf->Cell(30, 7, "Amount", 1, 0, "C", 1);
$pdf->Cell(20, 7, "Status", 1, 0, "C", 1);
$pdf->Ln();
$y = 45;
}
$pdf->setXY($x, $y);
}
$pdf->Output();
?>