                                                                                                                                                                                                                               
var BatchStore = new Ext.data.JsonStore({
    url: 'data/get-student-scholarship.php',
    root: 'data',
    remoteSort: true,
    fields: [{
        name: 'batch_id',
        type: 'int'
    }, {
        name: 'scholarship_name',
        type: 'string'
    }],
    autoLoad: true
});

var AddscholarshipForm = new Ext.FormPanel({
    id: 'AddscholarshipForm',
    name: 'AddscholarshipForm',
    layout: 'form',
    labelWidth: 80,
    url: 'save-scholarship.php',
    method: 'post',
    frame: true,
    items: [{
        xtype: 'textfield',
        fieldLabel: 'Scholarship Name ',
        id: 'scholarship_name',
        name: 'scholarship_name',
        width: 175,
        tabIndex: 1,
        allowBlank: false
    }, {
        xtype: 'textfield',
        labelSeparator: '',
        fieldLabel: 'Financial Year ',
        id: 'financial_year',
        name: 'financial_year',
        width: 175,
        tabIndex: 2,
        allowBlank: true
    },
	{
        xtype: 'textfield',
        fieldLabel: 'Educational Year ',
        id: 'educational_year',
        name: 'educational_year',
        width: 175,
        tabIndex: 2,
        allowBlank: true
    }, 
	{
        xtype: 'datefield',
        fieldLabel: 'Formfill Date ',
        id: 'formfill_date',
        name: 'formfill_date',
        width: 175,
        tabIndex: 2,
        allowBlank: true
    },
	{
        xtype: 'datefield',
        fieldLabel: 'Scholarship Approve Date',
        id: 'scholarshipaprove_date',
        name: 'scholarshipaprove_date',
        width: 175,
        tabIndex: 2,
        allowBlank: true
    },
	{
        xtype: 'datefield',
        fieldLabel: 'Scholarship Recive Date ',
        id: 'schiarshiprecive_date',
        name: 'schiarshiprecive_date',
        width: 175,
        tabIndex: 2,
        allowBlank: true
    },
	{
        xtype: 'textfield',
        fieldLabel: 'Scholarship Recive Price ',
        id: 'schiarshiprecive_price',
        name: 'schiarshiprecive_price',
        width: 175,
        tabIndex: 2,
        allowBlank: true
    },
	{
        xtype: 'datefield',
        fieldLabel: 'College Recive Date ',
        id: 'collegerecive_date',
        name: 'collegerecive_date',
        width: 175,
        tabIndex: 2,
        allowBlank: true
    },
	{
        xtype: 'textfield',
        fieldLabel: 'College Recive Price ',
        id: 'collegerecive_price',
        name: 'collegerecive_price',
        width: 175,
        tabIndex: 2,
        allowBlank: true
    }, ]
});

var AddScholarshipWindow = new Ext.Window({
    title: 'Add New scholarship',
    autoHeight: true,
    width: 400,
    border: false,
    modal: true,
    closeAction: 'hide',
    collapsible: true,
    items: AddscholarshipForm,
    buttonAlign: 'center',
    buttons: [{
        text: 'Save',
        iconCls: 'icon-save',
        tabIndex: 2,
        name: 'btnSave',
        id: 'btnSave',
        handler: function () {
            AddscholarshipForm.getForm().submit({
                waitMsg: 'Saving...',
                success: function () {
                    BatchStore.load();
                    AddscholarshipForm.getForm().reset();
                    Ext.getCmp('scholarship_name').focus(true, 500);
                },
                failure: function () {
                    Ext.MessageBox.show({
                        title: 'Error',
                        msg: 'Please fill complete form.',
                        buttons: Ext.MessageBox.OK,
                        icon: Ext.MessageBox.ERROR
                    });
                }
            });
        }
    }, {
        text: 'Reset',
        iconCls: 'icon-reset',
        name: 'btnReset',
        tabIndex: 4,
        handler: function () {
            AddscholarshipForm.getForm().reset();
            Ext.getCmp('btnDel').disable();
            Ext.getCmp('scholarship_name').focus(true, 500);
        }
    }, {
        text: 'Close',
        tabIndex: 5,
        iconCls: 'icon-close',
        handler: function () {
            AddScholarshipWindow.hide();
        }
    }]
});

var varWidth = (screen.width - AddScholarshipWindow.width) / 2;
AddScholarshipWindow.setPosition(varWidth, ((screen.height / 4) - 60));

// Show the window
AddScholarshipWindow.show();
