Ext.define('TradePortal.store.getPriceBookInfo', {
    extend: 'Ext.data.Store',
    model: 'TradePortal.model.getPriceBookInfo',
    storeId: 'getPriceBookInfo',
    proxy : {
        type : 'jsonajax',
        url: BASE_URL  + '/fluid/FluidAppServerProxy?ipApi=presenter&ipService=Frameworks.Interfaces.Mobile.TradePortal&ipFunction=getPriceBookInfo',
        reader : {
            type : 'json',
            root : 'dataset.PriceBook'
        }
    },
    listeners: {
        load: {
            fn: function (store, records, success) {
                if (store.data.length > 0) {
                    Ext.getCmp('pricebook_panel').down('form').getForm().loadRecord(records[0]);
                    Ext.getCmp('deliveryFormat').setValue(Ext.getStore('priceBookFormat').getById(records[0].get('deliveryFormat')).get("name"));
                    Ext.getCmp('typePricebook').setValue(Ext.getStore('priceBookType').getById(records[0].get('typePricebook')).get("name"));
                    Ext.getCmp('frequencyPricebook').setValue(Ext.getStore('priceBookFrequency').getById(records[0].get('frequencyPricebook')).get("name"));
                }
            }
        }
    }
});
