<?php require "../_header.php";?>
<div id="main-report" align="center">
<?php if($_REQUEST['radiotype']=="")
{
?>
	<script language="javascript" type="text/javascript">
		location.href='report-form-member-register.php';
	</script>
<?php
}
elseif($_SESSION['aCollegeId']!="" && isset($_SESSION['aCollegeId'])){
	        
		
		$header_row_string = "<u>Member Register Report</u>";
		$title_array = array();
		$title_array[0] = "Member Name,left,10%";
		$title_array[1] = "Member Address,left,22%";
		$title_array[2] = "Phone,center,13%";
		$title_array[3] = "Mobile,center,13%";
		$title_array[4] = "Member Referenc By,left,20%";
		$title_array[5] = "Joining Date,center,10%";
		$title_array[6] = "Leave Date,center,12%";
			
		$condition = " school_id = '".$_SESSION['aCollegeId']."' ";
				
		if($_REQUEST['member_from']!=""){
		    $member_from = DateConversion(Escape($_REQUEST['member_from']),"Y-m-d","d/m/Y");
			$condition .= " AND member_approvedfrom >= '$member_from' ";
		}
		if($_REQUEST['member_to']!=""){
			$member_to = DateConversion(Escape($_REQUEST['member_to']),"Y-m-d","d/m/Y");
			$condition .= " AND member_approvedfrom <= '$member_to' ";
		}
		
		
		$obj = new Query2Report();
		$obj->reportid="report-table";
		
		$obj->createHeaderRow($header_row_string);
		
		$query = "SELECT member_name,member_address,member_phone,member_mobileno,member_refby
			,DATE_FORMAT(member_approvedfrom,'$SQLDateFormat'),DATE_FORMAT(member_approvedto,'$SQLDateFormat') from lms_membermaster where ".$condition;
				
		$obj->generateReport($query,$title_array);
					
		
		
		$obj->displayReportData();
		if($obj->rowCount>0)
		{	
		  $HtmlUrl 	=	"member-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";?>