// <#-- Price List Store -->
Ext.define('App.store.MaterialBandStore', {
	extend: 'Ext.data.Store',

	constructor: function(cfg) {
		var me = this;
		cfg = cfg || {};
		me.callParent([Ext.apply({
			proxy: {
				type: 'ajax',
				url: App.url('/common/material/band/list.json'),
				extraParams: cfg.extraParams || {},
				reader: {
					type: 'json',
					root: 'records',
					idProperty: 'id'
				}
			},
			fields: [
				{
					name:'name',
					type:'string'
				},
				{
					name:'fileId',
					type: 'int',
				},
				{
					name: 'expectedPriceFormula',
					type: 'string'
				}
				
			],
		},
		cfg)]);
	}
});

Ext.define('App.store.MaterialItemStore', {
	extend: 'Ext.data.Store',
	groupField: 'name',
	sorters: [{
        property: 'orderIdx',
        direction: 'ASC'
    },{
        property: 'id',
        direction: 'ASC'
    }],
	constructor: function(cfg) {
		var me = this;
		cfg = cfg || {};
		me.callParent([Ext.apply({
			proxy: {
				type: 'ajax',
				url: App.url('/common/material/item/list.json'),
				extraParams: cfg.extraParams || {},
				reader: {
					type: 'json',
					root: 'records',
					idProperty: 'id'
				}
			},
			fields: [
				{
					name: 'id',
					type: 'int',
				},
				{
					name: 'drag',
					type: 'string',
					defaultValue: "≡",
				},
				{
					name: 'orderIdx',
					type: 'int',
				},
				{
					name:'name',
					type:'string',
				},
				{
					name:'bandId',
					type: 'int',
				},
				{
					name: 'bunch',
					type: 'string'
				},
				{
					name: 'itemNo',
					type: 'string'
				},
				{
					name: 'cost',
					type: 'float'
				},
				{
					name: 'suitPrice',
					type: 'float'
				},
				{
					name: 'jacketPrice',
					type: 'float'
				},
				{
					name: 'overcoatPrice',
					type: 'float'
				},
				{
					name: 'pantsPrice',
					type: 'float'
				},
				{
					name: 'otherPrice',
					type: 'float'
				},
				{
					name: 'forSearch',
					type: 'string',
					convert: function(val, record){
						return record.get('bunch')+" "+record.get("name")+" "+record.get("fabricNum");
					}
				}
			],
		},
		cfg)]);
	}
});

