<?php 
	require "_header.php"; 
	require "data/combo_semester.php";
	require "includeGridFilters.php";
	if($_SESSION["VedantnrUserRole"]=='Hod'){
		$hod_sql=" SELECT branch_name FROM `cms_employeemaster` WHERE `user_id` ='".$_SESSION["VedantnrUserId"]."'";
		$hod_out=dbQuery($hod_sql);
		$branch_name = dbArray($hod_out);
		$branch_name=$branch_name['branch_name'];
	}
	
?>
<div id="main-content">
<script language="javascript" type="text/javascript">
Ext.onReady(function(){
	Ext.QuickTips.init();

	var employeestore = new Ext.data.JsonStore({
	url:'data/get-subject-faculty1.php',
    root: 'data',
	autoLoad:true,
	totalProperty: 'total',
	fields: ['employee_id','employee_name'] 
	});
	
	var branchstore = new Ext.data.ArrayStore({		
		fields: ['branch_id','branch_name'],
		data:Ext.semester.branch
	});
	
	var semesterstore = new Ext.data.ArrayStore({		
		fields: ['semester_id','semester_name'],
		data:Ext.semester.semester
	});
	   
	var subjectstore = new Ext.data.JsonStore({
	url:'data/get-subject.php',
    root: 'data',
	totalProperty: 'total',
	fields: ['subject_id','subject_name'] 
	});
	subjectstore.load({params:{task:'getall'}});
	
	var branch = new Ext.form.ComboBox({
		name: 'branch_name',
		id:'branch_name',
		hiddenName:'branch_hidden',
		labelSeparator:'',	
		fieldLabel :'Branch :<span class="comp"></span>' ,
		displayField:'branch_name',
		valueField: 'branch_id',
		editable:true,
		triggerAction:'all',
		tabIndex:1,
		width:163,
		mode:'local',
		lastQuery:'',
		allowBlank:true,
		store: branchstore,
			listeners: {'select': function(cmb, rec, idx){
				var branch_name = Ext.getCmp('branch_name').getValue();
			employeestore.load({params:{branch_name:branch_name}});
			}}
	});

	var semester = new Ext.form.ComboBox({
		name: 'semester_name',
		id:'semester_name',
		hiddenName:'semester_hidden',
		labelSeparator:'',	
		fieldLabel :'Semester: <span class="comp"></span>' ,
		displayField:'semester_name',
		valueField: 'semester_id',
		editable:true,
		tabIndex:2,
		width:163,
		hidden:true,
		triggerAction:'all',
		mode:'local',
		allowBlank:true,
		store: semesterstore,
		listeners: {'select': function(cmb, rec, idx){
			Ext.getCmp('subject_name').reset();
			LoadData();
						
		}}
	});

	var subject = new Ext.form.ComboBox({
		name: 'subject_name',
		id:'subject_name',
		hiddenName:'subject_hidden',
		labelSeparator:'',	
		fieldLabel :'Subject: <span class="comp"></span>' ,
		displayField:'subject_name',
		valueField: 'subject_id',
		editable:true,
		triggerAction:'all',
		mode:'local',
		hidden:true,
		tabIndex:6,
		width:163,
		allowBlank:true,
		store: subjectstore,
		listeners: {'select': function(cmb, rec, idx){
			var subject_id = this.getValue();
			if(subject_id != "" ){		
				Ext.getCmp('employee_id').reset();	
				employeestore.removeAll();
				employeestore.load({params:{subject_id:subject_id}});
			}							
						
		}}
	});

 	function LoadData(){
	var branch_name = Ext.getCmp('branch_name').getValue();
	var semester_name = Ext.getCmp('semester_name').getValue();
	var employee_id = Ext.getCmp('employee_id').getValue();
	if(branch_name != '' && semester_name != ''){	
		Ext.getCmp('subject_name').reset();
		subjectstore.load({params:{branch_name:branch_name,semester_name:semester_name}});
	}
	
	}
 


	
	var PresentForm = new Ext.FormPanel({
		method:'post',
        frame:true,
		autoHeight:true,	
		id:'PresentForm',
		name:'PresentForm',
		url:'report-employee-icard-result.php',
		standardSubmit:true,       
       items :[branch,semester,subject,{		
					xtype: 'combo',
					name: 'employee_id',
					id:'employee_id',
					labelSeparator:'',	
					fieldLabel :'Employee :<span class="comp"></span>' ,
					forceSelection:true,				
					displayField:'employee_name',
					valueField: 'employee_id',
					hiddenName:'employee_id_hid'
					,lastQuery:''
					,allowBlank:true
					,triggerAction:'all'
					,mode:'local'
					,store:employeestore
					,width:163
					,selectOnFocus: true,
					tabIndex:8,
					listeners: {'select': function(cmb, rec, idx){
					}}
				}
			]	   
  	});
	
	
 	var PresentWindow = new Ext.Window({
        title: 'Employee I-Card Report',
		width:300,		
		autoHeight:true,	
		modal:true,	
		border: false,
		layout: 'fit',
		closeAction:'close',
		collapsible:true,
		items: PresentForm,
		buttonAlign: 'center',
	    buttons:[{xtype:'button',
						text:'View Report',
						iconCls: 'new-tab',
						width:70,
						tabIndex:9,
						name:'btnSave',
						id:'btnSave',
						handler: function(){
						
						var branch_hidden=PresentForm.getForm().findField('branch_hidden').getValue();


			var employee_id_hid=PresentForm.getForm().findField('employee_id_hid').getValue();

			
var redirect = 'report-employee-icard-result.php?branch_hidden='+branch_hidden + '&employee_id_hid='+employee_id_hid ; 
                window.location = redirect;


			}
			} ,{
						xtype:'button',
						iconCls:'icon-reset',
						text: 'Reset', 
						width:70,
						tabIndex:11,
						name:'btnReset',
						id:'btnReset',
						handler: function (){
							PresentForm.getForm().reset();
							Ext.getCmp('btnSave').enable();
							grid.getSelectionModel().clearSelections();
							Ext.getCmp('branch_name').focus(true,500);
							store.load();
						}
					},{
						xtype:'button',
							id:'btnClose',
							text:'Close',
							name:'btnClose',
							iconCls:'icon-close',
							width:70,
							tabIndex:11,
							handler: function () {
							PresentWindow.close();	
							}
						}]
	});
	
	var varWidth =  (screen.width - PresentWindow.width)/2;
	PresentWindow.setPosition(varWidth,((screen.height/4)));	 
	PresentWindow.show();
	<?php if($branch_name!=""){ ?>
		branchstore.filter('branch_id','<?php echo $branch_name ?>',true,true,true);
	<?php } ?>
	Ext.getCmp('branch_name').focus(true,1000);

});
</script>
<div align="center"></div>
</div>
<?php require "_footer.php";?>
