Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 9598)
+++ trunk/MagicSoft/Mars/Changelog	(revision 9599)
@@ -19,4 +19,24 @@
                                                  -*-*- END OF LINE -*-*-
 
+ 2010/06/28 Daniela Dorner
+
+   * datacenter/db/include.php:
+     - adapted status query for new db layout
+
+   * datacenter/db/menu.php:
+     - added and exchanged menu points and init elements for the new
+       layout of the FACT mc db
+     - bugfix that menu items can be switched off
+
+   * datacenter/db/mcinfo.php:
+     - adapted the queries for the new layout of the FACT mc db 
+       (different table names, structures and content)
+     - adapted query for the status group by
+
+   * datacenter/db/mcdefs.php:
+     - adapted the arrays for the new layout of the FACT mc db 
+
+
+
  2010/06/28 Thomas Bretz
 
@@ -88,4 +108,5 @@
 
 
+>>>>>>> 1.4293
  2010/06/24 Daniela Dorner
 
Index: trunk/MagicSoft/Mars/datacenter/db/include.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/include.php	(revision 9598)
+++ trunk/MagicSoft/Mars/datacenter/db/include.php	(revision 9599)
@@ -50,5 +50,5 @@
 }
 
-function StatusQuery($name, $needs, $timelimits)
+function StatusQuery($name, $timelimits)
 {
     if (empty($timelimits[$name]))
@@ -60,14 +60,41 @@
     switch ($_GET[$var])
     {
-    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 IsNull(fStartTime) AND IsNull(fFailedTime) AND NOT IsNull(" . $needs[$name] . ") AND "; break; //not done but step before is done
-    case 2: $txt .= "IsNull(" . $name . ") AND "; break; //not done no matter what status of previous step is
-    case 3: $txt .= $name ."='1970-01-01 00:00:00' AND "; break;
-    case 4: $txt .= " (IsNull(" . $name . ") AND IsNull(fFailedTime) AND NOT IsNull(fStartTime) AND date_sub(Now(),interval " . $timelimit . " 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 " . $timelimit . " hour) > fStartTime AND NOT IsNull(" . $needs[$name] . ")) AND "; break;
-//    case 6: $txt .= "crashed"; break;
-    case 7: $txt .= ""; break;
+    case 0://all
+        $txt .= " ";
+        break;
+    case 1://done
+        $txt .= " NOT ISNULL(" . $name . "Status.fStartTime) AND "
+            ." NOT ISNULL(" . $name . "Status.fStopTime) AND "
+            ." ISNULL(" . $name . "Status.fReturnCode) AND ";
+        break;
+    case 2://not done
+        $txt .= " ISNULL(" . $name . "Status.fStartTime) AND "
+            ." ISNULL(" . $name . "Status.fStopTime) AND "
+            ." ISNULL(" . $name . "Status.fReturnCode) AND ";
+        break;
+    case 3://not to be done
+        $txt .= $name ."Status.fStartTime='1970-01-01 00:00:00' AND "
+            . $name ."Status.fStopTime='1970-01-01 00:00:00' AND ";
+        break;
+    case 4://running
+        $txt .= " NOT ISNULL(" . $name . "Status.fStartTime) AND "
+            ." DATE_SUB(Now(),INTERVAL " . $timelimit . " HOUR) < " . $name . "Status.fStartTime AND "
+            ." ISNULL(" . $name . "Status.fStopTime) AND "
+            ." ISNULL(" . $name . "Status.fReturnCode) AND ";
+        break;
+    case 5://failed
+        $txt .= " NOT ISNULL(" . $name . "Status.fStartTime) AND "
+            ." NOT ISNULL(" . $name . "Status.fStopTime) AND "
+            ." NOT ISNULL(" . $name . "Status.fReturnCode) AND ";
+        break;
+    case 6://crashed
+        $txt .= " NOT ISNULL(" . $name . "Status.fStartTime) AND "
+            ." DATE_SUB(Now(),INTERVAL " . $timelimit . " HOUR) > " . $name . "Status.fStartTime AND "
+            ." ISNULL(" . $name . "Status.fStopTime) AND "
+            ." ISNULL(" . $name . "Status.fReturnCode) AND ";
+        break;
+    case 7://group by
+        $txt .= "";
+        break;
     }
     return $txt;
@@ -108,14 +135,4 @@
     }
 
-    /*
-    $status = array("all", "done", "not done", "not to be done");
-    $counter = 0;
-    foreach ($status as $element)
-    {
-        if ($counter==$_GET[$var])
-            printf("<option value=\"%d\" selected>%3s</option>\n", $counter++, $element);
-        else
-            printf("<option value=\"%d\">%3s</option>\n", $counter++, $element);
-    }*/
     printf(" </select>\n");
     printf(" &nbsp;&nbsp;&nbsp;\n");
@@ -329,5 +346,5 @@
 {
     foreach ($_GET as $key => $element)
-        if ($key==$column)
+        if ($key==$column."Status")
             if ($element==7)
                 return -1;
Index: trunk/MagicSoft/Mars/datacenter/db/mcdefs.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/mcdefs.php	(revision 9598)
+++ trunk/MagicSoft/Mars/datacenter/db/mcdefs.php	(revision 9599)
@@ -1,15 +1,11 @@
 <?php
-
-$needs = array
-    (
-     "fCorsikaInputCreated" => "MCRunProcessStatus.fMCRunNumber",
-     "fCorsikaFileAvail"    => "MCRunProcessStatus.fCorsikaInputCreated",
-     );
-
 
 $timelimits = array
     (
-     "fCorsikaInputCreated" => "1",
-     "fCorsikaFileAvail"    => "60",
+     "Corsika" => "60",
+     "Ceres" => "1",
+     "SequenceFile" => "1",
+     "Callisto" => "1",
+     "Star" => "1",
      );
 
@@ -18,4 +14,5 @@
     (
      "fParticleTypeName"                 => CheckWhere("fParticleTypeKEY"),
+     "fRunTypeName"                      => CheckWhere("fRunTypeKEY"),
      "fAtmosphericModelName"             => CheckWhere("fAtmosphericModelKEY"),
     );
@@ -24,4 +21,5 @@
     (
      "fParticleTypeName"                 => CheckGroup("fParticleTypeKEY"),
+     "fRunTypeName"                      => CheckGroup("fRunTypeKEY"),
      "fAtmosphericModelName"             => CheckGroup("fAtmosphericModelKEY"),
     );
@@ -30,6 +28,9 @@
 $checkstatusgroup = array
     (
-     "fCorsikaInputCreated" => CheckStatusGroup("fCorsikaInputCreatedStatus"),
-     "fCorsikaFileAvail" => CheckStatusGroup("fCorsikaFileAvailStatus"),
+     "Corsika"      => CheckStatusGroup("Corsika"),
+     "Ceres"        => CheckStatusGroup("Ceres"),
+     "SequenceFile" => CheckStatusGroup("SequenceFile"),
+     "Callisto"     => CheckStatusGroup("Callisto"),
+     "Star"         => CheckStatusGroup("Star"),
     );
 
@@ -38,30 +39,33 @@
 $alias = array
     (
-//     "fRunNumber"                       => "Run#",
-     "Run#"                    => "Run#",
-     "fNumEvents"              => "#Evts",
-     "SUM(fNumEvents)"         => "Evts",
-     "fParticleTypeName"       => "Particle",
-     "fAtmosphericModelName"   => "Atm.Model",
-     "fCorsikaInputCreated"    => "Input",
-     "fCorsikaFileAvail"       => "Corsika",
-     "fStartTime"              => "Process",
-     "fFailedTime"             => "Failed",
-     "fReturnCode"             => "Ret<br>Code",
-     "fProgramId"              => "Prgr<br>Id",
-     "fZenithDistanceMin"      => "Zd<br>Min",
-     "fZenithDistanceMax"      => "Zd<br>Max",
-     "fAzimuthMin"             => "Az<br>Min",
-     "fAzimuthMax"             => "Az<br>Max",
-     "Min(fZenithDistanceMin)" => "ZDMin",
-     "Max(fZenithDistanceMax)" => "ZDMax",
-     "fEnergyMin"              => "EMin<br>[GeV]",
-     "fEnergyMax"              => "EMax<br>[GeV]",
-     "fImpactMax"              => "Impact<br>[cm]",
-     "fViewConeMax"            => "View<br>cone<br>[deg]",
-     "fEnergySlope"            => "Slope",
-     "fNumReUseShower"         => "#ShowerReUse",
-     "fStartingAltitude"       => "Altitude<br>[g/sqcm]",
-     "fMirrorDiameter"         => "Mirror<br>diam.<br>[cm]",
+     "Run.File"                 => "Run.File",
+     "fNumEvents"               => "#Evts",
+     "SUM(fNumEvents)"          => "Evts",
+     "fParticleTypeName"        => "Particle",
+     "fRunTypeName"             => "RunType",
+     "fAtmosphericModelName"    => "Atm.Model",
+     "fCorsikaInputCreated"     => "Input",
+     "Corsika"                  => "Corsika",
+     "Ceres"                    => "Ceres",
+     "SequenceFile"             => "SequenceFile",
+     "Callisto"                 => "Callisto",
+     "Star"                     => "Star",
+     "fStartTime"               => "Process",
+     "fFailedTime"              => "Failed",
+     "fReturnCode"              => "Ret<br>Code",
+     "fProgramId"               => "Prgr<br>Id",
+     "fZenithDistanceMin"       => "Zd<br>Min",
+     "fZenithDistanceMax"       => "Zd<br>Max",
+     "fAzimuthMin"              => "Az<br>Min",
+     "fAzimuthMax"              => "Az<br>Max",
+     "Min(fZenithDistanceMin)"  => "ZDMin",
+     "Max(fZenithDistanceMax)"  => "ZDMax",
+     "fEnergyMin"               => "EMin<br>[GeV]",
+     "fEnergyMax"               => "EMax<br>[GeV]",
+     "fImpactMax"               => "Impact<br>[cm]",
+     "fViewConeMax"             => "View<br>cone<br>[deg]",
+     "fEnergySlope"             => "Slope",
+     "fStartingAltitude"        => "Altitude<br>[g/sqcm]",
+     "fMirrorDiameter"          => "Mirror<br>diam.<br>[cm]",
     );
 
@@ -80,5 +84,4 @@
      $alias["fViewConeMax"]              => "1",
      $alias["fEnergySlope"]              => "1",
-     $alias["fNumReUseShower"]           => "1",
      $alias["fStartingAltitude"]         => "1",
      $alias["fMirrorDiameter"]           => "1",
@@ -92,6 +95,7 @@
     $checks = array
         (
-         "fParticleTypeName"         => $fromtable . ".fParticleTypeKEY",
-         "fAtmosphericModelName"     => $fromtable . ".fAtmosphericModelKEY",
+         "fParticleTypeName"         => "ParticleType.fParticleTypeKEY",
+         "fRunTypeName"              => "RunType.fRunTypeKEY",
+         "fAtmosphericModelName"     => "AtmosphericModel.fAtmosphericModelKEY",
         );
 
@@ -117,17 +121,17 @@
          "fProgramId"                        => "fProgramId",
          "fParticleTypeName"                 => "ParticleType.fParticleTypeName",
+         "fRunTypeName"                      => "RunType.fRunTypeName",
          "fAtmosphericModelName"             => "AtmosphericModel.fAtmosphericModelName",
-         "fAzimuthMin"                       => $fromtable . ".fAzimuthMin",
-         "fAzimuthMax"                       => $fromtable . ".fAzimuthMax",
-         "fZenithDistanceMin"                => $fromtable . ".fZenithDistanceMin",
-         "fZenithDistanceMax"                => $fromtable . ".fZenithDistanceMax",
-         "fEnergyMin"                        => $fromtable . ".fEnergyMin",
-         "fEnergyMax"                        => $fromtable . ".fEnergyMax",
-         "fImpactMax"                        => $fromtable . ".fImpactMax",
-         "fViewConeMax"                      => $fromtable . ".fViewConeMax",
-         "fEnergySlope"                      => $fromtable . ".fEnergySlope",
-         "fNumReUseShower"                   => $fromtable . ".fNumReUseShower",
-         "fStartingAltitude"                 => $fromtable . ".fStartingAltitude",
-         "fMirrorDiameter"                   => $fromtable . ".fMirrorDiameter",
+         "fAzimuthMin"                       => "CorsikaInfo.fAzimuthMin",
+         "fAzimuthMax"                       => "CorsikaInfo.fAzimuthMax",
+         "fZenithDistanceMin"                => "CorsikaInfo.fZenithDistanceMin",
+         "fZenithDistanceMax"                => "CorsikaInfo.fZenithDistanceMax",
+         "fEnergyMin"                        => "CorsikaInfo.fEnergyMin",
+         "fEnergyMax"                        => "CorsikaInfo.fEnergyMax",
+         "fImpactMax"                        => "CorsikaInfo.fImpactMax",
+         "fViewConeMax"                      => "CorsikaInfo.fViewConeMax",
+         "fEnergySlope"                      => "CorsikaInfo.fEnergySlope",
+         "fStartingAltitude"                 => "CorsikaInfo.fStartingAltitude",
+         "fMirrorDiameter"                   => "CorsikaInfo.fMirrorDiameter",
          "Min(fZenithDistanceMin)"           => "'ZDMin'",
          "Max(fZenithDistanceMax)"           => "'ZDMax'",
@@ -137,6 +141,6 @@
     if (!empty($tables[$val]))
         $table=$tables[$val];
-    if ($val=="Tel:Run/File")
-        $table="'Tel:Run/File'";
+    if ($val=="Run.File")
+        $table="'Run.File'";
     if ($val=="Tel:Sequ")
         $table="CONCAT('M', Sequences.fTelescopeNumber, ':', LPAD(Sequences.fSequenceFirst, 8, '0'))";
@@ -147,4 +151,6 @@
     if ($val=="NumDS")
         $table="'# Datasets'";
+    if ($val=="# Files")
+        $table="'# Files'";
     if ($val=="NumDays")
         $table="'# days'";
@@ -160,5 +166,11 @@
         (
          "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) ",
         );
 
Index: trunk/MagicSoft/Mars/datacenter/db/mcinfo.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/mcinfo.php	(revision 9598)
+++ trunk/MagicSoft/Mars/datacenter/db/mcinfo.php	(revision 9599)
@@ -1,7 +1,7 @@
 <?php
 {
-    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits)
-    {
-        $fromtable="MCCorsikaRunData";
+    function CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $timelimits)
+    {
+        $fromtable="CeresInfo";
 
         $groups = 0;
@@ -42,19 +42,27 @@
                 foreach ($checkstatusgroup as $key => $element)
                     if ($element==-1)
-                        $query0 .= " (if(IsNull(" . $key . "), if(isnull(fStartTime), 'not done', if(isnull(fFailedTime),if(isnull(" . $needs[$key] . "),'not done',if(date_sub(Now(),interval " . $timelimits[$key] . " 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'";
-//                $query0 .= ", SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "' ";
-
+                        $query0 .= " IF( ISNULL(" . $key . "Status.fStartTime) "
+                            ." AND ISNULL(" . $key . "Status.fStopTime) "
+                            ." AND ISNULL(" . $key . "Status.fReturnCode), 'not done', "
+                            ." IF (NOT ISNULL(" . $key . "Status.fStartTime) "
+                            ." AND DATE_SUB(Now(),INTERVAL " . $timelimits[$key] . " HOUR) > " . $key . "Status.fStartTime "
+                            ." AND ISNULL(" . $key . "Status.fStopTime) "
+                            ." AND ISNULL(" . $key . "Status.fReturnCode), 'crashed', "
+                            ." IF (NOT ISNULL(" . $key . "Status.fStartTime) "
+                            ." AND DATE_SUB(Now(),INTERVAL " . $timelimits[$key] . " HOUR) < " . $key . "Status.fStartTime "
+                            ." AND ISNULL(" . $key . "Status.fStopTime) "
+                            ." AND ISNULL(" . $key . "Status.fReturnCode), 'running', "
+                            ." IF (NOT ISNULL(" . $key . "Status.fStartTime) "
+                            ." AND NOT ISNULL(" . $key . "Status.fStopTime) "
+                            ." AND ISNULL(" . $key . "Status.fReturnCode), 'done', 'bla' "
+                            ." )))) AS '". $key . "', ";
             }
-            $query0 .= " COUNT(*) as '# Runs' ";
+            $query0 .= " COUNT(*) as '# Files' ";
             $query0 .= ", SUM(fNumEvents) as '" . $alias["SUM(fNumEvents)"] . "' ";
         }
         else
         {
-            $query0 .= " MCCorsikaRunData.fCorsikaRunNumber as 'Run' ";
-//                $query0 .= " Concat(RunData.fTelescopeNumber,':', RunData.fRunNumber,':', RunData.fFileNumber) as 'Run' ";
-//                $query0 .= " Concat('M', RunData.fTelescopeNumber,':', LPAD(RunData.fRunNumber,8, ' '),'/', LPAD(RunData.fFileNumber, 3, ' ')) as 'Tel:Run/File' ";
+            $query0 .= " CONCAT(LPAD(" . $fromtable . ".fRunNumber,8, ' '),'.', ";
+            $query0 .= " RIGHT(LPAD(" . $fromtable . ".fFileNumber, 6, 0), 3)) as 'Run.File' ";
 
             if (empty($_GET["fSendTxt"]) && !empty($_GET["fLinks"]))
@@ -65,25 +73,31 @@
 
             foreach ($_GET as $key => $element)
-                if ($key!="fLinks" && $_GET[$key]=="On" && $key!="fTest")
-                    if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
-                        $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
-        }
-
-        $query0 .= " FROM MCCorsikaRunData ";
-
-        $query0 .= " LEFT JOIN MCRunProcessStatus ON MCCorsikaRunData.fCorsikaRunNumber=MCRunProcessStatus.fMCRunNumber ";
+                if ($_GET[$key]=="On" && $key!="fTest" && $key!="fLinks")
+                    if (!ereg("^f", $key))
+                    {
+
+                        $query0 .= ", IF (ISNULL(" . $key . "Status.fStartTime) AND ";
+                        $query0 .= " ISNULL(" . $key . "Status.fStopTime) AND ";
+                        $query0 .= " ISNULL(" . $key . "Status.fReturnCode), 'not done', ";
+                        $query0 .= " IF (NOT ISNULL(" . $key . "Status.fReturnCode), ";
+                        $query0 .= " CONCAT('failed (', " . $key . "Status.fReturnCode, ')'), ";
+                        $query0 .= " CONCAT('done (', " . $key . "Status.fStopTime, ')'))) ";
+
+                        //$query0 .= ", CONCAT( 'halo', " . $key . "Status.fStartTime)";
+                        $query0 .= " AS '" . $alias[$key] . "' ";
+                        //echo "ereg: " . $key . "<br>";
+                    }
+                    else
+                        if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
+                            $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
+        }
+
+        $query0 .= " FROM " . $fromtable;
+
+        $query0 .= " LEFT JOIN CorsikaInfo USING(fRunNumber,fFileNumber) ";
 
         foreach ($_GET as $key => $element)
             if (($_GET[$key]=="On" || $groups>0))// && !empty($joins[$key]))
                 $query0 .= GetJoin($fromtable,$key);
-
-        /*
-        if ($_GET["fTest"]!="On")
-        {
-            if ($_GET["fSourceName"]!="On")
-                $query0 .= " LEFT JOIN Source USING(fSourceKEY) ";
-            $query0 .= " WHERE fTest='no'";
-        }
-        */
 
         foreach ($checkwhere as $key => $element)
@@ -108,51 +122,13 @@
             $query0 .= " AND ";
 
-        $query0 .= StatusQuery("fCorsikaInputCreated", $needs, $timelimits);
-        $query0 .= StatusQuery("fCorsikaFileAvail", $needs, $timelimits);
+        $query0 .= StatusQuery("Corsika",      $timelimits);
+        $query0 .= StatusQuery("Ceres",        $timelimits);
+        $query0 .= StatusQuery("SequenceFile", $timelimits);
+        $query0 .= StatusQuery("Callisto",     $timelimits);
+        $query0 .= StatusQuery("Star",         $timelimits);
 
         if ((!empty($_GET["fRunMin"]) || $_GET["fRunMin"]=="0") && !empty($_GET["fRunMax"]))
-            $query0 .= "MCCorsikaRunData.fCorsikaRunNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
-
-//        if ((!empty($_GET["fZDMin"]) || $_GET["fZDMin"]==0) && !empty($_GET["fZDMax"]))
-//            $query0 .= "AND fZenithDistance BETWEEN " . $_GET["fZDMin"] . " AND  " . $_GET["fZDMax"] . " ";
-
-/*
-        if (!empty($_GET["fDate"]))
-            $query0 .= " AND fRunStart REGEXP \"^" . $_GET["fDate"] . "\" ";
-*/
-
-        /*
-        if (!empty($_GET["fSourceN"]))
-            $query0 .= " AND fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
-
-        if (!empty($_GET["fStartDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $startdate=substr($_GET["fStartDate"], 0, 10);
-            if ($startdate=="0000-00-00")
-                $query0 .=" fRunStart >= '" . $startdate . " 00:00:00' ";
-            else
-                $query0 .= " fRunStart >= ADDDATE('" . $startdate . " 13:00:00', INTERVAL -1 DAY) ";
-        }
-
-        if (!empty($_GET["fStopDate"]))
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $stopdate=substr($_GET["fStopDate"], 0, 10);
-            $query0 .= " fRunStart < '" . $stopdate . " 13:00:00' ";
-        }
-
-        if (!empty($_GET["fSequenceNo"]) || $_GET["fSequenceNo"]=="0")
-        {
-            if (strpos(strrev($query0), " DNA ")!=0)
-                $query0 .= " AND ";
-
-            $query0 .= " fSequenceFirst = '" . $_GET["fSequenceNo"] . "' ";
-        }
-        */
+            $query0 .= " " . $fromtable . ".fRunNumber BETWEEN " . $_GET["fRunMin"] . " AND " . $_GET["fRunMax"] . " ";
+
 
         //remove WHERE or AND in the end of the query
@@ -175,5 +151,4 @@
         if ($statusgroups>0)
         {
-//            $query0 .= " GROUP BY ";
             if (strpos($query0, " GROUP BY ")==FALSE)
                 $query0 .= " GROUP BY ";
@@ -198,5 +173,5 @@
         }
         else
-            $query0 .=" ORDER BY MCCorsikaRunData.fCorsikaRunNumber ASC";
+            $query0 .=" ORDER BY " . $fromtable . ".fRunNumber ASC";
 
         if (empty($_GET["fNumStart"]))
@@ -265,5 +240,5 @@
     }
 
-    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits)
+    function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $timelimits)
     {
         $db_id = mysql_connect($host, $user, $pw);
@@ -276,5 +251,5 @@
         mysql_query("SET BIG_TABLES=1"); // necessary for mySQL <= 4
 
-        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits);
+        $query0 = CreateQuery($_GET, $alias, $checkwhere, $checkgroup, $checkstatusgroup, $timelimits);
 
         $result0 = mysql_query($query0, $db_id);
@@ -310,10 +285,10 @@
         header("Content-Disposition: attachment; filename=query-result.txt");
 
-        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits);
+        PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $timelimits);
     }
     else
     {
         if (empty($_GET["fPrintTable"]))
-            echo (file_get_contents("index-header.html"));
+            echo (file_get_contents("index-header-fact.html"));
 
         $environment = sizeof($_GET);
@@ -328,7 +303,7 @@
         {
             if (empty($_GET["fPrintTable"]))
-                PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits);
+                PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $timelimits);
             else
-                PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $needs, $timelimits);
+                PrintPage("2", $host, $user, $pw, $db, $alias, $rightalign, $checkwhere, $checkgroup, $checkstatusgroup, $timelimits);
         }
 
Index: trunk/MagicSoft/Mars/datacenter/db/menu.php
===================================================================
--- trunk/MagicSoft/Mars/datacenter/db/menu.php	(revision 9598)
+++ trunk/MagicSoft/Mars/datacenter/db/menu.php	(revision 9599)
@@ -17,9 +17,5 @@
     CheckBox("fImpactMax",        "Impact");
     CheckBox("fViewConeMax",      "Viewcone");
-    CheckBox("fNumReUseShower",   "#Shower reuse");
     CheckBox("fStartingAltitude", "Starting alt.");
-
-    printf("  </tr><tr>\n");
-
     CheckBox("fMirrorDiameter", "Mirror diam.");
 
@@ -35,4 +31,6 @@
     PrintPullDown($host, $user, $pw, $db, "ParticleType",     "fParticleTypeName",     "fParticleTypeKEY", "Particle type");
     printf("  </td><td>\n");
+    PrintPullDown($host, $user, $pw, $db, "RunType",     "fRunTypeName",     "fRunTypeKEY", "Run type");
+    printf("  </td><td>\n");
     PrintPullDown($host, $user, $pw, $db, "AtmosphericModel",     "fAtmosphericModelName",     "fAtmosphericModelKEY", "Atm. model");
     printf("  </td>\n");
@@ -49,7 +47,15 @@
     printf("  <tr><td>\n");
 
-    PrintStatusMenu("fCorsikaInputCreated",    "Input");
-    printf("  </td><td>\n");
-    PrintStatusMenu("fCorsikaFileAvail",    "Corsika");
+    PrintStatusMenu("Corsika",    "Corsika");
+    printf("  </td><td>\n");
+    PrintStatusMenu("Ceres",    "Ceres");
+    printf("  </td><td>\n");
+    PrintStatusMenu("SequenceFile",    "SequenceFile");
+
+    printf("  </td></tr><tr><td>\n");
+
+    PrintStatusMenu("Callisto",    "Callisto");
+    printf("  </td><td>\n");
+    PrintStatusMenu("Star",    "Star");
 
     printf(" </td></tr></table>\n");
@@ -627,10 +633,10 @@
 {
     if (empty($_GET["fRunMin"]))
-        $min = GetMin("fCorsikaRunNumber", "MCCorsikaRunData", $host, $user, $pw, $db);
+        $min = GetMin("fRunNumber", "CorsikaInfo", $host, $user, $pw, $db);
     else
         $min = $_GET["fRunMin"];
 
     if (empty($_GET["fRunMax"]))
-        $max = GetMax("fCorsikaRunNumber", "MCCorsikaRunData", $host, $user, $pw, $db);
+        $max = GetMax("fRunNumber", "CorsikaInfo", $host, $user, $pw, $db);
     else
         $max = $_GET["fRunMax"];
@@ -1625,15 +1631,34 @@
 function InitMCRunStatus($_GET, $first)
 {
-    if (empty($_GET["fCorsikaFileAvail"]))
-        $_GET["fCorsikaFileAvail"]="On";
-
-    if (empty($_GET["fCorsikaFileAvailStatus"]))
-        $_GET["fCorsikaFileAvailStatus"]="0";
-
-    if (empty($_GET["fCorsikaInputCreated"]))
-        $_GET["fCorsikaInputCreated"]="Off";
-
-    if (empty($_GET["fCorsikaInputCreatedStatus"]))
-        $_GET["fCorsikaInputCreatedStatus"]="0";
+
+    if (empty($_GET["Corsika"]))
+        $_GET["Corsika"]=$first?"On":"";
+
+    if (empty($_GET["CorsikaStatus"]))
+        $_GET["CorsikaStatus"]="0";
+
+    if (empty($_GET["Ceres"]))
+        $_GET["Ceres"]=$first?"On":"";
+
+    if (empty($_GET["CeresStatus"]))
+        $_GET["CeresStatus"]="0";
+
+    if (empty($_GET["SequenceFile"]))
+        $_GET["SequenceFile"]=$first?"Off":"";
+
+    if (empty($_GET["SequenceFileStatus"]))
+        $_GET["SequenceFileStatus"]="0";
+
+    if (empty($_GET["Callisto"]))
+        $_GET["Callisto"]=$first?"Off":"";
+
+    if (empty($_GET["CallistoStatus"]))
+        $_GET["CallistoStatus"]="0";
+
+    if (empty($_GET["Star"]))
+        $_GET["Star"]=$first?"On":"";
+
+    if (empty($_GET["StarStatus"]))
+        $_GET["StarStatus"]="0";
 
 }
@@ -1649,5 +1674,8 @@
 
     if (empty($_GET["fParticleTypeName"]))
-        $_GET["fParticleTypeName"]="On";
+        $_GET["fParticleTypeName"]=$first?"On":"";
+
+    if (empty($_GET["fRunTypeName"]))
+        $_GET["fRunTypeName"]=$first?"On":"";
 
     if (empty($_GET["fAtmosphericModelName"]))
@@ -1658,38 +1686,35 @@
 
     if (empty($_GET["fZenithDistanceMin"]))
-        $_GET["fZenithDistanceMin"]="On";
+        $_GET["fZenithDistanceMin"]=$first?"On":"";
 
     if (empty($_GET["fZenithDistanceMax"]))
-        $_GET["fZenithDistanceMax"]="On";
+        $_GET["fZenithDistanceMax"]=$first?"On":"";
 
     if (empty($_GET["fAzimuthMin"]))
-        $_GET["fAzimuthMin"]="On";
+        $_GET["fAzimuthMin"]=$first?"On":"";
 
     if (empty($_GET["fAzimuthMax"]))
-        $_GET["fAzimuthMax"]="On";
+        $_GET["fAzimuthMax"]=$first?"On":"";
 
     if (empty($_GET["fEnergyMin"]))
-        $_GET["fEnergyMin"]="On";
+        $_GET["fEnergyMin"]=$first?"On":"";
 
     if (empty($_GET["fEnergyMax"]))
-        $_GET["fEnergyMax"]="On";
+        $_GET["fEnergyMax"]=$first?"On":"";
 
     if (empty($_GET["fImpactMax"]))
-        $_GET["fImpactMax"]="On";
+        $_GET["fImpactMax"]=$first?"On":"";
 
     if (empty($_GET["fViewConeMax"]))
-        $_GET["fViewConeMax"]="On";
+        $_GET["fViewConeMax"]=$first?"On":"";
 
     if (empty($_GET["fEnergySlope"]))
-        $_GET["fEnergySlope"]="On";
-
-    if (empty($_GET["fNumReUseShower"]))
-        $_GET["fNumReUseShower"]="Off";
+        $_GET["fEnergySlope"]=$first?"On":"";
 
     if (empty($_GET["fStartingAltitude"]))
-        $_GET["fStartingAltitude"]="On";
+        $_GET["fStartingAltitude"]=$first?"On":"";
 
     if (empty($_GET["fMirrorDiameter"]))
-        $_GET["fMirrorDiameter"]="On";
+        $_GET["fMirrorDiameter"]=$first?"On":"";
 
 }
