<?php require "_header.php";
include "Numbers/Words.php"; ?>
<div id="main-report" align="center">

<?php 
/*echo "<pre>";
print_r($_SESSION);
exit;*/
if($_SESSION['cCompany_id']!="" && isset($_SESSION['cCompany_id'])) 
{
	$customer_id = Escape($_REQUEST["ID"]);
	$startdate = Escape($_REQUEST["startdate"]);
	$enddate= Escape($_REQUEST["enddate"]);
	
 $cond = "";
	$height=300;
	$nw = new Numbers_Words();
	
	 if($startdate !="From" && $startdate !="To")
	{
		
		 $startdate = DateConversion($startdate,"Y-m-d","d/m/Y");
		 $enddate = DateConversion($enddate,"Y-m-d","d/m/Y");
		  $cond.= " AND CAST(createdon as Date) >= '$startdate' ";  
		  $cond.= " AND CAST(createdon as DATE) <=  '$enddate' ";  
	}
	
	$agencyid = $_SESSION["cCompany_id"];
	
	$headerflag=$_REQUEST['headerflag'];
	
	$qry = " SELECT * from csc_customer as cm,lms_customersupport as cs
			where 1= 1 and cm.customer_id = cs.customer_id ";
			
	$qry .= $cond;
	 
	

	$rs = dbQuery($qry);
	$count=dbRows($rs);
	
	$j=0;

	
	ob_start();
	$i=0;
	$sno=1;
?>
<table class="report" width="100%" align="center" border="1">
	<tr>
		<th>Sr No</th>
		<th>Party Name</th>
		<th>Group Name</th>
		<th>Opening Bal</th>
		<th>Ledger Contact</th>
		<th>Tel</th>
		<th>Contact No</th>
		<th>Opening Bal</th>
		<th>Email</th>
		<th>State Name</th>
		<th>PIN</th>
		<th>Address Line1</th>
		<th>Address Line2</th>
		<th>Address Line3</th>
		<th>Address Line4</th>
		<th>Alias</th>
		<th>Pan No</th>
		<th>GSTNO</th>
		<th>CSC ID</th>
	</tr>
	<?php
	while($row = dbArray($rs))
	{
		
	?>	
	<tr>
	<td><?php echo $sno++; ?>
		<td><?php echo $row['estore_name'];?></td>
		<td>&nbsp;</td>
		<td>0</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td><?php echo $row['estore_phoneno'];?></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td><?php echo $row['state'];?></td>
		<td><?php echo substr($row['address'],-6);?></td>		
		<td><?php echo $row['address'];?></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td><?php echo $row['gst_no'];?></td>
		<td><?php echo $row['csc_id'];?></td>
		
	
		
	</tr>
	
<?php
	}	
		  
		
	   ?>
</table> 

          
	   
<?php
	   $HtmlCode= ob_get_contents();
			ob_end_flush();
			$HtmlUrl 	=	"customerbill-report-". $_SESSION["eAgencyId"].".html";
			$HtmlPath 	=	"report/".$HtmlUrl;		
			createHTMLReportPage($header_row_string,$HtmlUrl,$HtmlPath,$HtmlCode,true); 		
		?>		
		<br />
<br /><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="Print" onClick="SetPageAction('PRINT');"/>
<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">
			//SetPageAction('PRINT');
			function SetPageAction(varAction) {
				
				if(varAction=="PRINT"){			
                        document.frm.action="print/create-print.php";
                        document.frm.submit();
                    }
			   else 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 }require "_footer.php";?>