PHP-Code:
<?
// Variabeln definieren
if (!isset($_POST['speichern'])) $_POST['speichern'] = '';
if (!isset($_POST['reset'])) $_POST['reset'] = '';
if (!isset($_POST['auswerten'])) $_POST['auswerten'] = '';
$rp = 0;
$ralleydaten = mysql_fetch_array(db_query("SELECT * FROM ".$db_prefix."_ralleydaten WHERE ralley='aktivralley' LIMIT 1"));
// Ralleystand reseten
if ($_POST['reset'] == 'Reseten') {
db_query ("DELETE FROM ".$db_prefix."_aktivralley");
}
// Ralley auswerten
if ($_POST['auswerten'] == 'Auswerten') {
$platz = db_query("SELECT * FROM ".$db_prefix."_aktivralley WHERE punkte > '".$ralleydaten['pro']."' ORDER BY punkte DESC LIMIT ".$ralleydaten['plaetze']."");
while ($pa = mysql_fetch_array($platz)) {
$rp++;
$buchungssumme = $ralleydaten['p'.$rp];
// Buchungen durchführen
db_query("UPDATE ".$db_prefix."_aktivralley SET ausgezahlt = '".time()."' WHERE uid='".$pa['uid']."'");
$buchungs_id = create_code(14);
kontobuchung ('+',$buchungssumme,$pa['uid']);
buchungsliste ($buchungs_id,'+'.$buchungssumme,'Aktivralley (Platz '.$rp.')',$pa['uid']);
// bilanz (0,$buchungssumme);
stg_bilanz (0,$buchungssumme,'Ralley','Aktivralley');
}
}
// Ralleydaten speichern
if ($_POST['speichern'] == 'Speichern') {
$ralleystart = strtotime("".$_POST['start_monat']."/".$_POST['start_tag']."/".$_POST['start_jahr']." ".$_POST['start_stunde']." hours ".$_POST['start_minute']." minutes 0 seconds");
$ralleyende = strtotime("".$_POST['ende_monat']."/".$_POST['ende_tag']."/".$_POST['ende_jahr']." ".$_POST['ende_stunde']." hours ".$_POST['ende_minute']." minutes 0 seconds");
db_query ("UPDATE ".$db_prefix."_ralleydaten SET start = '".$ralleystart."', ende = '".$ralleyende."', pro = '".$_POST['pro']."', plaetze = '".$_POST['plaetze']."', p1 = '".$_POST['p1']."', p2 = '".$_POST['p2']."', p3 = '".$_POST['p3']."', p4 = '".$_POST['p4']."', p5 = '".$_POST['p5']."', p6 = '".$_POST['p6']."', p7 = '".$_POST['p7']."', p8 = '".$_POST['p8']."', p9 = '".$_POST['p9']."', p10 = '".$_POST['p10']."' WHERE ralley = 'aktivralley'");
}
$ralleydaten = mysql_fetch_array(db_query("SELECT * FROM ".$db_prefix."_ralleydaten WHERE ralley='aktivralley' LIMIT 1"));
?>
<?head("Aktivralley bearbeiten");?>
<form action="" method="post">
<table cellpadding="2" cellspacing="2" border="0" align="center">
<tr>
<td align="left" valign="middle"><b>Start der Ralley</b> (<i>HH/MM. - TT/MM/JJJJ</i>)</td>
<td align="left" valign="middle">
<select name="start_stunde" size="1">
<?
for($x=0;$x<24;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("H",$ralleydaten['start']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
<select name="start_minute" size="1">
<?
for($x=0;$x<60;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("i",$ralleydaten['start']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
-
<select name="start_tag" size="1">
<?
for($x=1;$x<32;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("d",$ralleydaten['start']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
<select name="start_monat" size="1">
<?
for($x=1;$x<13;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("m",$ralleydaten['start']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
<select name="start_jahr" size="1">
<?
for($x=2005;$x<2019;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("Y",$ralleydaten['start']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td align="right" valign="middle"><b>Ende der Ralley</b> (<i>HH/MM. - TT/MM/JJJJ</i>)</td>
<td align="left" valign="middle">
<select name="ende_stunde" size="1">
<?
for($x=0;$x<24;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("H",$ralleydaten['ende']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
<select name="ende_minute" size="1">
<?
for($x=0;$x<60;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("i",$ralleydaten['ende']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
-
<select name="ende_tag" size="1">
<?
for($x=1;$x<32;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("d",$ralleydaten['ende']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
<select name="ende_monat" size="1">
<?
for($x=1;$x<13;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("m",$ralleydaten['ende']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
<select name="ende_jahr" size="1">
<?
for($x=2005;$x<2019;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if (date("Y",$ralleydaten['ende']) == $y) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td align="left" valign="middle" colspan="2">
<b>Anzahl der Plätze</b>
<select name="plaetze" size="1">
<?
for($x=0;$x<11;$x++){
if ($x <= 9) {$y = '0'.$x;} else {$y = $x;}
if ($ralleydaten['plaetze'] == $x) {$select = ' selected';} else {$select = '';}
echo '<option value="'.$x.'"'.$select.'>'.$y.'</option>';
}
?>
</select>
<b>Punkte die User min. braucht</b>
<input type="Text" name="pro" value="<?=$ralleydaten['pro'];?>" style="width:100px;">
</td>
</tr>
</table>
<br>
<table cellpadding="2" cellspacing="2" border="0" align="center">
<tr>
<td align="center" valign="middle">Gewinn Platz 01</td>
<td align="center" valign="middle">Gewinn Platz 02</td>
<td align="center" valign="middle">Gewinn Platz 03</td>
<td align="center" valign="middle">Gewinn Platz 04</td>
<td align="center" valign="middle">Gewinn Platz 05</td>
</tr>
<tr>
<td align="center" valign="middle"><input type="Text" name="p1" value="<?=$ralleydaten['p1'];?>" style="width:80px;"></td>
<td align="center" valign="middle"><input type="Text" name="p2" value="<?=$ralleydaten['p2'];?>" style="width:80px;"></td>
<td align="center" valign="middle"><input type="Text" name="p3" value="<?=$ralleydaten['p3'];?>" style="width:80px;"></td>
<td align="center" valign="middle"><input type="Text" name="p4" value="<?=$ralleydaten['p4'];?>" style="width:80px;"></td>
<td align="center" valign="middle"><input type="Text" name="p5" value="<?=$ralleydaten['p5'];?>" style="width:80px;"></td>
</tr>
<tr>
<td align="center" valign="middle">Gewinn Platz 06</td>
<td align="center" valign="middle">Gewinn Platz 07</td>
<td align="center" valign="middle">Gewinn Platz 08</td>
<td align="center" valign="middle">Gewinn Platz 09</td>
<td align="center" valign="middle">Gewinn Platz 10</td>
</tr>
<tr>
<td align="center" valign="middle"><input type="Text" name="p6" value="<?=$ralleydaten['p6'];?>" style="width:80px;"></td>
<td align="center" valign="middle"><input type="Text" name="p7" value="<?=$ralleydaten['p7'];?>" style="width:80px;"></td>
<td align="center" valign="middle"><input type="Text" name="p8" value="<?=$ralleydaten['p8'];?>" style="width:80px;"></td>
<td align="center" valign="middle"><input type="Text" name="p9" value="<?=$ralleydaten['p9'];?>" style="width:80px;"></td>
<td align="center" valign="middle"><input type="Text" name="p10" value="<?=$ralleydaten['p10'];?>" style="width:80px;"></td>
</tr>
<tr>
<td align="center" valign="middle" colspan="5"><input type="Submit" name="speichern" value="Speichern" style="width:100px;"></td>
</tr>
</table>
</form>
<?foot();?>
<?head("Platzierungen und Preise");?>
Dieses Aktivralley läuft von <b><?=date("d.m.Y - H:i:s",$ralleydaten['start']);?></b> bis <b><?=date("d.m.Y - H:i:s",$ralleydaten['ende']);?></b>.<br>
Für diese Ralley sind <b><?=number_format($ralleydaten['p1']+$ralleydaten['p2']+$ralleydaten['p3']+$ralleydaten['p4']+$ralleydaten['p5']+$ralleydaten['p6']+$ralleydaten['p7']+$ralleydaten['p8']+$ralleydaten['p9']+$ralleydaten['p10'],2,",",".").' '.$waehrung;?></b> ausgelobt die auf die Plätze <b>1</b> bis <b><?=$ralleydaten['plaetze'];?></b> verteilt werden.
<? if ($ralleydaten['pro'] > 0.00) {
echo 'Es müssen mindestens <b>'.number_format($ralleydaten['pro'],0,",",".").' Punkte</b> erreicht werden um gewertet zu werden';
}?>
<br>
<br>
<table cellpadding="1" cellspacing="1" border="0" bgcolor="#c0c0c0" align="center">
<tr bgcolor="#d0d0d0">
<td align="center"> <b>User</b> </td>
<td align="center"> <b>Punkte</b> </td>
<td align="center"> <b>möglicher Gewinn</b> </td>
<td align="center"> <b>Ausgewertet</b> </td>
</tr>
<?
$platz = db_query("SELECT * FROM ".$db_prefix."_aktivralley WHERE punkte > '".$ralleydaten['pro']."' ORDER BY punkte DESC LIMIT 10");
while ($pa = mysql_fetch_array($platz)) {
$rp++;
$mg = number_format($ralleydaten['p'.$rp],2,",",".");
if ($rp > $ralleydaten['plaetze']) $mg = '----';
if ($pa['ausgezahlt'] >= 1) {$ausg = date("d.m.Y - H:i:s",$pa['ausgezahlt']);} else {$ausg = '<b>Nein</b>';}
echo '
<tr bgcolor="#f0f0f0">
<td align="center">'.$pa['uid'].'</td>
<td align="right">'.number_format($pa['punkte'],2,",",".").' </td>
<td align="right">'.$mg.' </td>
<td align="center"> '.$ausg.' </td>
</tr>
';
}
for($x=$rp+1;$x<11;$x++){
$mg = number_format($ralleydaten['p'.$x],2,",",".");
if ($x > $ralleydaten['plaetze']) $mg = '----';
if ($pa['ausgezahlt'] >= 1) {$ausg = date("d.m.Y - H:i:s",$pa['ausgezahlt']);} else {$ausg = '<b>Nein</b>';}
echo '
<tr bgcolor="#f0f0f0">
<td align="center">N/A</td>
<td align="right">0 </td>
<td align="right">'.$mg.' </td>
<td align="center"> '.$ausg.' </td>
</tr>
';
}
?>
</table>
<br><br>
<div align="center">
<form action="" method="POST">
<input type="Submit" name="reset" value="Reseten">
<input type="Submit" name="auswerten" value="Auswerten">
</form>
</div>
<?foot();?>