<?php
include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."init.php");
	
$db->ChangeDatabase(DB_WARPIT_WEBCATI_BASE);

$ajax = "CRM/_forms/nastavitve/_ajax/ajax.settings.php";
$export = "CRM/_export/exportTable.php";
$compName = "NastavitveGrid";

?>
var sm = new Ext.grid.RowSelectionModel();
var <?php echo $compName;?> = new Ext.grid.EditorGridPanel({
	store: new Ext.data.Store({
		url: '<?php echo $ajax;?>',			
		baseParams:{
			action: 'get'
		},
		reader: new Ext.data.JsonReader({		
				root:'rows',
				totalProperty : "results"
			},
			new Ext.data.Record.create([
				{ name:"id", type: 'id'},
			 	{ name:"tab_name", type: 'string' }
			])
		)
	}),
	listeners:{
		'rowdblclick': function(grid, index, rec){
			var data = grid.getSelectionModel().getSelected().json;
			CallScript('CRM/_forms/nastavitve/tabs/'+data['tab_path'], { tabName: data['tab_name'] });
		}
	},
	sm: sm,
	viewConfig:{
		forceFit: true
	},
    id: '<?php echo $compName;?>',
    border: false,
  	columns: [
  		{xtype: 'actioncolumn', width: 30, items:[{
  			icon: '_img/database/EditRecord16ni8.gif',
  			handler: function(grid, rowIndex){
  				var data = grid.getStore().getAt(rowIndex).json;
				CallScript('CRM/_forms/nastavitve/tabs/'+data['tab_path'], { tabName: data['tab_name'] });
  			}
  		}]},
  		{header: '<?php echo $LangPack->GetLabel("CRM_settings_panel", "settings_column_name","Naziv"); ?>', sortable: true, dataIndex: 'tab_name' }
    ]     
});
    
<?php echo $compName; ?>.getStore().reload();  