<?php require "_header.php";?>
<div id="main-report" align="center"><br/><br/><br/>
<!--start main body  -->
 <?php 
    
	if($_REQUEST['queryanl']=="")
	{
	?>
	<script language="javascript" type="text/javascript">
		location.href='queryAnlaizer.php';
	</script>
	<?php
	}
	else
	{	
		$query= Escape($_REQUEST['queryanl']);
		
		$header_row_string="Selection Report ";
		 
		$obj = new Query2Report(); 		 
		$obj->reportid="report-table";
		$obj->createHeaderRow($header_row_string);	
		$obj->generateReport($query,$title_array,$footer=false,$field="",$counter=true);		
		$obj->displayReportData();
	 }
	 if($obj->rowCount>0)
	 {
	    $HtmlUrl 	=	"student-selection-report.html";
		$HtmlPath 	=	"report/".$HtmlUrl;		
		$obj->setHtmlUrl($HtmlUrl);
    	$obj->setHtmlPath($HtmlPath); 	
		$obj->saveReportData();	
?>
		<br/>
		<form name="frm" id="frm" action="" method="post">		
			<input type="hidden" name="txtFile" id="txtFile" value="<?php echo $HtmlUrl ;?>" />
			<input type="button" name="btnPdf" id="btnPdf" value="Create PDF" onClick="SetPageAction('PDF');"/>
			<input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');"/>
			<input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');"/>
			<input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');"/>
		</form>
		<script language="javascript" type="text/javascript">
			function SetPageAction(varAction) {
				if(varAction=="PDF"){			
					document.frm.action="convertpdf/create-pdf.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if(varAction=="HTML"){
					document.frm.action="<?php echo $HtmlPath ;?>";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if(varAction=="WORD"){
					document.frm.action="convertword/create-word.php";
					document.frm.target="_blank";
					document.frm.submit();
				}
				else if(varAction=="Excel"){
					document.frm.action="convertword/create-excel.php";
					document.frm.target="_blank";
					document.frm.submit();
				}
			}
		</script>			
	<?php 
		}
		else
		{
			echo "<br/><b>No Data Found</b>";
		}
?>
</div><br/><br/><br/>
<?php require "footer.php";?>