/**
* This file stores all common forms or functions to get forms.
*/
//generic email form with subject and body
Ext.ux.EmailForm = Ext.extend(Ext.form.FormPanel, {
    autoWidth: true,
    labelWidth: 70,
    border: true,
    frame: true,
    header: false,
    initComponent: function() {
        Ext.apply(this, {
                items:
                    [
                        new Ext.form.TextField(
                        {
                            fieldLabel:'Subject',
                            name:'email_title',
                            allowBlank:false,
                            width: 280
                        }),
                        new Ext.form.TextArea(
                        {
                            fieldLabel:'Message',
                            name:'email_body',
                            allowBlank:false,
                            width: 280,
                            height: 250

                        })
                    ]
        });
       Ext.ux.EmailForm.superclass.initComponent.apply(this, arguments);

    }
});
Ext.reg('email_form', Ext.ux.EmailForm);

Ext.ux.AddRepform = Ext.extend(Ext.form.FormPanel, {
    id: 'sales_rep_insert_form',
    labelWidth: 125,
    frame: true,
    autoScroll: true,
    initComponent: function() {
        Ext.apply(this, {
                items:
                    [
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*Username',
                            name:'username',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*Password',
                            name:'password',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*First Name',
                            name:'first_name',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*Last Name',
                            name:'last_name',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*Address 1',
                            name:'address1',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'Address 2',
                            name:'address2',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*City',
                            name:'city',
                            width: 250
                        }),
                        new Ext.ux.StateSelectBox(
                        {
                            fieldLabel:'*State',
                            name:'state',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*Zip Code',
                            name:'zip_code',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*Phone',
                            name:'phone',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'Fax',
                            name:'fax',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'*Email 1',
                            name:'email',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'Email 2',
                            name:'email2',
                            width: 250
                        }),
                        new Ext.form.TextField(
                        {
                            fieldLabel:'AIM',
                            name:'screen_name',
                            width: 250
                        }),
                        new Ext.form.ComboBox(
                        {
                            xtype: 'combo',
                            fieldLabel: 'Spring Break Week',
                            name: 'spring_break_week_id',
                            mode: 'local',
                            editable: false,
                            id: 'spring_break_select2',
                            triggerAction: 'all',
                            displayField: 'display',
                            valueField: 'id',
                            hiddenName: 'spring_break_date_id',
                            listClass: 'x-combo-list-small',
                            emptyText: 'Select a Spring Break Week',
                            store: new Ext.data.JsonStore({
                                url: '/index.php/sales_reps/get_spring_break_weeks',
                                root: 'data_set',
                                totalProperty: 'data_size',
                                fields: ['id', 'display'],
                                autoLoad: true
                            })
                        }),
                        new Ext.form.ComboBox(
                        {
                            xtype: 'combo',
                            mode: 'local',
                            editable: false,
                            triggerAction: 'all',
                            displayField: 'display',
                            valueField: 'value',
                            hiddenField: 'value',
                            allowBlank: true,
                            emptyText: 'Select Year',
                            store: new Ext.data.SimpleStore(
                            {
                                fields:
                                [
                                    'display',
                                    'value'
                                ],
                                data:
                                [
                                    ['2008', '2008'],
                                    ['2009', '2009'],
                                    ['2010', '2010'],
                                    ['2011', '2011'],
                                    ['2012', '2012'],
                                    ['2013', '2013'],
                                    ['2014', '2014'],
                                    ['2015', '2015']
                                ]
                            }),
                            fieldLabel: 'Grad Year',
                            hiddenName: 'class_year'
                        }),
                        new Ext.form.Hidden(
                        {
                            name: 'school_title'
                        }),
                        new Ext.ux.StateSelectBox(
                        {
                            name: 'school_state',
                            hiddenName: 'school_state',
                            fieldLabel: 'School\'s State',
                            listeners:
                            {
                                'select': function(selection)
                                {
                                    Ext.getCmp('rep_form_school_select').store.load({params: {state: selection.getValue()}});
                                }
                            }
                        }),
                        new Ext.ux.SchoolSelectBoxLocal(
                        {
                            id: 'rep_form_school_select',
                            store: new Ext.data.Store({
                                proxy: new Ext.data.HttpProxy({
                                    url: '/index.php/schools/school_list_data',
                                    method: 'POST'
                                }),
                                baseParams:
                                {
                                    'limit': 20
                                },
                                reader: new Ext.data.JsonReader({
                                    root: 'school_list',
                                    totalProperty: 'data_size',
                                    id: 'value'
                                },
                                [
                                    {name: 'value', type: 'string'},
                                    {name: 'display', type: 'string'}
                                ]),
                                sortInfo: {field: 'display', direction: 'ASC'}
                            }),
                            fieldLabel: '*School',
                            hiddenName: 'school_id',
                            hiddenField: 'display'
                        })
                    ]
        });
       Ext.ux.EmailForm.superclass.initComponent.apply(this, arguments);

    }
});

Ext.reg('add_rep_form', Ext.ux.AddRepform);
