<?php
define('NTLCMS', 1);
$module = 'full';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$page_title = 'Страница полной статистики - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('../system/head.php');
if (!$active){
header('Location: '.URL);
$_SESSION['fail'] = 'Вы не авторизированы!';
exit;
}
switch($act){
default:
echo '<div class="title"><b>'.razd.' Полная статистика</b></div>';
$k_post = DB :: run() -> querySingle("select count(distinct(`Y`)) from `clickdb` where `Y` <> ''");			
$sql = DB :: run() -> query("select * from `clickdb` where `Y` <> '' group by `Y` order by `id` asc ");
if ($k_post == 0){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Статистика  пуста!</center></div>';
} else {
echo '<div class="post"><center><b>Выберите год:</b></center></div>';		
echo '<center><table><tr>';
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
echo '<td><div class="menu"><a href="'.URL.'/full?act=month&y='.checkout($row -> Y).'">'.checkout($row -> Y).'</a></div></td>';
}
}
echo '</tr></table></center>';		
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/rate">Рейтинги клуба</a></div>';
break;
case 'month':
echo '<div class="title"><b>'.razd.' Полная статистика</b></div>';
echo '<div class="post"><center><b>Выберите месяц:</b></center></div>';
$year = isset($_GET['y']) ? checkin($_GET['y']) : false;
$k_post = DB :: run() -> querySingle("select count(distinct(`m`)) from `clickdb` where `m` <> '' and `Y` = ?", array($year));			
$sql = DB :: run() -> query("select * from `clickdb` where `m` <> '' and `Y` = ? group by `m` order by `id` asc ", array($year));
if ($k_post == 0){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Статистика  пуста!</center></div>';
} else {
echo '<center><table><tr>';
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
echo '<td><div class="menu"><a href="'.URL.'/full?act=day&m='.checkout($row -> m).'&y='.checkout($year).'">'.checkout($row -> m).'</a></div></td>';
//echo '<div class="menu">Выберите месяц: <a href="'.URL.'/full.asp?act=day&m='.checkout($row['m']).'&y='.checkout($year).'">'.checkout($row['m']).'</a></div>';
}
}
echo '</tr></table></center>';
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/rate">Рейтинги клуба</a></div>';
break;
case 'day':
echo '<div class="title"><b>'.razd.' Полная статистика</b></div>';
echo '<div class="post"><center><b>Выберите день:</b></center></div>';
$month = isset($_GET['m']) ? checkin($_GET['m']) : false;
$year = isset($_GET['y']) ? checkin($_GET['y']) : false;
$k_post = DB :: run() -> querySingle("select count(distinct(`d`)) from `clickdb` where `d` <> '' and `m` = ? and `Y` = ?", array($month, $year));			
$sql = DB :: run() -> query("select * from `clickdb` where `d` <> '' and `m` = ? and `Y` = ? group by `d` order by `id` asc ", array($month, $year));
if ($k_post == 0){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Статистика  пуста!</center></div>';
} else {
echo '<center><table><tr>';
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
echo '<td><div class="menu"><a href="'.URL.'/full?act=st&d='.checkout($row -> d).'&m='.checkout($row -> m).'&y='.checkout($year).'">'.checkout($row -> d).'</a></div></td>';
}
}
echo '</tr></table></center>';
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/rate">Рейтинги клуба</a></div>';
break;
case 'st':
$d = isset($_GET['d']) ? checkin($_GET['d']) : false;
$m = isset($_GET['m']) ? checkin($_GET['m']) : false;
$y = isset($_GET['y']) ? checkin($_GET['y']) : false;
echo '<div class="title"><center>Статистика переходов за '.$d.'.'.$m.'.'.$y.'</center></div>';
$k_post = DB :: run() -> querySingle("select count(`id`) from `clickdb` where `d` = ? and `m` = ? and `Y` = ?", array($d, $m, $y));			
$sql = DB :: run() -> query("select * from `clickdb` where `d` = ? and `m` = ? and `Y` = ? order by `id` asc ", array($d, $m, $y));
if ($k_post == 0){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Статистика  пуста!</center></div>';
} else {
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
echo '<div class="menu">'.login($row -> login, 0).' <span class="count">'.word(((int) $row -> clicks), 'переход', 'перехода', 'переходов').'</span></div>';			
}
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/rate">Рейтинги клуба</a></div>';
break;
}
include ('../system/foot.php');
?>