<?php
include_once ("_dirinfo.php");

include_once (PATH_TO_ROOT."init.php");

class HighChartsGraph{
	
	private $db;
	
	function __construct($db){$this->db = $db;}	
	
	function showWindowAction(){
		echo "new Ext.Window({
		id: 'intervStatGraphWin',
		layout: 'fit',
		iconCls: 'icon_basic_statistics',
		title: 'Interviewer statistics graph - [project]',
		renderTo: 'mainTabPanel',
		height: 400,
		width:  600,
		x:      40,
		y:      50,
		shadow: false,
		constrain: true,
		collapsible: true,		
		//items: [],	
		iconCls: 'iconActiveProjects',	
		tbar:[
			{
				xtype: 'combo',
				text: 'dd'
			}
		],		
		tools:[
			{
			id: 'close',
			handler: function(ev, tolEl, pan){
				pan.destroy();
				}		
			}],
		html: '<iframe id=\"\" width=100% height=100% style=\"background: white; border: none\" src=\"webcati/_forms/_ajax/ajax.interviewerStatisticsGraph.php?".
				http_build_query(array('projectId' => $projectId,
									   'action' => 'showGraph' ))."\"></iframe>',
//		listeners:{
//				show: function(){
//				Ext.select('#mainTabPanel').addListener('click', function() {
//                    alert('lost focus');
//                });
//					
//				},
//				destroy: function(){
//					alert('window destroyed');
//					Ext.select('#mainTabPanel').removeListener('click', enr);
//				}					
//		}
	}).show();";
	}
	
	function showGraphAction()
	{
		echo 'Tukaj bo graf ...';
	}
}

$db->ChangeDatabase($_POST['database']);
$tableName = $_POST['RMtable'];

$manipulator = new HighChartsGraph($db);
$comm = $_POST['action'].'Action';
if(!$_POST['action'])
	 $comm = $_GET['action'].'Action';
if(method_exists($manipulator,$comm))
	echo $manipulator->$comm();
else 
{
	
	Echo '{success:false,error:"Unknown action!"';		
}
?>