|
|
@ -63,43 +63,89 @@ function SaveSchedule()
|
|
|
|
if( $Erg )
|
|
|
|
if( $Erg )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "', war erfogreich<br>\n";
|
|
|
|
echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "', war erfogreich<br>\n";
|
|
|
|
if( mysql_num_rows($Erg1)==0)
|
|
|
|
|
|
|
|
|
|
|
|
//SID auslesen
|
|
|
|
|
|
|
|
$SQL1 = "Select `SID` FROM `Shifts` WHERE `PSID`='". $_GET["PSIDXML"]. "';";
|
|
|
|
|
|
|
|
$Erg1 = mysql_query($SQL1, $con);
|
|
|
|
|
|
|
|
$newSID = mysql_result($Erg1, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// erstellt ein Array der Reume
|
|
|
|
|
|
|
|
$sql2 = "SELECT * FROM `Room` ".
|
|
|
|
|
|
|
|
"WHERE `RID`='".$_GET["RIDXML"]. "' ".
|
|
|
|
|
|
|
|
"ORDER BY `Number`, `Name`;";
|
|
|
|
|
|
|
|
$Erg2 = mysql_query( $sql2, $con);
|
|
|
|
|
|
|
|
for( $j=0; $j<mysql_num_fields( $Erg2); $j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
echo "-->Create Shifts:<br>\n";
|
|
|
|
if( substr( mysql_field_name($Erg2, $j), 0, 12)=="DEFAULT_EID_" )
|
|
|
|
|
|
|
|
{
|
|
|
|
//SID auslesen
|
|
|
|
// extract db values
|
|
|
|
$SQL1 = "Select `SID` FROM `Shifts` WHERE `PSID`='". $_GET["PSIDXML"]. "';";
|
|
|
|
$EngelNeeded = mysql_result($Erg2, 0, $j);
|
|
|
|
$Erg1 = mysql_query($SQL1, $con);
|
|
|
|
$EngelTypeID = substr( mysql_field_name($Erg2, $j), 12);
|
|
|
|
|
|
|
|
|
|
|
|
// erstellt ein Array der Reume
|
|
|
|
|
|
|
|
$sql2 = "SELECT * FROM `Room` ".
|
|
|
|
// chech exist shifts
|
|
|
|
"WHERE `RID`='".$_GET["RIDXML"]. "' ".
|
|
|
|
$sqlShifts = "SELECT * FROM `ShiftEntry` ".
|
|
|
|
"ORDER BY `Number`, `Name`;";
|
|
|
|
"WHERE `SID`='". $newSID. "' AND ".
|
|
|
|
$Erg2 = mysql_query( $sql2, $con);
|
|
|
|
"`TID` = '". $EngelTypeID. "';";
|
|
|
|
for( $j=0; $j<mysql_num_fields( $Erg2); $j++)
|
|
|
|
$ErgShifts = mysql_query( $sqlShifts, $con);
|
|
|
|
if( substr( mysql_field_name($Erg2, $j), 0, 12)=="DEFAULT_EID_" &&
|
|
|
|
$EngelNeeded -= mysql_num_rows( $ErgShifts);
|
|
|
|
mysql_result($Erg2, 0, $j) > 0 )
|
|
|
|
|
|
|
|
|
|
|
|
// check for not empty shifts
|
|
|
|
|
|
|
|
$sqlShiftsNotEmpty = "SELECT * FROM `ShiftEntry` ".
|
|
|
|
|
|
|
|
"WHERE `SID`='". $newSID. "' AND ".
|
|
|
|
|
|
|
|
"`TID` = '". $EngelTypeID. "' AND ".
|
|
|
|
|
|
|
|
"`UID` != 0 ;";
|
|
|
|
|
|
|
|
$ErgShiftsNotEmpty = mysql_query( $sqlShiftsNotEmpty, $con);
|
|
|
|
|
|
|
|
if( (mysql_num_rows( $ErgShiftsNotEmpty) > 0) && ($EngelNeeded < 0) )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
echo "---> WARING ". mysql_num_rows( $ErgShiftsNotEmpty). " shift is used, can't deleting all shifts<br>\n";
|
|
|
|
|
|
|
|
$EngelNeeded += mysql_num_rows( $ErgShiftsNotEmpty);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Angel create/delte?
|
|
|
|
|
|
|
|
if( $EngelNeeded > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
echo "---->Create engeltype: ". substr( mysql_field_name($Erg2, $j), 12).
|
|
|
|
echo "---->Create Shifts for engeltype: ". $EngelTypeID. " ". $EngelNeeded. "x<br>\n------>\n";
|
|
|
|
" ". mysql_result($Erg2, 0, $j). "x<br>\n";
|
|
|
|
for( $i=0; $i < $EngelNeeded; $i++ )
|
|
|
|
for( $i=0; $i < mysql_result($Erg2, 0, $j); $i++ )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$SQL3 = "INSERT INTO `ShiftEntry` (`SID`, `TID`) VALUES (".
|
|
|
|
$SQL3 = "INSERT INTO `ShiftEntry` (`SID`, `TID`) VALUES (".
|
|
|
|
"'". mysql_result($Erg1, 0, 0). "', ".
|
|
|
|
"'". $newSID. "', ".
|
|
|
|
"'". substr( mysql_field_name($Erg2, $j), 12). "');";
|
|
|
|
"'". $EngelTypeID. "');";
|
|
|
|
|
|
|
|
$Erg3 = mysql_query($SQL3, $con);
|
|
|
|
|
|
|
|
if ($Erg3 == 1)
|
|
|
|
|
|
|
|
echo "pass ";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo "fail <u>". mysql_error($con).
|
|
|
|
|
|
|
|
"</u>($SQL3)<br>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ($EngelNeeded < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
echo "---->Delete empty Shifts for engeltype: ". $EngelTypeID. " ". $EngelNeeded. "x<br>\n------>\n";
|
|
|
|
|
|
|
|
for( ; $EngelNeeded < 0; $EngelNeeded++ )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$SQL3 = "DELETE FROM `ShiftEntry` ".
|
|
|
|
|
|
|
|
"WHERE `SID` = ". $newSID. " AND ".
|
|
|
|
|
|
|
|
"`TID` = ". $EngelTypeID. " AND ".
|
|
|
|
|
|
|
|
"`UID` = 0 ".
|
|
|
|
|
|
|
|
"LIMIT 1;";
|
|
|
|
$Erg3 = mysql_query($SQL3, $con);
|
|
|
|
$Erg3 = mysql_query($SQL3, $con);
|
|
|
|
if ($Erg3 == 1)
|
|
|
|
if ($Erg3 == 1)
|
|
|
|
echo "------>pass<br>\n";
|
|
|
|
echo "pass ";
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "------>fail <u>".
|
|
|
|
echo "fail <u>". mysql_error($con).
|
|
|
|
mysql_error($con).
|
|
|
|
|
|
|
|
"</u>($SQL3)<br>\n";
|
|
|
|
"</u>($SQL3)<br>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "<br>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "<br>\n";
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// echo "---->Nothing to do, for engeltype: ". $EngelTypeID. "<br>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "', war <u>nicht</u> erfogreich.(".
|
|
|
|
echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "', war <u>nicht</u> erfogreich.(".
|
|
|
|