 // vim: sw=4:ts=4:nu:nospell:fdc=4
 /*global Ext, EQP */
 /**
 * Componente de �rea de administra��o de grupos
 *
 * @author Ot�vio Augusto
 * @copyright (c) 2009, by Ot�vio Augusto
 * @company Net On - Solu��es Tecnol�gicas
 * @date 7 de Setembro 2009
 *
 */

//Define o namespace
Ext.ns('Financeiro');

Financeiro.Fluxo = Ext.extend(App.Module,{
	
	title: 'Fluxo de Caixa',	
	id: 'financeiro-fluxo',	
	bodyBorder: false,
	layout: 'fit',
	iconCls: 'app-financial-16',
	moduleAction: 'orcamento_action/',
	
	/**
	 * Inicializa o componente
	 */
	initComponent: function(){		
		//Chama o initComponent da super classe
		Financeiro.Fluxo.superclass.initComponent.apply(this, arguments);
	},//end of initComponent
		
	/**
	 * Cria o DataGrid de visualiza��o de Grupos
	 */
	createGrid : function(){
				
		//Cria o DataStore,
		this.store = new Ext.data.JsonStore({                    
                    proxy: new Ext.data.HttpProxy({
                            url: App.sysURL + this.moduleAction + 'findAll/',
                            method: 'POST'
                    }),
		    root: 'results',
		    idProperty: 'id',  
		    totalProperty: 'total',
		    fields: ['descricao','id']
		});
		
		var panel = {
			xtype: 'tabpanel',
			id: this.id + '-grid',
			activeTab: 0,
                        layoutConfig:{
                              deferredRender:false,
                              layoutOnCardChange: true
                        },
			items:[
			       {
			    	   xtype: 'fluxo-grid-pay'
			       },
			       {
			    	   xtype: 'fluxo-grid-receive'
			       },
			       {
			    	   xtype: 'fluxo-grid-payed',
			    	   iconCls: 'tab-selected'
			       },
			       {
			    	   xtype: 'fluxo-grid-received',
			    	   iconCls: 'tab-selected'			    	  
			       },
			       {
			    	   xtype: 'fluxo-consolidacao'
			       }			       
			       
			]
		};
		
		//Retorna o DataGrid criado
		return panel;
	},	
	
	/**
	 * Cria a janela e o formul�rio de edi��o de registro
	 */
	createForm : function(){
		this.window = new Ext.Window({
			title: 'Centro de Custo',
			iconCls: 'app-custo-16',
			layout: 'fit',
			width: 300,
			height: 150,
			closeAction: 'hide',
			defaultButton: 0,
			items:[
				this.form = new Ext.form.FormPanel({
					baseCls: 'x-plain',
					labelAlign:'top',
					bodyStyle: 'padding:8px',
					items:[
						{
							xtype: 'hidden',
							name: 'id'
						},
						{
							xtype: 'textfield',
							fieldLabel: 'Centro de custo',
							allowBlank: false,
							name: 'descricao',
							anchor: '98%'
						}
					]
				})
			],
			buttons:[
				{
					text:'<b>Salvar</b>',
					id: this.id + '-save-btn',
					scope: this
				},
				{
					text: 'Cancelar',
					scope: this,
					handler: this.cancel
				}
			]
		});
	}
});

//Registra o novo componente
Ext.reg('financeiro-fluxo',Financeiro.Fluxo);
