<?php
include '../../inc/config.inc.php';
include '../../inc/wap_tags.inc.php';
include '../../inc/functions.inc.php';
header("Content-type: charset=utf-8");
connect_to_db();
$today = date("Ymd");
$week_day = date("w");
function transliter($string){
$trans2=array("CSH","Csh","ZH","Zh","CH","Ch","SH","Sh","JO","Jo","JE","Je","JU","Ju","JA","Ja","csh","zh","ch","sh","jo","je","ju","ja","A","B","V","G","D","E","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","C","'","'","Y","a","b","v","g","d","e","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h","c","'","'","y");
$trans1=array("Щ","Щ","Ж","Ж","Ч","Ч","Ш","Ш","Ё","Ё","Э","Э","Ю","Ю","Я","Я","щ","ж","ч","ш","ё","э","ю","я","А","Б","В","Г","Д","Е","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","ь","ь","Ы","а","б","в","г","д","е","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ь","ь","ы");
$string=str_replace($trans1,$trans2,$string);
return $string;}
$result = mysql_query("
SELECT `top_operators`.`name`, `top_operators`.`label`, `top_operators_stat`.`count`
FROM `top_operators_stat`
LEFT JOIN `top_operators`
ON `top_operators`.`id` = `top_operators_stat`.`id_operator`
WHERE `date` = $today AND `day_week` = $week_day AND `uid` = $uid
ORDER BY `top_operators_stat`.`count` DESC
");
$oper_array = array();
$summ = 0;
if (mysql_num_rows($result))
{
while ($row = mysql_fetch_assoc($result))
{
$oper_array[] = $row;
$summ += $row['count'];
}
}
print "<chart>\n";
print " <chart_data>\n";
print " <row>\n";
print " <string></string>\n";
foreach ($oper_array AS $position => $row)
{
$p1 = split("\.", (round($row['count']/$summ*10000)/100));
if($p1[0] >= 5)echo ((empty($row['name']))? "<string>Other</string>\n" : "<string>" . transliter($row['name']) ."</string>\n");
}
print " </row>\n";
print " <row>\n";
print " <string></string>\n";
foreach ($oper_array AS $position => $row)
{
$p1 = split("\.", (round($row['count']/$summ*10000)/100));
if($p1[0] >= 5)echo "<number>".(round($row['count']/$summ*10000)/100)."</number>\n";
}
print " </row>\n";
print " </chart_data>\n";
print " <chart_grid_h alpha=\"20\" color=\"000000\" thickness=\"0\" type=\"solid\" />\n";
print " <chart_rect x=\"20\" y=\"13\" width=\"590\" height=\"190\" />\n";
print " <chart_type>3d pie</chart_type>\n";
print " <chart_value color=\"cccccc\" alpha=\"90\" font=\"arial\" bold=\"1\" size=\"10\" position=\"inside\" prefix=\"\" suffix=\"\" decimals=\"0\" separator=\"\" as_percentage=\"1\" />\n";
echo " <chart_label shadow='low' color='000000' alpha='95' size='10' position='inside' as_percentage='true' />\n";
print " <legend_label layout=\"horizontal\" bullet=\"circle\" font=\"arial\" bold=\"1\" size=\"13\" color=\"333333\" alpha=\"85\" />\n";
print " <legend_rect height=\"10\" />\n";
print "\n";
print " <series_explode>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " <value>9</value>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " <value>5</value>\n";
print " </series_explode>\n";
print "</chart>\n";
?>