Ignore:
Timestamp:
01/23/09 17:27:58 (16 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/db/sequinfo-aio.php

    r9175 r9249  
    1717        $query0 = "SELECT ";
    1818
    19         if ($groups>0)
    20         {
    21             foreach ($checkgroup as $key => $element)
    22                 if ($element==-1)
    23                     $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
     19        if ($groups>0 || ((!empty($_GET["fGroupByDate"])) && !$_GET["fGroupByDate"]==0) || $statusgroups>0)
     20        {
     21            if ($groups>0)
     22                foreach ($checkgroup as $key => $element)
     23                    if ($element==-1)
     24                        $query0 .=  $key . " as '" . $alias[$key] . "' " . ", ";
     25
     26            if ((!empty($_GET["fGroupByDate"])) && !$_GET["fGroupByDate"]==0)
     27            {
     28                $query0 .= " DATE_FORMAT(ADDDATE(fRunStart,Interval 12 hour), '";
     29                switch($_GET["fGroupByDate"])
     30                {
     31                case "Year":
     32                    $query0 .= "%Y ";
     33                    break;
     34                case "Month":
     35                    $query0 .= "%Y-%m ";
     36                    break;
     37                case "Night":
     38                    $query0 .= "%Y-%m-%d ";
     39                    break;
     40                }
     41                $query0 .= "')  AS GroupByDate, ";
     42            }
     43
    2444            //--------------------------------------------------
    2545            $query0 .= "SUM(fRunTime)/3600 as '" . $alias["SUM(fRunTime)/3600"] . "', ";
     
    2949            $query0 .= " Max(fZenithDistanceMax) as '" . $alias["Max(fZenithDistanceMax)"] . "', ";
    3050            $query0 .= " COUNT(*) as '# Sequ' ";
    31         }
    32         else
    33         {
     51
    3452            if ($statusgroups>0)
    3553            {
    3654                foreach ($checkstatusgroup as $key => $element)
    3755                    if ($element==-1)
    38                         $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] . "', ";
     56                        $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] . "' ";
    3957//                        $query0 .= " (if(IsNull(" . $key . "), 'not done' ,if(" . $key . "='1970-01-01 00:00:00','dont do','done'))) as '" . $alias[$key] . "', ";
    4058
    41                 $query0 .= " COUNT(*) as '# Sequ'";
     59                $query0 .= ", COUNT(*) as '# Sequ'";
    4260
    4361            }
     62        }
     63        else
     64        {
     65            if (!empty($_GET["fSendTxt"]))
     66                $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
    4467            else
    4568            {
    46                 if (!empty($_GET["fSendTxt"]))
    47                     $query0 .= " " . $fromtable . ".fSequenceFirst as '" . $alias["fSequenceFirst"] . "' ";
    48                 else
     69                //old version using fRunMin, fRunMax
     70                //$query0 .= " CONCAT('<A&ws;HREF=\"runinfo-aio.php?',  'fRunStart=On', '&amp;fZenithDistance=On', '&amp;fRunMin=', Sequences.fSequenceFirst, '&amp;fMeanTriggerRate=On', '&amp;fTest=On', '&amp;fRunTypeName=On', '&amp;fRunMax=', fSequenceLast, '&amp;fNumEvents=On', '&amp;fSourceName=On&amp;', 'fExcludedFDAKEY=1', '&amp;fSequenceFirst=On', '&amp;fRawFileAvail=On', '&amp;fCCFileAvail=On', '&amp;fCaCoFileAvail=On', '&amp;fNumResults=500\">', Sequences.fSequenceFirst, '</A>') ";
     71                //new version using fSequenceNo
     72                $query0 .= " CONCAT('<A&ws;HREF=\"runinfo-aio.php?',  'fRunStart=On', '&amp;fZenithDistance=On', '&amp;fSequenceNo=', Sequences.fSequenceFirst, '&amp;fMeanTriggerRate=On', '&amp;fTest=On', '&amp;fRunTypeName=On', '&amp;fNumEvents=On', '&amp;fSourceName=On&amp;', 'fExcludedFDAKEY=1', '&amp;fSequenceFirst=On', '&amp;fRawFileAvail=On', '&amp;fCCFileAvail=On', '&amp;fCaCoFileAvail=On', '&amp;fNumResults=500\">', 'M', Sequences.fTelescopeNumber, ':', LPAD(Sequences.fSequenceFirst, 8, ' '), '</A>') ";
     73                //$query0 .= " as " . $alias["fSequenceFirst"];
     74                $query0 .= " as 'Tel:Sequ'";
     75                if (!empty($_GET["fLinks"]))
    4976                {
    50                     //old version using fRunMin, fRunMax
    51                     //$query0 .= " CONCAT('<A&ws;HREF=\"runinfo-aio.php?',  'fRunStart=On', '&amp;fZenithDistance=On', '&amp;fRunMin=', Sequences.fSequenceFirst, '&amp;fMeanTriggerRate=On', '&amp;fTest=On', '&amp;fRunTypeName=On', '&amp;fRunMax=', fSequenceLast, '&amp;fNumEvents=On', '&amp;fSourceName=On&amp;', 'fExcludedFDAKEY=1', '&amp;fSequenceFirst=On', '&amp;fRawFileAvail=On', '&amp;fCCFileAvail=On', '&amp;fCaCoFileAvail=On', '&amp;fNumResults=500\">', Sequences.fSequenceFirst, '</A>') ";
    52                     //new version using fSequenceNo
    53                     $query0 .= " CONCAT('<A&ws;HREF=\"runinfo-aio.php?',  'fRunStart=On', '&amp;fZenithDistance=On', '&amp;fSequenceNo=', Sequences.fSequenceFirst, '&amp;fMeanTriggerRate=On', '&amp;fTest=On', '&amp;fRunTypeName=On', '&amp;fNumEvents=On', '&amp;fSourceName=On&amp;', 'fExcludedFDAKEY=1', '&amp;fSequenceFirst=On', '&amp;fRawFileAvail=On', '&amp;fCCFileAvail=On', '&amp;fCaCoFileAvail=On', '&amp;fNumResults=500\">', 'M', Sequences.fTelescopeNumber, ':', LPAD(Sequences.fSequenceFirst, 8, ' '), '</A>') ";
    54 //                    $query0 .= " as " . $alias["fSequenceFirst"];
    55                     $query0 .= " as 'Tel:Sequ'";
    56                     if (!empty($_GET["fLinks"]))
    57                     {
    58                         $query0 .= ", CONCAT('<A&ws;HREF=\"tabs.php?t=calib&n=', fSequenceFirst, '\">cal</A>'";
    59                         $query0 .= ", '&nbsp;<A&ws;HREF=\"tabs.php?t=signal&n=', fSequenceFirst, '\">sig</A>'";
    60                         $query0 .= ", '&nbsp;<A&ws;HREF=\"tabs.php?t=star&n=', fSequenceFirst, '\">star</A>'";
    61                         $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/sequences/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/sequence', LPAD(CONCAT(Sequences.fSequenceFirst , '.txt'), 12,'0') , '\">', 'f </A>' ";
    62 //                        $query0 .= ", '&nbsp;<A&ws;HREF=\"sequence.php?fSequenceNo=', Sequences.fSequenceFirst , '&amp;fAll=On\">i</A>'";
    63                         $query0 .= ", '&nbsp;<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&amp;fDate=2\">rbk</A>') ";
    64 //                        $query0 .= ", CONCAT('<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'callisto', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">cl</A>'";
    65 //                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">c</A>'";
    66 //                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'star', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">sl</A>'";
    67 //                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">s</A>'";
    68 //                        $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/sequences/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/sequence', LPAD(CONCAT(Sequences.fSequenceFirst , '.txt'), 12,'0') , '\">', 'f </A>' ";
    69 //                        $query0 .= ", '&nbsp;<A&ws;HREF=\"sequence.php?fSequenceNo=', Sequences.fSequenceFirst , '&amp;fAll=On\">i</A>'";
    70 //                        $query0 .= ", '&nbsp;<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&amp;fDate=2\">rbk</A>') ";
    71                         $query0 .= " as 'Links'";
    72                     }
     77                    $query0 .= ", CONCAT('<A&ws;HREF=\"tabs.php?t=calib&n=', fSequenceFirst, '\">cal</A>'";
     78                    $query0 .= ", '&nbsp;<A&ws;HREF=\"tabs.php?t=signal&n=', fSequenceFirst, '\">sig</A>'";
     79                    $query0 .= ", '&nbsp;<A&ws;HREF=\"tabs.php?t=star&n=', fSequenceFirst, '\">star</A>'";
     80                    $query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/sequences/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/sequence', LPAD(CONCAT(Sequences.fSequenceFirst , '.txt'), 12,'0') , '\">', 'f </A>' ";
     81                    //$query0 .= ", '&nbsp;<A&ws;HREF=\"sequence.php?fSequenceNo=', Sequences.fSequenceFirst , '&amp;fAll=On\">i</A>'";
     82                    $query0 .= ", '&nbsp;<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&amp;fDate=2\">rbk</A>') ";
     83                    //$query0 .= ", CONCAT('<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'callisto', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">cl</A>'";
     84                    //$query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/callisto/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">c</A>'";
     85                    //$query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), 'star', LPAD(CONCAT(Sequences.fSequenceFirst , '.html'), 13,'0') , '\">sl</A>'";
     86                    //$query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/star/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/', LPAD(CONCAT(Sequences.fSequenceFirst, '/'), 9,'0'), '\">s</A>'";
     87                    //$query0 .= ", '&nbsp;<A&ws;HREF=\"http://www.astro.uni-wuerzburg.de/datacenter/sequences/' , LEFT(LPAD(CONCAT(Sequences.fSequenceFirst, '.'), 9,'0'),4), '/sequence', LPAD(CONCAT(Sequences.fSequenceFirst , '.txt'), 12,'0') , '\">', 'f </A>' ";
     88                    //$query0 .= ", '&nbsp;<A&ws;HREF=\"sequence.php?fSequenceNo=', Sequences.fSequenceFirst , '&amp;fAll=On\">i</A>'";
     89                    //$query0 .= ", '&nbsp;<A&ws;HREF=\"queryrbk.php?fNight=', date_format(adddate(fRunStart, interval +13 HOUR), '%Y-%m-%d') , '&amp;fDate=2\">rbk</A>') ";
     90                    $query0 .= " as 'Links'";
    7391                }
    74 
    75                 foreach ($_GET as $key => $element)
    76                     if ($_GET[$key]=="On")
    77                         if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff" && $key!="fOnlySum")
    78                             if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
    79                                 $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
    8092            }
     93
     94            foreach ($_GET as $key => $element)
     95                if ($_GET[$key]=="On")
     96                    if ($key!="fLinks" && $key!="fOff" && $key!="fOnlyOff" && $key!="fOnlySum")
     97                        if (empty($checkwhere[$key]) || $checkwhere[$key]==0)
     98                            $query0 .= ", " . $key . " as '" . $alias[$key] . "' ";
    8199        }
    82100
     
    219237        }
    220238
     239        if ((!empty($_GET["fGroupByDate"])) && !$_GET["fGroupByDate"]==0)
     240            if (strpos($query0, " GROUP BY ")==FALSE)
     241                $query0 .= " GROUP BY GroupByDate ";
     242            else
     243                $query0 .= ", GroupByDate ";
     244
    221245        if ($statusgroups>0)
    222246        {
    223             $query0 .= " GROUP BY ";
     247//            $query0 .= " GROUP BY ";
     248            if (strpos($query0, " GROUP BY ")==FALSE)
     249                $query0 .= " GROUP BY ";
     250            else
     251                $query0 .= ", ";
    224252            $num = $statusgroups;
    225253            foreach ($checkstatusgroup as $key => $element)
     
    332360        printf("<p>");
    333361        PrintSourceMenu($host,$user,$pw,$db);
     362        PrintGroupByDateMenu();
     363        printf("<p>");
    334364        PrintNightRangeMenu($host,$user,$pw,$db, "Sequences");
    335365        printf("<p>");
Note: See TracChangeset for help on using the changeset viewer.