\n";
// erstellt ein Array der Reume
$sql = "SELECT `RID`, `Name` FROM `Room` ORDER BY `Name`";
$Erg = mysql_query($sql, $con);
$rowcount = mysql_num_rows($Erg);
for ($i=0; $i<$rowcount; $i++)
{
$Room[$i]["RID"] = mysql_result($Erg, $i, "RID");
$Room[$i]["Name"] = mysql_result($Erg, $i, "Name");
}
// erstellt ein Aray der Engeltypen
$sql = "SELECT `TID`, `Name` FROM `EngelType` ORDER BY `Name`";
$Erg = mysql_query($sql, $con);
$rowcount = mysql_num_rows($Erg);
for ($i=0; $i<$rowcount; $i++)
{
$EngelType[$i]["TID"] = mysql_result($Erg, $i, "TID");
$EngelType[$i]["Name"] = mysql_result($Erg, $i, "Name").Get_Text("inc_schicht_engel");
}
// sesion mit stanadrt werten befüllen
if( !isset( $_SESSION['shiftadd.php']['SchichtName']))
{
$_SESSION['shiftadd.php']['SchichtName'] = "--???--";
$_SESSION['shiftadd.php']['RID'] = "";
$_SESSION['shiftadd.php']['MonthJahr'] = gmdate("Y-m", $Time);
$_SESSION['shiftadd.php']['SDatum'] = gmdate("d", $Time);
$_SESSION['shiftadd.php']['STime'] = "10";
$_SESSION['shiftadd.php']['MoreThenOne'] = "ON";
$_SESSION['shiftadd.php']['EDatum'] = gmdate("d", $Time);
$_SESSION['shiftadd.php']['ETime'] = "12";
$_SESSION['shiftadd.php']['len'] = "2";
$_SESSION['shiftadd.php']['NachtON'] = "OFF";
$_SESSION['shiftadd.php']['len_night'] = "00-04-08-10-12-14-16-18-20-22-24";
}
// wenn werte übergeben in sesion eintragen
if( !isset($_GET["NachtON"]))
$_GET["NachtON"] = "OFF";
if( !isset($_GET["MoreThenOne"]))
$_GET["MoreThenOne"] = "OFF";
if( isset( $_GET["SchichtName"]))
{
foreach ($_GET as $k => $v)
{
$_SESSION['shiftadd.php'][$k] = $v;
}
}
if (!IsSet($_GET["action"]))
$_GET["action"] = "new";
switch( $_GET["action"])
{
case 'new':
?>
Hier kannst du neue Schichten eintragen. Dazu musst du den Anfang und das Ende der Schichten eintragen.
Über die Länge der Schichten errechnet sich dadurch die Anzahl dieser. Dadurch können gleich
mehrere Schichten auf einmal erfasst werden:
0))
{
$lenOrg = $_GET["len"];
if( $_GET["NachtON"] == "ON" )
{
$lenArrayDummy = explode( "-", $_GET["len_night"]);
foreach ( $lenArrayDummy as $Temp )
{
if( isset($Temp2) )
$lenArray[intval($Temp2)] = intval($Temp)-intval($Temp2);
$Temp2 = $Temp;
}//foreach
}//IF( $NachtON == "ON" )
echo "\n";
echo "\n";
echo "\tStart | \n";
echo "\tEnd | \n";
echo "\tlen | \n";
echo "\tRID | \n";
echo "\tBeschreibung | \n";
echo "\tEntry 'Shifts' | \n";
echo "\tSID | \n";
echo "\tEntrys | \n";
echo "
\n";
$DateEnd = $_GET["SDatum"];
$TimeEnd = intval($_GET["STime"]);
$len=0;
do
{
// define Start time
$Date = $DateEnd;
$Time = $TimeEnd;
$_DateS = $_GET["MonthJahr"]. "-". $Date. " ". $Time. ":00:00";
// define End time
if( $_GET["NachtON"] == "ON" )
{
if( !isset($lenArray[$Time])) die("Zeit $Time h nicht definiert.");
$_GET["len"] = $lenArray[$Time];
if( $_GET["len"]<1) die("len <1");
}
$TimeEnd = $Time+ $_GET["len"];
//Tagesüberschreitung
while( $TimeEnd >= 24 )
{
$TimeEnd -= 24;
$DateEnd += 1;
}
//ist schischt zu lang dan verkürzen
if( $DateEnd > $_GET["EDatum"] || ($DateEnd == $_GET["EDatum"] && $TimeEnd >= $_GET["ETime"]) )
{
$_GET["len"] -= ($DateEnd- $_GET["EDatum"])*24;
$_GET["len"] -= ($TimeEnd- $_GET["ETime"]); // -(-) ->> +
$DateEnd = $_GET["EDatum"];
$TimeEnd = $_GET["ETime"];
}
$_DateE = $_GET["MonthJahr"]. "-". $DateEnd. " ". $TimeEnd. ":00:00";
if( $_DateS != $_DateE )
CreateNewEntry();
if( $_GET["MoreThenOne"]!="ON" ) break;
if( $DateEnd >= $_GET["EDatum"] && $TimeEnd >= intval($_GET["ETime"]) ) break;
} while( true );
echo "
";
if( $_GET["OnlyShow"]=="ON" )
{
echo "";
} //if
} //IF
break;
case 'engeldel':
break;
} // end switch
function CreateNewEntry()
{
global $con, $_DateS, $_DateE, $EngelType, $DEBUG;
foreach ($EngelType As $TTemp)
{
$Temp = "EngelType".$TTemp["TID"];
global $$Temp;
}
echo "\n";
echo "\t$_DateS | \n";
echo "\t$_DateE | \n";
echo "\t". $_GET["len"]. " | \n";
echo "\t". $_GET["RID"]. " | \n";
echo "\t". $_GET["SchichtName"]. " | \n";
// Ist eintarg schon vorhanden?
$SQL = "SELECT `SID` FROM `Shifts` ";
$SQL .= "WHERE (".
"`DateS` = '". $_DateS. "' AND ".
"`DateE` = '". $_DateE. "' AND ".
"`RID` = '". $_GET["RID"]. "');";
$Erg = mysql_query($SQL, $con);
if( mysql_num_rows($Erg) != 0 )
echo "\texists | ";
elseif( $_GET["OnlyShow"] == "OFF" )
{
// erstellt Eintrag in Shifts für die algemeine schicht
$SQL = "INSERT INTO `Shifts` ( `DateS`, `DateE`, `Len`, `RID`, `Man`) VALUES ( ";
$SQL .= "'". $_DateS. "', '". $_DateE. "', ";
$SQL .= "'". $_GET["len"]. "', '". $_GET["RID"]. "', ";
$SQL .= "'". $_GET["SchichtName"]. "');";
$Erg = db_query($SQL, "create shift");
$SQLFail = "\n\t
[".$SQL. "]";
if ($Erg == 1) echo "\tpass | \n";
else echo "\tfail \n". mysql_error($con). "$SQLFail | \n";
} else
echo "\tonly show | \n";
// sucht SID von eingetragennen schiten
$SQL = "SELECT SID FROM `Shifts` ";
$SQL .= "WHERE (".
"`DateS` = '". $_DateS. "' AND ".
"`DateE` = '". $_DateE. "' AND ".
"`Len` = '". $_GET["len"]. "' AND ".
"`RID` = '". $_GET["RID"]. "');";
$Erg = mysql_query($SQL, $con);
if( mysql_num_rows($Erg) == 0 )
echo "\t? | ";
else
{
$SID = mysql_result($Erg, 0, "SID");
echo "\t". $SID. " | ";
}
// erstellt für jeden Engeltypen die eintrage in 'ShiftEntry'
echo "\t";
foreach ($EngelType As $TTemp)
{
$Temp = "EngelType".$TTemp["TID"];
if( $_GET[$Temp] > 0 )
{
$i = 0;
echo $_GET[$Temp]. " ".$TTemp["Name"]. " \t";
while( $i++ < $_GET[$Temp] )
{
if( $_GET["OnlyShow"] == "OFF" )
{
$SQL = "INSERT INTO `ShiftEntry` (`SID`, `TID`) VALUES (";
$SQL .= "'". $SID. "', ";
$SQL .= "'". $TTemp["TID"]. "');";
$Erg = mysql_query($SQL, $con);
if( $DEBUG ) $SQLFail = "\n\t [".$SQL. "]";
if ($Erg == 1) echo "'pass' ";
else echo "'fail' ". mysql_error($con). "$SQLFail | \n";
}
else
echo "+";
}
echo "
";
} // IF $$TEMP
} // FOREACH
echo "";
echo "
\n";
}
include ("../../../camp2011/includes/footer.php");
?>