<?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">
Ext.onReady(function(){
	Ext.QuickTips.init();
	
	labelArray = [
			['Course '],
			['Batch Year '],
			['Course Year '],
			['Semester '],
			['Student Name '],
			
		];
	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
		});
	
								   
	studentstore = new Ext.data.JsonStore({
		url:'data/getstudent-feesrecive1.php',
		root: 'data',
		totalProperty: 'total',
		fields: [{
			name: 'student_id',
			type:'int'
		},{
			name: 'student_name',
			type: 'string'
		},{
			name: 'student_gturegno',
			type: 'int'
		}] 
	});
	
	
	
	
	var cancel = new Ext.form.Radio({	
		hideLabel: true,
		name: 'leave_type',
		id: 'cancel',
		inputValue: 'a',
		checked:true,
		boxLabel:'Alumni Student'
	});
	
	
	var student_gturegno = new Ext.form.NumberField({
		name: 'student_gturegno',
		id:'student_gturegno',
		fieldLabel:'Enrollment No:<span class="comp"></span>',
		labelSeparator:'',
		allowBlank:true,
		readOnly:true,
		width:100
	
	});
	
	
	var leave_date = new Ext.form.DateField({
		id: 'leave_date',
		fieldLabel:'Alumni Date',
		name: 'leave_date',
		allowBlank:false,
		vtype: 'daterange',
		maxValue:new Date(),
		value:new Date()
	});	
	
	var leave_reason = new Ext.form.TextArea({
		name: 'leave_reason',
		id:'leave_reason',
		fieldLabel:'Alumni Reason',
		width:200,
		allowBlank:true
	});
	
	var leave_comment = new Ext.form.TextArea({
		name: 'leave_comment',
		id:'leave_comment',
		fieldLabel:'Comment',
		width:200,
		allowBlank:true
	});
	
	var CancelForm = new Ext.FormPanel({	
		id: 'CancelForm',
		frame: true,
		url: 'save-alumini.php',
    	labelAlign: 'left',
		labelWidth:90,
  		bodyStyle:'padding:5px',
   		items: [{
			columnWidth:1,
			layout:'column',
			items:[{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:1,
				items:[cancel]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:1,
				items:[{height:15}]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:1,
				items:[{
						xtype: 'combo',
						name: 'branch_name',
						id: 'branch_name',
						hiddenName: 'branch_hidden',
						fieldLabel: labelArray[0],
						displayField: 'branch_name',
						valueField: 'branch_id',
						width: 200,
						triggerAction: 'all',
						mode: 'local',
						allowBlank: true,
						store: branchstore,
						listeners: {
							'select': function (cmb, rec, idx) {

								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: 200,
						allowBlank: true,
						store: batchyearstore,
						listeners: {
                                'select': function (cmb, rec, idx) {
                                    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: 200,
						allowBlank: true,
						store: yearstore,
						listeners: {
							'select': function (cmb, rec, idx) {
								if (Ext.getCmp('branch_name').getValue() != "") {
								    studentstore.load({ params: { 'branch_id': Ext.getCmp('branch_name').getValue(),'year_id': Ext.getCmp('year_name').getValue(), 'branchyear_id': Ext.getCmp('branchyear_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: 200,
						allowBlank: true,
						store: semesterstore,
						listeners: {
							'select': function (cmb, rec, idx) {
								if (Ext.getCmp('branch_name').getValue() != "") {
									studentstore.load({ params: { 'branch_id': Ext.getCmp('branch_name').getValue(),'year_id': Ext.getCmp('year_name').getValue(), 'semester_id': Ext.getCmp('semester_name').getValue() } });
                              
								} else {
									alert('Select Branch First')
									this.reset();
								}
							}
						}
					},{
						xtype: 'combo',
						name: 'student_id',
						id: 'student_id',
						hiddenName: 'student_hidden',
						fieldLabel: labelArray[4],
						displayField: 'student_name',
						valueField: 'student_id',
						width: 200,
						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();
                                    }
                                }
                            }
					}]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.62,
				items:[student_gturegno]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:1,
				labelWidth:90,
				items:[leave_date]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:1,
				items:[leave_reason]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:1,
				items:[leave_comment]
			}]
		}]
    });
	
	var SuspendWindow = new Ext.Window({
		title: 'Student Alumni',
		width:350,		
		height:460,	
		frame: true,
		border: false,
		modal:true,
		layout: 'fit',
		closeAction:'close',
		collapsible:true,
		items: CancelForm,
		buttons:[{
			text: 'Save', 
			name:'btnSave',
			iconCls:'icon-save',
			id:'btnSave',
			handler: function(){
				if(Ext.getCmp('cancel').getValue() == true){
					CancelForm.getForm().submit({
						waitMsg: 'Saving...',
						success: function () {	
							CancelForm.getForm().reset();	
							Ext.MessageBox.show({
								title: 'Message',
								msg: 'Data has been saved..',
								buttons: Ext.MessageBox.OK,
								icon:Ext.MessageBox.INFO
							});
						},
						failure: function () {
							Ext.MessageBox.show({
								title: 'Error',
								msg: 'Please fill up complete form.',
								buttons: Ext.MessageBox.OK,
								icon:Ext.MessageBox.ERROR
							});
						}
					});
				}
				else{
					Ext.MessageBox.show({
						title: 'Error',
						msg: 'Select cancel option.',
						buttons: Ext.MessageBox.OK,
						icon:Ext.MessageBox.ERROR
					});	
				}
			}	
		},{
			text: 'Reset', 
			name:'btnreset',
			iconCls:'icon-reset',
			id:'btnreset',
			handler: function (){
				CancelForm.getForm().reset();
				//if(flgAdd == "true"){
					Ext.getCmp('btnSave').enable();
				//}
				Ext.getCmp('branch_name').focus(true,1000);
			}
		},{
			text:'Close', 
			name:'btnclose',
			iconCls:'icon-close',
			id:'btnclose',
			handler: function (){
				SuspendWindow.close();
			}
		}]
	});
	
	var varWidth =  (screen.width - SuspendWindow.width)/2;
	SuspendWindow.setPosition(varWidth,((screen.height/4)-85));
	SuspendWindow.show();
	
	//if(flgAdd == "true"){
		Ext.getCmp('btnSave').enable();
	//} else{
		//Ext.getCmp('btnSave').disable();
	//}
	Ext.getCmp('branch_name').focus(true,1000);
});
</script>
<div id="abcd"></div>
</div>
<?php require "_footer.php";?>
