Ext.namespace("Pago");

Pago.Ingresar = function(){
	
	var el = Ext.DomHelper.append(document.body, {tag: "div"}, true);
	
	Pago.Ingresar.superclass.constructor.call(this, el, {
        modal: true,
		closable: false,
		collapsible: false,
		resizable: false,
        width: 320,
        height: 240,
		title: "Ingresar pago inscripción",
        center: {
            tabPosition: "top",
            alwaysShowTabs: true
        }
    });
	
	var panel = this.layout.add("center", new Ext.ContentPanel({
		autoCreate: true,
		fitContainer: true,
		fitToFrame: true,
		title: "Pago inscripción"
	}));
	
	var formulario = new Ext.form.Form({
		method: "GET",
		labelWidth: "auto",
		style: "padding:10px;",
		reader: new Ext.data.JsonReader({
			root: "resultado", 
			successProperty: "exito"
		}, [
			{name: "PAG_ID", type: "int"},
			{name: "PAG_NUMERO_DEPOSITO", type: "string"},
			{name: "PAG_LUGAR_DEPOSITO", type: "string"},
			{name: "PAG_FECHA_DEPOSITO", type: "date", dateFormat: "Y-m-d"}
		]),
		errorReader: new Ext.data.JsonReader({
			root: "resultado", 
			successProperty: "exito"
		}, ["id", "msg"])
	});
	
	formulario.column({width: 280}, 
		new Ext.form.TextField({
			allowBlank: false,
			name: "PAG_NUMERO_DEPOSITO",
			fieldLabel: "Número depósito",
			width: 150
		}),
		new Ext.form.TextArea({
			allowBlank: false,
			name: "PAG_LUGAR_DEPOSITO",
			fieldLabel: "Lugar depósito",
			width: 150
		}),
		new Ext.form.DateField({
			allowBlank: false,
			format: "Y-m-d",
			name: "PAG_FECHA_DEPOSITO",
			fieldLabel: "Fecha depósito",
			width: 150
		})
	);
	
	formulario.render(panel.getEl());
	
	this.addButton({
		text: "Grabar",
		handler: this.__grabar,
		scope: this
	});
	
	this.addButton({
		text: "Cerrar",
		handler: this.__cerrar,
		scope: this
	});
	
	this.formulario = formulario;
	
	this.on("show", this.__listar, this);
	
};

Ext.extend(Pago.Ingresar, Ext.LayoutDialog, {
		   
	__cerrar: function(){
	
		this.destroy(true);
	
	},
	
	__grabar: function(){
	
		this.formulario.submit({
			url: "modulos/pago/grabar.php"					   
		});
		
	},
	
	__listar: function(){
		
		this.formulario.load({
			url: "modulos/pago/listar.php"					   
		});		
		
	},
	
	mostrar: function(){
	
		this.show();
		
	}
		   
});