Index: trunk/MagicSoft/Mars/datacenter/db/statussbs.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/statussbs.php	(revision 7484)
+++ trunk/MagicSoft/Mars/datacenter/db/statussbs.php	(revision 7527)
@@ -1,5 +1,5 @@
 <?php
 {
-    function CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere)
+    function CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs)
     {
         $statusgroups = 0;
@@ -14,5 +14,6 @@
             foreach ($checkstatusgroup as $key => $element)
                 if ($element==-1)
-                    $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
+                    $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval 12 hour) < fStartTime,'running','crashed')),if(isnull(" . $needs[$key] . "),'not done','failed'))) ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
+//                    $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
 
             $query0 .= " count(*) as '#days'";
@@ -43,7 +44,7 @@
             $query0 .= " AND ";
 
-        $query0 .= StatusQuery("fCCFilled");
-        $query0 .= StatusQuery("fExclusionsDone");
-        $query0 .= StatusQuery("fSequenceEntriesBuilt");
+        $query0 .= StatusQuery("fCCFilled", $needs);
+        $query0 .= StatusQuery("fExclusionsDone", $needs);
+        $query0 .= StatusQuery("fSequenceEntriesBuilt", $needs);
 
         $query0 .= "fDate BETWEEN '" . $_GET["fRunMin"] . "' AND '" . $_GET["fRunMax"] . "' ";
@@ -165,5 +166,5 @@
     }
 
-    function PrintPage($html, $db, $alias, $rightalign, $checkstatusgroup, $checkwhere)
+    function PrintPage($html, $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs)
     {
         $db_id = mysql_connect("hercules.astro.uni-wuerzburg.de", "MAGIC", "d99swMT!");
@@ -175,5 +176,5 @@
         mysql_select_db($db);
 
-        $query0 = CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere);
+        $query0 = CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs);
 
         $result0 = mysql_query($query0, $db_id);
@@ -206,5 +207,5 @@
         header("Content-Disposition: attachment; filename=query-result.txt");
 
-        PrintPage("0", $db, $alias, $rightalign, $checkstatusgroup, $checkwhere);
+        PrintPage("0", $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs);
     }
     else
@@ -220,5 +221,5 @@
             printf("No query submitted yet.<BR>");
         else
-            PrintPage("1", $db, $alias, $rightalign, $checkstatusgroup, $checkwhere);
+            PrintPage("1", $db, $alias, $rightalign, $checkstatusgroup, $checkwhere, $needs);
 
         echo (file_get_contents("index-footer.html"));
