function GetGraphArray($arFilter, &$arrLegend) { $err_mess = "File: " . __FILE__ . "<br>Line: "; $DB = CDatabase::GetModuleConnection('statistic'); $arSqlSearch = array("D.SEARCHER_ID <> 1"); $strSqlSearch = ""; if (is_array($arFilter)) { foreach ($arFilter as $key => $val) { if (is_array($val)) { if (count($val) <= 0) { continue; } } else { if (strlen($val) <= 0 || $val === "NOT_REF") { continue; } } $match_value_set = array_key_exists($key . "_EXACT_MATCH", $arFilter); $key = strtoupper($key); switch ($key) { case "SEARCHER_ID": $arSqlSearch[] = GetFilterQuery("D.SEARCHER_ID", $val, "N"); break; case "DATE1": if (CheckDateTime($val)) { $arSqlSearch[] = "D.DATE_STAT>=" . $DB->CharToDateFunction($val, "SHORT"); } break; case "DATE2": if (CheckDateTime($val)) { $arSqlSearch[] = "D.DATE_STAT<=" . $DB->CharToDateFunction($val . " 23:59:59", "FULL"); } break; } } } $arrDays = array(); $arrLegend = array(); $strSqlSearch = GetFilterSqlSearch($arSqlSearch); $summa = $arFilter["SUMMA"] == "Y" ? "Y" : "N"; $strSql = CSearcher::GetGraphArray_SQL($strSqlSearch); $rsD = $DB->Query($strSql, false, $err_mess . __LINE__); while ($arD = $rsD->Fetch()) { $arrDays[$arD["DATE_STAT"]]["D"] = $arD["DAY"]; $arrDays[$arD["DATE_STAT"]]["M"] = $arD["MONTH"]; $arrDays[$arD["DATE_STAT"]]["Y"] = $arD["YEAR"]; if ($summa == "N") { $arrDays[$arD["DATE_STAT"]][$arD["SEARCHER_ID"]]["TOTAL_HITS"] = $arD["TOTAL_HITS"]; $arrLegend[$arD["SEARCHER_ID"]]["COUNTER_TYPE"] = "DETAIL"; $arrLegend[$arD["SEARCHER_ID"]]["NAME"] = $arD["NAME"]; } elseif ($summa == "Y") { $arrDays[$arD["DATE_STAT"]]["TOTAL_HITS"] += $arD["TOTAL_HITS"]; $arrLegend[0]["COUNTER_TYPE"] = "TOTAL"; } } reset($arrLegend); $total = sizeof($arrLegend); while (list($key, $arr) = each($arrLegend)) { $color = GetNextRGB($color, $total); $arr["COLOR"] = $color; $arrLegend[$key] = $arr; } reset($arrDays); reset($arrLegend); return $arrDays; }