<?php require "../_header.php";?>
<div id="main-report" align="center">
<?php
if($_REQUEST['registerid']=="" && $_REQUEST['Search_field']=="" && $_REQUEST['search_text']=="")
{
?>
	<script language="javascript" type="text/javascript">
		location.href='report-form-book-general.php';
	</script>
<?php
}
elseif($_SESSION['aCollegeId']!="" && isset($_SESSION['aCollegeId'])){
	    
		$header_row_string = "<u>Book General Register Report</u>";
		
		$title_array = array();
		$title_array[0] = "Book Reg.No,center,10%";
		$title_array[1] = "Book Name,left,90%";
		
		
		   $book_registerno   = Escape($_REQUEST['registerid']);
	       $search_field      = Escape($_REQUEST['Search_field']);
	       $search_text	   = Escape($_REQUEST['search_text']);	
		
		$condition ="";
			
		if($book_registerno != ""){
			$condition .= "book_registerid='$book_registerno' and book_active='1'";
		}
		
		if($search_field != "" && $search_text != ""){
			$condition .= "and ".$search_field. "='$search_text'";
		}	
		$qry = "SELECT book_registerno,book_name from lms_bookmaster where ".$condition;
		 
		$obj = new Query2Report();
		$obj->reportid="report-table";
		
		$obj->createHeaderRow($header_row_string);
		$header_row_string = "";
		$obj->generateReport($qry,$title_array);
		
		$obj->displayReportData();  
	    if($obj->rowCount>0)
		{
		    $HtmlUrl 	=	"book-general-register-report-". $_SESSION["aUserId"].".html";
			$HtmlPath 	=	"../report/".$HtmlUrl;
			
			$obj->setHtmlUrl($HtmlUrl);
			$obj->setHtmlPath($HtmlPath); 	
			$obj->saveReportData();		
		?>
		<script type="text/javascript">
		Ext.onReady(function(){
			 var grid = new Ext.ux.grid.TableGrid("report-table", {
					stripeRows: true // stripe alternate rows
				});
				grid.render();
		});
		</script>
		<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>
<?php require "../_footer.php";?>