 // vim: sw=4:ts=4:nu:nospell:fdc=4
 /*global Ext, EQP */
 /**
 * Classe que define o painel de lista de pedido
 *
 * @author Otávio Augusto
 * @copyright (c) 2009, by Otávio Augusto
 * @company Net On - Soluções Tecnol�gicas
 * @date 10 de Setembro 2009
 *
 */

//Define o namespace
Ext.ns('Pedido.Pedido.Situacao');

//Cria a classe base a ser estendida
Pedido.Pedido.Situacao.Criado = Ext.extend(Ext.grid.GridPanel,{
		
	/**
	 * Inicializa o componente
	 */
	initComponent : function(){				
		//Cria a configuração personalizada
		config = {
                    xtype: 'editorgrid',
                    title: 'Pedidos Novos',
                    iconCls: 'pedido-novo',
                    store: this.store = new Ext.data.JsonStore({
                        proxy: new Ext.data.HttpProxy({
                                url: App.sysURL + 'pedido_action/findAllNovo/',
                                method: 'POST'
                        }),
                        root: 'results',
                        idProperty: 'id',
                        totalProperty: 'total',
                        fields: ['tipo','id','identificacao','observacao',{name: 'dt_pedido', type: 'date', dateFormat: 'Y-m-d'},'situacao','nome','justificativa']
                    }),                    
                    tbar: {
                        xtype: 'toolbar',
                        items:[
                            {
                                    text: 'Novo',
                                    iconCls: 'ui-add-icon',
                                    tooltip: 'Adicionar novo registro',
                                    handler: this.parent.createRecord,
                                    scope: this.parent

                            },
                            {
                                    text: 'Visualizar',
                                    iconCls: 'ui-view-icon',
                                    tooltip: 'Visualizar o pedido',
                                    handler: function(){
                                        this.parent.editRecord(this);
                                    },
                                    scope: this
                            }
			]
                        
                    },
                    bbar: {
                        xtype: 'paging',
                        store: this.store,       // grid and PagingToolbar using same store
                        displayInfo: true,
                        pageSize: App.pageSize,
                        prependButtons: true
                    },
                    columns:[
                            {id: 'dt_pedido',header:'Data do Pedido',dataIndex:'dt_pedido',width:80, renderer: Ext.util.Format.dateRenderer('d/m/Y')},
                            {id: 'tipo',header:'Tipo de solicita&ccedil;&atilde;o',dataIndex:'tipo',width:100, renderer: this.parent.renderTipo},
                            {id: 'identificacao',header:'Pedido',dataIndex:'identificacao',width:250},
                            {id: 'solicitante',header:'Solicitante',dataIndex:'nome',width:150}
                    ],
                    view : new Ext.grid.GridView({
                            forceFit: true
                    }),

                    listeners: {
                        scope: this,
                        'show' : function(){
                            this.store.load();
                        }
                    }

		};

                this.store.load();
		Ext.apply(this,config);							

		//Chama o initComponent da super classe
		Pedido.Pedido.Situacao.Autorizado.superclass.initComponent.apply(this, arguments);

		this.on('dblclick',function(){
                    this.parent.editRecord(this);
                }, this);

	}

});

//Registra o novo componente
Ext.reg('pedido-situacao-criado',Pedido.Pedido.Situacao.Criado);


//Cria a classe base a ser estendida
Pedido.Pedido.Situacao.Autorizado = Ext.extend(Ext.grid.GridPanel,{

	/**
	 * Inicializa o componente
	 */
	initComponent : function(){
		//Cria a configuração personalizada
		config = {
                    xtype: 'editorgrid',
                    iconCls: 'pedido-autorizado',
                    title: 'Pedidos Autorizados',
                    store: this.store = new Ext.data.JsonStore({
                        proxy: new Ext.data.HttpProxy({
                                url: App.sysURL + 'pedido_action/findAllAutorizado/',
                                method: 'POST'
                        }),
                        root: 'results',
                        idProperty: 'id',
                        totalProperty: 'total',
                        fields: ['tipo','id','identificacao','observacao',{name: 'dt_pedido', type: 'date', dateFormat: 'Y-m-d'},'situacao','nome','justificativa']
                    }),
                    tbar: {
                        xtype: 'toolbar',
                        items:[
                            {
                                    text: 'Visualizar',
                                    iconCls: 'ui-view-icon',
                                    tooltip: 'Visualizar o pedido',
                                    handler: function(){
                                        this.parent.editRecord(this);
                                    },
                                    scope: this
                            }
			]

                    },
                    bbar: {
                        xtype: 'paging',
                        store: this.store,       // grid and PagingToolbar using same store
                        displayInfo: true,
                        pageSize: App.pageSize,
                        prependButtons: true
                    },
                    columns:[
                            {id: 'dt_pedido',header:'Data do Pedido',dataIndex:'dt_pedido',width:80, renderer: Ext.util.Format.dateRenderer('d/m/Y')},
                            {id: 'tipo',header:'Tipo de solicita&ccedil;&atilde;o',dataIndex:'tipo',width:100, renderer: this.parent.renderTipo},
                            {id: 'identificacao',header:'Pedido',dataIndex:'identificacao',width:250},
                            {id: 'solicitante',header:'Solicitante',dataIndex:'nome',width:150}
                    ],
                    view : new Ext.grid.GridView({
                            forceFit: true
                    })

		};

		Ext.apply(this,config);
                this.store.load();
		//Chama o initComponent da super classe
		Pedido.Pedido.Situacao.Criado.superclass.initComponent.apply(this, arguments);

		this.on('dblclick',function(){
                    this.parent.editRecord(this);
                }, this);

	}

});

//Registra o novo componente
Ext.reg('pedido-situacao-autorizado',Pedido.Pedido.Situacao.Autorizado);

//Cria a classe base a ser estendida
Pedido.Pedido.Situacao.NaoAutorizado = Ext.extend(Ext.grid.GridPanel,{

	/**
	 * Inicializa o componente
	 */
	initComponent : function(){
		//Cria a configuração personalizada
		config = {
                    xtype: 'editorgrid',
                    iconCls: 'pedido-nao-autorizado',
                    title: 'Pedidos N&atilde;o Autorizados',
                    store: this.store = new Ext.data.JsonStore({
                        proxy: new Ext.data.HttpProxy({
                                url: App.sysURL + 'pedido_action/findAllNaoAutorizado/',
                                method: 'POST'
                        }),
                        root: 'results',
                        idProperty: 'id',
                        totalProperty: 'total',
                        fields: ['tipo','id','identificacao','observacao',{name: 'dt_pedido', type: 'date', dateFormat: 'Y-m-d'},'situacao','nome','justificativa']
                    }),
                    tbar: {
                        xtype: 'toolbar',
                        items:[
                            {
                                    text: 'Visualizar',
                                    iconCls: 'ui-view-icon',
                                    tooltip: 'Visualizar o pedido',
                                    handler: function(){
                                        this.parent.editRecord(this);
                                    },
                                    scope: this
                            }
			]

                    },
                    bbar: {
                        xtype: 'paging',
                        store: this.store,       // grid and PagingToolbar using same store
                        displayInfo: true,
                        pageSize: App.pageSize,
                        prependButtons: true
                    },
                    columns:[
                            {id: 'dt_pedido',header:'Data do Pedido',dataIndex:'dt_pedido',width:80, renderer: Ext.util.Format.dateRenderer('d/m/Y')},
                            {id: 'tipo',header:'Tipo de solicita&ccedil;&atilde;o',dataIndex:'tipo',width:100, renderer: this.parent.renderTipo},
                            {id: 'identificacao',header:'Pedido',dataIndex:'identificacao',width:250},
                            {id: 'solicitante',header:'Solicitante',dataIndex:'nome',width:150}
                    ],
                    view : new Ext.grid.GridView({
                            forceFit: true
                    })

		};

		Ext.apply(this,config);
                this.store.load();
                
		//Chama o initComponent da super classe
		Pedido.Pedido.Situacao.NaoAutorizado.superclass.initComponent.apply(this, arguments);

		this.on('dblclick',function(){
                    this.parent.editRecord(this);
                }, this);

	}

});

//Registra o novo componente
Ext.reg('pedido-situacao-nao-autorizado',Pedido.Pedido.Situacao.NaoAutorizado);

//Cria a classe base a ser estendida
Pedido.Pedido.Situacao.Entregue = Ext.extend(Ext.grid.GridPanel,{

	/**
	 * Inicializa o componente
	 */
	initComponent : function(){
		//Cria a configuração personalizada
		config = {
                    xtype: 'editorgrid',
                    title: 'Pedidos Conclu&iacute;dos',
                    iconCls: 'tab-selected',
                    store: this.store = new Ext.data.JsonStore({
                        proxy: new Ext.data.HttpProxy({
                                url: App.sysURL + 'pedido_action/findAllEntregue/',
                                method: 'POST'
                        }),
                        root: 'results',
                        idProperty: 'id',
                        totalProperty: 'total',
                        fields: ['tipo','id','identificacao','observacao',{name: 'dt_pedido', type: 'date', dateFormat: 'Y-m-d'},'situacao','nome','justificativa']
                    }),
                    tbar: {
                        xtype: 'toolbar',
                        items:[
                            {
                                    text: 'Visualizar',
                                    iconCls: 'ui-view-icon',
                                    tooltip: 'Visualizar o pedido',
                                    handler: function(){
                                        this.parent.editRecord(this);
                                    },
                                    scope: this
                            }
			]

                    },
                    bbar: {
                        xtype: 'paging',
                        store: this.store,       // grid and PagingToolbar using same store
                        displayInfo: true,
                        pageSize: App.pageSize,
                        prependButtons: true
                    },
                    columns:[
                            {id: 'dt_pedido',header:'Data do Pedido',dataIndex:'dt_pedido',width:80, renderer: Ext.util.Format.dateRenderer('d/m/Y')},
                            {id: 'tipo',header:'Tipo de solicita&ccedil;&atilde;o',dataIndex:'tipo',width:100, renderer: this.parent.renderTipo},
                            {id: 'identificacao',header:'Pedido',dataIndex:'identificacao',width:250},
                            {id: 'solicitante',header:'Solicitante',dataIndex:'nome',width:150}
                    ],
                    view : new Ext.grid.GridView({
                            forceFit: true
                    })

		};

		Ext.apply(this,config);
                this.store.load();
                
		//Chama o initComponent da super classe
		Pedido.Pedido.Situacao.Entregue.superclass.initComponent.apply(this, arguments);

		this.on('dblclick',function(){
                    this.parent.editRecord(this);
                }, this);

	}

});

//Registra o novo componente
Ext.reg('pedido-situacao-entregue',Pedido.Pedido.Situacao.Entregue);

