<?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>'],
	['Batch Name '],
	['Month '],
	['Student '],
	['Year ']	
];

		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 date = new Date();
var currmonthno = date.getMonth();
var year = date.getFullYear();
currmonthno =currmonthno;



var monthstore = new Ext.data.ArrayStore({
	fields: ['valuemonth','displaymonth'],
	data: [['1','January'],['2','February'],['3','March'],['4','April'], ['5','May'],['6','June'],
		   ['7','July'],['8','August'],['9','September'],['10','October'],['11','November'],['12','December']]
});





var txtYear = new Ext.form.TextField({
	
});



var studentstore = new Ext.data.JsonStore({
			url: 'data/getstudent-feesrecive.php',
			root: 'data',
			totalProperty: 'total',
			fields: [
				{ name: 'student_id', type: 'int' },
				{ name: 'student_name', type: 'string' }
			]
		});



var blank_sheet = new Ext.form.Radio({	
	hideLabel: true,
	name: 'report_type',
	inputValue: 'blank_sheet',	
	checked: true,		
	boxLabel: 'Blank Sheet'
});

var detail_sheet = new Ext.form.Radio({	
	hideLabel: true,
	name: 'report_type',
	inputValue: 'detail_sheet',		
	boxLabel: 'Detail Sheet'
});
var belowper = new Ext.form.NumberField({
	name: 'belowper',
	id:'belowper',
	labelSeparator:'',
	allowBlank:false,
	width:205,
	value:100,
	maxLength:3,
	fieldLabel:'Below %'
});
var BatchStore = new Ext.data.JsonStore({
    url:'data/get-batch.php',
    root: 'data',
	remoteSort: true,
    fields: [{
        name:'batch_id',
        type: 'int'
    },{
        name: 'batch_name',
        type: 'string'
    }],autoLoad:true,
});
Ext.onReady(function(){
    Ext.QuickTips.init();
	
	var sectionliststore = new Ext.data.Store({
			url: 'data/getsectionlist.php',          
	        reader: new Ext.data.JsonReader({			
                fields: ['section_id', 'section_name'],
                root: 'rows'
            })
        });
   
   var student_feesreceipt = new Ext.FormPanel({
        labelWidth: 80,
        url:'report-present-notice-result1.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();
							Ext.getCmp('student_id').reset();
								studentstore.removeAll();
							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());	
							if (Ext.getCmp('branch_name').getValue() != "") {
                                       // Ext.getCmp('student_name').reset();
                                        studentstore.load({ params: { 'branch_id': Ext.getCmp('branch_name').getValue(), 'year_id': Ext.getCmp('year_name').getValue() } });
                                    } else {
                                        this.reset();
                                    }
						}
					}
					
				}, {
					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() != "") {
								Ext.getCmp('student_id').reset();
							} 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() != "") {
								Ext.getCmp('student_id').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				},{
				xtype: 'combo',
				name: 'batch_id',
				id:'batch_id',
				hiddenName: 'batch_idhidden',
				allowBlank:true,
				fieldLabel: labelArray[4],
				forceSelection:true,
				labelSeparator:'',	
				displayField:'batch_name',
				valueField: 'batch_id',
				width: 180,
				triggerAction:'all',
				mode:'local',
				store: BatchStore ,
				  listeners: {'select': function(cmb, rec, idx){
					Ext.getCmp('batch_disp').setValue(this.getRawValue());
					if(Ext.getCmp('branch_name').getValue()!=""){
						studentstore.load({params: {'branch_id': Ext.getCmp('branch_name').getValue(),'batch_id': Ext.getCmp('batch_id').getValue()}});

					}else{
						alert('Select Branch First')
						this.reset();
					}
  					}}
				},{
						xtype: 'combo',
						name: 'student_id',
						id: 'student_id',
						hiddenName: 'student_hidden',
						fieldLabel: labelArray[6],
						displayField: 'student_name',
						valueField: 'student_id',
						width: 180,
						triggerAction: 'all',
						mode: 'local',
						allowBlank: true,
						store: studentstore,
						listeners: {
                                'select': function (cmb, rec, idx) {
                                    if (Ext.getCmp('branch_name').getValue() != "" && Ext.getCmp('year_name').getValue() != "") {
                                    }
                                    else if (Ext.getCmp('branch_name').getValue() != "" && Ext.getCmp('branchyear_name').getValue() != "") {
                                    }
                                    else if (Ext.getCmp('branch_name').getValue() != "" && Ext.getCmp('semester_name').getValue() != "") {
                                    }
                                    else {
                                        this.reset();
                                    }
                                }
                            }
					},belowper,
		{
			xtype:'container',
			autoEl:{},
			border:false,
			layout:'column',
			anchor:'100%',
			defaultType:'field',
			items:[{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.77,
				items:[{
					xtype: 'combo',
					name: 'monthname',
					id:'monthid',
					hiddenName:'monthname',
					fieldLabel :labelArray[5] ,
					displayField:'displaymonth',
					valueField: 'valuemonth',
					editable:true,
					triggerAction:'all',
					mode:'local',
					width:145,
					allowBlank:false,
					store: monthstore,
					//value: currmonthno,
    				listeners: {'select': function(cmb, rec, idx){
						Ext.getCmp('month_disp').setValue(this.getRawValue());
					}}
				}]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.23,
				labelWidth:1,
				items:[{
					xtype:'textfield',
					name: 'year',
					id:'year',
					width:50,
					value: year
				}]
			}]
		},{
			xtype:'container',
			autoEl:{},
			border:false,
			layout:'column',
			anchor:'100%',
			defaultType:'field',
			items:[{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.4,
				items:[blank_sheet]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.4,
				labelWidth:1,
				items:[detail_sheet]
			}]
		},{
					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,
				},{
					xtype: 'displayfield',
					name: 'batch_disp',
                    id: 'batch_disp',
                   hidden:true,
				},
				{
					xtype: 'displayfield',
					name: 'month_disp',
                    id: 'month_disp',
                   hidden:true,
				}]
    });
	 var FeesReceiptReportWindow = new Ext.Window({
        title: 'Present Notice Report',
        height: 350,
        width: 340,
		modal:true,
        layout: 'fit',
		border: false,
		closeAction:'close',
		collapsible:'true',
		items: student_feesreceipt,
		buttonAlign: 'center',
	    buttons: [{
							text:'View Report',iconCls: 'new-tab',
							handler: function(b, e)
							{	
							
			var branch_hidden=student_feesreceipt.getForm().findField('branch_hidden').getValue();
			var semester_hidden=student_feesreceipt.getForm().findField('semester_hidden').getValue();
			var year_hidden=student_feesreceipt.getForm().findField('year_hidden').getValue();
			var branchyear_hidden=student_feesreceipt.getForm().findField('branchyear_hidden').getValue();
			var student_hidden=student_feesreceipt.getForm().findField('student_hidden').getValue();
			var batch_idhidden=student_feesreceipt.getForm().findField('batch_idhidden').getValue();
			var monthname=student_feesreceipt.getForm().findField('monthname').getValue();	
			
			var year=student_feesreceipt.getForm().findField('year').getValue();
			var belowper=student_feesreceipt.getForm().findField('belowper').getValue();
			
			
			var branch_disp=student_feesreceipt.getForm().findField('branch_disp').getValue();
			var year_disp=student_feesreceipt.getForm().findField('year_disp').getValue();
			var branchyear_disp=student_feesreceipt.getForm().findField('branchyear_disp').getValue();
			var semester_disp=student_feesreceipt.getForm().findField('semester_disp').getValue();
			var month_disp=student_feesreceipt.getForm().findField('month_disp').getValue();
			var batch_disp=student_feesreceipt.getForm().findField('batch_disp').getValue();
			
			
var redirect = 'report-present-notice-result1.php?branch_hidden='+branch_hidden + '&semester_hidden='+semester_hidden + 
			 '&year_hidden='+year_hidden + '&branchyear_hidden='+branchyear_hidden + '&student_hidden='+student_hidden + 
			'&batch_idhidden='+batch_idhidden + '&monthname='+monthname +
			+ '&branch_disp='+branch_disp +'&year_disp='+year_disp + '&branchyear_disp='+branchyear_disp +
'&semester_disp='+semester_disp + '&month_disp='+month_disp +'&batch_disp='+batch_disp +
			'&belowper='+belowper; 
							window.location = redirect;
				
							}
						},
				  {
							text: 'Reset', iconCls: 'icon-reset',
							handler: function () {   
			                student_feesreceipt.getForm().reset();
							Ext.getCmp('batch_id').setValue(0);
							Ext.getCmp('batch_id').setRawValue('All');
							Ext.getCmp('branch_name').focus(true,500);
								
		               }
			        },
				  {
		   		           text: 'Close',iconCls: 'icon-close',
					       handler: function () {    
						   FeesReceiptReportWindow.close();
						
				          }
                       }
				 ]
    });
	 var varWidth =  (screen.width - FeesReceiptReportWindow.width)/2;
FeesReceiptReportWindow.setPosition(varWidth,((screen.height/4)-85));
FeesReceiptReportWindow.show();
Ext.getCmp('batch_id').setValue(0);
	Ext.getCmp('batch_id').setRawValue('All');
Ext.getCmp('branch_name').focus(true,1000);

Ext.getCmp('month_disp').setValue(Ext.getCmp('monthid').getRawValue());
});
</script>
<div id="abcd" align="center"></div>
</div>
<?php require "_footer.php";?>