<?php
include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."init.php");
include_once(PATH_TO_ROOT."_class/class.Extjs_grid.php");


	$tabId = $_POST['uniqueTabId'];
	$projectId = $_POST['id_project'];
	$projName = $_POST['projName'];
	$tableName = $projName.'___telIndex';
	$id_telTable = $db->get('_Projects',$_POST['id_project'],'id_telname',DB_WARPIT_WEBCATI_BASE);
		
	//let's check if there is any telIndex table
	if(!$db->TableExists($projName.'___telIndex',DB_WARPIT_WEBCATI_BASE))
	{
		echo "Ext.Msg.alert('Error','Please attach telephone table to the project!');
		removeSession('$tabId')";
		exit;
	}
		
	$grid = new MakeGrid( 'grid_'.$tabId );
	
	$grid->setMainTable($tableName,DB_WARPIT_WEBCATI_BASE)->setTitle('Sample statistics')->dateSQL = 'U';
	$grid->setReqUrl("webcati/_ajax/telNumberManagment/ajax.sampleStatistics.php");
		
			
	$grid->addColumn('status','ID status')->width(80);
	$grid->addColumn('status_rec','ID rec status')->width(80);
	$grid->addColumn('status_name','Call status')->width(300);
	$grid->addColumn('total_count','Total')->width(60);
	
	$grid->setSortable(false)->region('center')
		 ->addTbarItem("{iconCls:'x-tbar-loading',handler:function(){ $grid.getStore().reload(); }}");
			  
	$grid->addExportButton();
	echo $grid->createGrid();
	
	echo "
	mainTabPanel.add({
	id: '$tabId', 
	iconCls:'RMicon_sample_statistics',
	layout:'border',
	title: 'Sample statistics - $tableName',
	closable: true,
	items:[$grid]

	 })";
	 if(!$_POST['uniqueNotShow'])
		echo  ".show();";
?>