Index: trunk/MagicSoft/Mars/datacenter/db/mcdefs.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/mcdefs.php	(revision 9616)
+++ trunk/MagicSoft/Mars/datacenter/db/mcdefs.php	(revision 9617)
@@ -4,5 +4,5 @@
     (
      "Corsika" => "60",
-     "Ceres" => "1",
+     "Ceres" => "2",
      "SequenceFile" => "1",
      "Callisto" => "1",
@@ -40,4 +40,5 @@
     (
      "Run.File"                 => "Run.File",
+     "fSequenceNumber"          => "Sequ",
      "fNumEvents"               => "#Evts",
      "SUM(fNumEvents)"          => "Evts",
@@ -69,5 +70,5 @@
 $rightalign = array
     (
-//     $alias["fRunNumber"]                => "1",
+     $alias["fSequenceNumber"]           => "1",
      $alias["fNumEvents"]                => "1",
      $alias["fZenithDistanceMin"]        => "1",
@@ -157,12 +158,20 @@
     $joins = array
         (
-         "fParticleTypeName"           => " LEFT JOIN ParticleType         USING(fParticleTypeKEY) ",
-         "fRunTypeName"                => " LEFT JOIN RunType              USING(fRunTypeKEY) ",
-         "fAtmosphericModelName"       => " LEFT JOIN AtmosphericModel     USING(fAtmosphericModelKEY) ",
-         "Corsika"                     => " LEFT JOIN CorsikaStatus        USING(fRunNumber, fFileNumber) ",
-         "Ceres"                       => " LEFT JOIN CeresStatus          USING(fRunNumber, fFileNumber, fCeresSetupKEY) ",
-         "SequenceFile"                => " LEFT JOIN SequenceFileStatus   USING(fSequenceNumber) ",
-         "Callisto"                    => " LEFT JOIN CallistoStatus       USING(fSequenceNumber, fCeresSetupKEY) ",
-         "Star"                        => " LEFT JOIN StarStatus           USING(fSequenceNumber, fCeresSetupKEY) ",
+         "fParticleTypeKEY"           => " LEFT JOIN ParticleType         USING(fParticleTypeKEY) ",
+         "fRunTypeKEY"                => " LEFT JOIN RunType              USING(fRunTypeKEY) ",
+         "fAtmosphericModelKEY"       => " LEFT JOIN AtmosphericModel     USING(fAtmosphericModelKEY) ",
+         "fParticleTypeName"          => " LEFT JOIN ParticleType         USING(fParticleTypeKEY) ",
+         "fRunTypeName"               => " LEFT JOIN RunType              USING(fRunTypeKEY) ",
+         "fAtmosphericModelName"      => " LEFT JOIN AtmosphericModel     USING(fAtmosphericModelKEY) ",
+         "CorsikaStatus"              => " LEFT JOIN CorsikaStatus        USING(fRunNumber, fFileNumber) ",
+         "CeresStatus"                => " LEFT JOIN CeresStatus          USING(fRunNumber, fFileNumber, fCeresSetupKEY) ",
+         "SequenceFileStatus"         => " LEFT JOIN SequenceFileStatus   USING(fSequenceNumber) ",
+         "CallistoStatus"             => " LEFT JOIN CallistoStatus       USING(fSequenceNumber, fCeresSetupKEY) ",
+         "StarStatus"                 => " LEFT JOIN StarStatus           USING(fSequenceNumber, fCeresSetupKEY) ",
+         "Corsika"                    => " LEFT JOIN CorsikaStatus        USING(fRunNumber, fFileNumber) ",
+         "Ceres"                      => " LEFT JOIN CeresStatus          USING(fRunNumber, fFileNumber, fCeresSetupKEY) ",
+         "SequenceFile"               => " LEFT JOIN SequenceFileStatus   USING(fSequenceNumber) ",
+         "Callisto"                   => " LEFT JOIN CallistoStatus       USING(fSequenceNumber, fCeresSetupKEY) ",
+         "Star"                       => " LEFT JOIN StarStatus           USING(fSequenceNumber, fCeresSetupKEY) ",
         );
 
Index: trunk/MagicSoft/Mars/datacenter/db/mcinfo.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/mcinfo.php	(revision 9616)
+++ trunk/MagicSoft/Mars/datacenter/db/mcinfo.php	(revision 9617)
@@ -85,5 +85,5 @@
                         $query0 .= " CONCAT('running (since ', " . $key . "Status.fStartTime, ')'), ";
                         $query0 .= " IF (NOT ISNULL(" . $key . "Status.fReturnCode), ";
-                        $query0 .= " CONCAT('failed (', " . $key . "Status.fReturnCode, ')'), ";
+                        $query0 .= " CONCAT('failed (', " . $key . "Status.fReturnCode, ', ', " . $key . "Status.fStopTime, ')'), ";
                         $query0 .= " CONCAT('done (', " . $key . "Status.fStopTime, ";
                         $query0 .= " ', ', TIMEDIFF(" . $key . "Status.fStopTime, " . $key . "Status.fStartTime), ')')))) ";
@@ -103,6 +103,7 @@
 
         foreach ($_GET as $key => $element)
-            if (($_GET[$key]=="On" || $groups>0 || $statusgroups>0))// && !empty($joins[$key]))
-                $query0 .= GetJoin($fromtable,$key);
+            if ($_GET[$key]=="On" || $_GET[$key]!=0)
+                if (strpos($query0, GetJoin($fromtable,$key))==FALSE)
+                    $query0 .= GetJoin($fromtable,$key);
 
         foreach ($checkwhere as $key => $element)
@@ -123,5 +124,5 @@
 
         if (strpos($query0, " WHERE ")==FALSE)
-            $query0 .= " WHERE ";
+            $query0 .= " WHERE";
         else
             $query0 .= " AND ";
@@ -138,6 +139,6 @@
 
         //remove WHERE or AND in the end of the query
-        $query0=ereg_replace(" WHERE \$", " ", $query0);
-        $query0=ereg_replace(" AND \$", " ", $query0);
+        $query0=preg_replace("/ WHERE\s+$/", " ", $query0);
+        $query0=preg_replace("/ AND\s+$/", " ", $query0);
 
         if ($groups>0)
Index: trunk/MagicSoft/Mars/datacenter/db/menu.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/menu.php	(revision 9616)
+++ trunk/MagicSoft/Mars/datacenter/db/menu.php	(revision 9617)
@@ -9,7 +9,5 @@
 
     CheckBox("fNumEvents",        "Num of events");
-    CheckBox("fEnergyMin",        "Emin");
-    CheckBox("fEnergyMax",        "Emax");
-    CheckBox("fEnergySlope",      "Slope");
+    CheckBox("fSequenceNumber",   "Sequ#");
 
     printf("  </tr><tr>\n");
@@ -22,8 +20,14 @@
     printf("  </tr><tr>\n");
 
-    CheckBox("fZenithDistanceMin", "Zenith distance min");
-    CheckBox("fZenithDistanceMax", "Zenith distance max");
+    CheckBox("fZenithDistanceMin", "Zenith dist. min");
+    CheckBox("fZenithDistanceMax", "Zenith dist. max");
     CheckBox("fAzimuthMin",        "Azimuth min");
     CheckBox("fAzimuthMax",        "Azimuth max");
+
+    printf("  </tr><tr>\n");
+
+    CheckBox("fEnergyMin",        "Emin");
+    CheckBox("fEnergyMax",        "Emax");
+    CheckBox("fEnergySlope",      "Slope");
 
     printf("  </tr><tr>\n");
@@ -633,10 +637,10 @@
 {
     if (empty($_GET["fRunMin"]))
-        $min = GetMin("fRunNumber", "CorsikaInfo", $host, $user, $pw, $db);
+        $min = GetMin("fRunNumber", "CeresInfo", $host, $user, $pw, $db);
     else
         $min = $_GET["fRunMin"];
 
     if (empty($_GET["fRunMax"]))
-        $max = GetMax("fRunNumber", "CorsikaInfo", $host, $user, $pw, $db);
+        $max = GetMax("fRunNumber", "CeresInfo", $host, $user, $pw, $db);
     else
         $max = $_GET["fRunMax"];
@@ -790,19 +794,4 @@
 }
 
-function InitFailInfo($first)
-{
-    if (empty($_GET["fStartTime"]))
-        $_GET["fStartTime"]="Off";
-
-    if (empty($_GET["fFailedTime"]))
-        $_GET["fFailedTime"]="Off";
-
-    if (empty($_GET["fReturnCode"]))
-        $_GET["fReturnCode"]="Off";
-
-    if (empty($_GET["fProgramId"]))
-        $_GET["fProgramId"]="Off";
-}
-
 function InitInfo($first)
 {
@@ -810,7 +799,4 @@
         $_GET["fNumResults"]="20";
 
-    if (empty($_GET["fNumEvents"]))
-        $_GET["fNumEvents"]="Off";
-
     if (empty($_GET["fRunStart"]))
         $_GET["fRunStart"]="Off";
@@ -908,5 +894,7 @@
     InitRunStatus($first);
     InitInfo($first);
-    InitFailInfo($first);
+
+    if (empty($_GET["fNumEvents"]))
+        $_GET["fNumEvents"]=$first?"Off":"";
 
     if (empty($_GET["fLinks"]))
@@ -1185,8 +1173,10 @@
     InitInfo($first);
     InitSequStatus($first);
-    InitFailInfo($first);
     InitCalInfo($first);
     InitStarInfo($first);
 
+    if (empty($_GET["fNumEvents"]))
+        $_GET["fNumEvents"]=$first?"Off":"";
+
     if (empty($_GET["fRunTime/60"]))
         $_GET["fRunTime/60"]="Off";
@@ -1256,5 +1246,4 @@
 {
     InitDataSetStatus($first);
-    InitFailInfo($first);
 
     if (empty($_GET["fNumResults"]))
@@ -1612,5 +1601,7 @@
     InitCTAMCRunStatus($first);
     InitInfo($first);
-    InitFailInfo($first);
+
+    if (empty($_GET["fNumEvents"]))
+        $_GET["fNumEvents"]=$first?"Off":"";
 
     if (empty($_GET["fObsLevel"]))
@@ -1671,5 +1662,4 @@
     InitMCRunStatus($_GET, $first);
     InitInfo($_GET, $first);
-    InitFailInfo($_GET, $first);
 
     if (empty($_GET["fParticleTypeName"]))
@@ -1685,15 +1675,18 @@
         $_GET["fNumEvents"]=$first?"On":"";
 
+    if (empty($_GET["fSequenceNumber"]))
+        $_GET["fSequenceNumber"]=$first?"On":"";
+
     if (empty($_GET["fZenithDistanceMin"]))
-        $_GET["fZenithDistanceMin"]=$first?"On":"";
+        $_GET["fZenithDistanceMin"]=$first?"Off":"";
 
     if (empty($_GET["fZenithDistanceMax"]))
-        $_GET["fZenithDistanceMax"]=$first?"On":"";
+        $_GET["fZenithDistanceMax"]=$first?"Off":"";
 
     if (empty($_GET["fAzimuthMin"]))
-        $_GET["fAzimuthMin"]=$first?"On":"";
+        $_GET["fAzimuthMin"]=$first?"Off":"";
 
     if (empty($_GET["fAzimuthMax"]))
-        $_GET["fAzimuthMax"]=$first?"On":"";
+        $_GET["fAzimuthMax"]=$first?"Off":"";
 
     if (empty($_GET["fEnergyMin"]))
