                                                                                                                                                                                                                               
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.student.semester
});

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

var categorystore = new Ext.data.ArrayStore({
	fields: ['category'],
	data: [['GENERAL'], ['OBC'], ['SC'], ['ST'], ['MINORITY'], ['EWS']]
});


var corestore = new Ext.data.ArrayStore({
	fields: ['ba_core'],
	data: [['Sanskrit'], ['English'], ['Gujarati'], ['Psychology'], ['History'], ['Economics']]
});

var el1store = new Ext.data.ArrayStore({
	fields: ['ba_el1'],
	data: [['Sanskrit'], ['Gujarati'], ['Psychology'], ['History'], ['Economics'], ['Hindi']]
});

var el2store = new Ext.data.ArrayStore({
	fields: ['ba_el2'],
	data: [['Sanskrit'], ['Gujarati'], ['Psychology'], ['History'], ['Economics']]
});

var bscstore = new Ext.data.ArrayStore({
	fields: ['bsc_group'],
	data: [['Physics/Chemistry/Maths'], ['Physics/Chemistry/Zoology'], ['Chemistry/Botony/Micro'], ['Chemistry/Zoology/Micro'], ['Chemistry/Physics'], ['Micro/Physics'], ['Chemistry'], ['Micro']]
});

var mscstore = new Ext.data.ArrayStore({
	fields: ['msc_group'],
	data: [['Orgenic Chemistry']]
});

var genderstore = new Ext.data.ArrayStore({
	fields: ['gender'],
	data: [['Male'], ['Female']]
});

var branch_search = new Ext.form.ComboBox({
	name: 'branch_id1',
	hiddenName: 'branch_hidden1',
	id: 'branch_id1',
	fieldLabel: 'Course<span class="comp">*</span> ',
	forceSelection: true,
	tabIndex: 1,
	displayField: 'branch_name',
	valueField: 'branch_id'
	, triggerAction: 'all'
	, mode: 'local'
	, store: branchstore
	, width: 250
	, selectOnFocus: true
	, listeners: {
		'select': function (cmb, rec, idx) {
			semesterstore.filter('branch_id', cmb.getValue(), false, true, true);
		}
	}
});

var semester_id1 = new Ext.form.ComboBox({
	name: 'semester_id1',
	hiddenName: 'semester_hidden1',
	id: 'semester_id1',
	fieldLabel: 'Semester ',
	forceSelection: true,
	tabIndex: 2,
	displayField: 'semester_name',
	valueField: 'semester_id'
	, triggerAction: 'all'
	, mode: 'local'
	, lastQuery: ''
	, store: semesterstore
	, width: 190
	, selectOnFocus: true
	, listeners: {
		'select': function (cmb, rec, idx) {
			var branch1 = Ext.getCmp('branch_id1').getValue();
		}
	}
});

var grno_search = new Ext.form.NumberField({
	name: 'enrollment_no',
	id: 'enrollment_no',
	fieldLabel: 'Enrollment No. ',
	allowNegative: false,
	tabIndex: 3,
	width: 190,
	allowDecimals: false,
	autoCreate: { tag: 'input', type: 'text', maxlength: '10' }
});

var surname_search = new Ext.form.TextField({
	id: 'student_surname',
	name: 'student_surname',
	width: 140,
	tabIndex: 4,
	emptyText: 'Sur-Name',
	fieldLabel: 'Name '
});

var firstname_search = new Ext.form.TextField({
	id: 'student_firstname',
	name: 'student_firstname',
	width: 140,
	tabIndex: 5,
	emptyText: 'First-Name'
});

var lastname_search = new Ext.form.TextField({
	id: 'student_lastname',
	name: 'student_lastname',
	width: 140,
	tabIndex: 6,
	emptyText: 'Last-Name'
});
var student_gender = new Ext.form.ComboBox({
	xtype: 'combo',
	name: 'student_gender',
	id: 'student_gender',
	hiddenName: 'gender_hidden',
	fieldLabel: 'Gender<span class="comp">*</span> ',
	forceSelection: true,
	displayField: 'gender',
	valueField: 'gender',
	allowBlank: false
	, triggerAction: 'all'
	, mode: 'local'
	, store: genderstore
	, width: 190
	, selectOnFocus: true,
	tabIndex: 7
});

var student_city = new Ext.form.TextField({
	id: 'student_city',
	name: 'student_city',
	width: 190,
	fieldLabel: 'City ',
	tabIndex: 8,
	emptyText: 'City'
});
var student_mobilestudents = new Ext.form.NumberField({
	id: 'student_mobilestudents',
	name: 'student_mobilestudents',
	width: 190,
	fieldLabel: 'Mobile',
	minLength: 10,
	tabIndex: 9,
	emptyText: 'Mobile'
});
var category = new Ext.form.ComboBox({
	xtype: 'combo',
	name: 'student_category',
	id: 'student_category',
	hiddenName: 'category_hidden',
	fieldLabel: 'Category ',
	forceSelection: true,
	displayField: 'category',
	valueField: 'category',
	width: 190,
	allowBlank: false,
	triggerAction: 'all',
	mode: 'local',
	store: categorystore,
	tabIndex: 11
});
var ID = new Ext.form.TextField({
	id: 'ID',
	name: 'ID',
	width: 90,
	value: 0,
	hidden: true,
	tabIndex: 7,

});
var computer_fee = new Ext.form.Checkbox({
	id: 'computer_fee',
	name: 'computer_fee',
	width: 90,
	fieldLabel: 'Computer Fee ',
	tabIndex: 8,

});

var name_search = {
	layout: 'column',
	items: [{
		columnWidth: 0.38,
		layout: 'form',
		items: [surname_search]
	}, {
		columnWidth: 0.24,
		layout: 'form',
		labelWidth: 1,
		items: [firstname_search]
	}, {
		columnWidth: 0.3,
		layout: 'form',
		labelWidth: 1,
		items: [lastname_search]
	}]
}

var searchitems = {
	xtype: 'fieldset',
	labelWidth: 90,
	border: false,
	defaults: { width: 260 },
	autoHeight: true,
	width: 650,
	layout: 'column',
	items: [
		{ columnWidth: 1, layout: 'form', items: [branch_search] },
		{ columnWidth: 1, layout: 'form', items: [semester_id1] },
		{ columnWidth: 1, layout: 'form', items: [ID] },
		{ columnWidth: 1, layout: 'form', items: [grno_search] },
		{ columnWidth: 1, layout: 'form', items: [name_search] },
		{ columnWidth: 1, layout: 'form', items: [student_gender] },
		{ columnWidth: 1, layout: 'form', items: [student_city] },
		{ columnWidth: 1, layout: 'form', items: [student_mobilestudents] },
		{ columnWidth: 1, layout: 'form', items: [category] },

		{
			columnWidth: 1, layout: 'form',

			items: [
				{
					
					layout: 'column',
					items: [{
						columnWidth: 0.32,
						labelWidth: 90,
						layout: 'form',
						items: [{ height: 1 },
						{
							xtype: 'combo',
							name: 'ba_core',
							id: 'ba_core',
							hiddenName: 'ba_hiddencore',
							fieldLabel: 'Core Subject ',
							forceSelection: true,
							displayField: 'ba_core',
							valueField: 'ba_core',
							width: 100,
							allowBlank: true,
							triggerAction: 'all',
							mode: 'local',
							store: corestore,
							tabIndex: 9
						}]
					},
					{
						columnWidth: 0.27,
						labelWidth: 60,
						layout: 'form',
						items: [{ height: 1 },
						{
							xtype: 'combo',
							name: 'ba_el1',
							id: 'ba_el1',
							hiddenName: 'ba_hiddenel1',
							fieldLabel: 'Elective1 ',
							forceSelection: true,
							displayField: 'ba_el1',
							valueField: 'ba_el1',
							width: 100,
							allowBlank: true,
							triggerAction: 'all',
							mode: 'local',
							store: el1store,
							tabIndex: 10
						},
						]
					},
					{
						columnWidth: 0.4,
						labelWidth: 60,
						layout: 'form',
						items: [{ height: 1 },
						{
							xtype: 'combo',
							name: 'ba_el2',
							id: 'ba_el2',
							hiddenName: 'ba_hiddenel2',
							fieldLabel: 'Elective2 ',
							forceSelection: true,
							displayField: 'ba_el2',
							valueField: 'ba_el2',
							width: 88,
							allowBlank: true,
							triggerAction: 'all',
							mode: 'local',
							store: el2store,
							tabIndex: 11
						},
						]
					},
					]
				},
				{
					columnWidth: 1,
					layout: 'column',
					items: [
						{
							columnWidth: 0.80,
							labelWidth: 90,
							layout: 'form',
							items: [{ height: 10 }, {
								xtype: 'combo',
								name: 'bsc_group',
								id: 'bsc_group',
								hiddenName: 'bsc_hiddengroup',
								fieldLabel: 'BSC Group ',
								forceSelection: true,
								displayField: 'bsc_group',
								valueField: 'bsc_group',
								width: 190,
								allowBlank: true,
								triggerAction: 'all',
								mode: 'local',
								store: bscstore,
								tabIndex: 12
							}]
						},
					]
				},
				{
					columnWidth: 1,
					layout: 'column',
					items: [
						{
							columnWidth: 0.80,
							labelWidth: 90,
							layout: 'form',
							items: [{ height: 10 }, {
								xtype: 'combo',
								name: 'msc_group',
								id: 'msc_group',
								hiddenName: 'msc_hiddengroup',
								fieldLabel: 'MSC Group ',
								forceSelection: true,
								displayField: 'msc_group',
								valueField: 'msc_group',
								width: 190,
								allowBlank: true,
								triggerAction: 'all',
								mode: 'local',
								store: mscstore,
								tabIndex: 13
							}]
						},
					]
				},
			]
		},
		{
			columnWidth: 0.50,
			layout: 'form',
			items: [{
				buttons: [{
					text: 'Save',
					tabIndex: 8,
					style: { margin: '0px 0px 0px 0px', padding: '0px 0px 0px 10px' },
					handler: function () {
						searchform.getForm().submit({
							waitMsg: 'Saving...',
							success: function () {
								branch_id = searchform.getForm().findField('branch_id1').getValue();
								branch_name = searchform.getForm().findField('branch_hidden1').getRawValue();
								semester_name = searchform.getForm().findField('semester_hidden1').getRawValue();
								enrollment_no = searchform.getForm().findField('enrollment_no').getRawValue();
								surname = searchform.getForm().findField('student_surname').getRawValue();

								set_grno(branch_name, semester_name, division_name, enrollment_no, surname);
							},
							failure: function () {
								Ext.MessageBox.show({
									title: 'Error',
									msg: 'Please fill complete form.',
									buttons: Ext.MessageBox.OK,
									icon: Ext.MessageBox.ERROR
								});
							}
						});

					}
				}, {
					text: 'Reset',
					id: 'reset1',
					tabIndex: 9,
					handler: function () {
						reset_thisform();
						Ext.getCmp('batch_id').setValue(0);
						Ext.getCmp('batch_id').setRawValue('All');
					}
				}]
			}]
		}
	]
}
var searchform = new Ext.FormPanel({
	id: 'searchform',
	frame: true,
	url: 'save-temp-gr.php',
	labelAlign: 'left',
	bodyStyle: 'padding:5px',
	draggable: false,
	layout: 'column',
	items: [searchitems]
});

function reset_thisform() {
	searchform.getForm().reset();
	Ext.getCmp('fees_type').focus(true, 500);
}

var win_search = new Ext.Window({
	title:'New Gr Entry',
	height: 500,
	width: 630,
	layout: 'fit',
	border: false,
	modal: true,
	closeAction: 'hide',
	autoDestroy: true,
	collapsible: true,
	items: searchform
})


var varWidth = (screen.width - win_search.width) / 2;
win_search.setPosition(varWidth, ((screen.height / 4) - 160));
get_ReceiptNo();




function set_grno(branch_name, semester_name, enrollment_no, surname) {
	win_search.show();
	//var branch_name = Ext.getCmp('branch_name').setRawValue(branch_name);
	//var semester_name = Ext.getCmp('semester_name').setRawValue(semester_name);
	//var student_gturegno = Ext.getCmp('student_gturegno').setValue(enrollment_no);
	//var student_name = Ext.getCmp('student_name').setRawValue(surname);	
	get_ReceiptNo();
	reset_thisform();
	win_search.hide();
}

function general_search() {
	reset_thisform();
	win_search.show();
	Ext.getCmp('branch_id1').focus(true, 500);
}

function get_ReceiptNo() {
	Ext.Ajax.request({
		loadMask: true,
		sync: true,
		url: 'data/getGrno.php',
		success: function (resp) {
			var value = Ext.decode(resp.responseText).count;
			if (value == ',') {
				receiveform.getForm().reset();
				feeshead_grid_store.removeAll();
				receivedfees_grid_store.removeAll();
				Ext.getCmp('branch_name').focus(true, 500);
				studentstore.removeAll();
				Ext.MessageBox.show({
					title: 'Error',
					msg: 'Recipt No Not Found for this number.',
					buttons: Ext.MessageBox.OK,
					icon: Ext.MessageBox.ERROR
				});
			} else {
				var arr_data = new Array();
				arr_data = value.split(",");
				Ext.getCmp('enrollment_no').setValue(arr_data[0]);

			}
		}
	});
}

function OpenStudentSearch() {
	win_search.show();
	Ext.getCmp('branch_id1').focus(true, 500);

}
function OpenStudentSearch1() {
	win_search.hide();
	Ext.getCmp('branch_id1').focus(true, 500);

}