                                                                                                                                                                                                                               
	var branchstore2 = new Ext.data.ArrayStore({
		fields: ['branch_id','branch_name'],
		data: Ext.student.branch
	});
var employee_salaryno = new Ext.form.NumberField({
	  id: 'txtemployee_salaryno',
	  name: 'txtemployee_salaryno',
	  fieldLabel: 'Salary No',
	  width:90
});				

var employee_name = new Ext.form.TextField({
     id: 'txtemployee_name',
	 name: 'txtemployee_name',
	 fieldLabel: 'Employee Name',
	 width:200
});	

var branch_name2 = new Ext.form.ComboBox({
				name: 'branch_name2',
				hiddenName: 'branch_hidden2',
				id:'branch_name2',
				labelSeparator:'',	
				fieldLabel :'Branch :' ,
				forceSelection:true,				
				displayField:'branch_name',
				valueField: 'branch_name'
				,allowBlank:true
				,triggerAction:'all'
				,mode:'local'
				,store: branchstore2
				,width:200
				
				,selectOnFocus: true
				

   
});

var employeesearchresultstore = new Ext.data.JsonStore({
url: 'data/getemployeedata.php',
root: 'employee',
totalProperty: 'count',
fields: [{ name: 'employee_id' },
		 { name: 'employee_name' },
		 { name: 'employee_salaryno' },
		 { name: 'branch_name' },
		 { name: 'employee_designation' },
		 { name: 'employee_category'}]
});	

var createColModel = function (finish, start){
	var columns = [
		{
            dataIndex: 'employee_id',
            header: 'ID',
			align:'center',
			width:50
        },{
            dataIndex: 'employee_salaryno',
            header: 'Salary No',
			align:'center'
        },{
            dataIndex: 'employee_name',
            header: 'Name'  
		},{
            dataIndex: 'branch_name',
            header: 'Branch Name',  
            filter:{
                type: 'list',
				options: ['Pre-Primary', 'Primary', 'Secondary','Higher-Secondary(Science)','Higher-Secondary(General)']
			}
		},{
            dataIndex: 'employee_designation',
            header: 'Designation',
            filter:{
                type: 'list',
                options: ['Principal', 
						  'Supervisior', 
						  'Assistent Teacher',
						  'Office Supritendent',
						  'Head Clerk',
						  'Senior Clerk',
						  'Junior clerk']
       		}
        },{
            dataIndex: 'employee_category',
            header: 'Category',
            filter:{
				type: 'list',
                options: ['General','OBC','SC','ST','Minority']
        	}
        }
	];
	return new Ext.grid.ColumnModel({
    	columns: columns.slice(start || 0, finish),
        defaults: {
        	sortable: true
		}
	});
	
	};

var employeesearchresultgrid = new Ext.grid.GridPanel({
	store: employeesearchresultstore,
	colModel: createColModel(40), 
	loadMask: true,
    columnLines:true,
    stripeRows: true,
	//frame: true,
	enableColLock:false,
	width: 565,
	height: 230,
	layout: 'fit',
	selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
	listeners:{
		render:{
			fn: function(){ employeesearchresultstore.reload({ params: { start: 0, limit: 10 } }); }
		}
	},
	bbar: new Ext.PagingToolbar({
		store: employeesearchresultstore,
		pageSize: 10,
		displayInfo: true
		
	})
});

var employeesearchitems = {
	xtype: 'fieldset',
	labelWidth: 100,
	border: false,
	defaults: { width: 260 }, 
	autoHeight: true,
	width:584,
	bodyStyle: Ext.isIE ? 'padding:0 0 5px 15px;' : 'padding:10px 15px;',
	layout:'column',	 				 
	items: [
		{
			columnWidth:1,
			layout:'form',
			items:[branch_name2]
		},{
			columnWidth:1,
			layout:'form',
			items:[employee_name]
		},{
			columnWidth:1,
			layout:'form',
			items:[employee_salaryno]
		},{
			columnWidth:0.99,
			layout:'form',
			items:[{
				buttons:[{ 
					text: 'Search',
					style:{margin:'0px 0px 0px 0px',padding:'0px 0px 0px 380px'},	 
					handler: function(){
						load_employeegrid();	
					}
				},{
					text: 'Reset',
					id:'reset2',
					handler: function(){
						reset_employeeform();
					}
				}]
			}]
		}
	]				 }

var employeesearchform = new Ext.FormPanel({
	id: 'employeesearchform',
	frame: true,
	labelAlign: 'left',
	bodyStyle: 'padding:5px',
	
	draggable: false,
	layout:'column',
	items:[employeesearchitems,employeesearchresultgrid]
});

var EmployeeSearchWindow = new Ext.Window({
	title: 'Employee General Search',
	height:420,
	width:600,		
	layout: 'fit',
	closeAction:'close',
	border: false,
	autoDestroy :true,
	modal:true,
	collapsible:true,
	items: employeesearchform
});

employeesearchresultstore.on({'beforeload': {
	fn: function(employeesearchresultstore, options){
		options.params || (options.params = {}); //assert params
		Ext.apply(options.params, {
			pageNo: this.pageNumber,
			//section:Ext.getCmp('section').getValue(),
			employee_salaryno:Ext.getCmp('txtemployee_salaryno').getValue(),
			employee_name:Ext.getCmp('txtemployee_name').getValue()
		});
	},
	scope: this}});
	
function reset_employeeform(){
	employeesearchform.getForm().reset();
	employeesearchresultstore.removeAll();	}

function load_employeegrid(){
	
	employeesearchresultstore.load({params:{
		//section:Ext.getCmp('section').getValue(),
		branch_name2:Ext.getCmp('branch_name2').getRawValue(),
		txtemployee_salaryno:Ext.getCmp('txtemployee_salaryno').getValue(),
		txtemployee_name:Ext.getCmp('txtemployee_name').getValue(),
		start: 0,limit: 10
	}});	
	employeesearchresultstore.removeAll();
	}

function KeyCheck(e){
   var KeyID = (window.event) ? event.keyCode : e.keyCode;
   if(KeyID=='13'){
		load_employeegrid();
	}
   if(KeyID=='46'){
		reset_employeeform();
		 
	 }}

function OpenEmployeeSearch(){
	
	EmployeeSearchWindow.show();
	//sectionstore.load();
	document.onkeyup = KeyCheck;
	employeesearchresultgrid.getSelectionModel().on('rowselect', function(sm, rowIndex, record) {				
		Ext.getCmp('member_id').setValue(record.data.employee_id);
		
		Ext.getCmp('txtgrno').setValue(record.data.employee_salaryno);
		Ext.getCmp('txtgrno').enable();
		
		Ext.getCmp('membername').setValue(record.data.employee_name);
		Ext.getCmp('membername').enable();
		
		Ext.getCmp('txttotalIssueablebook').enable();
		Ext.getCmp('txttotalissuedbook').enable();
		Ext.getCmp('txtbookregno').enable();
		Ext.getCmp('txtbookname').enable();
		Ext.getCmp('book_returndate').enable();
		Ext.getCmp('txtgrno').focus();
		employeesearchresultstore.reload();
		EmployeeSearchWindow.hide();
	}); }