0) { 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 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 '# Runs'"; } else { $query0 .= "fRunNumber as '# Runs' "; foreach ($_GET as $key => $element) if ($_GET[$key]=="On") if (empty($checkwhere[$key]) || $checkwhere[$key]==0) $query0 .= ", " . $key . " as '" . $alias[$key] . "' "; } $query0 .= " FROM RunProcessStatus "; if (strpos($query0, " WHERE ")==FALSE) $query0 .= " WHERE "; else $query0 .= " AND "; $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"] . " "; if ($statusgroups>0) { $query0 .= " GROUP BY "; $num = $statusgroups; foreach ($checkstatusgroup as $key => $element) if ($element==-1) { $query0 .= $alias[$key]; if ($num-->1) $query0 .= ", "; } } if (!empty($_GET["fSortBy"])) { $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " "; if (substr($_GET["fSortBy"], -1)=="-") $query0 .= "DESC"; } if (empty($_GET["fNumStart"])) $_GET["fNumStart"]=0; if (empty($_GET["fSendTxt"])) $query0 .= " LIMIT " . $_GET["fNumStart"] . ", " . $_GET["fNumResults"]; return $query0; } function InitGet($_GET) { // Find out whether it is the first call to the php script $first = empty($_GET["fRunMin"]) && empty($_GET["fRunMax"]); if (empty($_GET["fNumResults"])) $_GET["fNumResults"]="20"; if (empty($_GET["fDataCheckDone"])) $_GET["fDataCheckDone"]="Off"; if (empty($_GET["fDataCheckDoneStatus"])) $_GET["fDataCheckDoneStatus"]="0"; if (empty($_GET["fCCFileAvail"])) $_GET["fCCFileAvail"]=$first?"On":""; if (empty($_GET["fCCFileAvailStatus"])) $_GET["fCCFileAvailStatus"]="0"; if (empty($_GET["fCaCoFileAvail"])) $_GET["fCaCoFileAvail"]=$first?"On":""; if (empty($_GET["fCaCoFileAvailStatus"])) $_GET["fCaCoFileAvailStatus"]="0"; if (empty($_GET["fCaCoFileFound"])) $_GET["fCaCoFileFound"]="Off"; if (empty($_GET["fCaCoFileFoundStatus"])) $_GET["fCaCoFileFoundStatus"]="0"; if (empty($_GET["fRawFileAvail"])) $_GET["fRawFileAvail"]=$first?"On":""; if (empty($_GET["fRawFileAvailStatus"])) $_GET["fRawFileAvailStatus"]="0"; if (empty($_GET["fTimingCorrection"])) $_GET["fTimingCorrection"]=$first?"On":""; if (empty($_GET["fTimingCorrectionStatus"])) $_GET["fTimingCorrectionStatus"]="0"; } function PrintForm($_GET, $host, $user, $pw, $db) { printf("