<?php session_start(); ?>
<html>
<head>
<script type="text/javascript">
function score_home() {
var score_h = prompt("Score:","Home - Away");
xmlhttp.send("score=" + score_h);
//location.href = '/Applications/MAMP/htdocs/FC Wien/Klasse_Termin.php?ergebnis=' +score;
}
function score_away() {
var score_a = prompt("Score:","Home - Away");
xmlhttp.send("score=" + score_a);
}
</script>
<script type="text/javascript">
function vollst() {
var errmsg = "";
if (document.termin.tag.value == "Tag" || document.termin.tag.value == "") {
document.termin.tag.style.background = "red";
document.termin.tag.style.color = "white";
errmsg += "Tag \n";
}
if (document.termin.ort.value == "Ort" || document.termin.ort.value == "") {
document.termin.ort.style.background = "red";
document.termin.ort.style.color = "white";
errmsg += "Ort \n";
}
/*if (document.termin.art.selectedindex == -1) {
errmsg += "Art \n";
}*/
if (errmsg == '') {
return true;
}
else {
alert ("Bitte: \n" + errmsg + "\n eintragen!");
return false;
}
}
</script>
</head>
</html>
<?php
session_start();
include 'database.php';
include 'FC_Wien_login';
if (isset($_POST["Termin_Eintragen"])) {
$e_objekt = new Termin();
$e_objekt -> T_eintragen($_POST[tag], $_POST[ort],$_POST[rasen],$_POST[art], $_POST[gegner], $_POST[ho_aw], $_POST[datum], $_POST[zeit], $e_objekt);
}
if (isset($_POST["Termine_Anzeigen"])) {
$a_objekt = new Termin();
$a_objekt -> T_anzeigen();
}
if(isset($_POST['delete'])) {
$del_object = new Termin;
$del_object -> T_loeschen($_POST['checkbox']);
}
class Termin {
#--- Variablen Deklaration für die Klasse ---#
var $tag;
var $ort;
var $rasen;
var $art;
var $gegner;
var $home_away;
var $datum;
var $zeit;
var $resultat;
var $uebergeben;
#--- Termin eintragen Formular ---#
function T_eintragen_form() {
echo "<div id='main_content'><table cellpadding='10' align='center'>
<th>
<h1>Termindaten hier eingeben!</h1>
</th>
<form action='$HTTP_SERVER_VARS[PHP_SELF]' method='post' name='termin' onsubmit='return vollst()'>
<tr>
<td align='middle' valign='top'>
<b>Tag:</b>
<p><input type='text' name='tag' size='15' value='Tag' onclick='this.value=\"\"' maxlength='14'/></p>
<br />
<b>Datum und Uhrzeit:</b>
<p><input name='datum' value='dd. month' onclick='this.value=\"\"' size='15' maxlength='12'/></p>
<p><input name='zeit' value='hh:mm (24h)' onclick='this.value=\"\"' size='15' maxlength='12'/></p>
</td>
<td valign='top'>
<b>Rasen:</b>
<p><select name='rasen' size='1' style='width:150px;'>
<option disabled selected='selected'>Bitte Waehlen</option>
<option value='H'>Halle (H)</option>
<option value='KR'>Kunstrasen (KR)</option>
<option value='K2'>Kleinfeldkunstrasen (K2)</option>
<option value='R'>Rasen (R)</option>
<option value='R2'>Kleinfeldrasen (R2)</option>
</select></p>
<br />
<b>Ort:</b>
<p><input type='text' name='ort' value='Ort' onclick='this.value=\"\"' size='23' maxlength='20'/></p>
</td>
</tr>
<tr>
<td>
<p align='middle'><b>Art:</b></p>
<p align='center'><input type='radio' name='ho_aw' value='Home'> Home</input>
<input type='radio' name='ho_aw' value='Away'> Away</input>
<p align='middle'><select name='art' style='width:150px'>
<option disabled selected='selected' >Bitte Waehlen</option>
<option value='FR'>Freundschaftsspiel</option>
<option value='LS'>Ligaspiel</option>
<option value='T'>Training</option>
<option value='LT'>Lauftraining</option>
</select></p>
<p align='center'><b>Gegner:</b></p>
<p align='center'><input name='gegner' value='Gegner' onclick='this.value=\"\"' size='15' maxlength='15'/>
</td>
<td>
<p align='center'><input type='submit' name='Termin_Eintragen' value='Termin Eintragen' /></p>
</td>
</tr>
</form>
</table></div>";
}
#--- ---#
#--- Termine eintragen ---#
function T_eintragen($g_tag, $g_ort, $g_rasen, $g_art, $g_gegner, $g_home_away, $g_datum, $g_zeit, $uebergabe) {
$this->tag = $g_tag;
$this->ort = $g_ort;
$this->rasen = $g_rasen;
$this->art = $g_art;
$this->gegner = $g_gegner;
$this->home_away = $g_home_away;
$this->datum = $g_datum;
$this->zeit = $g_zeit;
$this->uebergeben = $uebergabe;
#--- Einfügen in die Datenbank
$t_eintragen = ("INSERT INTO Termin (art, ort, rasen, mannschaft, Tag, home_away, Datum, Uhrzeit) VALUES ('$this->art', '$this->ort', '$this->rasen', '$this->gegner', '$this->tag', '$this->home_away', '$this->datum', '$this->zeit')");
$this->resultat = mysql_query($t_eintragen);
echo "<div id='main_content'>Termin wurde erfolgreich eingetragen!</div>";
}
#-------- ---------#
#--- Alle Termine anzeigen ---#
function T_anzeigen() {
$result = mysql_query("SELECT * FROM Termin");
echo "<div id='main_content'><table class='termin' >
<form action='' method='post'>
<tr><td>
<table class='termin' border='' cellpadding='5'>
<thead>
<tr align='left' class='odd'>
<th></th>
<th>Datum/Uhrzeit</th>
<th align='center'>Tag</th>
<th>Art</th>
<th>Ort</th>
<th>Rasen</th>
<th>Home/Away</th>
<th>Ergebnis</th>
</tr>
</thead>";
while($row = mysql_fetch_array($result)) {
echo "<tbody>";
if ($row['art'] == LS) echo "<tr class='ligaspiel'>";
elseif ($row['art'] == FR) echo "<tr class='friendly'>";
elseif ($row['art'] == T) echo "<tr class='training'>";
elseif ($row['art'] == LT) echo "<tr class='laufen'>";
echo "<td align='center'><input type='checkbox' name='checkbox[]' id='checkbox[]' value='$row[T_id]' /></td>";
echo "<td>" . $row['Datum'] . ' / ' . $row['Uhrzeit'] . "</td>";
echo "<td>" . $row['Tag'] . "</td>";
echo "<td>" . $row['art'] . "</td>";
echo "<td>" . $row['ort'] . "</td>";
echo "<td>" . $row['rasen'] . "</td>";
if ($row['art'] == T) echo "<td align='center'>FC Wien</td><td align='center'>n/A</td>";
else {
if ($row['home_away'] == "Ho") {
echo "<td>FC Wien - " . $row['mannschaft'] . "</td>";
if ($row['art'] != "T" && $row['art'] != "LT") echo "<td> <input type='button' name='score_h' onclick='score_home()' value='Ergebnis eintragen' /> </td>";
else echo "<td>n/A</td>";
}
else {
echo "<td>" . $row['mannschaft'] . " - FC Wien</td>";
if ($row['art'] != "T" && $row['art'] != "LT") echo "<td> <input type='button' name='score_a' onclick='score_away()' value='Ergebnis eintragen' /> </td>";
else echo "<td align='center'> n/A </td>";
}
}
echo "</tr></tbody>";
}
echo "</table>
</td></tr>
<tr><td align='center'>
<input name='delete' type='submit' id='delete' value='Ausgewaehlte Termine loeschen'>
</form>
</td></tr>
</table></div>";
#<input type='button' name='cover' onclick='' value='Editieren' />
#if(isset($_POST['score']))
# echo "Hallo";
}
#--- Termine loeschen (checkbox Wahl) ---#
function T_loeschen($checkbox) {
for($i=0; $i < 200; $i++) {
$del_id = $checkbox[$i];
$sql = "DELETE FROM Termin WHERE T_id = '$del_id'";
$result = mysql_query($sql);
}
if ($result) {
echo "<meta http-equiv='PHP_SELF' content=\"0\">";
echo "<div id='main_content'><p align='center'>Ausgewaehlte Termine erfolgreich geloescht!</p></div>";
}
}
#-- Delete Selected Kurs --
#-------- ---------#
}
?>