Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 7526)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 7527)
@@ -24,8 +24,18 @@
        (P31 - P39, without P36!(problems with spline))
 
+
+
  2006/02/24 Daniela Dorner
+
+   * datacenter/db/datacheck.php, datasetinfo.php, dbstatus.php,
+     findoffdata.php, include.php, magicdefs.php, runinfo.php, 
+     sequinfo.php, statusrps.php, statussbs.php, statussps.php: 
+     - included failure handling columns
 
    * datacenter/db/findoffdata.php: 
      - added DT
+
+   * datacenter/db/statusrps.php: 
+     - fixed bug
 
    * datacenter/db/sequinfo.php: 
Index: /trunk/MagicSoft/Mars/datacenter/db/datacheck.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/datacheck.php	(revision 7526)
+++ /trunk/MagicSoft/Mars/datacenter/db/datacheck.php	(revision 7527)
@@ -1,5 +1,5 @@
 <?php
 {
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup)
+    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup, $needs)
     {
         $fromtable="RunData";
@@ -35,5 +35,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 'Runs'";
@@ -100,6 +101,6 @@
             $query0 .= " AND ";
 
-        $query0 .= StatusQuery("fRawFileAvail");
-        $query0 .= StatusQuery("fDataCheckDone");
+        $query0 .= StatusQuery("fRawFileAvail", $needs);
+        $query0 .= StatusQuery("fDataCheckDone", $needs);
 
         $query0 .= EnumQuery("fHasSignal");
@@ -379,5 +380,5 @@
     }
 
-    function PrintPage($html, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup)
+    function PrintPage($html, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup, $needs)
     {
         $db_id = mysql_connect("hercules.astro.uni-wuerzburg.de", "MAGIC", "d99swMT!");
@@ -389,5 +390,5 @@
         mysql_select_db($db);
 
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup);
+        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup, $needs);
 
         $result0 = mysql_query($query0, $db_id);
@@ -420,5 +421,5 @@
         header("Content-Disposition: attachment; filename=query-result.txt");
 
-        PrintPage("0", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup);
+        PrintPage("0", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup, $needs);
     }
     else
@@ -437,7 +438,7 @@
         {
             if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup);
+                PrintPage("1", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup, $needs);
             else
-                PrintPage("2", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup);
+                PrintPage("2", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $checkenumgroup, $needs);
         }
 
Index: /trunk/MagicSoft/Mars/datacenter/db/datasetinfo.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/datasetinfo.php	(revision 7526)
+++ /trunk/MagicSoft/Mars/datacenter/db/datasetinfo.php	(revision 7527)
@@ -1,5 +1,5 @@
 <?php
 {
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup)
+    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs)
     {
         $fromtable="DataSets";
@@ -30,5 +30,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 'DataSet#'";
@@ -83,8 +84,8 @@
             $query0 .= " AND ";
 
-        $query0 .= StatusQuery("fDataSetInserted");
-        $query0 .= StatusQuery("fStarFilesAvail");
-        $query0 .= StatusQuery("fGanymed");
-        $query0 .= StatusQuery("fFillGanymed");
+        $query0 .= StatusQuery("fDataSetInserted", $needs);
+        $query0 .= StatusQuery("fStarFilesAvail", $needs);
+        $query0 .= StatusQuery("fGanymed", $needs);
+        $query0 .= StatusQuery("fFillGanymed", $needs);
 
         if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
@@ -332,5 +333,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!");
@@ -342,5 +343,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);
@@ -390,7 +391,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);
         }
 
Index: /trunk/MagicSoft/Mars/datacenter/db/dbstatus.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/dbstatus.php	(revision 7526)
+++ /trunk/MagicSoft/Mars/datacenter/db/dbstatus.php	(revision 7527)
@@ -1,5 +1,5 @@
 <?php
 {
-    function CreateQuery($_GET, $alias)
+    function CreateQuery($_GET, $alias, $needs)
     {
         $joins = array
@@ -72,5 +72,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#'";
@@ -125,10 +126,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"]))
@@ -330,5 +331,5 @@
     }
 
-    function PrintPage($html, $db)
+    function PrintPage($html, $db, $needs)
     {
         $db_id = mysql_connect("hercules.astro.uni-wuerzburg.de", "MAGIC", "d99swMT!");
@@ -353,5 +354,5 @@
             );
 
-        $query0 = CreateQuery($_GET, $alias);
+        $query0 = CreateQuery($_GET, $alias, $needs);
 
         $result0 = mysql_query($query0, $db_id);
@@ -400,7 +401,7 @@
         {
             if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $db);
+                PrintPage("1", $db, $needs);
             else
-                PrintPage("2", $db);
+                PrintPage("2", $db, $needs);
         }
 
Index: /trunk/MagicSoft/Mars/datacenter/db/findoffdata.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/findoffdata.php	(revision 7526)
+++ /trunk/MagicSoft/Mars/datacenter/db/findoffdata.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'";
@@ -119,5 +120,5 @@
             $query0 .= " AND ";
 
-        $query0 .= StatusQuery("fStar");
+        $query0 .= StatusQuery("fStar", $needs);
 
         if (!empty($_GET["fRunMin"]) && !empty($_GET["fRunMax"]))
@@ -603,5 +604,5 @@
     }
 
-    function PrintPage($html, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms)
+    function PrintPage($html, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms, $needs)
     {
         $db_id = mysql_connect("hercules.astro.uni-wuerzburg.de", "MAGIC", "d99swMT!");
@@ -613,5 +614,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);
@@ -644,5 +645,5 @@
         header("Content-Disposition: attachment; filename=query-result.txt");
 
-        PrintPage("0", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms);
+        PrintPage("0", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms, $needs);
     }
     else
@@ -661,7 +662,7 @@
         {
             if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms);
-            else
-                PrintPage("2", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms);
+                PrintPage("1", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms, $needs);
+            else
+                PrintPage("2", $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $limits, $rms, $needs);
         }
 
Index: /trunk/MagicSoft/Mars/datacenter/db/include.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/include.php	(revision 7526)
+++ /trunk/MagicSoft/Mars/datacenter/db/include.php	(revision 7527)
@@ -104,5 +104,5 @@
 }
 
-function StatusQuery($name)
+function StatusQuery($name, $needs)
 {
     $var  = $name . "Status";
@@ -112,7 +112,11 @@
     case 0: $txt .= ""; break;
     case 1: $txt .= "NOT (IsNull(" . $name . ") OR " . $name . "='1970-01-01 00:00:00') AND "; break;
-    case 2: $txt .= "IsNull(" . $name . ") AND "; break;
+    case 2: $txt .= "IsNull(" . $name . ") AND IsNull(fStartTime) AND IsNull(fFailedTime) AND NOT IsNull(" . $needs[$name] . ") AND "; break;
     case 3: $txt .= $name ."='1970-01-01 00:00:00' AND "; break;
-    case 4: $txt .= ""; break;
+    case 4: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval 12 hour) < fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
+    case 5: $txt .= " (IsNull(" . $name . ") AND NOT IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
+    case 6: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval 12 hour) > fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
+//    case 6: $txt .= "crashed"; break;
+    case 7: $txt .= ""; break;
     }
     return $txt;
@@ -138,9 +142,12 @@
           2 => "not done",
           3 => "not to be done",
-          4 => "group by"
+          4 => "running",
+          5 => "failed",
+          6 => "crashed",
+          7 => "group by",
         );
 
     $stat=$_GET[$var];
-    for ($i=0; $i<5; $i++)
+    for ($i=0; $i<8; $i++)
     {
         if ($stat==$i)
@@ -399,5 +406,5 @@
     foreach ($_GET as $key => $element)
         if ($key==$column)
-            if ($element==4)
+            if ($element==7)
                 return -1;
     return 0;
Index: /trunk/MagicSoft/Mars/datacenter/db/magicdefs.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/magicdefs.php	(revision 7526)
+++ /trunk/MagicSoft/Mars/datacenter/db/magicdefs.php	(revision 7527)
@@ -1,3 +1,27 @@
 <?php
+
+$needs = array
+    (
+     "fCCFilled"             => "SequenceBuildStatus.fDate",
+     "fExclusionsDone"       => "fCCFilled",
+     "fSequenceEntriesBuilt" => "fExclusionsDone",
+     "fCCFileAvail"          => "RunProcessStatus.fRunNumber",
+     "fCaCoFileAvail"        => "RunProcessStatus.fRunNumber",
+     "fCaCoFileFound"        => "RunProcessStatus.fRunNumber",
+     "fRawFileAvail"         => "RunProcessStatus.fRunNumber",
+     "fDataCheckDone"        => "fRawFileAvail",
+     "fTimingCorrection"     => "fRawFileAvail",
+     "fSequenceFileWritten"  => "SequenceProcessStatus.fSequenceFirst",
+     "fAllFilesAvail"        => "fSequenceFileWritten",
+     "fCallisto"             => "fAllFilesAvail",
+     "fStar"                 => "fCallisto",
+     "fFillCallisto"         => "fCallisto",
+     "fFillStar"             => "fStar",
+     "fDataSetInserted"      => "DataSetProcessStatus.fDataSetNumber",
+     "fStarFilesAvail"       => "fDataSetInserted",
+     "fGanymed"              => "fStarFilesAvail",
+     "fFillGanymed"          => "fGanymed",
+     );
+
 
 $limits = array
@@ -70,5 +94,5 @@
      "fCaCoFileAvail"                    => CheckStatusGroup("fCaCoFileAvailStatus",       $_GET),
      "fCaCoFileFound"                    => CheckStatusGroup("fCaCoFileFoundStatus",       $_GET),
-     "fRawFileAvail"                     => CheckStatusGroup("fRawFileAvailStatu",         $_GET),
+     "fRawFileAvail"                     => CheckStatusGroup("fRawFileAvailStatus",        $_GET),
      "fTimingCorrection"                 => CheckStatusGroup("fTimingCorrectionStatus",    $_GET),
      "fDataCheckDone"                    => CheckStatusGroup("fDataCheckDoneStatus",       $_GET),
@@ -145,5 +169,5 @@
      "fCaCoFileAvail"                   => "CaCoFile",
      "fCaCoFileFound"                   => "CaCoRun",
-     "fRawFileAvail"                    => "Rawfile",
+     "fRawFileAvail"                    => "RawFile",
      "fTimingCorrection"                => "TimingCorr",
      "fDataCheckDone"                   => "Datacheck",
@@ -236,4 +260,9 @@
      "fEMin"                            => "Emin",
      "fEMax"                            => "Emax",
+     "fStartTime"                       => "Process",
+     "fFailedTime"                      => "Failed",
+     "fReturnCode"                      => "Ret<br>Code",
+     "fFailedCode"                      => "Err<br>Code",
+     "fFailedCodeAdd"                   => "Code<br>Add",
     );
 
@@ -309,4 +338,7 @@
      $alias["fPositionAsymInterlaced"]   => "1",
      $alias["fHeightAsymInterlaced"]     => "1",
+     $alias["fReturnCode"]               => "1",
+     $alias["fFailedCode"]               => "1",
+     $alias["fFailedCodeAdd"]            => "1",
      "Time"                              => "1",
 //     "Time [h]"                 => "1",
@@ -468,4 +500,9 @@
          "Max(fZenithDistance)"              => "'ZdMax'",
 //         "COUNT(*)"                          => "'Sequ'",
+         "fStartTime"                       => "fStartTime",
+         "fFailedTime"                      => "fFailedTime",
+         "fReturnCode"                      => "fReturnCode",
+         "fFailedCode"                      => "fFailedCode",
+         "fFailedCodeAdd"                   => "fFailedCodeAdd",
         );
 
Index: /trunk/MagicSoft/Mars/datacenter/db/runinfo.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/runinfo.php	(revision 7526)
+++ /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);
         }
 
Index: /trunk/MagicSoft/Mars/datacenter/db/sequinfo.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/sequinfo.php	(revision 7526)
+++ /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);
         }
 
Index: /trunk/MagicSoft/Mars/datacenter/db/statusrps.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/statusrps.php	(revision 7526)
+++ /trunk/MagicSoft/Mars/datacenter/db/statusrps.php	(revision 7527)
@@ -1,5 +1,5 @@
 <?php
 {
-    function CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere)
+    function CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs)
     {
         $query0 = "SELECT ";
@@ -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 '" . $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 '" . $key . "', ";
 
             $query0 .= " count(*) as 'Run#'";
@@ -36,10 +37,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);
 
         $query0 .= "fRunNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
@@ -52,5 +53,5 @@
                 if ($element==-1)
                 {
-                    $query0 .= $key;
+                    $query0 .= $alias[$key];
                     if ($num-->1)
                         $query0 .= ", ";
@@ -189,5 +190,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!");
@@ -199,5 +200,5 @@
         mysql_select_db($db);
 
-        $query0 = CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere);
+        $query0 = CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs);
 
         $result0 = mysql_query($query0, $db_id);
@@ -230,5 +231,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
@@ -244,5 +245,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"));
Index: /trunk/MagicSoft/Mars/datacenter/db/statussbs.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/statussbs.php	(revision 7526)
+++ /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"));
Index: /trunk/MagicSoft/Mars/datacenter/db/statussps.php
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/db/statussps.php	(revision 7526)
+++ /trunk/MagicSoft/Mars/datacenter/db/statussps.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 'Sequence#'";
@@ -40,10 +41,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);
 
         $query0 .= "fSequenceFirst BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
@@ -178,5 +179,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!");
@@ -188,5 +189,5 @@
         mysql_select_db($db);
 
-        $query0 = CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere);
+        $query0 = CreateQuery($_GET, $alias, $checkstatusgroup, $checkwhere, $needs);
 
         $result0 = mysql_query($query0, $db_id);
@@ -219,5 +220,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
@@ -233,5 +234,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"));
