<?php 
	require "_header.php";
	require "data/combo_student.php";
	require "data/combo_semester.php";
	require "data/combo_branchyear.php";
?>
<div id="main-content">
<script type="text/javascript">
var labelArray;
labelArray = [
	['Branch <span class="comp">*</span>'],
	['Batch Year <span class="comp">*</span>'],
	['Course Year <span class="comp">*</span>'],
	['Semester <span class="comp">*</span>'],
	['Date:<span class="comp">*</span>'],
	['Order By:']
];


		
var branchstore = new Ext.data.ArrayStore({
			fields: ['branch_id', 'branch_name'],
			data: Ext.semester.branch
		});

		var batchyearstore = new Ext.data.ArrayStore({
			fields: ['year_id', 'year_name'],
			data: Ext.semester.yearname
		});

		var semesterstore = new Ext.data.ArrayStore({
			fields: ['branch_id', 'semester_id', 'semester_name'],
			data: Ext.semester.semester
		});

		var yearstore = new Ext.data.ArrayStore({
			fields: ['branch_id', 'branchyear_id', 'branchyear_name'],
			data: Ext.year.year
		});




var orderbystore = new Ext.data.ArrayStore({
	fields: ['order_by2','order_by1'],
	data: [['present_percent','Present Percent'],
		   ['student_gturegno','Enrollment No'],
		   ['student_name','Student Name']]
}); 



Ext.onReady(function(){
	Ext.QuickTips.init();
	
	var AttendenceForm = new Ext.FormPanel({
    	labelWidth: 80,
        url:'report-continue-absent-result.php',
		frame:true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 6px 0',
        layout:'form',
		defaultType: 'textfield',
        items :[{
					xtype: 'combo',
					name: 'branch_name',
					id: 'branch_name',
					hiddenName: 'branch_hidden',
					fieldLabel: labelArray[0],
					displayField: 'branch_name',
					valueField: 'branch_id',
					width: 180,
					triggerAction: 'all',
					mode: 'local',
					allowBlank: true,
					store: branchstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							Ext.getCmp('branch_disp').setValue(this.getRawValue());
							Ext.getCmp('semester_name').reset();
							Ext.getCmp('year_name').reset();
							Ext.getCmp('branchyear_name').reset();
							
							semesterstore.filter('branch_id', cmb.getValue(), false, true, true);
							yearstore.filter('branch_id', cmb.getValue(), false, true, true);
							var semesterCombo = Ext.getCmp('semester_name');
							if (cmb.getValue() == 3 || cmb.getValue() == 5) {
								semesterCombo.enable();
							} else {
								semesterCombo.disable();
								semesterCombo.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'year_name',
					id: 'year_name',
					hiddenName: 'year_hidden',
					fieldLabel: labelArray[1],
					displayField: 'year_name',
					valueField: 'year_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank: true,
					store: batchyearstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							Ext.getCmp('year_disp').setValue(this.getRawValue());	
						}
					}
					
				}, {
					xtype: 'combo',
					name: 'branchyear_name',
					id: 'branchyear_name',
					hiddenName: 'branchyear_hidden',
					fieldLabel: labelArray[2],
					displayField: 'branchyear_name',
					valueField: 'branchyear_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank: true,
					store: yearstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							Ext.getCmp('branchyear_disp').setValue(this.getRawValue());
							if (Ext.getCmp('branch_name').getValue() != "") {
								
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'semester_name',
					id: 'semester_name',
					hiddenName: 'semester_hidden',
					fieldLabel: labelArray[3],
					displayField: 'semester_name',
					valueField: 'semester_id',
					lastQuery: '',
					disabled: true,
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank: true,
					store: semesterstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							Ext.getCmp('semester_disp').setValue(this.getRawValue());
							if (Ext.getCmp('branch_name').getValue() != "") {
								
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				},{
			xtype:'container',
			autoEl:{},
			border:false,
			layout:'column',
			anchor:'100%',
			defaultType:'field',
			items:[{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.63,
				items:[{
					xtype:'datefield',
					id: 'absent_startdate',
					labelSeparator:'',	
					fieldLabel :labelArray[4] ,
					name: 'absent_startdate',
					allowBlank:false,
					vtype: 'daterange',
					endDateField:'absent_enddate'}]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.37,
				labelWidth:1,
				items:[{
					xtype:'datefield',
					id: 'absent_enddate',
					fieldLabel: '',
					name: 'absent_enddate',
					allowBlank:false,
					vtype: 'daterange',
					startDateField: 'absent_startdate' 
				}]
			}]
		},
		{
			xtype: 'combo',
			name: 'orderby',
			id:'orderby',
			hiddenName:'hid_orderby',
			labelSeparator:'',	
			fieldLabel :labelArray[5] ,
			displayField:'order_by1',
			valueField: 'order_by2',
			editable:true,
			width:197,
			triggerAction:'all',
			mode:'local',
			store:orderbystore
		},
		{
					xtype: 'displayfield',
					name: 'branch_disp',
                    id: 'branch_disp',
                   hidden:true,
				},
				{
					xtype: 'displayfield',
					name: 'year_disp',
                    id: 'year_disp',
                   hidden:true,
				},
				{
					xtype: 'displayfield',
					name: 'branchyear_disp',
                    id: 'branchyear_disp',
                   hidden:true,
				},
				{
					xtype: 'displayfield',
					name: 'semester_disp',
                    id: 'semester_disp',
                   hidden:true,
				}]
 	});
	
	var AttendenceWindow = new Ext.Window({
        title: 'Continue Absent Student List Report',
        height: 270,
        width: 335,
		modal:true,
        layout: 'fit',
		border: false,
		closeAction:'close',
		collapsible:'true',
		items: AttendenceForm,
		buttonAlign: 'center',
	    buttons: [{
			text:'View Report',iconCls: 'new-tab',
			handler: function(b, e){	
			
			var branch_hidden=AttendenceForm.getForm().findField('branch_hidden').getValue();
			var semester_hidden=AttendenceForm.getForm().findField('semester_hidden').getValue();
			var year_hidden=AttendenceForm.getForm().findField('year_hidden').getValue();
			var branchyear_hidden=AttendenceForm.getForm().findField('branchyear_hidden').getValue();
			var absent_startdate=AttendenceForm.getForm().findField('absent_startdate').getValue().format('Y-m-d');
			var absent_enddate=AttendenceForm.getForm().findField('absent_enddate').getValue().format('Y-m-d');
			var hid_orderby=AttendenceForm.getForm().findField('hid_orderby').getValue();
			var branch_disp=AttendenceForm.getForm().findField('branch_disp').getValue();
			var year_disp=AttendenceForm.getForm().findField('year_disp').getValue();
			var branchyear_disp=AttendenceForm.getForm().findField('branchyear_disp').getValue();
			var semester_disp=AttendenceForm.getForm().findField('semester_disp').getValue();
			
		//	alert(show_mobile_no);
			
var redirect = 'report-continue-absent-result.php?branch_hidden='+branch_hidden + '&semester_hidden='+semester_hidden + 
  '&year_hidden='+year_hidden + '&branchyear_hidden='+branchyear_hidden + '&absent_startdate='+absent_startdate + '&absent_enddate='+absent_enddate + '&hid_orderby='+hid_orderby
  + '&branch_disp='+branch_disp +'&year_disp='+year_disp + '&branchyear_disp='+branchyear_disp +
'&semester_disp='+semester_disp ; 
                window.location = redirect;	
			}
		},{
			text: 'Reset', iconCls: 'icon-reset',
			handler: function(){   
			  	AttendenceForm.getForm().reset();
				Ext.getCmp('branch_name').focus(true,500);
			}
		},{
		  	text: 'Close',iconCls: 'icon-close',
			handler: function () {    
				AttendenceWindow.close();
			}
      	}]
	});
	
	var varWidth =  (screen.width - AttendenceWindow.width)/2;
	AttendenceWindow.setPosition(varWidth,((screen.height/4)-85));
	AttendenceWindow.show();
	Ext.getCmp('branch_name').focus(true,1000);
	Ext.getCmp('orderby').setValue('present_percent');
});
</script>
<div id="abcd"></div>
</div>
<?php require "_footer.php";?>