                                                                                                                                                                                                                               
	
var branchstore_emp = new Ext.data.ArrayStore({
		fields: ['branch_id','branch_name'],
		data: Ext.semester.branch2
});
	 var xg = Ext.grid;
	 var sm2 = new xg.CheckboxSelectionModel({
        listeners: {
            selectionchange: function(sm) {}
        }
    }); 
OfficeContectstore = new Ext.data.JsonStore({
    	autoDestroy: true,
        url:  'data/importcontect-employee.php',
        remoteSort: true,
		 autoLoad: true,
        storeId: 'myStore',
        idProperty: 'member_id',
        root: 'data',
        totalProperty: 'count',
        fields: [{
            name: 'employee_id',
			type:'int'
        }, {
            name: 'employee_name'
        },{
            name: 'BranchName'
        }, {
            name: 'employee_mobile'
        }] 
    });
	
	//OfficeContectstore.load();

var createColModel = function (finish, start) {
        var columns = [
		sm2,
		{
            dataIndex: 'employee_id',
            header: 'Member ID',
			hidden:true
        }, {
            dataIndex: 'employee_name',
            header: 'Employee Name',
			width:190,
            filterable: true
        },{
            dataIndex: 'BranchName',
            header: 'Deptt.',
			width:140,
            filterable: true
        },
		{
            dataIndex: 'employee_mobile',
            header: 'Mobile No',
			width:100,
			filterable: false
		}];
return new Ext.grid.ColumnModel({
            columns: columns.slice(start || 0, finish),
            defaults: {
                sortable: true
            }
        });
    };
	
var Officecontectgrid = new Ext.grid.GridPanel({
        store: OfficeContectstore,
        colModel: createColModel(40), 
        loadMask: true,
		frame: false,
		enableColLock:false,
		height: 250,    
        width: 475,
        layout: 'fit',
		columnLines: true,
		loadMask:true,
		stripeRows: true,
    	selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
		sm: sm2
    });
var officecontactform = new Ext.FormPanel({
		method:'post',
        frame:true,
		standardSubmit:true,       
        layout:'column',        
		items :[{columnWidth: 0.6,
				layout: 'form',
				labelWidth:80,
				items:[{
								xtype: 'combo',
								name: 'branch_name_emp',
								id:'branch_name_emp',
								labelSeparator:'',	
								fieldLabel :'Deptt. Name' ,
								displayField:'branch_name',
								valueField:'branch_id',
								hiddenName:'branch_name_hid',
								width:158,	
								tabIndex:4,	
								allowBlank:false,
								editable :true,
								triggerAction:'all',
								blankText : 'Please enter or select Branch Name.',
								mode:'local',
								forceSelection:true,
								store: branchstore_emp

										}]},
				{columnWidth: 0.4,
				layout: 'form',
				labelWidth:70,
				items:[{
									columnWidth: 0.5,
									layout: 'column',
									labelWidth:70,
									style: 'padding:5px 0px',
									items:[{columnWidth: 0.6,
											layout: 'form',
											style: 'padding:0px 0px 0px 50px',
											labelWidth:70,
											items:[{xtype:'button',
													width:50,
													text:'View',
													handler: function(b,e)
													{	
															OfficeContectstore.load({params:{
															section:Ext.getCmp('branch_name_emp').getValue()
																	
																	} 
														});	
														
													}}]},{columnWidth: 0.35,
													layout: 'form',
													style: 'padding:0px 0px 0px 0px',
													labelWidth:70,
													items:[{xtype:'button',
															width:50,
															text:'Reset',
															handler: function(b,e)
															{	officecontactform.getForm().reset();	
																OfficeContectstore.load();
																officecontactform.getForm().findField('branch_name_emp').focus(true,500);
														}}]
											}]}
								]},
				{columnWidth: 1,
				layout: 'form',
				items:[Officecontectgrid]}
               ]		   
    });
   
   OfficeContectstore.on({'load': {fn: function(){
			    if(OfficeContectstore.getCount() <= 0){
					       Ext.MessageBox.show({
							   title: 'Error',
							   msg: 'There is no Data found for this Selection.',
							   buttons: Ext.MessageBox.OK,
							   icon:Ext.MessageBox.ERROR
							   });
					 
					  } 
					 
				}
		 }
});	
   var officecontactWindow = new Ext.Window({
        title: "Import Employee Contect",
		width:500,		
		height:380,		
		border: false,
		modal:true,
		layout: 'fit',
		closeAction:'hide',
		collapsible:true,
		items: officecontactform,
		buttonAlign: 'center',
	    buttons: [{
							text:'Import',
							id:'importoffice',
							tabIndex:5,
							handler: function(b, e)
							{
								if(Officecontectgrid.selModel.getCount() > 0)
								{
									var selectedContactsoffice = "";
									var mobnooffice = "";
							
											 var selections = Officecontectgrid.selModel.getSelections();
											 for(i = 0; i< Officecontectgrid.selModel.getCount(); i++){
											 mobnooffice=selections[i].json.employee_mobile;
												   if(mobnooffice.length == 10 ){
													selectedContactsoffice = selectedContactsoffice + mobnooffice + ",";
												 }
										  }
									var old= Ext.getCmp('mobile_number').getValue();
									selectedContactsoffice= selectedContactsoffice.substr(0,selectedContactsoffice.length - 1);
									if(old!="")
									{
										Ext.getCmp('mobile_number').setValue(old +","+ selectedContactsoffice);	
									}else
									{
										Ext.getCmp('mobile_number').setValue(selectedContactsoffice);
									}
									
									officecontactWindow.hide();		
									}
										else
										{
											Ext.MessageBox.show({
													   title: 'Error',
													   msg: 'Please Select Atlist One Person To Send Message.',
													   buttons: Ext.MessageBox.OK,
													   icon:Ext.MessageBox.ERROR
													  });
										}
								
						}},
						{
							text:'Reset',
							id:'resetimport',
							tabIndex:6,	
							handler: function(b,e)
							{	officecontactform.getForm().reset();	
								OfficeContectstore.removeAll();
								Officecontectgrid.getSelectionModel().clearSelections();
								OfficeContectstore.load();
								officecontactform.getForm().findField('branch_name_emp').focus(true,500);
							}
						}
					]

	});
	var varWidth =  (screen.width - officecontactWindow.width)/2;
	
	
