\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");
}
if (!IsSet($action))
$action = "new";
$Time = time()+3600+3600;
switch ($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:
break; // Ende new
case 'newsave':
if (isset($SDatum) && ($len > 0)) {
$lenOrg = $len;
if( $NachtON == "ON" )
{
$lenArrayDummy = explode( ";", $len_night);
foreach ( $lenArrayDummy as $Temp )
{
if( isset($Temp2) )
{
$lenArray[$Temp2] = $Temp-$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 = $SDatum;
$TimeEnd = $STime;
do {
// define Start time
$Date = $DateEnd;
$Time = $TimeEnd;
$_DateS = $MonthJahr. "-". $Date. " ". $Time. ":00:00";
// define End time
if( $NachtON == "ON" )
{
$len = $lenArray[$Time];
}
$TimeEnd = $Time+ $len;
//Tagesüberschreitung
while( $TimeEnd >= 24 )
{
$TimeEnd -= 24;
$DateEnd += 1;
}
//ist schischt zu lang dan verkürzen
if( $DateEnd > $EDatum || ($DateEnd == $EDatum && $TimeEnd >= $ETime) )
{
$len -= ($DateEnd- $EDatum)*24;
$len -= ($TimeEnd- $ETime); // -(-) ->> +
$DateEnd = $EDatum;
$TimeEnd = $ETime;
}
$_DateE = $MonthJahr. "-". $DateEnd. " ". $TimeEnd. ":00:00";
if( $_DateS != $_DateE )
CreateNewEntry();
if( $MoreThenOne!="ON" ) break;
if( $DateEnd == $EDatum && $TimeEnd >= $ETime ) break;
} while( true );
echo "
";
if( $OnlyShow!="" )
{
echo "";
} //if
} //IF
break;
case 'engeldel':
break;
} // end switch
function CreateNewEntry()
{
global $con, $_DateS, $_DateE, $len, $RID, $SchichtName, $OnlyShow, $EngelType, $DEBUG;
foreach ($EngelType As $TTemp)
{
$Temp = "EngelType".$TTemp["TID"];
global $$Temp;
}
echo "\n";
echo "\t$_DateS | \n";
echo "\t$_DateE | \n";
echo "\t$len | ";
echo "\t$RID | \n";
echo "\t$SchichtName | \n";
// Ist eintarg schon vorhanden?
$SQL = "SELECT SID FROM `Shifts` ";
$SQL .= "WHERE (".
"`DateS` = '". $_DateS. "' AND ".
"`DateE` = '". $_DateE. "' AND ".
"`RID` = '". $RID. "');";
$Erg = mysql_query($SQL, $con);
if( mysql_num_rows($Erg) != 0 )
echo "\texists | ";
elseif( $OnlyShow == "" )
{
//Suchet nach letzter SID
$SQLin = "SELECT `SID` FROM `Shifts` ".
"WHERE NOT (`FromPentabarf` = 'Y') ".
"ORDER BY `SID` DESC";
$Ergin = mysql_query($SQLin, $con);
if( mysql_num_rows( $Ergin) > 0)
$newSID = mysql_result( $Ergin, 0, 0)+1;
else
$newSID = 10000;
// erstellt Eintrag in Shifts für die algemeine schicht
$SQL = "INSERT INTO `Shifts` (`SID`, `DateS`, `DateE`, `Len`, `RID`, `Man`) VALUES ('$newSID', ";
$SQL .= "'". $_DateS. "', '". $_DateE. "', ";
$SQL .= "'". $len. "', '". $RID. "', ";
$SQL .= "'". $SchichtName. "');";
$Erg = mysql_query($SQL, $con);
$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` = '". $len. "' AND ".
"`RID` = '". $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( $$Temp > 0 )
{
$i = 0;
echo $$Temp. " ".$TTemp["Name"]. " \t";
while( $i++ < $$Temp )
{
$SQL = "INSERT INTO `ShiftEntry` (`SID`, `TID`) VALUES (";
$SQL .= "'$SID', ";
$SQL .= "'". $TTemp["TID"]. "');";
if( $OnlyShow == "" )
{
$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 "'only show' ";
}
echo "
";
} // IF $$TEMP
} // FOREACH
echo "";
echo "
\n";
}
include ("./inc/footer.php");
?>