Index: trunk/MagicSoft/Mars/datacenter/db/runinfo.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/runinfo.php	(revision 7484)
+++ trunk/MagicSoft/Mars/datacenter/db/runinfo.php	(revision 7527)
@@ -1,5 +1,5 @@
 <?php
 {
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup)
+    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
     {
         $fromtable="RunData";
@@ -40,5 +40,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 'Run#'";
@@ -92,10 +93,10 @@
             $query0 .= " AND ";
 
-        $query0 .= StatusQuery("fCCFileAvail");
-        $query0 .= StatusQuery("fCaCoFileAvail");
-        $query0 .= StatusQuery("fCaCoFileFound");
-        $query0 .= StatusQuery("fRawFileAvail");
-        $query0 .= StatusQuery("fDataCheckDone");
-        $query0 .= StatusQuery("fTimingCorrection");
+        $query0 .= StatusQuery("fCCFileAvail", $needs);
+        $query0 .= StatusQuery("fCaCoFileAvail", $needs);
+        $query0 .= StatusQuery("fCaCoFileFound", $needs);
+        $query0 .= StatusQuery("fRawFileAvail", $needs);
+        $query0 .= StatusQuery("fDataCheckDone", $needs);
+        $query0 .= StatusQuery("fTimingCorrection", $needs);
 
         if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
@@ -476,5 +477,5 @@
     }
 
-    function PrintPage($html, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup)
+    function PrintPage($html, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
     {
         $db_id = mysql_connect("hercules.astro.uni-wuerzburg.de", "MAGIC", "d99swMT!");
@@ -487,5 +488,5 @@
         mysql_query("SET BIG_TABLES=1"); // necessary for mySQL <= 4
 
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup);
+        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
 
         $result0 = mysql_query($query0, $db_id);
@@ -518,5 +519,5 @@
         header("Content-Disposition: attachment; filename=query-result.txt");
 
-        PrintPage("0", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup);
+        PrintPage("0", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
     }
     else
@@ -535,7 +536,7 @@
         {
             if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup);
+                PrintPage("1", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
             else
-                PrintPage("2", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup);
+                PrintPage("2", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
         }
 
