2005-09-10 19:25:43 +02:00
|
|
|
<?php
|
|
|
|
$title = "Räume";
|
|
|
|
$header = "Verwaltung der Räume";
|
|
|
|
include ("./inc/header.php");
|
|
|
|
include ("./inc/funktion_user.php");
|
|
|
|
|
|
|
|
function runSQL( $SQL)
|
|
|
|
{
|
|
|
|
include( "./inc/db.php");
|
|
|
|
// hier muesste das SQL ausgefuehrt werden...
|
|
|
|
$Erg = mysql_query($SQL, $con);
|
2006-04-19 20:44:12 +02:00
|
|
|
if ($Erg)
|
|
|
|
{
|
2005-11-06 02:19:11 +01:00
|
|
|
echo "Änderung wurde gesichert...<br>";
|
|
|
|
echo "[$SQL]<br>";
|
|
|
|
return 1;
|
2006-04-19 20:44:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-06 02:19:11 +01:00
|
|
|
echo "Fehler beim speichern... bitte noch ein mal probieren :)";
|
|
|
|
echo "<br><br>".mysql_error( $con ). "<br>";
|
|
|
|
echo "[$SQL]<br>";
|
|
|
|
return 0;
|
2005-09-10 19:25:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-19 20:44:12 +02:00
|
|
|
function runSQL_log( $SQL, $commed)
|
|
|
|
{
|
|
|
|
include( "./inc/db.php");
|
|
|
|
// hier muesste das SQL ausgefuehrt werden...
|
|
|
|
$Erg = db_query($SQL, $commed);
|
|
|
|
if ($Erg)
|
|
|
|
{
|
|
|
|
echo "Änderung wurde gesichert...<br>";
|
|
|
|
echo "[$SQL]<br>";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "Fehler beim speichern... bitte noch ein mal probieren :)";
|
|
|
|
echo "<br><br>".mysql_error( $con ). "<br>";
|
|
|
|
echo "[$SQL]<br>";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-10 19:25:43 +02:00
|
|
|
|
2005-11-19 21:23:09 +01:00
|
|
|
$Sql = "SELECT * FROM `EngelType` ORDER BY NAME";
|
2005-09-10 19:25:43 +02:00
|
|
|
$Erg = mysql_query($Sql, $con);
|
|
|
|
|
2005-11-06 02:19:11 +01:00
|
|
|
if( !IsSet($_GET["action"]) )
|
2005-09-10 19:25:43 +02:00
|
|
|
{
|
|
|
|
echo "Hallo ".$_SESSION['Nick'].
|
|
|
|
",<br>\nhier hast du die Möglichkeit, neue Engeltypen für die Schichtpläne einzutragen ".
|
|
|
|
"oder vorhandene abzuändern:<br><br>\n";
|
|
|
|
|
|
|
|
echo "<a href=\"./EngelType.php?action=new\">- Neuen EngelType eintragen</a><br>\n";
|
|
|
|
|
|
|
|
echo "<table width=\"100%\" class=\"border\" cellpadding=\"2\" cellspacing=\"1\">\n";
|
|
|
|
echo "<tr class=\"contenttopic\">\n";
|
|
|
|
|
|
|
|
for( $i = 1; $i < mysql_num_fields($Erg); $i++ )
|
|
|
|
{
|
|
|
|
echo "\t<td>". mysql_field_name($Erg, $i). "</td>";
|
|
|
|
}
|
|
|
|
echo "\t<td>Ändern</td>";
|
|
|
|
echo "</tr>";
|
|
|
|
|
|
|
|
for( $t = 0; $t < mysql_num_rows($Erg); $t++ )
|
|
|
|
{
|
|
|
|
echo "\t<tr class=\"content\">\n";
|
|
|
|
for ($j = 1; $j < mysql_num_fields($Erg); $j++)
|
|
|
|
{
|
|
|
|
echo "\t\t<td>".mysql_result($Erg, $t, $j)."</td>\n";
|
|
|
|
}
|
|
|
|
echo "\t\t<td><a href=\"./EngelType.php?action=change&TID=".mysql_result($Erg, $t, "TID")."\">###</a></td>\n";
|
|
|
|
echo "\t</tr>\n";
|
|
|
|
} // ende Auflistung Raeume
|
|
|
|
echo "</table>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2005-11-06 02:19:11 +01:00
|
|
|
switch ($_GET["action"]) {
|
2005-09-10 19:25:43 +02:00
|
|
|
|
|
|
|
case 'new':
|
|
|
|
echo "Neuen EngelType einrichten: <br>";
|
2005-11-06 02:19:11 +01:00
|
|
|
echo "<form action=\"./EngelType.php\" method=\"GET\">\n";
|
2005-09-10 19:25:43 +02:00
|
|
|
echo "<table>\n";
|
|
|
|
|
|
|
|
for( $Uj = 1; $Uj < mysql_num_fields($Erg); $Uj++ )
|
|
|
|
{
|
|
|
|
echo "<td>".mysql_field_name($Erg, $Uj)."</td>".
|
|
|
|
"<td><input type=\"text\" size=\"40\" name=\"".mysql_field_name($Erg, $Uj)."\"></td></tr>\n";
|
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"newsave\">\n";
|
|
|
|
echo "<input type=\"submit\" value=\"sichern...\">\n";
|
|
|
|
echo "</form>";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'newsave':
|
2005-11-06 02:19:11 +01:00
|
|
|
$vars = $HTTP_GET_VARS;
|
2005-09-10 19:25:43 +02:00
|
|
|
$count = count($vars) - 1;
|
|
|
|
$vars = array_splice($vars, 0, $count);
|
2005-11-06 02:19:11 +01:00
|
|
|
$Keys="";
|
|
|
|
$Values="";
|
2005-09-10 19:25:43 +02:00
|
|
|
foreach($vars as $key => $value){
|
|
|
|
$Keys .= ", `$key`";
|
|
|
|
$Values .= ", '$value'";
|
|
|
|
}
|
|
|
|
|
2006-04-19 20:44:12 +02:00
|
|
|
if( runSQL_log( "INSERT INTO `EngelType` (". substr($Keys, 2). ") VALUES (". substr($Values, 2). ")",
|
|
|
|
"save new EngelType") )
|
2005-09-10 19:25:43 +02:00
|
|
|
{
|
|
|
|
SetHeaderGo2Back();
|
|
|
|
|
2005-11-06 02:19:11 +01:00
|
|
|
$SQL2 = "SELECT * FROM `EngelType` WHERE `Name`='". $_GET["Name"]. "'";
|
2005-09-10 19:25:43 +02:00
|
|
|
$ERG = mysql_query($SQL2, $con);
|
|
|
|
|
|
|
|
if( mysql_num_rows($ERG) == 1)
|
2006-04-19 20:44:12 +02:00
|
|
|
runSQL_log( "ALTER TABLE `Room` ADD `DEFAULT_EID_". mysql_result( $ERG, 0, 0).
|
|
|
|
"` INT DEFAULT '0' NOT NULL;",
|
|
|
|
"add new EngelType in Romm Table");
|
2005-09-10 19:25:43 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'change':
|
2005-11-06 02:19:11 +01:00
|
|
|
if (! IsSet($_GET["TID"])) {
|
2005-09-10 19:25:43 +02:00
|
|
|
echo "Fehlerhafter Aufruf!";
|
|
|
|
} else {
|
|
|
|
|
|
|
|
echo "Raum abändern:\n";
|
|
|
|
|
|
|
|
echo "Hier kannst du eintragen, den EngelType ändern.";
|
|
|
|
|
2005-11-06 02:19:11 +01:00
|
|
|
echo "<form action=\"./EngelType.php\" method=\"GET\">\n";
|
2005-09-10 19:25:43 +02:00
|
|
|
echo "<table>\n";
|
|
|
|
|
2005-11-06 02:19:11 +01:00
|
|
|
$SQL2 = "SELECT * FROM `EngelType` WHERE `TID`='". $_GET["TID"]. "'";
|
2005-09-10 19:25:43 +02:00
|
|
|
$ERG = mysql_query($SQL2, $con);
|
|
|
|
|
|
|
|
for ($Uj = 1; $Uj < mysql_num_fields($ERG); $Uj++)
|
|
|
|
{
|
2005-11-06 02:19:11 +01:00
|
|
|
echo "<tr><td>". mysql_field_name($ERG, $Uj). "</td>".
|
|
|
|
"<td><input type=\"text\" size=\"40\" name=\"e". mysql_field_name($ERG, $Uj). "\" ".
|
|
|
|
"value=\"". mysql_result($ERG, 0, $Uj). "\"></td></tr>\n";
|
2005-09-10 19:25:43 +02:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
2005-11-06 02:19:11 +01:00
|
|
|
echo "<input type=\"hidden\" name=\"eTID\" value=\"". $_GET["TID"]. "\">\n";
|
2005-09-10 19:25:43 +02:00
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"changesave\">\n";
|
|
|
|
echo "<input type=\"submit\" value=\"sichern...\">\n";
|
|
|
|
echo "</form>";
|
2005-11-06 02:19:11 +01:00
|
|
|
echo "<form action=\"./EngelType.php\" method=\"GET\">\n";
|
|
|
|
echo "<input type=\"hidden\" name=\"TID\" value=\"". $_GET["TID"]. "\">\n";
|
2005-09-10 19:25:43 +02:00
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"delete\">\n";
|
|
|
|
echo "<input type=\"submit\" value=\"Löschen...\">";
|
|
|
|
echo "</form>";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'changesave':
|
2005-11-06 02:19:11 +01:00
|
|
|
$vars = $HTTP_GET_VARS;
|
2005-09-10 19:25:43 +02:00
|
|
|
$count = count($vars) - 2;
|
|
|
|
$vars = array_splice($vars, 0, $count);
|
2005-11-06 02:19:11 +01:00
|
|
|
$keys="";
|
|
|
|
$sql="";
|
2005-09-10 19:25:43 +02:00
|
|
|
foreach($vars as $key => $value){
|
|
|
|
$keys = substr($key,1);
|
|
|
|
$sql .= ", `".$keys."`='".$value."'";
|
|
|
|
}
|
2006-04-19 20:44:12 +02:00
|
|
|
runSQL_log( "UPDATE `EngelType` SET ". substr($sql, 2). " WHERE `TID`='". $_GET["eTID"]. "'",
|
|
|
|
"Save Change EngelType");
|
2005-09-10 19:25:43 +02:00
|
|
|
SetHeaderGo2Back();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete':
|
2005-11-06 02:19:11 +01:00
|
|
|
if (IsSet($_GET["TID"]))
|
2005-09-10 19:25:43 +02:00
|
|
|
{
|
2006-04-19 20:44:12 +02:00
|
|
|
runSQL_log( "DELETE FROM `EngelType` WHERE `TID`='". $_GET["TID"]. "'", "delate EngelType");
|
|
|
|
runSQL_log( "ALTER TABLE `Room` DROP `DEFAULT_EID_". $_GET["TID"]. "`;", "delate EngelType in Room Table");
|
2005-09-10 19:25:43 +02:00
|
|
|
} else {
|
|
|
|
echo "Fehlerhafter Aufruf";
|
|
|
|
}
|
|
|
|
SetHeaderGo2Back();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
include ("./inc/footer.php");
|
|
|
|
?>
|