Ext.define('TradePortal.store.SendEmail', {
    extend: 'Ext.data.Store',
    model: 'TradePortal.model.Valid',
    storeId: 'SendEmail',
    proxy: {
        type: 'jsonajax',
        url: BASE_URL + '/fluid/FluidAppServerProxy?ipApi=presenter&ipService=Frameworks.Interfaces.Mobile.TradePortal&ipFunction=emailTransactions'
    },
    listeners: {
        load: {
            fn: function (store, records, options) {
                if (store.data.items.length > 0) {
                    Ext.getCmp('emailinvoice_window').setLoading(false);
                    if (!records[0].data.errorTable) {
                        Ext.getCmp('emailinvoice_window').close();
                        Ext.Msg.alert('Email Invoices', 'Your invoice sent request has been queued and will be emailed to the specified recipients when generated', Ext.emptyFn);
                    } else {
                        Ext.Msg.alert('Alert', records[0].data.errorTable[0].msg, Ext.emptyFn);
                    }
                }

            }
        }
    }
});
