-
Notifications
You must be signed in to change notification settings - Fork 2
/
CreateTicketPDF.php
166 lines (142 loc) · 4.65 KB
/
CreateTicketPDF.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
<?php
require_once( "./fpdf181/fpdf.php");
class Ticket extends FPDF{
function header(){
$this->Image('http://hfteam3.infhaarlem.nl/cms/Images/Home/Logo.png',10,6,50,50);
$this->SetFont('Arial', 'B', 20);
$this->Ln(20);
$this->Cell(30);
$this->Cell(0,5,'Haarlem Festival',0,0,'C');
$this->Ln();
$this->Cell(30);
$this->SetFont('Times','',12);
$this->Cell(0,10,'26 - 29 juni 2020',0,0,'C');
$this->Ln(30);
}
function footer(){
$this->SetY(-15);
$this->SetFont('Arial','', 8);
$this->Cell(0, 10, 'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
function nameContent($info){
$this->SetFont('Arial', 'B', 20);
$this->Cell(20);
$this->Cell(40,10,'Customer Info:',0,0,'L');
$this->SetFont('Times', 'B', 12);
$this->Ln(10);
$this->Cell(20);
$this->Cell(40,10,'Name',0,0,'L');
$this->Cell(40,10,current($info),0,0,'L');
$this->Ln();
$this->Cell(20);
$this->Cell(40,10,'Email',0,0,'L');
$this->Cell(40,10,next($info),0,0,'L');
$this->Ln();
$this->Cell(20);
$this->Cell(40,10,'Address',0,0,'L');
$this->Cell(40,10,next($info),0,0,'L');
$this->Ln();
$this->Cell(20);
$this->Cell(40,10,'Phonenumber',0,0,'L');
$this->Cell(40,10,next($info),0,0,'L');
$this->Ln();
$this->Cell(20);
$this->Cell(40,10,'Ordernumber',0,0,'L');
$this->Cell(40,10,next($info),0,0,'L');
$this->Ln();
$this->Cell(20);
$this->SetFont('Times', 'B', 8);
$this->Cell(40,10,'*Use this number to see your program in my Program',0,0,'L');
}
function EventTicket($ticketInfo, $extraHeight, $qrImage, $last = false){
$this->Rect(7, 65 + $extraHeight, 190, 70);
$this->SetFont('Arial', 'B', 10);
$this->Cell( 25, 40, $this->Image('http://hfteam3.infhaarlem.nl/cms/Images/Home/Food.png', 50, 66 + $extraHeight, 49), 0, 0, 'L', false );
$this->Cell( 25, 40, $this->Image('http://hfteam3.infhaarlem.nl/cms/Images/Home/Dance.png', 75, 66 + $extraHeight, 49), 0, 0, 'L', false );
$this->Cell( 25, 40, $this->Image('http://hfteam3.infhaarlem.nl/cms/Images/Home/Historic.png', 100, 66 + $extraHeight, 49), 0, 0, 'L', false );
$this->Cell( 25, 40, $this->Image('http://hfteam3.infhaarlem.nl/cms/Images/Home/Jazz.png', 125, 66 + $extraHeight, 49), 0, 0, 'L', false );
$this->Ln(5);
//name of event
$this->Cell(2.);
$this->Cell(50,0,current($ticketInfo),0,0,'L');
//venue of event
$this->SetFont('Arial', "", 7);
$this->Cell(107);
$this->Cell(14,10,'Ticket Price:',0,0,'L');
$this->Cell(10,10,EURO." ".next($ticketInfo),0,0,'L');
$this->Ln(7);
$this->Cell(159);
$this->Cell(12,3,'',0,0,'L');
$this->MultiCell(17,3,"",0,"B");
$this->Ln(-12);
$this->SetFont('Arial', 'B', 10);
//locatie of event
$this->Cell(2);
$this->Cell(50,20,next($ticketInfo),0,0,'L');
$this->Ln(5);
$this->Cell(2);
$this->SetFont('Arial', '', 7);
$this->Cell(50,17,next($ticketInfo),0,0,'L');
$this->Ln(5);
//datum of event
$this->Cell(2);
$this->SetFont('Arial', 'B', 10);
$this->Cell(50,30,next($ticketInfo),0,0,'L');
$this->Ln(5);
//tijd of event
$this->Cell(2);
$this->Cell(50,30,next($ticketInfo),0,0,'L');
$this->Ln(5);
$this->Cell( 40, 40, $this->Image('http://hfteam3.infhaarlem.nl/cms/Images/Home/Logo.png', $this->GetX() +5, $this->GetY() +14, 28), 0, 0, 'L', false );
//qrcode of event
$this->Cell(104);
$this->Cell( 25, 40, $this->Image($qrImage, $this->GetX()+ 7.5, $this->GetY()+9, 35), 0, 0, 'L', false );
if($last){
$this->Ln(42.9);
$this->Cell(148);
$this->Cell(10,0,next($ticketInfo),0,0,'L');
}
else{
$this->Ln(43);
$this->Cell(148);
$this->Cell(10,0,next($ticketInfo),0,0,'L');
}
//was 50
$this->Ln(7);
}
}
class PDFMaker{
public function MakePDF($customerInfo, $tickets)
{
/*$customerInfo = array("Tim", "Gras", "[email protected]", "1544MK nieuwestraat 8", "061473655", 0);
$tickets = array();
$tickets[] = array("Hardwell B2B", "5060.00", "Jopenkerk", "1544MK nieuwestraat 8", "Dinsdag 20 november", "15:00 - 16:00", "0824418001577780878");*/
require_once( "Autoloader.php");
$qr = new QrGenerator;
$Config = Config::getInstance();
$pdf = new Ticket();
$height = 0;
$pdf->AliasNbPages();
$pdf->AddPage('P', 'A4', 0);
$pdf->nameContent($customerInfo);
$pdf->AddPage();
$amountOnPage = 0;
foreach($tickets as $ticket){
$test = false;
if($amountOnPage == 3){
$pdf->AddPage();
$height = 0;
$amountOnPage = 0;
}
if($amountOnPage == 2){
$test = true;
}
$qrimage = $qr->GenerateQRCode("http://cms.hfteam3.infhaarlem.nl/" ."CMSTicket.php?TicketCode=". $ticket[6], $ticket[6]);
$pdf->EventTicket($ticket, $height, $qrimage, $test);
$height += 73;
$amountOnPage++;
}
return $pdf->Output('attachment.pdf', 'S');
}
}
?>