-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathurkundenPDF.php
More file actions
230 lines (186 loc) · 6.3 KB
/
urkundenPDF.php
File metadata and controls
230 lines (186 loc) · 6.3 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
use setasign\Fpdi\Fpdi;
require 'vendor/autoload.php';
include("function.php");
$link = connectDB();
session_start();
$stnr=0;
$_GET = filterParameters($_GET);
$_POST = filterParameters($_POST);
class PDF extends FPDI
{
function urkunde($action, $num, $id, $raceData) {
$oldVnummer = "";
$rennen = $id;
$rennen = checkTeamTogetherWith($rennen, $raceData['teamTogetherWith']);
if($action == 'gesamt') {
$sql= "SELECT t.* from teilnehmer as t where t.vID = ".$_SESSION['vID']." and lid = $id and platz > 0 and platz <= $num order by geschlecht, platz";
} elseif ($action == 'klasse') {
$sql= "SELECT t.* from teilnehmer as t where t.vID = ".$_SESSION['vID']." and lid = $id and akplatz > 0 and akplatz <= $num order by klasse, platz";
} elseif ($action == 'einzel') {
$sql= "SELECT t.* from teilnehmer as t where t.vID = ".$_SESSION['vID']." and id = $id";
} elseif ($action == 'team') {
$sql= "SELECT t.* from teilnehmer as t where t.vID = ".$_SESSION['vID']." and lid in ($rennen) and vnummer <> '' order by vplatz, zeit asc";
} else {
echo "keine action gewählt";
die;
}
$result = dbRequest($sql, 'SELECT');
$this->setMyFont();
if($raceData['template'] != '') {
$this->setSourceFile($raceData['template']);
$tplIdx = $this->importPage(1);
}
$i = 1;
if ($action != 'team') {
if($result[1] > 0) {
foreach ($result[0] as $row) {
$this->AddPage('Portrait', 'A4');
if($raceData['template'] != '') {
$this->useTemplate($tplIdx);
}
if ($action == 'gesamt') {
$platz = $row['platz'];
} else {
$platz = $row['akplatz'];
}
$stnr=$row['stnr'];
include($raceData['definition']);
$i++;
}
} else {
echo "<h1>no Results available</h1>";
die;
}
} else {
$i = -1;
if($result[1] > 0) {
foreach ($result[0] as $row) {
if ($row['vnummer'] != $oldVnummer) {
$i++;
$ii = 1;
$teamRow[$i]['verein'] = $row['verein'];
$teamRow[$i]['vplatz'] = $row['vplatz'];
$teamRow[$i]['vtime'] = $row['vtime'];
$teamRow[$i]['Name'][$ii] = $row['nachname'].", ".$row['vorname'];
$ii++;
}
if ($row['vnummer'] == $oldVnummer) {
$teamRow[$i]['Name'][$ii] = $row['nachname'].", ".$row['vorname'];
$ii++;
}
$oldVnummer = $row['vnummer'];
}
} else {
echo "<h1>no Team available</h1>";
die;
}
foreach ($teamRow as $row) {
$this->AddPage('Portrait', 'A4');
if($raceData['template'] != '') {
$this->useTemplate($tplIdx);
}
include($raceData['definition']);
$i++;
}
}
}
function setHeader() {
}
function setMyFont() {
$this->SetTextColor(0);
$this->SetFont('Verdana','',10);
//$this->SetDrawColor(0,0,0);
//$this->SetLineWidth(.5);
}
function getHeader($veranstaltung, $id, $action) {
$sql = "select titel, untertitel, datum from veranstaltung where id = $veranstaltung";
$result = dbRequest($sql, 'SELECT');
if($result[1] > 0) {
foreach ($result[0] as $row) {
$header['titel'] = $row['titel'];
$header['untertitel'] = $row['untertitel'];
$header['datum'] = $row['datum'];
}
}
if($action == "einzel") {
$sql = "select lauf, lauf2 from lauf where id = $id";
} else {
$sql = "select titel, untertitel from lauf where id = $id";
}
$result = dbRequest($sql, 'SELECT');
if($result[1] > 0) {
foreach ($result[0] as $row) {
$header['lauf'] = $row['titel'];
$header['lauf2'] = $row['untertitel'];
}
}
return $header;
}
// function Footer() {
// $this->SetY(-15);
// $this->SetFont('Verdana','I',8);
// $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
// }
}
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddFont('verdana','','verdana.php');
$pdf->AddFont('verdana','B','verdanab.php');
if(!isset($_GET['id'])) { $_GET['id'] = 0;}
if($_GET['action'] != 'einzel') {
$anzahl=$_SESSION['anzUrkunden-'.$_GET['id']];
} else {
$anzahl=0;
}
if($anzahl == 'ALL') { $anzahl = 10000; }
if(isset($_GET['action']) && ($_GET['id'] != 0)) {
$raceData = getRaceData($_GET['action'], $_GET['id']);
$pdf->urkunde($_GET['action'], $anzahl, $_GET['id'], $raceData);
$filename = $raceData['LTitel']."_".$raceData['LUntertitel'].".pdf";
}
if($_GET['action'] == "gesamt") {
$filename = "Urkunden_Gesamt_$anzahl-".$filename;
} elseif($_GET['action'] == "klasse") {
$filename = "Urkunden_Klasse_$anzahl-".$filename;
} elseif($_GET['action'] == "einzel") {
$filename = "Urkunde_Einzel-$stnr.pdf";
} elseif($_GET['action'] == "team") {
$filename = "Urkunden_Team_$anzahl-".$filename;
}
$pdf->Output($filename,"I");
function getRaceData($action, $id) {
$raceData['template'] = "";
$raceData['definition'] = "";
$raceData['LTitel'] = "";
$raceData['LUntertitel'] = "";
$raceData['VTitel'] = "";
$raceData['VUntertitel'] = "";
if($action == "einzel") {
$sql = "SELECT l.uDefinition uDefinition, l.uTemplate uTemplate, l.titel LTitel, l.untertitel LUntertitel, v.titel VTitel, v.untertitel VUntertitel, teamTogetherWith".
" FROM `teilnehmer` as t ".
" INNER JOIN lauf as l ON t.lID = l.ID ".
" INNER JOIN veranstaltung as v ON t.vID = v.ID ".
" where t.id = $id";
} else {
$sql = "SELECT l.uDefinition uDefinition, l.uTemplate uTemplate, l.titel LTitel, l.untertitel LUntertitel, v.titel VTitel, v.untertitel VUntertitel, teamTogetherWith".
" FROM lauf as l ".
" INNER JOIN veranstaltung as v ON l.vID = v.ID ".
" where l.id = $id";
}
$result = dbRequest($sql, 'SELECT');
if($result[1] > 0) {
foreach ($result[0] as $row) {
$raceData['template'] = $row['uTemplate'];
$raceData['definition'] = $row['uDefinition'];
$raceData['LTitel'] = $row['LTitel'];
$raceData['LUntertitel'] = $row['LUntertitel'];
$raceData['VTitel'] = $row['VTitel'];
$raceData['VUntertitel'] = $row['VUntertitel'];
$raceData['teamTogetherWith'] = $row['teamTogetherWith'];
}
}
return $raceData;
}
$link->close();
?>