1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
country.php
См. документацию.
1<?php
2
4{
5 public static function GetList($by = 's_name', $order = 'asc', $arFilter = [])
6 {
7 $DB = CDatabase::GetModuleConnection('statistic');
8 $arSqlSearch = Array();
9 if (is_array($arFilter))
10 {
11 foreach ($arFilter as $key => $val)
12 {
13 if(is_array($val))
14 {
15 if(count($val) <= 0)
16 continue;
17 }
18 else
19 {
20 if( ((string)$val == '') || ($val === "NOT_REF") )
21 continue;
22 }
23 $match_value_set = array_key_exists($key."_EXACT_MATCH", $arFilter);
24 $key = strtoupper($key);
25 switch($key)
26 {
27 case "ID":
28 if ($val!="ALL")
29 {
30 $match = ($arFilter[$key."_EXACT_MATCH"]=="N" && $match_value_set) ? "Y" : "N";
31 $arSqlSearch[] = GetFilterQuery("C.ID",$val,$match);
32 }
33 break;
34 case "SHORT_NAME":
35 case "NAME":
36 $match = ($arFilter[$key."_EXACT_MATCH"]=="Y" && $match_value_set) ? "N" : "Y";
37 $arSqlSearch[] = GetFilterQuery("C.".$key,$val,$match);
38 break;
39 case "SESSIONS1":
40 $arSqlSearch[] = "C.SESSIONS>='".intval($val)."'";
41 break;
42 case "SESSIONS2":
43 $arSqlSearch[] = "C.SESSIONS<='".intval($val)."'";
44 break;
45 case "NEW_GUESTS1":
46 $arSqlSearch[] = "C.NEW_GUESTS>='".intval($val)."'";
47 break;
48 case "NEW_GUESTS2":
49 $arSqlSearch[] = "C.NEW_GUESTS<='".intval($val)."'";
50 break;
51 case "HITS1":
52 $arSqlSearch[] = "C.HITS>='".intval($val)."'";
53 break;
54 case "HITS2":
55 $arSqlSearch[] = "C.HITS<='".intval($val)."'";
56 break;
57 case "EVENTS1":
58 $arSqlSearch[] = "C.C_EVENTS>='".intval($val)."'";
59 break;
60 case "EVENTS2":
61 $arSqlSearch[] = "C.C_EVENTS<='".intval($val)."'";
62 break;
63 }
64 }
65 }
66
67 if ($by == "s_id") $strSqlOrder = "ORDER BY C.ID";
68 elseif ($by == "s_short_name") $strSqlOrder = "ORDER BY C.SHORT_NAME";
69 elseif ($by == "s_name") $strSqlOrder = "ORDER BY C.NAME";
70 elseif ($by == "s_sessions") $strSqlOrder = "ORDER BY C.SESSIONS";
71 elseif ($by == "s_dropdown") $strSqlOrder = "ORDER BY C.NEW_GUESTS desc, C.NAME";
72 elseif ($by == "s_new_guests") $strSqlOrder = "ORDER BY C.NEW_GUESTS";
73 elseif ($by == "s_hits") $strSqlOrder = "ORDER BY C.HITS ";
74 elseif ($by == "s_events") $strSqlOrder = "ORDER BY C.C_EVENTS ";
75 else
76 {
77 $strSqlOrder = "ORDER BY C.NAME";
78 }
79
80 if ($order == "desc")
81 {
82 $strSqlOrder .= " desc ";
83 }
84 else
85 {
86 $strSqlOrder .= " asc ";
87 }
88
89 $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
90 $strSql = "
91 SELECT
92 C.*,
93 C.ID as REFERENCE_ID,
94 ".$DB->Concat("'['", "C.ID", "'] '", $DB->IsNull("C.NAME","''"))." as REFERENCE
95 FROM
96 b_stat_country C
97 WHERE
98 $strSqlSearch
99 $strSqlOrder
100 ";
101
102 $res = $DB->Query($strSql);
103
104 return $res;
105 }
106
107 // returns arrays needed to plot graph and diagram
108 public static function GetGraphArray($arFilter, &$arLegend)
109 {
110 global $arCountryColor;
111 $DB = CDatabase::GetModuleConnection('statistic');
112 $arSqlSearch = Array();
113 if (is_array($arFilter))
114 {
115 foreach ($arFilter as $key => $val)
116 {
117 if(is_array($val))
118 {
119 if(count($val) <= 0)
120 continue;
121 }
122 else
123 {
124 if( ((string)$val == '') || ($val === "NOT_REF") )
125 continue;
126 }
127 $match_value_set = array_key_exists($key."_EXACT_MATCH", $arFilter);
128 $key = strtoupper($key);
129 switch($key)
130 {
131 case "COUNTRY_ID":
132 if ($val!="NOT_REF")
133 $arSqlSearch[] = GetFilterQuery("D.COUNTRY_ID",$val,"N");
134 break;
135 case "DATE1":
136 if (CheckDateTime($val))
137 $arSqlSearch[] = "D.DATE_STAT>=".$DB->CharToDateFunction($val, "SHORT");
138 break;
139 case "DATE2":
140 if (CheckDateTime($val))
141 $arSqlSearch[] = "D.DATE_STAT<=".$DB->CharToDateFunction($val." 23:59:59", "FULL");
142 break;
143 }
144 }
145 }
146 $arrDays = array();
147 $arLegend = array();
148 $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
149 $strSql = "
150 SELECT
151 ".$DB->DateToCharFunction("D.DATE_STAT","SHORT")." DATE_STAT,
152 ".$DB->DateFormatToDB("DD", "D.DATE_STAT")." DAY,
153 ".$DB->DateFormatToDB("MM", "D.DATE_STAT")." MONTH,
154 ".$DB->DateFormatToDB("YYYY", "D.DATE_STAT")." YEAR,
155 D.COUNTRY_ID,
156 D.SESSIONS,
157 D.NEW_GUESTS,
158 D.HITS,
159 D.C_EVENTS,
160 C.NAME,
161 C.SESSIONS TOTAL_SESSIONS,
162 C.NEW_GUESTS TOTAL_NEW_GUESTS,
163 C.HITS TOTAL_HITS,
164 C.C_EVENTS TOTAL_C_EVENTS
165 FROM
166 b_stat_country_day D
167 INNER JOIN b_stat_country C ON (C.ID = D.COUNTRY_ID)
168 WHERE
169 ".$strSqlSearch."
170 ORDER BY
171 D.DATE_STAT, D.COUNTRY_ID
172 ";
173
174 $rsD = $DB->Query($strSql);
175 while ($arD = $rsD->Fetch())
176 {
177 $arrDays[$arD["DATE_STAT"]]["D"] = $arD["DAY"];
178 $arrDays[$arD["DATE_STAT"]]["M"] = $arD["MONTH"];
179 $arrDays[$arD["DATE_STAT"]]["Y"] = $arD["YEAR"];
180 $arrDays[$arD["DATE_STAT"]][$arD["COUNTRY_ID"]]["SESSIONS"] = $arD["SESSIONS"];
181 $arrDays[$arD["DATE_STAT"]][$arD["COUNTRY_ID"]]["NEW_GUESTS"] = $arD["NEW_GUESTS"];
182 $arrDays[$arD["DATE_STAT"]][$arD["COUNTRY_ID"]]["HITS"] = $arD["HITS"];
183 $arrDays[$arD["DATE_STAT"]][$arD["COUNTRY_ID"]]["C_EVENTS"] = $arD["C_EVENTS"];
184
185 $arLegend[$arD["COUNTRY_ID"]]["NAME"] = $arD["NAME"];
186 $arLegend[$arD["COUNTRY_ID"]]["SESSIONS"] += $arD["SESSIONS"];
187 $arLegend[$arD["COUNTRY_ID"]]["NEW_GUESTS"] += $arD["NEW_GUESTS"];
188 $arLegend[$arD["COUNTRY_ID"]]["HITS"] += $arD["HITS"];
189 $arLegend[$arD["COUNTRY_ID"]]["C_EVENTS"] += $arD["C_EVENTS"];
190
191 $arLegend[$arD["COUNTRY_ID"]]["TOTAL_SESSIONS"] = $arD["TOTAL_SESSIONS"];
192 $arLegend[$arD["COUNTRY_ID"]]["TOTAL_NEW_GUESTS"] = $arD["TOTAL_NEW_GUESTS"];
193 $arLegend[$arD["COUNTRY_ID"]]["TOTAL_HITS"] = $arD["TOTAL_HITS"];
194 $arLegend[$arD["COUNTRY_ID"]]["TOTAL_C_EVENTS"] = $arD["TOTAL_C_EVENTS"];
195 }
196 $color_getnext = "";
197 $total = sizeof($arLegend);
198 foreach ($arLegend as $key => $arr)
199 {
200 if ($arCountryColor[$key] <> '')
201 {
202 $color = $arCountryColor[$key];
203 }
204 else
205 {
206 $color = GetNextRGB($color_getnext, $total);
207 $color_getnext = $color;
208 }
209 $arr["COLOR"] = $color;
210 $arLegend[$key] = $arr;
211 }
212
213 reset($arrDays);
214 reset($arLegend);
215 return $arrDays;
216 }
217}
Определения country.php:4
static GetGraphArray($arFilter, &$arLegend)
Определения country.php:108
static GetList($by='s_name', $order='asc', $arFilter=[])
Определения country.php:5
$arr
Определения file_new.php:624
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
GetFilterSqlSearch($arSqlSearch=array(), $FilterLogic="FILTER_logic")
Определения filter_tools.php:397
GetFilterQuery($field, $val, $procent="Y", $ex_sep=array(), $clob="N", $div_fields="Y", $clob_upper="N")
Определения filter_tools.php:383
global $DB
Определения cron_frame.php:29
GetNextRGB($base_color, $total)
Определения img.php:93
CheckDateTime($datetime, $format=false)
Определения tools.php:398
$order
Определения payment.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$val
Определения options.php:1793
global $arCountryColor
Определения colors.php:2
$arFilter
Определения user_search.php:106