<?php 

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

$tableName = $_POST['project'] . "_errorReport"; ;

$idGroup = intval($_POST['id_report']);
$tabId = 'reportDetails_'.$idGroup;
$projName = $_POST['projName'];
$linksGrid = new MakeGrid($tabId.'_details');
$linksGrid->setMainTable($tableName, DB_WARPIT_WEBCATI_BASE)
		->setCheckBoxSelectionModel()
		//->setReqUrl('webuserspool/_ajax/incentiveSystem/ajax.incentiveGroup.php')
		//->setAutoExpand('incentive_code',150)
		->region('west')
		->setWidth(250)
		->setPaging(30)
		->setFiltering()
		->baseParams = " SQLwhere : 'id_sup = $idGroup'";
		
$linksGrid->addExportButton();

$linksGrid->dateSQL = "Y-m-d H:i:s";
$linksGrid->dateDisplay = "d.m.Y H:i";

$linksGrid->addListener('columnresize',"function(){
	this.getView().refresh();
}");
$linksGrid->addColumn('id_record','Record ID')->width(100);
$linksGrid->addColumn('q_name','Question name')->width(100);
$linksGrid->addColumn('msg','Message')->width(300);
$linksGrid->addColumn('additionalData', 'Additional data') -> width(300);
$linksGrid->addColumn('d_start','Start')->width(130)->type('date');
$linksGrid->addColumn('d_stop','Stop')->width(130)->type('date')->renderer("function(val,md,r){
    return new Date(val).format('$linksGrid->dateDisplay');
}");

$grpTree = 'PoolMenu_1';


$linksGrid->addTbarItem ("'->'  ");
	
//$linksGrid->addExportButton();
$linksGrid->setSearchField('Search');

//$linksGrid->dateDisplay = "DD.MM.YYYY HH:MM";


echo $linksGrid->createGrid();

//set a load event to get some extra data...if it's possible :/
echo "$linksGrid.store.on('load',function(s,r,o){
});
";




//$propertiesForm->addItem($chartGrid);



echo "
	var $tabId = new Ext.Panel({
		id:'$tabId',
		title:'$projName',
		iconCls:'icon_build_questionnare',
		defaults:{split:true,border:false},
	
		layout:/*{
			    type: 'hbox',
			    pack: 'start',
			    align: 'stretch'
			}*/'border',
		border: false,
		closable:true,
		items:[
		{ xtype: 'form', region: 'center',flex:1,layout:'fit',id:'uploadForm_$tabId',enctype:'multipart/form-data',
      			  fileUpload: true,method:'POST',url: 'webuserspool/_ajax/incentiveSystem/ajax.upload.php',
      			  baseParams: { id_incentive_group : $idGroup },
				items: [ $linksGrid ] 
		}, 
		/*{ xtype:'panel',flex:1,width:450,collapseMode: 'mini',
                 layout:{
						    type: 'vbox',
						    pack: 'start',
						    align: 'stretch'
						} ,region:'east',
						items:[
						//a tab panel here
						{
						xtype : 'tabpanel',flex:2,activeTab:0,
						items: [$propertiesForm ,{ 
							xtype: 'panel',title:'Statistics',iconCls:'icon_basic_statistics',
							layout:{
						    type: 'vbox',
						    pack: 'start',
						    align: 'stretch'
							},
							items: [ $chartGrid ]
						
						} ]
						} 
						 ] 
						 
		} */  ]
	});
Ext.getCmp('errrorReportTabPanel').add( $tabId ).show();  "


?>