bugfix in counter

git-svn-id: svn://svn.cccv.de/engel-system@335 29ba0400-6e00-0410-a75a-ca02368028f8
main
cookie 16 years ago
parent 3b7d279a94
commit cdcea4b449

@ -41,6 +41,8 @@ function SaveSchedule()
$Erg1 = mysql_query($SQL1, $con); $Erg1 = mysql_query($SQL1, $con);
if( mysql_num_rows($Erg1)==0) if( mysql_num_rows($Erg1)==0)
{
echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "'";
$SQL= "INSERT INTO `Shifts` (`PSID`, `DateS`, `DateE`, `Len`, `RID`, `Man`, `URL`) ". $SQL= "INSERT INTO `Shifts` (`PSID`, `DateS`, `DateE`, `Len`, `RID`, `Man`, `URL`) ".
"VALUES ('". $_GET["PSIDXML"]. "', ". "VALUES ('". $_GET["PSIDXML"]. "', ".
"'". $_GET["DateXML"]. "', ". "'". $_GET["DateXML"]. "', ".
@ -50,7 +52,11 @@ function SaveSchedule()
"'". mysql_escape_string($_GET["ManXML"]). "', ". "'". mysql_escape_string($_GET["ManXML"]). "', ".
"'". $_GET["URLXML"]. "'". "'". $_GET["URLXML"]. "'".
");"; ");";
}
else else
{
echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "' (SID ".
mysql_result( $Erg1, 0, "SID"). ")";
$SQL= "UPDATE `Shifts` SET ". $SQL= "UPDATE `Shifts` SET ".
"`DateS` = '". $_GET["DateXML"]. "', ". "`DateS` = '". $_GET["DateXML"]. "', ".
"`DateE` = '". $DateEnd. "', ". "`DateE` = '". $DateEnd. "', ".
@ -59,10 +65,11 @@ function SaveSchedule()
"`Man` = '". mysql_escape_string($_GET["ManXML"]). "', ". "`Man` = '". mysql_escape_string($_GET["ManXML"]). "', ".
"`URL`= '". $_GET["URLXML"]. "' ". "`URL`= '". $_GET["URLXML"]. "' ".
"WHERE `PSID` = '". $_GET["PSIDXML"]. "' LIMIT 1;"; "WHERE `PSID` = '". $_GET["PSIDXML"]. "' LIMIT 1;";
}
$Erg = mysql_query($SQL, $con); $Erg = mysql_query($SQL, $con);
if( $Erg ) if( $Erg )
{ {
echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "', war erfogreich<br>\n"; echo ", war erfogreich<br>\n";
//SID auslesen //SID auslesen
$SQL1 = "Select `SID` FROM `Shifts` WHERE `PSID`='". $_GET["PSIDXML"]. "';"; $SQL1 = "Select `SID` FROM `Shifts` WHERE `PSID`='". $_GET["PSIDXML"]. "';";
@ -88,7 +95,7 @@ function SaveSchedule()
"WHERE `SID`='". $newSID. "' AND ". "WHERE `SID`='". $newSID. "' AND ".
"`TID` = '". $EngelTypeID. "';"; "`TID` = '". $EngelTypeID. "';";
$ErgShifts = mysql_query( $sqlShifts, $con); $ErgShifts = mysql_query( $sqlShifts, $con);
$EngelNeeded -= mysql_num_rows( $ErgShifts); $EngelNeeded_Exist = mysql_num_rows( $ErgShifts);
// check for not empty shifts // check for not empty shifts
$sqlShiftsNotEmpty = "SELECT * FROM `ShiftEntry` ". $sqlShiftsNotEmpty = "SELECT * FROM `ShiftEntry` ".
@ -96,18 +103,14 @@ function SaveSchedule()
"`TID` = '". $EngelTypeID. "' AND ". "`TID` = '". $EngelTypeID. "' AND ".
"`UID` != 0 ;"; "`UID` != 0 ;";
$ErgShiftsNotEmpty = mysql_query( $sqlShiftsNotEmpty, $con); $ErgShiftsNotEmpty = mysql_query( $sqlShiftsNotEmpty, $con);
if( (mysql_num_rows( $ErgShiftsNotEmpty) > 0) && ($EngelNeeded < 0) ) $EngelNeeded_NotEmpty = mysql_num_rows( $ErgShiftsNotEmpty);
{
echo "---> WARING ". mysql_num_rows( $ErgShiftsNotEmpty). " shift is used, can't deleting all shifts<br>\n";
$EngelNeeded += mysql_num_rows( $ErgShiftsNotEmpty);
}
// Angel create/delte? // Angel create/delte?
if( $EngelNeeded > 0) if( $EngelNeeded > $EngelNeeded_Exist)
{ {
echo "---->Create Shifts for engeltype: ". $EngelTypeID. " ". $EngelNeeded. "x<br>\n------>\n"; echo "---->Create Shifts for engeltype: ". TID2Type($EngelTypeID). " ".
for( $i=0; $i < $EngelNeeded; $i++ ) ($EngelNeeded-$EngelNeeded_Exist). "x<br>\n------>\n";
for( $i=0; $i < ($EngelNeeded-$EngelNeeded_Exist); $i++ )
{ {
$SQL3 = "INSERT INTO `ShiftEntry` (`SID`, `TID`) VALUES (". $SQL3 = "INSERT INTO `ShiftEntry` (`SID`, `TID`) VALUES (".
"'". $newSID. "', ". "'". $newSID. "', ".
@ -121,10 +124,22 @@ function SaveSchedule()
} }
echo "<br>\n"; echo "<br>\n";
} }
else if ($EngelNeeded < 0) else if ($EngelNeeded < $EngelNeeded_Exist)
{ {
echo "---->Delete empty Shifts for engeltype: ". $EngelTypeID. " ". $EngelNeeded. "x<br>\n------>\n"; if( $EngelNeeded > $EngelNeeded_NotEmpty)
for( ; $EngelNeeded < 0; $EngelNeeded++ ) {
$EngelMin = $EngelNeeded;
}
else
{
$EngelMin = $EngelNeeded_NotEmpty;
echo "---> WARING ". $EngelNeeded_NotEmpty.
" shift is used, can't del ". TID2Type($EngelTypeID). " shifts\t";
}
echo "---->Delete empty Shifts for engeltype: ". TID2Type($EngelTypeID). " ".
($EngelNeeded_Exist-$EngelMin)."x<br>\n------>\n";
for( $i=$EngelMin; $i<$EngelNeeded_Exist; $i++ )
{ {
$SQL3 = "DELETE FROM `ShiftEntry` ". $SQL3 = "DELETE FROM `ShiftEntry` ".
"WHERE `SID` = ". $newSID. " AND ". "WHERE `SID` = ". $newSID. " AND ".
@ -142,14 +157,14 @@ function SaveSchedule()
} }
else else
{ {
// echo "---->Nothing to do, for engeltype: ". $EngelTypeID. "<br>\n"; // echo "---->Nothing to do, for engeltype: ". TID2Type($EngelTypeID). "<br>\n";
} }
} }
} }
} }
else else
echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "', war <u>nicht</u> erfogreich.(". echo ", war <u>nicht</u> erfogreich.(".
mysql_error($con). ")<br>[$SQL]<br>\n"; mysql_error($con). ")<br>[$SQL]<br>\n";
} }
else else

Loading…
Cancel
Save