Просмотр файла includes/modules/stat_day.php

Размер файла: 1.51Kb
<?php
$page = isset( $_GET['page'] ) ? (int) ($_GET['page'] - 1) : 0;

$template_vars['header'] = array(
'TITLE' => $lang['STAT_DAY'],
'CSS' => $css
);

$template->set_vars('header', $template_vars['header']);

$query = "SELECT COUNT(*) FROM `" . CATALOGUE_STAT . "`;";

if( !$sql->query($query) )
{
	put_error(DBMS_ERROR, htmlspecialchars($sql->error['message']), __LINE__, __FILE__);
}

$total = $sql->result($sql->result, 0);

$maxpage = maxpage($total, 10);
$limit = limit($page, 10);

if( !($qresult = $sql->query("SELECT *, ((`in_mp` * 100) / `total_in` ) AS `mp_percent` FROM `" . CATALOGUE_STAT . "` ORDER BY `id` DESC LIMIT " . $limit . ";")) )
{
	put_error(DBMS_ERROR, htmlspecialchars($sql->error['message']), __LINE__, __FILE__);
}

for( $i = 1; $stat = $sql->fetch_assoc($qresult); $i++ )
{
	$template->set_block_vars('body', 'stat', array(
	'PLACE' => $page * 10 + $i,
	'DATE' => date('d.m.Y', strtotime('-1 day', $stat['dt'])),
	'IN' => $stat['total_in'],
	'OUT' => $stat['out']
	));
}

$pages = pages($page, $maxpage, 10, 2, '', gen_uri($m));

$template_vars['body'] = array(
'IN' => $lang['IN'],
'OUT' => $lang['OUT'],
'PAGES' => $pages,
'STAT_HREF' => gen_uri('statistics'),
'STAT' => $lang['STAT'],
'BACK_HREF' => gen_uri('index'),
'BACK' => $lang['BACK']
);

$template_vars['footer'] = array(
'SWITCH_VERSION' => switch_version($m, '', ''),
'COUNTER' => ''
);

$template->set_vars('body', $template_vars['body']);
$template->set_vars('footer', $template_vars['footer']);
?>