// <#-- Part Store -->
Ext.define('App.store.CustomerStore', {
	extend: 'Ext.data.Store',
	constructor: function(cfg) {
		var me = this;
		cfg = cfg || {};
		me.callParent([Ext.apply({
			proxy: {
				type: 'ajax',
				url: App.url('/customer/list.json'),
				extraParams: cfg.extraParams || {},
				reader: {
					type: 'json',
					root: 'records',
					idProperty: 'id'
				}
			},
			fields: [
				{
					name: 'id',
					type: 'int',
					useNull: true
				},
				{
					name: 'surname',
					type: 'string'
				},
				{
					name: 'firstName',
					type: 'string'
				},
				{
					name: 'nameCh',
					type: 'string'
				},
				{
					name: 'customerName',
					type: 'string'
				},
				{
					name: 'phone1',
					type: 'string'
				},
				{
					name: 'phone2',
					type: 'string'
				},
				{
					name: 'companyPhone',
					type: 'string'
				},
				{
					name: 'companyEmail',
					type: 'string'
				},
				{
					name: 'companyAddress',
					type: 'string'
				},
				{
					name: 'email',
					type: 'string'
				},
				{
					name: 'address',
					type: 'string'
				},
				{
					name: 'remarks',
					type: 'string'
				},
				{
					name: 'ref',
					type: 'int'
				},
				{
					name: 'isBalance',
					type: 'boolean'
				},
				{
					name: 'onHandOrderNum',
					type: 'int'
				},
				{
					name: 'lastMeetingDate',
					type: 'date',
					dateFormat: 'time'
				},
				{
					name: 'nextMeetingDate',
					type: 'date',
					dateFormat: 'time',
				},
			],
		},
		cfg)]);
	}
});

Ext.define('App.store.CustomerComboStore', {
	extend: 'Ext.data.Store',
	autoLoad: true,
	constructor: function(cfg) {
		var me = this;
		cfg = cfg || {};
		me.callParent([Ext.apply({
			proxy: {
				type: 'ajax',
				url: App.url('/customer/combo.json'),
				extraParams: cfg.extraParams || {},
				reader: {
					type: 'json',
					root: 'records',
					idProperty: 'id'
				}
			},
			fields: [
				{
					name: 'id',
					type: 'int',
					useNull: true
				},
				{
					name: 'customerName',
					type: 'string'
				},
				{
					name: 'phone',
					type: 'string',
					convert: function(value, record){
						if(value){
							return " - "+value;
						}
						return "";
					}
				},
			],
		},
		cfg)]);
	}
});

