Index: trunk/MagicSoft/Mars/datacenter/db/sequinfo.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/sequinfo.php	(revision 7524)
+++ trunk/MagicSoft/Mars/datacenter/db/sequinfo.php	(revision 7527)
@@ -1,5 +1,5 @@
 <?php
 {
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup)
+    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
     {
         $fromtable="Sequences";
@@ -36,5 +36,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 'Sequence'";
@@ -110,10 +111,10 @@
             $query0 .= " AND ";
 
-        $query0 .= StatusQuery("fSequenceFileWritten");
-        $query0 .= StatusQuery("fAllFilesAvail");
-        $query0 .= StatusQuery("fCallisto");
-        $query0 .= StatusQuery("fFillCallisto");
-        $query0 .= StatusQuery("fStar");
-        $query0 .= StatusQuery("fFillStar");
+        $query0 .= StatusQuery("fSequenceFileWritten", $needs);
+        $query0 .= StatusQuery("fAllFilesAvail", $needs);
+        $query0 .= StatusQuery("fCallisto", $needs);
+        $query0 .= StatusQuery("fFillCallisto", $needs);
+        $query0 .= StatusQuery("fStar", $needs);
+        $query0 .= StatusQuery("fFillStar", $needs);
 
         if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
@@ -385,4 +386,19 @@
             $_GET["fMaxHumidity"]="Off";
 
+        if (empty($_GET["fStartTime"]))
+            $_GET["fStartTime"]="Off";
+
+        if (empty($_GET["fFailedTime"]))
+            $_GET["fFailedTime"]="Off";
+
+        if (empty($_GET["fReturnCode"]))
+            $_GET["fReturnCode"]="Off";
+
+        if (empty($_GET["fFailedCode"]))
+            $_GET["fFailedCode"]="Off";
+
+        if (empty($_GET["fFailedCodeAdd"]))
+            $_GET["fFailedCodeAdd"]="Off";
+
     }
 
@@ -426,4 +442,18 @@
         printf("</td></tr> </table>\n");
         printf(" <p>\n");
+
+        printf(" <table>\n");
+        printf("  <tr>\n");
+
+        CheckBox("fStartTime",     "StartTime");
+        CheckBox("fFailedTime",    "FailedTime");
+        CheckBox("fReturnCode",    "ErrCode");
+        CheckBox("fFailedCode",    "RetCode");
+        CheckBox("fFailedCodeAdd", "CodeAdd");
+
+        printf("  </tr>\n");
+        printf(" </table>\n");
+        printf(" <p>\n");
+
         printf(" <table>\n");
         printf("  <tr>\n");
@@ -584,5 +614,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!");
@@ -594,5 +624,5 @@
         mysql_select_db($db);
 
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup);
+        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs);
 
         $result0 = mysql_query($query0, $db_id);
@@ -625,5 +655,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
@@ -642,7 +672,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);
         }
 
