-
Notifications
You must be signed in to change notification settings - Fork 2
/
CreateInvoicePDF.php
128 lines (122 loc) · 3.66 KB
/
CreateInvoicePDF.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
<?php
require_once("Autoloader.php");
require_once( "./fpdf181/fpdf.php");
class Invoice extends FPDF{
function header(){
$this->SetFont('Arial','B',25);
$this->Image('http://hfteam3.infhaarlem.nl/cms/Images/Home/Logo.png',120,20,70);
$this->Cell(1,60,'Invoice Haarlem Festival');
}
function content($customerinfo, $tickets){
$this->SetFont('Arial','B',16);
$this->Ln(50);
$this->Rect(10,50,110,55);
$this->Cell(1,0,'Personal Information:');
$this->SetFont('Arial','B',11);
$this->Ln(10);
$this->Cell(1,0,'First Name:');
$this->Cell(40);
$this->SetFont('Arial','',11);
$this->Cell(1,0,current($customerinfo));
$this->Ln(5);
$this->SetFont('Arial','B',11);
$this->Cell(1,0,'Last Name:');
$this->Cell(40);
$this->SetFont('Arial','',11);
$this->Cell(1,0,next($customerinfo));
$this->Ln(5);
$this->SetFont('Arial','B',11);
$this->Cell(1,0,'Order Number:');
$this->Cell(40);
$this->SetFont('Arial','',11);
$this->Cell(1,0,next($customerinfo));
$this->Ln(5);
$this->SetFont('Arial','B',11);
$this->Cell(1,0,'Address:');
$this->Cell(40);
$this->SetFont('Arial','',11);
$this->Cell(1,0,next($customerinfo));
$this->Ln(5);
$this->SetFont('Arial','B',11);
$this->Cell(1,0,'Phone Number:');
$this->Cell(40);
$this->SetFont('Arial','',11);
$this->Cell(1,0,next($customerinfo));
$this->Ln(5);
$this->SetFont('Arial','B',11);
$this->Cell(1,0,'E-mail:');
$this->Cell(40);
$this->SetFont('Arial','',11);
$this->Cell(1,0,next($customerinfo));
$this->Ln(5);
$this->SetFont('Arial','B',11);
$this->Cell(1,0,'Invoice Date:');
$this->Cell(40);
$this->SetFont('Arial','',11);
$this->Cell(1,0,next($customerinfo));
$this->Ln(5);
$extraAmount = 7 * (count($tickets)-1);
$this->Ln(30);
$this->Rect(10,130,190,17+$extraAmount);
$this->Rect(10,147+$extraAmount,190,0);
$this->Rect(10,140,190,0);
$this->Rect(110,130,0,25+$extraAmount);
$this->Rect(135,130,0,25+$extraAmount);
$this->Rect(165,130,0,25+$extraAmount);
$this->SetFont('Arial','B',14);
$this->Cell(1,0,'Event:');
$this->Cell(100);
$this->Cell(1,0,'Amount:');
$this->Cell(25);
$this->Cell(1,0,'Sub Total:');
$this->Cell(30);
$this->Cell(1,0,'VAT:');
$this->Ln(2);
$this->events($tickets);
$this->Ln(8);
$TotalPriceAmount = 0;
$TotalAmount = 0;
foreach($tickets as $ticket){
$TotalPriceAmount += $ticket[4] * $ticket[3];
$TotalAmount += intval($ticket[3]);
}
$this->SetFont('Arial','B',14);
$this->Cell(1,0,'Total:');
$this->Cell(100);
$this->SetFont('Arial','',12);
$this->Cell(1,0,$TotalAmount);
$this->Cell(25);
$this->Cell(1,0,EURO." ".$TotalPriceAmount);
}
public function Events($tickets)
{
foreach($tickets as $ticket){
$this->Ln(7);
$this->SetFont('Arial','',12);
$this->Cell(1,0, current($ticket) . " ". next($ticket). " ". next($ticket));
$this->Cell(100);
$this->Cell(1,0,next($ticket));
$this->Cell(25);
$this->Cell(1,0,EURO." ".(next($ticket)* $ticket[3]));
$this->Cell(30);
$this->Cell(1,0, next($ticket));
}
}
}
class PDFInvoiceMaker{
public function MakePDF($customerInfo, $tickets)
{
$pdf = new Invoice();
define('EURO',chr(128));
/*$customerInfo = array("Tim", "Gras", "0000000000", "1544MK nieuwestraat 8", "061473655","[email protected]", Date("d-m-Y"));
$tickets = array();
$tickets[] = array("Hardwell B2B", "2020-07-12", "15:00 - 16:00", 5, "300.00", "9%");
$tickets[] = array("Hardwell B2B", "2020-07-12", "15:00 - 16:00", 5, "300.00", "9%");
$tickets[] = array("Hardwell B2B", "2020/-07-12", "15:00 - 16:00", 5, "300.00", "9%");*/
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->content($customerInfo, $tickets);
return $pdf->Output('attachment.pdf', 'S');
}
}
?>