<?php 
	require "_header.php";
	//require "../includeLanguageBar.php";
	require "data/combo_employee.php";
	require "data/combo_semester.php";
		
?>
<!-- start custom CSS/JS -->
<style>
.myBold
{
   font-weight: bold;
   color:#006;
   font-size: 11px;
}

</style>
<script language="javascript" type="text/javascript">
var labelArray;
labelArray = [
	['Faculty Salary No:<span class="comp"></span>'],
	['Faculty Name :<span class="comp">*</span>'],
	['Designation :<span class="comp">*</span>'],
	['Branch Name :<span class="comp">*</span>'],
	['Gender :<span class="comp">*</span>'],
	['Category :'],
	['Is Handicap :'],
	['Pay Type :'],
	['Birth Date :'],
	['Dept.Join Date :'],
	['Is Working :<span class="comp">*</span>'],
	['Basic Salary :'],
	['Collage Join Date :'],
	['GPF Acc No :'],
	['Is Teaching :'],
	['Pension Type :']
];

var EmpFields = [
	{name: 'employee_id'},{name: 'school_id'},{name: 'employee_salaryno'},{name: 'employee_name'},{name: 'employee_shortname'},
	{name: 'employee_gender'},{name: 'branch_name'},{name: 'employee_designation'}
	,{name: 'employee_isteaching'},
	{name: 'employee_workingperiods'},{name: 'employee_category'},{name: 'employee_ishandicap'},{name: 'employee_birthdate'}, 	
	{name: 'employee_regularorfixpay'},{name: 'employee_panno'},{name: 'employee_gpfacno'},{name: 'employee_bankacno'}, 	
	{name: 'employee_deptjoindate'},{name: 'employee_schooljoindate'},{name: 'employee_payscale'},{name: 'employee_basicsalary'}, 	
	{name: 'employee_incrdate'},{name: 'employee_pension'},{name: 'employee_eduqualification'},{name: 'employee_edusub'}, 	
	{name: 'employee_eduuni'},{name: 'employee_eduyear'},{name: 'employee_eduobtclass'},{name: 'employee_profqualification'}, 	
	{name: 'employee_profsub'},{name: 'employee_profuni'},{name: 'employee_profyear'},{name: 'employee_profobtclass'}, 	
	{name: 'employee_otherqualification'},{name: 'employee_othersub'},{name: 'employee_otheruni'},{name: 'employee_otheryear'}, 	
	{name: 'employee_otherobtclass'},{name: 'employee_retddate'},{name: 'employee_nominee'},{name: 'employee_active'}, 	
	{name: 'employee_curaddress'}, {name: 'employee_contactnores'}, {name: 'employee_mobile'},{name: 'employee_permaddress'}, 	
	{name: 'employee_phone'},{name: 'employee_emailid'},{name: 'employee_bloodgroup'},{name: 'employee_photo'}
]

var Store = new Ext.data.JsonStore({
    url:'library/data/employee-grid-filter.php',
    root:'data',
	remoteSort: true,
    sortInfo: {
    	field: 'employee_id',
        direction: 'ASC'
   	},
    fields: EmpFields,
    idProperty: 'employee_id',
	autoLoad: true,
    writer:new Ext.data.JsonWriter()
});


var Eduqualificationstore = new Ext.data.JsonStore({
    	url: 'library/data/qualification-combo.php',
    	root: 'data',
	 	fields: ['employee_eduqualification']
		
	});
	Eduqualificationstore.load({params:{action:'Eduqul'}});

var Edusubjectstore = new Ext.data.JsonStore({
    	url: 'library/data/qualification-combo.php',
    	root: 'data',
	 	fields: ['employee_edusub']
		
	});
	Edusubjectstore.load({params:{action:'Edusub'}});
///pro
var Proqualificationstore = new Ext.data.JsonStore({
    	url: 'library/data/qualification-combo.php',
    	root: 'data',
	 	fields: ['employee_profqualification']
		
	});
	Proqualificationstore.load({params:{action:'Proqul'}});

var Prosubjectstore = new Ext.data.JsonStore({
    	url: 'library/data/qualification-combo.php',
    	root: 'data',
	 	fields: ['employee_profsub']
		
	});
	Prosubjectstore.load({params:{action:'Prosub'}});

///other
var Othqualificationstore = new Ext.data.JsonStore({
    	url: 'library/data/qualification-combo.php',
    	root: 'data',
	 	fields: ['employee_otherqualification']
		
	});
	Othqualificationstore.load({params:{action:'Othqul'}});

var Othsubjectstore = new Ext.data.JsonStore({
    	url: 'library/data/qualification-combo.php',
    	root: 'data',
	 	fields: ['employee_othersub']
		
	});
	Othsubjectstore.load({params:{action:'Othsub'}});


Ext.onReady(function(){
	
	Ext.QuickTips.init();
	
	var colModel = new Ext.grid.ColumnModel([
		{ 
			header: "Employee ID",
			dataIndex: 'employee_id', 
			sortable: true, 
			hidden: true 
		},{ 
			id: 'employee_name',
			header: "Faculty Name",
			width: 150,
			dataIndex: 'employee_name',
			align: 'left',
			sortable: true
        },{
			id: 'employee_salaryno',
			header: "Sal.No",
			width: 50,
			dataIndex: 'employee_salaryno',
			align: 'left',
			sortable: true
		}
    ]);
	
	var grid = new Ext.grid.GridPanel({
		xtype: 'grid',
		ds: Store,
		cm: colModel,
		sm: new Ext.grid.RowSelectionModel({
			singleSelect: true,
			listeners: {
				rowselect: function(sm, row, rec) {
					Ext.getCmp('btnDelete').enable();
					Ext.getCmp("employeeentry").getForm().loadRecord(rec);
					Ext.getCmp('employee_retddate').enable();
					var photoname = Ext.getCmp('employeephoto').getValue();
					//alert(Ext.getCmp('employeephoto').getValue());
					if(photoname != ""){
						pictUploadForm.getForm().load({ 
							params:{ act:'getPicture',id:1,photoname:photoname}
						});
					
					}
				}
			}
		}),
		autoExpandColumn: 'employee_name',
		height: 480,
		border: true
	});
	
	grid.on('render', function() {
		grid.tip = new Ext.ToolTip({
			view: grid.getView(),
			target: grid.getView().mainBody,
			delegate: '.x-grid3-row',
			trackMouse: true,
			renderTo: document.body,
			listeners: {
				beforeshow: function updateTipBody(tip) {
					tip.body.dom.innerHTML = "Please Click Here To Edit Records.";
				}
			}
		});
  	});
	
	
	
	var genderstore = new Ext.data.ArrayStore({
		fields: ['gender'],
		data: [['Male'],['Female']]
	});
var designationstore = new Ext.data.ArrayStore({
			fields:['designation_id','designation_nameeng'],
			data:Ext.employee.designation
	});
	var categorystore = new Ext.data.ArrayStore({
    	fields: ['employee_category'],
	    data: [['General'],['OBC'], ['SC'], ['ST'], ['Minority']]
  	});
	
	var ishandicapstore = new Ext.data.ArrayStore({
    	fields: ['employee_ishandicap'],
	    data: [['Yes'],['No']]
  	});
	
	var paystore = new Ext.data.ArrayStore({
    	fields: ['employee_regularorfixpay'],
	    data: [['Regular'],['Fix']]
  	});
	
	var payscalestore = new Ext.data.ArrayStore({			
        	fields: ['payscale_id','payscale'],
	     data:Ext.employee.payscale
	});
		
	var activestore = new Ext.data.ArrayStore({
    	fields: ['employee_active'],
	    data: [['Yes'],['No']]
  	});
	
	var pensiontypestore = new Ext.data.ArrayStore({
    	fields: ['employee_pension'],
	    data: [['GPF'],['CPF']]
   	});
	
	var teachingstore = new Ext.data.ArrayStore({
    	fields: ['employee_isteaching'],
	    data: [['Yes'],['No']]
  	});
	
	var obtclassstore = new Ext.data.ArrayStore({
    	fields: ['obtclass'],
	    data: [['First'],['Second'],['Pass']]
   	});
	
	var uobtclassstore = new Ext.data.ArrayStore({
    	fields: ['uobtclass'],
	    data: [['First'],['Second'],['Pass']]
  	});

	var otherobtclassstore = new Ext.data.ArrayStore({
    	fields: ['otherobtclass'],
	    data: [['First'],['Second'],['Pass']]
   	});
		
  var branchstore = new Ext.data.ArrayStore({		
	fields: ['branch_id','branch_name'],
	data:Ext.semester.branch
});
	
	var bloodgroupstore = new Ext.data.ArrayStore({
    	fields: ['bloodgroup'],
	    data: [['O+'],['A+'],['B+'],['AB+'],['O-'],['A-'],['B-'],['AB-']]
   	}); 
		
	var picFiles = { 
		columnWidth: .8,
		layout: 'form',
		labelAlign:'top',
		items: [
			{
				xtype: 'textfield',
				fieldLabel: 'Current',
				labelSeparator: '',
				name: 'currPic',
				id:'currPic',
				readOnly: true,
				disabled:true,
				anchor:'80%'
			},
			{
				xtype: 'textfield',
				fieldLabel: 'New (JPG or JPEG only)',
				labelSeparator: '',
				name: 'newPic',
				id:'newPic',
				style:'width: 200px',
				inputType: 'file',
				allowBlank: false
			}
		]
	}

	var pictUploadForm = new Ext.FormPanel({
		frame: true,
		bodyStyle: 'padding:5px',
		width: 415,
		layout: 'column',
		url:'library/empphotoupload.php',
		method: 'POST',
		fileUpload: true,
		items: [picFiles],
		buttons: [{
			text: 'Upload Picture',
			handler: function() {
				var theForm = pictUploadForm.getForm();
				if(!theForm.isValid()){
					Ext.MessageBox.show({
						title: 'Change Picture',
						msg: 'Please select a picture',
						buttons: Ext.MessageBox.OK,
						icon:Ext.MessageBox.ERROR
					});
					return;
				}
				if(!validateFileExtension(Ext.getDom('newPic').value)){
					Ext.MessageBox.show({
						title: 'Change Picture',
						msg: 'Only JPG or JPEG please.',
						buttons: Ext.MessageBox.OK,
						icon:Ext.MessageBox.ERROR
					});
					return;
				}
				theForm.submit({		 
					params: { act: 'setPicture', id:0},
					waitMsg: 'Uploading picture'
				});
			}
		},{
			text: 'Reset',
			handler: function(){
				pictUploadForm.getForm().reset();
				
			}
		},{
			text: 'Close',
			handler: function(){
				window.location = 'loginhome.php'; 
			}
		}]
	});
  
	pictUploadForm.on({
		actioncomplete: function(form, action){
			if(action.type == 'load'){
				var pic = action.result.data;			
				Ext.getDom('pic').src = pic.file;
				Ext.getCmp('currPic').setValue(pic.file);
			}
			if(action.type == 'submit'){
				var pic = action.result.data;
				Ext.getDom('pic').src = pic.file;
				
				employeeentry.getForm().findField('employeephoto').setValue(pic.photoname);
				Ext.getCmp('currPic').setValue(pic.file);
				Ext.getDom('newPic').value = '';
				win.hide();
			}
		}
	});

	pictUploadForm.getForm().load({ 
		params:{ act:'getPicture',id:0,photoname:'<?php  print $employee_photo; ?>'}, 
		waitMsg: 'Loading'
	});
						  
  	var win = new Ext.Window({
    	title: 'Change Picture',
        height: 180,
        width: 415,
		modal:true,
        layout: 'fit',
		closeAction:'close',
		border: false,
     	autoDestroy :true,
		items: pictUploadForm
    });
	
	var accordion = new Ext.Panel({
		width: 600,
		height:478,
		layout:'accordion',
			items:[{
				title: '<span class="myBold">Official Details</span>',
				forceLayout:true, 
				hideBorders: true,
				layout: 'column',
				items: [{
					columnWidth: .52,
					layout: 'form',					
					items:[{height:5},{
						xtype:'numberfield',
						name: 'employee_salaryno',
						id:'employee_salaryno',
						labelSeparator:'',	
						fieldLabel :labelArray[0] ,
						allowBlank:true,
						tabIndex:1,
						width: 158,
						allowNegative: false,
						allowDecimals: false,
						autoCreate: {tag: 'input', type: 'text',  maxlength: '10'}
					},{
						xtype:'textfield',
						name: 'employee_name',
						id:'employee_name',
						tabIndex:2,
						allowBlank:false,
						maxLength:50,
						width:158,
						labelSeparator:'',	
						fieldLabel :labelArray[1] ,
						autoCreate: {tag: 'input', type: 'text',  maxlength: '50'}
					},{
						xtype:'combo',
						name:'employee_designation',
						id:'employee_designation',
						labelSeparator:'',	
						hiddenName: 'employeedesignation',
						fieldLabel :labelArray[2] ,			
						displayField:'designation_nameeng',
						valueField: 'designation_id',
						blankText: 'Please enter or select Employee Designation',
						width:158,										
						tabIndex:3,
						allowBlank:false,
						//triggerAction:'all',
						mode:'local',
						hideTrigger:true,
						store: designationstore,
						editable:false
						//forceSelection:true
					},{				
						        xtype: 'combo',
								name: 'branch_name',
								id:'branch_name',
								labelSeparator:'',	
								fieldLabel :labelArray[3] ,
								displayField:'branch_name',
								valueField:'branch_name',
								width:158,	
								tabIndex:4,	
								allowBlank:false,
								editable :true,
								triggerAction:'all',
								blankText : 'Please enter or select Branch Name.',
								mode:'local',
								forceSelection:true,
								store: branchstore
					},{			
						xtype: 'combo',
						name: 'employee_gender',
						id:'employee_gender',
						labelSeparator:'',	
						fieldLabel :labelArray[4] ,
						forceSelection:true,										
						displayField:'gender',
						valueField: 'gender',
						editable:false,
						width:158,
						tabIndex:5,
						allowBlank:false,
						triggerAction:'all',
						mode:'local',
						editable:false,
						store: genderstore
					},{
						xtype: 'combo',
						name: 'employee_category',
						id:'employee_category',
						labelSeparator:'',	
						fieldLabel :labelArray[5] ,
						forceSelection:true,				
						displayField:'employee_category',
						valueField: 'employee_category',
						width:158,
						tabIndex:6,
						allowBlank:true,
						triggerAction:'all',
						mode:'local',
						editable:false,
						store: categorystore
					},{				
						xtype: 'combo',
						name: 'employee_ishandicap',
						id:'employee_ishandicap',
						labelSeparator:'',	
						fieldLabel :labelArray[6],
						forceSelection:true,				
						displayField:'employee_ishandicap',
						valueField: 'employee_ishandicap',
						width:158,
						tabIndex:7,
						allowBlank:true,
						triggerAction:'all',
						mode:'local',
						editable:false,
						store: ishandicapstore
					},{
						xtype: 'combo',
						name: 'employee_regularorfixpay',
						id:'employee_regularorfixpay',
						labelSeparator:'',	
						fieldLabel :labelArray[7] ,
						forceSelection:true,				
						displayField:'employee_regularorfixpay',
						valueField: 'employee_regularorfixpay',
						width:158,
						tabIndex:9,
						allowBlank:true,
						triggerAction:'all',
						mode:'local',
						editable:false,
						store: paystore
					},{
						xtype: 'combo',
						name: 'employee_isteaching',
						id:'employee_isteaching',
						labelSeparator:'',	
						fieldLabel :labelArray[14] ,
						forceSelection:true,				
						displayField:'employee_isteaching',
						valueField: 'employee_isteaching',
						width:158,
						tabIndex:11,
						allowBlank:true,
						triggerAction:'all',
						mode:'local',
						editable:false,
						store: teachingstore
					},{
						xtype: 'datefield',
						name: 'employee_birthdate',
						id:'employee_birthdate',
						labelSeparator:'',	
						fieldLabel :labelArray[8] ,
						tabIndex:13,
						maxValue:new Date('<?php echo date("d M Y H:i:s")?>'),
						allowBlank:true,
						width:158									
					},{
						xtype: 'datefield',
						name: 'employee_deptjoindate',
						id:'employee_deptjoindate',
						tabIndex:15,
						labelSeparator:'',	
						fieldLabel :labelArray[9] ,
						allowBlank:true,
						width:158
					},{
						xtype: 'textfield',
						name: 'employee_bankacno',
						id:'employee_bankacno',
						tabIndex:16,
						width:158,
						autoCreate: {tag: 'input', type: 'text',  maxlength: '20'},
						fieldLabel: 'Bank Acc No',
						enableKeyEvents: true,
						listeners:{
							keyup: validRegno
						}
					},{
						xtype: 'textfield',
						name: 'employee_panno',
						id:'employee_panno',
						fieldLabel: 'Pan No',
						width:158,
						tabIndex:18,
						autoCreate: {tag: 'input', type: 'text',  maxlength: '20'},
						enableKeyEvents: true,
						listeners:{
							keyup: validRegno
						}			
					},{
						xtype: 'combo',
						name: 'employee_pension',
						id:'employee_pension',
						labelSeparator:'',	
						fieldLabel :labelArray[15] ,
						forceSelection:true,				
						displayField:'employee_pension',
						valueField: 'employee_pension',
						width:158,
						tabIndex:20,
						allowBlank:true,
						triggerAction:'all',
						mode:'local',
						editable:false,
						store: pensiontypestore
					}]
				},{
					columnWidth:.48,
					layout:'form',
					height:157,
					style:'padding:10px 0px 0px 170px',							
					items:[{
						xtype:'box',										       
						autoEl:{ 
							tag:'div',
							html:'<img id="pic" src="library/images/default.gif" alt="photograph" class="img-contact" width="<?php echo $SiteImageWidth ?>" height="<?php echo $SiteImageHeight ?>"/>'
						}
					},{
						style: 'padding:0px 0px 0px 30px',
						xtype: 'button',
						tabIndex:6,											
						text: 'Upload',
						width:80,
						handler:function(){
							win.show();
							Ext.getDom('newPic').size = 30;																						
						}
					}]				
				},{
					columnWidth: .48,
					layout: 'form',					
					items:[{height:10},{										
						xtype: 'combo',
						name: 'employee_active',
						id:'employee_active',
						labelSeparator:'',	
						fieldLabel :labelArray[10] ,
						forceSelection:true,				
						displayField:'employee_active',
						valueField: 'employee_active',
						width:158,
						tabIndex:8,
						allowBlank:false,
						triggerAction:'all',
						mode:'local',
						editable:false,
						store: activestore								
					},{
						xtype: 'numberfield',
						name: 'employee_basicsalary',
						id:'employee_basicsalary',
						tabIndex:10,
						labelSeparator:'',	
						fieldLabel :labelArray[11] ,
						width:158,
						allowBlank:true,
						autoCreate: {tag: 'input', type: 'text',  maxlength: '10'}
					},{
						xtype: 'datefield',
						name: 'employee_incrdate',
						id:'employee_incrdate',
						fieldLabel: 'Increment Date',
						width:158,
						height:25,
						tabIndex:11
					},{
						xtype: 'datefield',
						name: 'employee_schooljoindate',
						id:'employee_schooljoindate',
						tabIndex:13,
						labelSeparator:'',	
						fieldLabel :labelArray[12] ,
						allowBlank:true,
						width:158								    					
					},{
						xtype: 'datefield',
						name: 'employee_retddate',
						id: 'employee_retddate',
						fieldLabel: 'Retirement Date',
						tabIndex:15,													
						disabled: true,
						width:158,
						allowBlank:true
					},{
						xtype: 'textfield',
						name: 'employee_gpfacno',
						id:'employee_gpfacno',
						tabIndex:17,
						labelSeparator:'',	
						fieldLabel :labelArray[13] ,
						width:158,
						allowBlank:true,
						autoCreate: {tag: 'input', type: 'text',  maxlength: '20'},
						enableKeyEvents: true,
						listeners:{
							keyup: validRegno
						}
					},{
						xtype:'textfield',
						name: 'employee_nominee',
						id: 'employee_nominee',
						fieldLabel: 'Nominee',
						tabIndex:19,
						width:158,									
						autoCreate: {tag: 'input', type: 'text',  maxlength: '100'}
					}]        				
				},{ 
					columnWidth: 1,
					layout: 'form',	
					items:[{
						xtype: 'combo',
						name: 'employee_payscale',
						id:'employee_payscale',
						hiddenName:	'payscale_id',	
						fieldLabel: 'Pay Scale',
						forceSelection:true,				
						displayField:'payscale',
						valueField: 'payscale_id',
						width:300,
						allowBlank:true,
						mode:'local',
						emptyText:'Current-Payscale / Pay-Band / Grade-Pay',
						tabIndex:21,
						triggerAction:'all',
						editable:false,
						store: payscalestore
					}]		
				}]
			},{
			title: '<span class="myBold">Qualification Information</span>',
			forceLayout:true, 
			hideBorders: true,
			layout: 'column',
			items : [{
				columnWidth: .52,
				layout: 'form',
				items:[{height:10},{
					xtype:'combo',
					name: 'employee_eduqualification',
					id: 'employee_eduqualification',
					tabIndex:22,
					fieldLabel:'Education Quali.',
					width:158,
					displayField:'employee_eduqualification',
		            valueField: 'employee_eduqualification',
					triggerAction:'all',
					hideTrigger:false,
					mode:'local',
					editable:true,
					//forceSelection:true,
					store:Eduqualificationstore,
					autoCreate: {tag: 'input', type: 'text', maxlength: '50'}
				},{
					xtype:'combo',
					name: 'employee_edusub',
					id: 'employee_edusub',
					fieldLabel: 'Subject',
					tabIndex:24,
					displayField:'employee_edusub',
		            valueField: 'employee_edusub',
					triggerAction:'all',
					hideTrigger:false,
					mode:'local',
					editable:true,
					//forceSelection:true,
					store:Edusubjectstore,
					autoCreate: {tag: 'input', type: 'text', maxlength: '50'},
					width:158									
				},{
					xtype: 'numberfield',
					name: 'employee_eduyear',
					id:'employee_eduyear',
					minLength:4,
					tabIndex:26,
					autoCreate: {tag: 'input', type: 'text', maxlength: '4'},
					fieldLabel: 'Year',
					width:158
				},{
					xtype:'combo',
					name: 'employee_profqualification',
					id: 'employee_profqualification',
					fieldLabel: 'Professional Quali.',
					autoCreate: {tag: 'input', type: 'text', maxlength: '50'},
					displayField:'employee_profqualification',
		            valueField: 'employee_profqualification',
					triggerAction:'all',
					hideTrigger:false,
					mode:'local',
					editable:true,
					//forceSelection:true,
					store:Proqualificationstore,
					width:158,
					tabIndex:27
				},{
					xtype:'combo',
					name: 'employee_profsub',
					id: 'employee_profsub',
					fieldLabel: 'Subject',
					displayField:'employee_profsub',
		            valueField: 'employee_profsub',
					triggerAction:'all',
					hideTrigger:false,
					mode:'local',
					editable:true,
					//forceSelection:true,
					store:Prosubjectstore,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '50'},
					tabIndex:29,
					width:158
				},{
					xtype: 'numberfield',
					name: 'employee_profyear',
					id:'employee_profyear',
					fieldLabel: 'Year',
					width:158,
					minLength:4,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '4'},
					tabIndex:31
				},{
					xtype:'combo',
					name: 'employee_otherqualification',
					id: 'employee_otherqualification',
					tabIndex:32,
					fieldLabel: 'Other Quali.',
					width:158,
					displayField:'employee_otherqualification',
		            valueField: 'employee_otherqualification',
					triggerAction:'all',
					hideTrigger:false,
					mode:'local',
					editable:true,
					//forceSelection:true,
					store:Othqualificationstore,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '50'}
				},{
					xtype:'combo',
					name: 'employee_othersub',
					id: 'employee_othersub',
					tabIndex:34,
					displayField:'employee_othersub',
		            valueField: 'employee_othersub',
					triggerAction:'all',
					hideTrigger:false,
					mode:'local',
					editable:true,
				//	forceSelection:true,
					store:Othsubjectstore,
					fieldLabel: 'Subject',
					autoCreate: {tag: 'input', type: 'text',  maxlength: '50'},
					width:158
				},{
					xtype: 'numberfield',
					name: 'employee_otheryear',
					id:'employee_otheryear',
					fieldLabel: 'Year',
					minLength:4,
					autoCreate: {tag: 'input', type: 'text',maxlength: '4'},
					tabIndex:36,
					width:158
				}]				
			},{
				columnWidth: .48,
				layout: 'form',
				items:[{height:10},{
					xtype:'textfield',
					name: 'employee_eduuni',
					id: 'employee_eduuni',
					tabIndex:23,
					fieldLabel:'University',
					width:158,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '50'}
				},{
					xtype: 'textfield',
					name: 'employee_eduobtclass',
					id:'employee_eduobtclass',
					fieldLabel: 'Obtain Classed',
					//forceSelection:true,
					tabIndex:25,				
					autoCreate: {tag: 'input', type: 'text',  maxlength: '10'},
					width:158									
				},{
					xtype:'',
					name: 'temp3',
					fieldLabel: '',
					width:158,
					height:25
				},{	
					xtype:'textfield',
					name: 'employee_profuni',
					id: 'employee_profuni',
					tabIndex:28,
					fieldLabel:'University',
					width:158,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '50'}														
				},{
					xtype: 'textfield',
					name: 'employee_profobtclass',
					id:'employee_profobtclass',
					fieldLabel: 'Obtain Classed',
					autoCreate: {tag: 'input', type: 'text',  maxlength: '10'},
					tabIndex:30,
					width:158
				},{
					xtype: '',
					name: 'temp3',
					fieldLabel: '',
					width:127,
					height:25
				},{
					xtype:'textfield',
					name: 'employee_otheruni',
					id: 'employee_otheruni',
					tabIndex:33,
					fieldLabel:'University',
					width:158,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '50'}
				},{
					xtype: 'textfield',
					name: 'employee_otherobtclass',
					id:'employee_otherobtclass',
					fieldLabel: 'Obtained Class',
				//	forceSelection:true,				
					autoCreate: {tag: 'input', type: 'text',  maxlength: '10'},
					tabIndex:35,
					width:158													
				},{
					xtype: 'textfield',
					name: 'employee_photo',
					id:'employeephoto',
					hidden: true,
					width:158
				}]								
			}]			   
		},{
			title: '<span class="myBold">Personal Details</span>',
			forceLayout:true, 
			hideBorders: true,
			layout: 'column',
			items:[{
				columnWidth: .5,
				layout: 'form',					
				items:[{height:10},{ 
					xtype: 'textarea',
					growAppend: "",
					name: 'employee_curaddress',
					id:'employee_curaddress',
					fieldLabel: 'Contact Address',
					maxLength: 200,
					tabIndex:36,
					maxLengthText: 'max 250 characters',
					width: 158
				},{
					xtype: 'textfield',
					name: 'employee_contactnores',
					id: 'employee_contactnores',
					tabIndex:38,
					fieldLabel: 'Contact No(R)',
					width:158,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '13'},
					enableKeyEvents: true,
					listeners:{
						keyup: validphoneno
					}
				},{
					xtype: 'textfield',
					name: 'employee_mobile',
					id: 'employee_mobile',
					tabIndex:41,
					fieldLabel: 'Contact No(O)',
					width:158,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '13'},
					enableKeyEvents: true,
					listeners:{
						keyup: validphoneno
					}
				},{
					xtype:'textfield',
					name: 'employee_emailid',
					fieldLabel: 'Email',
					width:158,
					tabIndex:45,
					vtype:'email',
					autoCreate: {tag: 'input', type: 'text',  maxlength: '50'}
				}]				
			},{
				columnWidth: .5,
				layout: 'form',					
				items:[{height:10},{ 
					xtype: 'textarea',
					growAppend: "",
					name: 'employee_permaddress',
					id:'employee_permaddress',
					fieldLabel: 'Permanent Address',
					maxLength: 160,
					tabIndex:37,
					maxLengthText: 'max 250 characters',
					width: 158
				},{
					xtype: 'numberfield',
					name: 'employee_phone',
					id: 'employee_phone',
					tabIndex:40,
					fieldLabel: 'Contact No(M)', 
					width:158,
					autoCreate: {tag: 'input', type: 'text',  maxlength: '13'}
				},{				
					xtype: 'combo',
					name: 'employee_bloodgroup',
					id:'employee_bloodgroup',
					fieldLabel: 'Blood Group',	
					displayField:'bloodgroup',
					valueField: 'bloodgroup',
					width:100,	
				 lazyRender:true,
					tabIndex:43,	
					allowBlank:true,
					triggerAction:'all',
					mode:'local',
					store: bloodgroupstore,
					editable:true,
					forceSelection:true		
				
				},
				{
					xtype: 'textfield',
					name: 'employee_id',
					id:'employee_id',
					hidden:true,
					value:0
				}]
			}]			    
		}]
	});
		 		
	var employeeentry = new Ext.FormPanel({
		id: 'employeeentry',
    	url:'library/save-employee.php',
		method:'post',
        frame:true,
		height:507,
		layout:'column',
        bodyStyle:'padding:5px 10px',
		items: [
			{
				columnWidth: 0.25,
				layout: 'fit',
				items:[grid]
			},
			{
				columnWidth: 0.75,
				autoScroll: true,
				labelWidth: 120,
				defaults: {border:false},
				defaultType: 'textfield',
				autoHeight: true,
				bodyStyle: Ext.isIE ? 'padding:0 0 5px 10px;' : 'padding:10px 10px;',
				border: false,
				style: {
					"margin-left": "10px", 
					"margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0" 
				},
				items:[accordion]
       		}
		]
	});
	
    var EmployeeWindow = new Ext.Window({		
        title: 'Faculty Entry Form',
		width:900,		
		height:600,
		modal:true,
		shadow:false,
		border: false,
		//layout: 'fit',
		closeAction:'close',
		collapsible:true,
		items: employeeentry,
		buttonAlign: 'center',
	    buttons:[
			{
				text: 'Add New', 
				name:'btnAdd',
				iconCls:'icon-add',
				id:'btnAdd',
				handler: function (){
					Ext.getCmp('btnDelete').disable();
					employeeentry.getForm().reset();
					Ext.getCmp('employee_salaryno').focus();
					Ext.getCmp('employee_id').setValue('0');
					 Ext.getCmp('employee_designation').setValue(23);
					pictUploadForm.getForm().load({
						params:{act:'getPicture',id: 0 , photoname:'default.gif'},
						waitMsg: 'Loading' 
					});
				}
			},{
      		text: 'Save',
			iconCls:'icon-save',
			tabIndex:46,
			handler: function(){				
				check_datevalidation();

			}
      	},{
				text: 'Delete',
				iconCls:'remove',
				name:'btnDelete',
				id:'btnDelete',
				handler: function(){ 
				Ext.MessageBox.confirm('Confirmation', ' Are you sure want to delete This Record.?', deleterecord);
					
				}
		},{
		  	text: 'Reset',
			iconCls:'icon-reset',
			tabIndex:47,
			handler: function(){
				Ext.getCmp('btnDelete').disable();
				employeeentry.getForm().reset();
				Ext.getCmp('employee_salaryno').focus();
				Ext.getCmp('employee_id').setValue('0');
				 Ext.getCmp('employee_designation').setValue(23);
				pictUploadForm.getForm().load({
					params:{act:'getPicture',id: 0 , photoname:'default.gif'},
					waitMsg: 'Loading' 
				});
			}	
        },
		{
        	text: 'Close',
			iconCls:'icon-close',
			tabIndex:48,
			handler: function () {
				EmployeeWindow.close();	
			}
        }]
	});
	
	function deleterecord(btn){
    	if(btn=='yes'){
			employeeentry.getForm().submit({
						waitMsg: 'Deleting...',
						params:{act:'del'},
						success: function () {	
							Ext.getCmp('btnDelete').disable();
							Store.load();
							employeeentry.getForm().reset();	
							 Ext.getCmp('employee_designation').setValue(23);
							pictUploadForm.getForm().load({
								params:{act:'getPicture',id: 0 , photoname:'default.gif'},
								waitMsg: 'Loading' 
							});										
						}
					});
	  		
	  }}
	var varWidth =  (screen.width - EmployeeWindow.width)/2;
	EmployeeWindow.setPosition(varWidth,((screen.height/4)-190));
	EmployeeWindow.show();
	Ext.getCmp('employee_salaryno').focus(true,500);
		
	employeeentry.getForm().findField('employee_birthdate').on('blur',function (){
		if(employeeentry.getForm().findField('employee_birthdate').validate() == true){	
			employeeentry.getForm().findField('employee_retddate').enable();
			var Bdate = employeeentry.getForm().findField('employee_birthdate').getValue();
			var Teaching = employeeentry.getForm().findField('employee_isteaching').getValue();
			Bdate.setFullYear(Bdate.getFullYear()+58);	
			var month = Bdate.getMonth()+1;
			if(Teaching == "Yes"){
				if(month>=6 && month<=11){
					Bdate.setFullYear(Bdate.getFullYear(),10,30);
				} else{
					Bdate.setFullYear(Bdate.getFullYear(),5,31);
				}
			}
			employeeentry.getForm().findField('employee_retddate').setValue(Bdate);
		}
	});
	
	employeeentry.getForm().findField('employee_salaryno').on('blur',function (){
		var varsalaryno=employeeentry.getForm().findField('employee_salaryno').getValue();	
		var varid=employeeentry.getForm().findField('employee_id').getValue();	
		if(varsalaryno!="" || varsalaryno!=0){
			Ext.Ajax.request({
				loadMask: true,
				sync : true,
				url: 'library/data/get-employee-salaryno.php',
				params:{id:varid,salaryno: varsalaryno},
				success: function(resp){
					resbool=Ext.decode(resp.responseText).success;
					if(resbool== true){
						Ext.MessageBox.show({
							title: 'Error',
							msg: 'This salary no is already entered.',
							buttons: Ext.MessageBox.OK,
							icon:Ext.MessageBox.ERROR
						});
						Ext.getCmp('employee_salaryno').reset();
					}	
				}				
			});		
		}
	});
	
	employeeentry.getForm().findField('employee_regularorfixpay').on('select',function (){
		var pay = employeeentry.getForm().findField('employee_regularorfixpay').getValue();
		if(pay == "Regular"){
			employeeentry.getForm().findField('employee_payscale').allowBlank=false;
			employeeentry.getForm().findField('employee_incrdate').allowBlank=false;
		}
		else{
			employeeentry.getForm().findField('employee_payscale').allowBlank=true;
			employeeentry.getForm().findField('employee_incrdate').allowBlank=true;
			employeeentry.getForm().findField('employee_payscale').reset();
			employeeentry.getForm().findField('employee_incrdate').reset();
		}
	});
	
	function check_datevalidation(){
    	var dt = new Date('<?php echo date("d M Y H:i:s")?>');
  			
		var emp_birthdate      = Ext.getCmp('employee_birthdate').getValue();
	 	var emp_deptjoindate   = Ext.getCmp('employee_deptjoindate').getValue();
	 	var emp_schooljoindate = Ext.getCmp('employee_schooljoindate').getValue();
	 	var emp_incrdate       = Ext.getCmp('employee_incrdate').getValue();
	 	var emp_retireddate    = Ext.getCmp('employee_retddate').getValue();
	 	if(emp_birthdate !="" && emp_birthdate > dt ){    
			Ext.MessageBox.show({
				title: 'Error',
				msg: 'Employee\'s Birth-date should be less than today.',
				buttons: Ext.MessageBox.OK,
				icon:Ext.MessageBox.ERROR
			}); 
			return ; 	
	    }    
    
     	if(emp_deptjoindate !="" && emp_birthdate !="" && emp_deptjoindate < emp_birthdate){    
			Ext.MessageBox.show({
				title: 'Error',
				msg: 'Employee\'s Department-Join-date should be greater than Birth-date.',
				buttons: Ext.MessageBox.OK,
				icon:Ext.MessageBox.ERROR
			});
			return ; 
		}    
   
     	if(emp_deptjoindate !="" && emp_schooljoindate !="" && emp_deptjoindate > emp_schooljoindate ){    
			Ext.MessageBox.show({
				title: 'Error',
				msg: 'Employee\'s Department-Join-date should be less than School-Join-Date.',
				buttons: Ext.MessageBox.OK,
				icon:Ext.MessageBox.ERROR
			}); 
			return ; 
	   	}    

     	if(emp_incrdate !="" && emp_deptjoindate !="" && emp_incrdate < emp_deptjoindate){    
			Ext.MessageBox.show({
				title: 'Error',
				msg: 'Employee\'s Increment-date should be greater than Department-Join-date.',
				buttons: Ext.MessageBox.OK,
				icon:Ext.MessageBox.ERROR
			}); 
			return ; 
	   	}    

     	if(emp_incrdate !=""  && emp_retireddate !="" && emp_incrdate > emp_retireddate){    
			Ext.MessageBox.show({
				title: 'Error',
				msg: 'Employee\'s Increment-date should be less than Retired-date.',
				buttons: Ext.MessageBox.OK,
				icon:Ext.MessageBox.ERROR
			}); 
			return ; 
	   	}    
	 
	 	if(emp_schooljoindate !="" && emp_retireddate !="" && emp_schooljoindate > emp_retireddate){  
			Ext.MessageBox.show({
				title: 'Error',
				msg: 'Employee\'s Collage-Join-date should be less than Retired-date.',
				buttons: Ext.MessageBox.OK,
				icon:Ext.MessageBox.ERROR
			}); 
			return ;
	  	}    
	 
		if(emp_schooljoindate !="" && emp_schooljoindate  > dt){  
			Ext.MessageBox.show({
				title: 'Error',
				msg: 'Employee\'s School-Join-date should be less than Today.',
				buttons: Ext.MessageBox.OK,
				icon:Ext.MessageBox.ERROR
			}); 
			return ;
	   	}    

		clearEmptyText(employeeentry);
    	
		employeeentry.getForm().submit({					
			waitMsg: 'Saving...',
			success: function () {
				Ext.MessageBox.show({
					title: 'Message',
					msg: 'Data has been saved',
					buttons: Ext.MessageBox.OK,
					icon:Ext.MessageBox.INFO
				});	
				
				Ext.getCmp('btnDelete').disable();
				employeeentry.getForm().reset();
				 Ext.getCmp('employee_designation').setValue(23);
				grid.getSelectionModel().clearSelections();
				Store.load();
				
				Eduqualificationstore.load({params:{action:'Eduqul'}});
				Edusubjectstore.load({params:{action:'Edusub'}});
				Proqualificationstore.load({params:{action:'Proqul'}});
				Prosubjectstore.load({params:{action:'Prosub'}});
				Othqualificationstore.load({params:{action:'Othqul'}});
				Othsubjectstore.load({params:{action:'Othsub'}});
				
				pictUploadForm.getForm().load({
					params:{act:'getPicture',id: 0 , photoname:'default.gif'},
					waitMsg: 'Loading' 
				});

			
				
			},
			failure: function (){
				Ext.MessageBox.show({
					title: 'Error',
					msg: 'Please fill complete form',
					buttons: Ext.MessageBox.OK,
					icon:Ext.MessageBox.ERROR
				});
			}
		});
	} 
	
	Ext.getCmp('btnDelete').disable();
 Ext.getCmp('employee_designation').setValue(23); // 23 for faculty
 	
});
</script>
<!-- end custom CSS/JS -->`
<div align="center"><div id="main-content" style="width:680px" ></div></div> 
<?php require "_footer.php";?>