<?php
include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."init.php");
include_once(PATH_TO_ROOT."webcati/_class/class.webrecode.statistics.php");

$db->ChangeDatabase(DB_WARPIT_WEBCATI_BASE);
if(isset($_POST["id_project"]))
	$id_proj=$_POST["id_project"];
else 
	$id_proj=0;
	
$q=new webrecode_statistics($id_proj, $db);

if($_POST["grid_action"]=="general_statistics")
{
	if(!isset($_POST["statistics_mode"]))
		$mode=0;
	else
		$mode=$_POST["statistics_mode"];
		
	if($q->create_statistics($mode))
	{
		echo '{success:true, rows:'.json_encode($q->statistics_result).'}'; 
	}
	else
		echo $q->error;
	
}


?>