<?php require "_header.php"; ?>
<div id="main-content">
<script type="text/javascript">
Ext.onReady(function(){
    Ext.QuickTips.init();
    
   var simpleForm = new Ext.FormPanel ({
    	layout: 'form',		
       	url:'runquery.php',	
		method:'post',
		standardSubmit:true,
		frame:true,
        bodyStyle:'padding:5px 5px 0',
        width: 350,
		labelWidth: 60, // label settings here cascade unless overridden
		buttonAlign:'center',
        items: [{ 
			xtype: 'textarea',
			growAppend: "",
			name: 'queryanl',
			id:'queryanl',
			fieldLabel: 'Query',

			width: 400,
			height: 250
		}]
	});
   
   
   var districtWindow = new Ext.Window({
        title: 'Query Analaizer',
		width:500,		
		height:350,		
		border: false,
		modal:true,
		layout: 'fit',
		closeAction:'close',
		collapsible:true,
		items: simpleForm,
		buttonAlign: 'center',
	    buttons: [{
							text:'Run',	
							
							handler: function(b, e)
							{
								
								rest1 = simpleForm.getForm().findField('queryanl').getValue();
								sel=rest1.substring(0,6);
								if(sel.toLowerCase()!='select')
								{
										Ext.MessageBox.show({
										   title: 'Error',
										   msg: 'You can execute only Select Query',
										   buttons: Ext.MessageBox.OK,
										   icon:Ext.MessageBox.ERROR
										});
										simpleForm.getForm().findField('queryanl').reset();
										simpleForm.getForm().findField('queryanl').focus(true,500);
								}
								else
								{ 					
									/*simpleForm.getForm().getEl().dom.target = '_blank';
									simpleForm.getForm().getEl().dom.action = 'runquery.php';
									simpleForm.getForm().getEl().dom.submit(
									{
										waitMsg: 'Saving...',
										success: function (){},
										failure: function (){
											Ext.Msg.alert ('Error Message','Please fill up complete form.');
										}
									});*/
									//simpleForm.getForm().getEl().dom.target = '_blank';
									//simpleForm.getForm().getEl().dom.action = 'runquery.php';
									simpleForm.getForm().submit(
									{
										waitMsg: 'Saving...',
										success: function (){},
										failure: function (){
											Ext.Msg.alert ('Error Message','Please fill up complete form.');
										}
									});
								}	
							}
						},
						{
						   text:'Reset',	
						   handler: function(b,e)
							{	//alert(districtform.getForm().findField('districtid').getValue());	
								simpleForm.getForm().reset();	
								simpleForm.getForm().findField('queryanl').focus(true,500);
							}
						}
					]

	});
	var varWidth =  (screen.width - districtWindow.width)/2;
    districtWindow.setPosition(varWidth,((screen.height/4)-85));
	districtWindow.show();
	simpleForm.getForm().findField('queryanl').focus(true,500);
});
</script>
<!-- end custom CSS/JS -->
<div id="abcd"></div>
</div>
<?php require "_footer.php";?>
