- Модуль: statistic
- Путь к файлу: ~/bitrix/modules/statistic/classes/general/searcher.php
- Класс: CAllSearcher
- Вызов: CAllSearcher::GetGraphArray
static function GetGraphArray($arFilter, &$arrLegend)
{
$err_mess = "File: ".__FILE__."
Line: ";
$DB = CDatabase::GetModuleConnection('statistic');
$arSqlSearch = Array("D.SEARCHER_ID <> 1");
if (is_array($arFilter))
{
foreach ($arFilter as $key => $val)
{
if(is_array($val))
{
if(count($val) <= 0)
continue;
}
else
{
if( ((string)$val == '') || ($val === "NOT_REF") )
continue;
}
$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";
}
}
$color = "";
$total = sizeof($arrLegend);
foreach ($arrLegend as $key => $arr)
{
$color = GetNextRGB($color, $total);
$arrLegend[$key]["COLOR"] = $color;
}
return $arrDays;
}