<?php
// Определяем текущуую дату
$date = isset ($_REQUEST['date']) ? func::checkin($_REQUEST['date']) : date("Y-m-d",core::$realtime);
$daten = date("Y-m-d",(strtotime($date)-3600*24*30));
$datup = date("Y-m-d",(strtotime($date)+3600*24*30));
if($datestart<=$daten) $datens = '<a href="?stat='.$stat.'&order='.$order.'&date='.$daten.'"><< '.$daten.'</a> | ';
if($date<date("Y-m-d",core::$realtime)) $dateup = '| <a href="?stat='.$stat.'&order='.$order.'&date='.$datup.'">'.$datup.' >></a>';
echo '<div class="col-md-12 col-sm-12 col-xs-12"><div class="panel panel-default">
<b>отчет:</b> Число просмотров, совершаемых одним посетителем
<div class="panel-heading">'.$datens.' <b>С '.$daten.' по '.$date.'</b> '.$dateup.'</div>';
// Проверяем есть ли в базе выбранная дата
$dates = core:: $db -> queryFetch("SELECT `id` FROM `top_count` WHERE `url`=? and date>=? LIMIT 1;", array($url,$daten));
if(!isset($dates['id'])){
echo "<br /><b>Статистики за выбранный вами периoд не найдено.</b><br />";
}else{
// расчитываем количество дней, которые ведется статистика
$dayss = round((core::$realtime - strtotime($datestart))/(3600*24));
if($dayss>31) $dayss = 31;
echo '<div class="col-md-12 col-sm-12 col-xs-12">
<div class="panel panel-blu">
<div class="panel-heading"><b>График</b></div>';
?>
<script>
var chart;
AmCharts.monthNames = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
AmCharts.shortMonthNames = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
var chart = AmCharts.makeChart("graph_dey", {
"type": "serial",
"theme": "light",
"marginRight": 70,
"dataProvider": [
<?php
echo '{"times": "1 просмотр",';
echo '"vozvrat": '.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` = '1' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).',
"color": "#FF0F00"
},';
echo '{"times": "2-3 просмотра",';
echo '"vozvrat": '.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '2' and `hit` < '4' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).',
"color": "#FF6600"
},';
echo '{"times": "от 4 до 7 просмотров",';
echo '"vozvrat": '.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '4' and `hit` < '8' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).',
"color": "#FF9E01"
},';
echo '{"times": "от 8 до 20 просмотров",';
echo '"vozvrat": '.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '8' and `hit` < '21' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).',
"color": "#FCD202"
},';
echo '{"times": "от 21 до 50 просмотров",';
echo '"vozvrat": '.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '21' and `hit` < '51' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).',
"color": "#F8FF01"
},';
echo '{"times": "от 51 до 100 просмотров",';
echo '"vozvrat": '.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '51' and `hit` < '101' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).',
"color": "#B0DE09"
},';
echo '{"times": "от 100 до 200 просмотров",';
echo '"vozvrat": '.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '101' and `hit` < '201' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).',
"color": "#04D215"
},';
echo '{"times": "более 200 просмотров",';
echo '"vozvrat": '.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '201' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).',
"color": "#0D8ECF"
}';
?>
],
"valueAxes": [{
"axisAlpha": 0,
"position": "left"
}],
"startDuration": 1,
"graphs": [{
"balloonText": "<div style='margin:5px; font-size:19px;'>[[category]]: <b>[[value]]</b></div>",
"fillColorsField": "color",
"fillAlphas": 0.9,
"lineAlpha": 0.2,
"type": "column",
"valueField": "vozvrat"
}],
"chartCursor": {
"categoryBalloonEnabled": false,
"cursorAlpha": 0,
"zoomable": false
},
"categoryField": "times",
"categoryAxis": {
"gridPosition": "start",
"labelRotation": 45
},
"export": {
"enabled": true
}
});
</script>
<!-- chart container -->
<div id="graph_dey" style="width: auto; height: 300px;"></div>
<?php
echo '</div></div>';
echo '<div class="col-md-12 col-sm-12 col-xs-12">
<div class="panel panel-blu">';
echo '<div class="panel-heading"><b>Число просмотров за 31 день </b></div>
<div class="table-responsive">
<table class="table"><thead><tr><th>Время</th><th>Просмотров (среднесуточное)</th></tr></thead>
<tbody> ';
echo '<tr class="success"><td>1 просмотр</td><td>'.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` = '1' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).'</td></tr> ';
echo '<tr class="success"><td>2-3 просмотра</td><td>'.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '2' and `hit` < '4' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).'</td></tr> ';
echo '<tr class="success"><td>от 4 до 31 просмотров</td><td>'.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '4' and `hit` < '8' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).'</td></tr> ';
echo '<tr class="success"><td>от 8 до 20 просмотров</td><td>'.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '8' and `hit` < '21' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).'</td></tr> ';
echo '<tr class="success"><td>от 21 до 50 просмотров</td><td>'.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '21' and `hit` < '51' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).'</td></tr> ';
echo '<tr class="success"><td>от 51 до 100 просмотров</td><td>'.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '51' and `hit` < '101' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).'</td></tr> ';
echo '<tr class="success"><td>от 101 до 200 просмотров</td><td>'.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '101' and `hit` < '201' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).'</td></tr> ';
echo '<tr class="success"><td>более 200 просмотров</td><td>'.round((core:: $db -> querySingle("select count(*) as num from top_ip WHERE `url` = '".$url."' and `hit` >= '201' and date >= '".$daten."' and date <= '".$date."';")/$dayss), 2).'</td></tr> ';
echo '</tbody>
</table>
</div>
';
echo '</div></div>';
}
?>