MeetingTypeCombo = {
    TYPE_COMMISSION: 0, // Commission
    TYPE_FITTING: 1, // Fitting
    TYPE_PICKUP: 2, // Pick Up
    TYPE_NEW: 3 // New 
};

Ext.apply(MeetingTypeCombo, {
    convertToString: function(value) {
        switch (parseInt(value)) {
            case this.TYPE_COMMISSION:
                return App.localeRes('Commission');
            case this.TYPE_FITTING:
                return App.localeRes('Fitting');
            case this.TYPE_PICKUP:
                return App.localeRes('Pick Up');
            case this.TYPE_NEW:
                return App.localeRes('New');
        }
        return;
    }
});

Ext.apply(MeetingTypeCombo, {
    color: function(value) {
        switch (parseInt(value)) {
            case this.TYPE_COMMISSION:
                return '#a55ec7';
            case this.TYPE_FITTING:
                return '#FB6E52';
            case this.TYPE_PICKUP:
                return '#48CFAE';
            case this.TYPE_NEW:
                return '#ff8e01';
        }
        return;
    }
});

Ext.apply(MeetingTypeCombo, {
    colorType: function(value) {
        switch (parseInt(value)) {
            case this.TYPE_COMMISSION:
                return '<b><span style="color:' + this.color(value) + '">C</span></b>';
            case this.TYPE_FITTING:
                return '<b><span style="color:' + this.color(value) + '">F</span></b>';
            case this.TYPE_PICKUP:
                return '<b><span style="color:' + this.color(value) + '">P</span></b>';
            case this.TYPE_NEW:
                return '<b><span style="color:' + this.color(value) + '">N</span></b>';
        }
        return;
    }
});

//Meeting Type Combo
Ext.define('App.view.MeetingTypeCombo', {
    extend: 'Ext.form.field.ComboBox',
    alias: 'widget.meetingTypeCombo',

    fieldLabel: App.localeRes('Type'),
    name: 'type',
    displayField: 'name',
    valueField: 'value',
    editable: false,
    value: 0,
    tpl: '<tpl for="."><div class="x-boundlist-item">{name}</div></tpl>',

    initComponent: function() {
        var me = this;

        if (!me.store)
            me.store = Ext.create('Ext.data.Store', {
                fields: ['value', 'name'],
                data: [
                    {
                        value: MeetingTypeCombo.TYPE_FITTING,
                        name: MeetingTypeCombo.convertToString(MeetingTypeCombo.TYPE_FITTING)
                    },
                    {
                        value: MeetingTypeCombo.TYPE_PICKUP,
                        name: MeetingTypeCombo.convertToString(MeetingTypeCombo.TYPE_PICKUP)
                    },
                    {
                        value: MeetingTypeCombo.TYPE_NEW,
                        name: MeetingTypeCombo.convertToString(MeetingTypeCombo.TYPE_NEW)
                    },
                    {
                        value: MeetingTypeCombo.TYPE_COMMISSION,
                        name: MeetingTypeCombo.convertToString(MeetingTypeCombo.TYPE_COMMISSION)
                    },
                ]
            });

        me.callParent();
    }
});
