-
Notifications
You must be signed in to change notification settings - Fork 1
/
exportRundenzeiten.php
170 lines (136 loc) · 4.45 KB
/
exportRundenzeiten.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
require('Classes/fpdf/fpdf.php');
include("function.php");
$link = connectDB();
session_start();
$_GET = filterParameters($_GET);
$_POST = filterParameters($_POST);
class PDF extends FPDF
{
function exportRundenzeiten($id) {
$numBefore = 0;
$fill = false;
$linesPerPage = 45;
$pageheader = $this->getHeader($_SESSION['vID'], $id);
$rd = getRennenData($id);
$startZeit = $rd['startZeit'];
$this->setHeader($pageheader);
$this->setMyFont();
if($rd['use_lID'] == 1) {
$sql_lID = " and z.lID = $id";
} else { $sql_lID = "";
}
$sql = "SELECT stnr, nachname, vorname, verein from teilnehmer where vID = ".$_SESSION['vID']." and lID = $id and platz <> 0";
$result = dbRequest($sql, 'SELECT');
if($result[1] > 0) {
foreach ($result[0] as $row) {
// Fuer Folgeseiten neue Seite samt Header anfangen, auf erster nicht
if(isset($r)){
$this->AddPage();
$this->setHeader($pageheader);
$this->setMyFont();
}
if($row['nachname'].$row['vorname'] != "") { $team = " | ".htmlspecialchars_decode(utf8_decode($row['nachname']), ENT_QUOTES).", ".htmlspecialchars_decode(utf8_decode($row['vorname']), ENT_QUOTES)." - ".htmlspecialchars_decode(utf8_decode($row['verein']), ENT_QUOTES); }
$header = "StNr: ".$row['stnr']." ".$team;
$this->setGroupHeader($header);
$r = 1;
$fill=false;
$zeitBefore = $startZeit;
$sql2 = "select zeit from zeit z where zeit > '".$startZeit."' and vID = ".$_SESSION['vID']." $sql_lID and nummer = '".$row['stnr']."' order by zeit asc";
$result2 = dbRequest($sql2, 'SELECT');
if($result2[1] > 0) {
foreach ($result2[0] as $row2) {
$rundenzeit = getRealTime($zeitBefore, $row2['zeit']);
$this->Cell(15,5,$r,0,0,'R',$fill);
$this->Cell(20,5,substr($row2['zeit'],10),0,0,'R',$fill);
$this->Cell(25,5,$rundenzeit,0,0,'R',$fill);
$this->Ln();
$fill=!$fill;
$zeitBefore = $row2['zeit'];
$r++;
}
}
}
}
}
function setGroupHeader($header) {
$this->Ln(5);
$this->SetFillColor(220,220,220);
$this->Cell(120,5,$header,'',0,'L',1);
$this->Ln();
$this->Cell(15,5,"Runde",'B',0,'R',1);
$this->Cell(20,5,"Uhrzeit",'B',0,'R',1);
$this->Cell(25,5,"Rundenzeit",'B',0,'R',1);
$this->Cell(60,5,"",'B',0,'R',1);
$this->Ln();
$this->SetFillColor(224,235,255);
}
function setMyFont() {
$this->SetTextColor(0);
$this->SetFont('Arial','',10);
//$this->SetDrawColor(0,0,0);
//$this->SetLineWidth(.5);
}
function getHeader($veranstaltung, $rennen) {
$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'] = htmlspecialchars_decode($row['titel'], ENT_QUOTES);
$header['untertitel'] = htmlspecialchars_decode($row['untertitel'], ENT_QUOTES);
$header['datum'] = htmlspecialchars_decode($row['datum'], ENT_QUOTES);
}
}
$sql = "select titel, untertitel from lauf where id = $rennen";
$result = dbRequest($sql, 'SELECT');
if($result[1] > 0) {
foreach ($result[0] as $row) {
$header['lauf'] = htmlspecialchars_decode($row['titel'], ENT_QUOTES);
$header['lauf2'] = htmlspecialchars_decode($row['untertitel'], ENT_QUOTES);
}
}
return $header;
}
function setHeader($header) {
$this->SetTextColor(0);
$this->SetY(1);
$this->SetFont('Arial','',10);
$this->Ln(5);
$this->Cell(160);
$d = explode("-",$header['datum']);
$this->Cell(30,10,$d[2].".".$d[1].".".$d[0],0,0,'R');
$this->Ln(5);
$this->SetFont('Arial','BI',16);
$this->Cell(80);
$this->Cell(30,10,utf8_decode($header['titel']),0,0,'C');
if($header['untertitel'] != "") {
$this->SetFont('Arial','BI',12);
$this->Ln(5);
$this->Cell(80);
$this->Cell(30,10,utf8_decode($header['untertitel']),0,0,'C');
}
$this->Ln(5);
$this->SetFont('Arial','BI',10);
$this->Cell(80);
$this->Cell(30,10,utf8_decode($header['lauf']),0,0,'C');
$this->Ln(5);
$this->Cell(80);
$this->Cell(30,10,utf8_decode($header['lauf2']),0,0,'C');
$this->Ln(5);
}
function Footer() {
$this->SetY(-15);
$this->SetFont('Arial','I',8);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
//$filename = $_GET['action'].'.pdf';
$filename = 'Rundenzeiten.pdf';
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage('Portrait', 'A4');
$pdf->exportRundenzeiten($_GET['id']);
$pdf->Output($filename,"I");
$pdf->Output();
$link->close();
?>