Ext.define('TradePortal.store.getProductDetails', {
    extend: 'Ext.data.Store',
    model: 'TradePortal.model.getProductDetails',
    storeId: 'getProductDetails',
    proxy: {
        type: 'jsonajax',
        url: BASE_URL + '/fluid/FluidAppServerProxy?ipApi=presenter&ipService=Frameworks.Interfaces.Mobile.TradePortal&ipFunction=getProductDetails',
        reader: {
            type: 'json',
            root: 'dataset.getProductDetails'
        }
    },
    listeners: {
        load: {
            fn: function (store, records, options) {
                if (Ext.getCmp('productuom_drill') != undefined) {
                    Ext.getCmp('productuom_drill').destroy();
                }
                var st2 = new Ext.data.SimpleStore({
                    fields: [
                        {name: 'UOM', type: 'string'}
                    ]
                });
                var data = [];
                var UList = records[0].data.UOMList.split('|');

                for (var i in UList) {
                    var uom = [UList[i]];
                    data.push(uom);
                }
                st2.loadData(data);
                if (Ext.getCmp('drilldownprod_panel') != undefined) {
                    if (Ext.getCmp('productuom_drill') == undefined) {
                        Ext.getCmp('drilldownprod_panel').items.items[0].items.items[1].items.items[1].items.insert(3, Ext.create('Ext.form.ComboBox', {
                            fieldLabel: '',
                            id: 'productuom_drill',
                            store: st2,
                            value: UList[0],
                            queryMode: 'local',
                            displayField: 'UOM',
                            valueField: 'UOM',
                            width: 60
                        }));
                        if (updateQty) {
                            Ext.getCmp('productquantity_drill').setValue(1);
                        }
                        updateQty = true;
                        Ext.getCmp('drilldownprod_panel').items.items[0].items.items[1].items.items[1].doLayout();
                        Ext.getStore('Cart').each(function (rec) {
                            if ((Ext.getCmp('productID_hidden_drill').getValue() == rec.data.productID) && Ext.getCmp('product_add_cart').hidden) {
                                Ext.getCmp('productuom_drill').disable();
                            }
                        });
                    }
                }
            }
        }

    }

});
