<?php require "_header.php"; ?>
<style type="text/css">
th{
	width: 160px;
}
</style>

<div id="main-report" align="center">
<center><h4>Customer Detail Report</h4></center>
<?php	
  if($_SESSION["cCompany_id"]=="")
 	{
	?>
		<script language="javascript" type="text/javascript">
			location.href='report-form-employee.php';
		</script>
	<?php
    }elseif($_SESSION["cCompany_id"]!="" && isset($_SESSION["cCompany_id"]))
    {	
	
			$date = new Date();
			
			$limit=0;
			$start=0;
			$condition="";
			$order_field="";
			$order_type="";
			$header_row_string="Customer Detail Report";
			
			$customer_id =Escape($_REQUEST["ID"]);
			$hiddendist_code =Escape($_REQUEST["hiddendist_code"]);
			
			
			if(isset($customer_id)){  
				if($customer_id!=""){
					$condition.=" and  lc.customer_id = '$customer_id' ";
				}
			}
			if($hiddendist_code !="" && $hiddendist_code !="All")
			{
			 	$condition.= " AND lc.district_id = '".$hiddendist_code."' ";  
			}	
			$condition .= " Order By lc.district_id,lc.customer_orgname";
			$objCustomerMgmt = new CustomerMgmt();
			$out = $objCustomerMgmt->getAllRecordsCustReport($limit,$start,$condition,$order_field,$order_type);
			if(dbRows($out)) {
			   ob_start(); //starting for
			   
			
		  ?>
		  <table width="90%" align="center" class="report">
		
		  <tr>
			  <td align="center" style='width:5%; font-weight:bold;'>SrNo.</td>
			  <td align="center" style='width:15%; font-weight:bold;'>District Name</td>
			  <td align="center" style='width:15%; font-weight:bold;'>Taluka</td>
			  <td align="center" style='width:30%; font-weight:bold;'>Customer Org Name</td>
			  <td align="center" style='width:30%; font-weight:bold;'>Current Address</td>
			  <td align="center" style='width:25%; font-weight:bold;'>Phone No1.</td>
			  <td align="center" style='width:25%; font-weight:bold;'>Contact Person</td>
			  <td align="center" style='width:25%; font-weight:bold;'>Mobile</td>
      </tr>
		 
		  <?php
			   $i = 0;
				while($row=dbArray($out)) {
					//print_r($row);
					extract($row);
					if($employee_photo=="")
					$imgfile = $SiteImagePath."default.gif";
					else
					$imgfile = $EmployeeImagePath .$employee_photo;
					
				
		?>
		
		
		  
<tr>
		  
			<td ><?php echo $i + 1; ?></td>
			<td ><?php echo $dist_nameeng; ?></td>
			<td >&nbsp;&nbsp;&nbsp;</td>
			<td  ><?php echo $customer_orgname; ?> </td>
			<td  ><?php echo $customer_address; ?> </td>
			<td ><?php echo $customer_phone1;?>  </td>
			<td ><?php echo $customer_cpname1;?> </td>
		 	<td ><?php echo $customer_cpmobile1;?></td>
		</tr>  
           
		  	
  
  
		<?php $i++; } //while loop over
	?>	
	
	</table>
	<?php		 
			  $HtmlCode= ob_get_contents();
			  ob_end_flush();
			  $HtmlUrl 	=	"customer-personal-detail-report-". $_SESSION["cUserId"].".html";
			  $HtmlPath 	=	"report/".$HtmlUrl;		
			  createHTMLReportPage($header_row_string,$HtmlUrl,$HtmlPath,$HtmlCode,false);  ?>
		<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>
		    <br/><br/>   
		<?php	} else {
			         echo "<center><b> No Records Found.</b></center>";
                   } 
    }
	
	else {
	        echo "Session Expired";
	      }	
	?>
</div>
<?php require "_footer.php";?>
