Ext.define('App.store.WorkshopStore', {
    extend: 'Ext.data.Store',

    constructor: function(cfg) {
        var me = this;
        cfg = cfg || {};
        me.callParent([Ext.apply({
            proxy: {
                type: 'ajax',
                url: App.url('/order/list-for-workshop.json'),
                extraParams: cfg.extraParams || {},
                reader: {
                    type: 'json',
                    root: 'records',
                    idProperty: 'id'
                }
            },
            fields: [
				{
					name: 'id',
					type: 'int',
					useNull: true
				},
				{
					name: 'code',
					type: 'string'
				},
				{
					name: 'type',
					type: 'string'
				},
				{
					name: "orderNo",
					type: "string",
					convert: function(value, record) {
						return record.get("type")+record.get("code");
					}
				},
				{
					name: "ref",
					type: 'int'
				},
				{
					name: "refNo",
					type: 'string'
				},
				{
					name: "status",
					type: 'int'
				},
				{
					name: 'date',
					type: 'date'
				},
				{
					name: 'custId',
					type: 'int'
				},
				{
					name: 'customerName',
					type: 'string'
				},
				{
					name: 'workshopStatus',
					type: 'int'
				},
				{
					name: 'outDate',
					type: 'date',
				},
				{
					name: 'outRemark',
					type: 'string',
				},
				{
					name: 'complete',
					type: 'boolean',
				},
			],
        },
        cfg)]);
    }
});

Ext.define('App.store.WorkshopItemStore', {
	extend: 'Ext.data.Store',

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