summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8>2008-12-29 19:04:43 +0000
committercookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8>2008-12-29 19:04:43 +0000
commitcdcea4b4499c563229ef0d0fefbdf4c29ca7ac6c (patch)
treea788747691ddaedcc24e9aab1250828f60a3eec2
parent3b7d279a944eb737b3793b9d52c7125bfdd6d891 (diff)
bugfix in counter
git-svn-id: svn://svn.cccv.de/engel-system@335 29ba0400-6e00-0410-a75a-ca02368028f8
-rwxr-xr-xincludes/funktion_xml_schudle.php49
1 files changed, 32 insertions, 17 deletions
diff --git a/includes/funktion_xml_schudle.php b/includes/funktion_xml_schudle.php
index a7cf9af4..f6931301 100755
--- a/includes/funktion_xml_schudle.php
+++ b/includes/funktion_xml_schudle.php
@@ -41,6 +41,8 @@ function SaveSchedule()
$Erg1 = mysql_query($SQL1, $con);
if( mysql_num_rows($Erg1)==0)
+ {
+ echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "'";
$SQL= "INSERT INTO `Shifts` (`PSID`, `DateS`, `DateE`, `Len`, `RID`, `Man`, `URL`) ".
"VALUES ('". $_GET["PSIDXML"]. "', ".
"'". $_GET["DateXML"]. "', ".
@@ -50,7 +52,11 @@ function SaveSchedule()
"'". mysql_escape_string($_GET["ManXML"]). "', ".
"'". $_GET["URLXML"]. "'".
");";
+ }
else
+ {
+ echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "' (SID ".
+ mysql_result( $Erg1, 0, "SID"). ")";
$SQL= "UPDATE `Shifts` SET ".
"`DateS` = '". $_GET["DateXML"]. "', ".
"`DateE` = '". $DateEnd. "', ".
@@ -59,10 +65,11 @@ function SaveSchedule()
"`Man` = '". mysql_escape_string($_GET["ManXML"]). "', ".
"`URL`= '". $_GET["URLXML"]. "' ".
"WHERE `PSID` = '". $_GET["PSIDXML"]. "' LIMIT 1;";
+ }
$Erg = mysql_query($SQL, $con);
if( $Erg )
{
- echo "Aenderung, am Schedule '". $_GET["PSIDXML"]. "', war erfogreich<br>\n";
+ echo ", war erfogreich<br>\n";
//SID auslesen
$SQL1 = "Select `SID` FROM `Shifts` WHERE `PSID`='". $_GET["PSIDXML"]. "';";
@@ -88,7 +95,7 @@ function SaveSchedule()
"WHERE `SID`='". $newSID. "' AND ".
"`TID` = '". $EngelTypeID. "';";
$ErgShifts = mysql_query( $sqlShifts, $con);
- $EngelNeeded -= mysql_num_rows( $ErgShifts);
+ $EngelNeeded_Exist = mysql_num_rows( $ErgShifts);
// check for not empty shifts
$sqlShiftsNotEmpty = "SELECT * FROM `ShiftEntry` ".
@@ -96,18 +103,14 @@ function SaveSchedule()
"`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);
- }
-
-
+ $EngelNeeded_NotEmpty = mysql_num_rows( $ErgShiftsNotEmpty);
+
// Angel create/delte?
- if( $EngelNeeded > 0)
+ if( $EngelNeeded > $EngelNeeded_Exist)
{
- echo "---->Create Shifts for engeltype: ". $EngelTypeID. " ". $EngelNeeded. "x<br>\n------>\n";
- for( $i=0; $i < $EngelNeeded; $i++ )
+ echo "---->Create Shifts for engeltype: ". TID2Type($EngelTypeID). " ".
+ ($EngelNeeded-$EngelNeeded_Exist). "x<br>\n------>\n";
+ for( $i=0; $i < ($EngelNeeded-$EngelNeeded_Exist); $i++ )
{
$SQL3 = "INSERT INTO `ShiftEntry` (`SID`, `TID`) VALUES (".
"'". $newSID. "', ".
@@ -121,10 +124,22 @@ function SaveSchedule()
}
echo "<br>\n";
}
- else if ($EngelNeeded < 0)
+ else if ($EngelNeeded < $EngelNeeded_Exist)
{
- echo "---->Delete empty Shifts for engeltype: ". $EngelTypeID. " ". $EngelNeeded. "x<br>\n------>\n";
- for( ; $EngelNeeded < 0; $EngelNeeded++ )
+ if( $EngelNeeded > $EngelNeeded_NotEmpty)
+ {
+ $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` ".
"WHERE `SID` = ". $newSID. " AND ".
@@ -142,14 +157,14 @@ function SaveSchedule()
}
else
{
-// echo "---->Nothing to do, for engeltype: ". $EngelTypeID. "<br>\n";
+// echo "---->Nothing to do, for engeltype: ". TID2Type($EngelTypeID). "<br>\n";
}
}
}
}
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";
}
else