-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheinlaufListe.php
More file actions
297 lines (237 loc) · 9.01 KB
/
einlaufListe.php
File metadata and controls
297 lines (237 loc) · 9.01 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?php
function einlaufListe() {
echo einlaufListeForm();
}
function einlaufListeForm() {
?>
<script>
$(document).ready(function(){
checkEinlaufListe( this );
});
function markField(id) {
$( '#div_' + id ).addClass( "has-error" );
}
</script>
<h3>Einlaufliste</h3>
<div class="table-responsive">
<table class="table table-striped table-vcenter">
<thead>
<tr>
<th>ID</th>
<th>Titel</th>
<th>Start</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$veranstaltung = $_SESSION['vID'];
$sql = "select * from lauf where vID = $veranstaltung order by start asc, titel;";
$result = dbRequest($sql, 'SELECT');
if(!isset($_SESSION['rennenIDs']) || $_SESSION['rennenIDs'] == '') {
$rennenIDs = array();
} else {
$rennenIDs = explode( ",", $_SESSION['rennenIDs']);
}
if($result[1] > 0) {
foreach ($result[0] as $row) {
if(in_array($row['ID'], $rennenIDs) === true) { $c = "checked"; } else { $c = ""; }
$rInfo = getRennenData($row['ID']);
?>
<tr>
<td><?php echo $row['ID']; ?></td>
<td><?php echo $row['titel']." / ".$row['untertitel']; ?></td>
<td><?php echo substr($row['start'], 10); ?></td>
<td>
<?php if($rInfo['rundenrennen'] == 0) { ?>
<input <?php echo $c; ?> class="chkboxtable" type="checkbox" onchange="javascript:checkEinlaufListe( this );" name="<?php echo $row['ID']; ?>" id="<?php echo $row['ID']; ?>">
<?php } ?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
<?php
}
function showEinlaufListe() {
$rennen = $_GET['id'];
$action = $_GET['action'];
// der anzuzeigenden rennen werden in der Variable $_SESSION['rennenIDs'] gespeichert
if(!isset($_SESSION['rennenIDs']) || $_SESSION['rennenIDs'] == '') {
$rennenIDs = array();
} else {
$rennenIDs = explode( ",", $_SESSION['rennenIDs']);
}
if($action == 'add') {
if(in_array($rennen, $rennenIDs) === false) {
array_push( $rennenIDs , $rennen );
}
} else {
if(in_array($rennen, $rennenIDs) === true) {
$id = array_search($rennen, $rennenIDs);
unset($rennenIDs[$id]);
}
}
$_SESSION['rennenIDs'] = implode(",", $rennenIDs);
//echo $_SESSION['rennenIDs'];
if($_SESSION['rennenIDs'] != "") {
$i = 0;
$rIDs = explode( ",", $_SESSION['rennenIDs']);
$tmptable = "tmp_".rand(100, 999);
$sql = "CREATE TEMPORARY TABLE IF NOT EXISTS $tmptable (
`ID` bigint(20) NOT NULL DEFAULT '0',
`stnr` int(11) NOT NULL,
`vorname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`nachname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`verein` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`klasse` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
`lid` int(11) NOT NULL,
`lname` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`usemantime` int(1) NOT NULL DEFAULT '0',
`manzeit` time NOT NULL DEFAULT '00:00:00',
`zielzeit` datetime,
`millisecond` int(3),
`startzeit` datetime,
PRIMARY KEY (`ID`)
) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$result = dbRequest($sql, 'INSERT');
foreach ($rIDs as $rid) {
$rd = getRennenData($rid);
$startZeit = $rd['startZeit'];
if($rd['use_lID'] == 1) { $sql_lID = "and lid = $rid "; } else { $sql_lID = ""; }
$sql = "INSERT into $tmptable (SELECT t.ID, t.stnr, t.vorname, t.nachname, t.verein, t.klasse, t.lid, '".$rd['titel']."' as lname, t.usemantime, t.manzeit, min(z.zeit) as zielzeit, z.millisecond, '".$startZeit."' as startzeit FROM `teilnehmer` as t
LEFT JOIN (select nummer, zeit, millisecond from zeit where zeit > '".$startZeit."' and vID = ".$_SESSION["vID"]." $sql_lID) as z ON t.stnr = z.nummer
where t.vid = ".$_SESSION["vID"]." and t.lid = ".$rid." and disq = 0 and del = 0 group by t.stnr);";
//echo $sql;
$result = dbRequest($sql, 'INSERT');
$i++;
}
// Zielzeit fuer manuell gesetzte Laufzeit berechnen und eintragen
$sql = "select * from $tmptable where usemantime = 1";
$result = dbRequest($sql, 'SELECT');
if($result[1] > 0) {
foreach ($result[0] as $row) {
$zielzeit = getSeconds($row['startzeit']) + getSeconds('1970-01-01 '.$row['manzeit']);
date_default_timezone_set("UTC");
$zielzeit = date("Y-m-d H:i:s", $zielzeit);
date_default_timezone_set("Europe/Berlin");
$sql = "update $tmptable set zielzeit = '".$zielzeit."' where ".$row['ID']." = ID";
$result = dbRequest($sql, 'UPDATE');
}
}
// um richtig sortieren zu koennen werden die Zeiten in der spalte manzeit zusammengefasst.
$sql = "update $tmptable set manzeit = zielzeit where zielzeit is not NULL and usemantime <> 2";
$result = dbRequest($sql, 'UPDATE');
$sql = "SELECT * from $tmptable where zielzeit is not NULL or usemantime = 2 order by manzeit, millisecond asc;";
$result = dbRequest($sql, 'SELECT');
$html2 = "";
$i=1;
$dataSetBefore['zeit'] = 'none';
$dataSetBefore['klasse'] = 'none';
$dataSetBefore['lname'] = 'none';
$sameTimeAsBefore ='';
?>
<div class="table-responsive">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Verein</th>
<th>Klasse</th>
<th>Rennen</th>
<th>Laufzeit</th>
<th>Stnr.</th>
<th>Zielzeit</th>
</tr>
</thead>
<?php
if($result[1] > 0) {
foreach ($result[0] as $row) {
$laufzeit = getRealTime($row['startzeit'], $_SESSION['vDatum']." ".$row['manzeit']);
if($row['usemantime'] == 1 ) { $umt = '*'; } else { $umt = ''; }
if (($dataSetBefore['zeit'] == $laufzeit) && ($dataSetBefore['klasse'] == $row['klasse']) && ($dataSetBefore['lname'] == $row['lname'])) {
$sameTimeAsBefore = '!"';
}
?>
<tr>
<td><a href="index.php?func=teilnehmer&id=<?php echo $row['ID']; ?>&nextFunc=einlaufListe"><?php echo $row['nachname'].", ".$row['vorname']; ?></a></td>
<td><?php echo $row['verein']; ?></td>
<td><?php echo $row['klasse']; ?></td>
<td><?php echo $row['lname']; ?></td>
<td <?php echo $sameTimeAsBefore; ?>><?php echo $laufzeit.$umt; ?></td>
<td><?php echo $row['stnr']; ?></td>
<td>
<div class="col-sm-5" id="div_zeit_<?php echo $row['ID']; ?>">
<input id="zeit_<?php echo $row['ID']; ?>" class="form-control input-sm input-very-small" onchange="markField('zeit_<?php echo $row['ID']; ?>'); return false;" value="<?php echo $row['manzeit']; ?>">
</div>
<a class="manzeit" id="<?php echo $row['ID']; ?>" onclick="javascript:saveManZielzeit( this, 'save'); return false;" href="#"><i class="fa fa-floppy-o fa-lg"></i></a>
<?php if ($row['usemantime'] == 2 ) { ?>
| <a class="setmanzeit" id="<?php echo $row['ID']; ?>" onclick="javascript:saveManZielzeit( this, 'del'); return false;" href="#"><i class="fa fa-times fa-lg"></i></a>
<?php } ?>
<?php if ($sameTimeAsBefore != "" ) { ?>
| <i class="fa fa-hand-paper-o fa-lg"></i>
<?php } ?>
</td>
</tr>
<?php
$dataSetBefore['zeit'] = $laufzeit;
$dataSetBefore['klasse'] = $row['klasse'];
$dataSetBefore['lname'] = $row['lname'];
$sameTimeAsBefore = "";
$i++;
}
}
$sql = "SELECT * from $tmptable where zielzeit is NULL and usemantime <> 2";
$result = dbRequest($sql, 'SELECT');
$dataSetBefore['zeit'] = 'none';
$dataSetBefore['klasse'] = 'none';
$sameTimeAsBefore ='';
if($result[1] > 0) {
foreach ($result[0] as $row) {
$laufzeit = '00:00:00';
if($row['usemantime'] == 1 ) { $umt = '*'; $laufzeit = $row['manzeit']; } else { $umt = ''; }
?>
<tr>
<td><a href="index.php?func=teilnehmer&id=<?php echo $row['ID']; ?>&nextFunc=einlaufListe"><?php echo $row['nachname'].", ".$row['vorname']; ?></a></td>
<td><?php echo $row['verein']; ?></td>
<td><?php echo $row['klasse']; ?></td>
<td><?php echo $row['lname']; ?></td>
<td><?php echo $laufzeit.$umt; ?></td>
<td><?php echo $row['stnr']; ?></td>
<td>
<div class="col-sm-5">
<input id="zeit_<?php echo $row['ID']; ?>" class="form-control input-sm input-very-small" value="<?php echo $row['manzeit']; ?>">
</div>
<a class="manzeit" id="<?php echo $row['ID']; ?>" onclick="javascript:saveManZielzeit( this, 'save'); return false;" href="#"><i class="fa fa-floppy-o fa-lg"></i></a>
<?php if ($row['usemantime'] == 2 ) { ?>
| <a class="setmanzeit" id="<?php echo $row['ID']; ?>" onclick="javascript:saveManZielzeit( this, 'del'); return false;" href="#"><i class="fa fa-times fa-lg"></i></a>
<?php } ?>
</td>
</tr>
<?php
$i++;
}
}
?>
</tbody>
</table>
</div>
<?php
}
}
function saveManZielzeit() {
$id = $_GET['id'];
$action = $_GET['action'];
$time = $_GET['time'];
if ($action == 'save') {
$sql = "update teilnehmer set usemantime = 2, manzeit = '".base64_decode($time)."' where id = $id";
} elseif ($action == 'del') {
$sql = "update teilnehmer set usemantime = 0, manzeit = '00:00:00' where id = $id";
}
$result = dbRequest($sql, 'UPDATE');
echo "ok";
}