function getClients(){
	
		var buttons=$.ajax({
		  url: "js_wrapper.php?mod=clients&act=buttons",
		  async: false
		 }).responseText;

		var r_menu=$.ajax({
		  url: "js_wrapper.php?mod=clients&act=r_menu",
		  async: false
		 }).responseText;
	
		var fields = [
						{name: 'id'},
						{name: 'login'},
						{name: 'full_name'},
						{name: 'balance'},
						{name: 'adress'},
						{name: 'mobile_phone'},
						{name: 'home_phone'}
					];
					
		var mapping = [
						{name: 'id', mapping: 'id'},
						{name: 'login', mapping: 'login'},
						{name: 'full_name', mapping: 'full_name'},
						{name: 'balance', mapping: 'balance'},
						{name: 'adress', mapping: 'adress'},
						{name: 'mobile_phone', mapping: 'mobile_phone'},
						{name: 'home_phone', mapping: 'home_phone'}
					];	
					
					
		var columns = 	[
							{
								header: '#',
								dataIndex: 'id',
								hidden: true,
								sortable: true
							},{
								header: 'Пользователь',
								dataIndex: 'login',
								sortable: true
							},{
								header: 'Полное имя',
								dataIndex: 'full_name',
								sortable: true
							},{
								header: 'Баланс',
								dataIndex: 'balance',
								sortable: true
							},{
								header: 'Адрес',
								dataIndex: 'adress',
								sortable: true
							},{
								header: 'Номер моб. тел.',
								dataIndex: 'mobile_phone',
								sortable: true
							},{
								header: 'Номер дом. тел.',
								dataIndex: 'home_phone',
								sortable: true
							}
						];					
	
	var store = new Ext.data.GroupingStore({
			remoteSort: true,
			sortInfo:{field: 'id', direction: "DESC"},
			proxy: new Ext.data.HttpProxy({
				url: "wrapper.php?mod=clients&act=get"
			}),
			reader: new Ext.data.JsonReader({
				root: 'data',
				id: 'id',
				totalProperty: 'totalCount',
				fields: fields
			},
				mapping
			)
		});
	
	var grid = new Ext.grid.GridPanel({
		id: 'grid-clients-',
		region: 'center',
		closable: true,
		store: store,
		groupField:'id',
		columns:columns,
		view: new Ext.grid.GroupingView({
			forceFit:true,
			groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
	    }),
		sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
		iconCls: "client-group",
		title: 'Список клиентов',
		loadMask: {
			msg: "Загрузка данных..."
		},
		tbar: eval(buttons),

		bbar: new Ext.PagingToolbar({
			pageSize: 50,
			store: store,
			displayInfo: true,
			displayMsg: 'Отображаемые записи {0} - {1} of {2}',
			emptyMsg: "Нет записей"
		}),
		onContextClick: function(grid, index, e){
				var row=grid.getSelectionModel().getSelected();
				
				this.menu = new Ext.menu.Menu({
					id: 'grid-ctx',
					items: eval(r_menu)
				});
				
				e.stopEvent();
				this.menu.showAt(e.getXY());
			},
		view: new Ext.grid.GroupingView({
            forceFit:true,
            showGroupName: false,
            enableNoGroups:false, // REQUIRED!
            hideGroupedColumn: true
        })
	});

		grid.on('rowcontextmenu', grid.onContextClick, grid);
		grid.on('rowdblclick', function(grid, row, e) {
				var id=grid.getView().ds.getAt(row).data.id;
				var conn = new Ext.data.Connection();
				conn.request({
					url: "wrapper.php?mod=clients&act=details",
					method: 'POST',
					params: {
						"id": id
					},
					success: function(req){
						var data = Ext.decode(req.responseText);
						tplDetails.overwrite(panelDetails.body, data);
					},
					failure: function(){
						Ext.Msg.alert('Status', 'Ошибка');
					}
				});		
				
				var tplDetails = new Ext.XTemplate(
				    '<p><tpl for="data">',
					'<p><b>ID:</b> {id}</p>',
				    '<p><b>Логин:</b> {login}</p>',
				    '<p><b>Полное Имя:</b> {full_name}</p>',
				    '<p><b>Адрес:</b> {adress}</p>',
				    '<p><b>Баланс:</b> {balance}</p>',
				    '<p><b>E-mail:</b> {email}</p>',
				    '<p><b>Мобильный телефон:</b> {mobile_phone}</p>',
				    '<p><b>Домашний телефон:</b> {home_phone}</p>',
				    '</tpl></p>'
		
				);
		
				var panelDetails= new Ext.Panel({ 
					title:'Детали',
					frame: true,
					collapsible:true,
					autoScroll:true
				});						
				
				var m_client_details = new Ext.Panel({  
					title: 'Детали клиента',
					layout:'border',
					closable: true,
					items:[{  
						title: 'Детали клиента',
						frame: true,
						region:'center',
						autoScroll:true,
						items:[panelDetails]
					}]
				}); 			
				
				var tp = Ext.getCmp('main-tabs');
				tp.add(m_client_details).show();
				tp.doLayout();
				
			});
		
		function submitSearch() {
	        var params=store.lastOptions.params;
	        params['no_validation']='';
	        params['start']=0;
	        var fFields=searchForm.getForm().getValues();
	        for(var f in fFields){     
	        	params[f]=fFields[f];
	        }
			store.reload({params: params});			
		}	    
    
		var panelCol1 = new Ext.Panel({  
			layout:'form',
			width: 180,
			minWidth: 180,  
			items: [{
					xtype:'textfield',
					hideLabel: true,	
					name: 'login',
					anchor:'100%',
					emptyText:'Логин',
					fireKey: function(e){if (e.getKey() == e.ENTER) { submitSearch(); } }
				},{
					xtype:'textfield',
					hideLabel: true,	
					name: 'home_phone',
					anchor:'100%',
					emptyText:'Домашний телефон',
					fireKey: function(e){if (e.getKey() == e.ENTER) { submitSearch(); } }
				},{
					xtype:'textfield',
					hideLabel: true,	
					name: 'mobile_phone',
					anchor:'100%',
					emptyText:'Мобильный телефон',
					fireKey: function(e){if (e.getKey() == e.ENTER) { submitSearch(); } }
				}
			]
		}); 
		
	    var searchForm = new Ext.FormPanel({
			titlebar: false, 
	        title: 'Поиск',
	        collapsible:true,
	        collapsed:true,
	        autoHeight: true,
	        split:true,
			width: 180,
			minWidth: 180,
			defaults:{autoHeight:true}, 
	    	frame:true,
	        region: 'east',
	        layout:'column',
			items:[panelCol1],
	        buttons:[{
	        	text: 'Искать',
	        	handler: function(){
					submitSearch();
	        	}
	        },{
	        	text: 'Сбросить',
	        	handler: function(){
	        		searchForm.getForm().reset();
	        		store.reload({params: {start: 0, limit: 50}});
	        	}
	        }]
	    });
	
	    var panel= {
	    	id: 'panel-clients-',
			title: 'Клиенты',
			iconCls: 'client-group',
			closable: true,
			layout:'border',
			items:[searchForm,grid]
		};
	
	var tp = Ext.getCmp('main-tabs');
	tp.add(panel).show();
	tp.doLayout();
	
	store.load({
		params: {
			start: 0,
			limit: 50
		}
	});
}