- Модуль: statistic
- Путь к файлу: ~/bitrix/modules/statistic/classes/general/country.php
- Класс: CCountry
- Вызов: CCountry::GetGraphArray
static function GetGraphArray($arFilter, &$arLegend)
{
$err_mess = "File: ".__FILE__."
Line: ";
global $arCountryColor;
$DB = CDatabase::GetModuleConnection('statistic');
$arSqlSearch = Array();
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;
}
$match_value_set = array_key_exists($key."_EXACT_MATCH", $arFilter);
$key = strtoupper($key);
switch($key)
{
case "COUNTRY_ID":
if ($val!="NOT_REF")
$arSqlSearch[] = GetFilterQuery("D.COUNTRY_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();
$arLegend = array();
$strSqlSearch = GetFilterSqlSearch($arSqlSearch);
$strSql = "
SELECT
".$DB->DateToCharFunction("D.DATE_STAT","SHORT")." DATE_STAT,
".$DB->DateFormatToDB("DD", "D.DATE_STAT")." DAY,
".$DB->DateFormatToDB("MM", "D.DATE_STAT")." MONTH,
".$DB->DateFormatToDB("YYYY", "D.DATE_STAT")." YEAR,
D.COUNTRY_ID,
D.SESSIONS,
D.NEW_GUESTS,
D.HITS,
D.C_EVENTS,
C.NAME,
C.SESSIONS TOTAL_SESSIONS,
C.NEW_GUESTS TOTAL_NEW_GUESTS,
C.HITS TOTAL_HITS,
C.C_EVENTS TOTAL_C_EVENTS
FROM
b_stat_country_day D
INNER JOIN b_stat_country C ON (C.ID = D.COUNTRY_ID)
WHERE
".$strSqlSearch."
ORDER BY
D.DATE_STAT, D.COUNTRY_ID
";
$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"];
$arrDays[$arD["DATE_STAT"]][$arD["COUNTRY_ID"]]["SESSIONS"] = $arD["SESSIONS"];
$arrDays[$arD["DATE_STAT"]][$arD["COUNTRY_ID"]]["NEW_GUESTS"] = $arD["NEW_GUESTS"];
$arrDays[$arD["DATE_STAT"]][$arD["COUNTRY_ID"]]["HITS"] = $arD["HITS"];
$arrDays[$arD["DATE_STAT"]][$arD["COUNTRY_ID"]]["C_EVENTS"] = $arD["C_EVENTS"];
$arLegend[$arD["COUNTRY_ID"]]["NAME"] = $arD["NAME"];
$arLegend[$arD["COUNTRY_ID"]]["SESSIONS"] += $arD["SESSIONS"];
$arLegend[$arD["COUNTRY_ID"]]["NEW_GUESTS"] += $arD["NEW_GUESTS"];
$arLegend[$arD["COUNTRY_ID"]]["HITS"] += $arD["HITS"];
$arLegend[$arD["COUNTRY_ID"]]["C_EVENTS"] += $arD["C_EVENTS"];
$arLegend[$arD["COUNTRY_ID"]]["TOTAL_SESSIONS"] = $arD["TOTAL_SESSIONS"];
$arLegend[$arD["COUNTRY_ID"]]["TOTAL_NEW_GUESTS"] = $arD["TOTAL_NEW_GUESTS"];
$arLegend[$arD["COUNTRY_ID"]]["TOTAL_HITS"] = $arD["TOTAL_HITS"];
$arLegend[$arD["COUNTRY_ID"]]["TOTAL_C_EVENTS"] = $arD["TOTAL_C_EVENTS"];
}
$color_getnext = "";
$total = sizeof($arLegend);
foreach ($arLegend as $key => $arr)
{
if ($arCountryColor[$key] <> '')
{
$color = $arCountryColor[$key];
}
else
{
$color = GetNextRGB($color_getnext, $total);
$color_getnext = $color;
}
$arr["COLOR"] = $color;
$arLegend[$key] = $arr;
}
reset($arrDays);
reset($arLegend);
return $arrDays;
}