<?php
$id="07-15-2024";

include("database_connection.php");

  function cleanData($str)
  {
    $str = preg_replace("/\t/", "\\t", $str);
    $str = preg_replace("/\r?\n/", "\\n", $str);
    if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
  }

  // filename for download
  $filename = " Report From" .$id.  ".xls";

 	header("Content-Disposition: attachment; filename=\"$filename\"");
  	header("Content-Type: application/vnd.ms-excel");

  $flag = false;
 ?><table border="1">
	<tr> 
		<th>Sr No</th>
		<th>Bank Name</th>
		<th>App No</th>
		<th>Ref No</th>		
		<th>Customer Name</th>
		<th>Address</th>
		<th>Fe Name</th>
		<th>Zone</th>
		<th>Allocation Date</th>
		<th>Report Date</th>
				
	</tr>
	<?php
	$dump_date=$id;
	$queryr="SELECT  *  FROM `allocation_tbl` WHERE report_date='$dump_date' order by id asc";
	$resultr = MYSQL_QUERY($queryr);
		
	 $j=1;
	while($data=mysql_fetch_array($resultr)) {	
	$user_code=$data['user_code'];
	$sqlfe="select first_name,last_name,mobile,zone,location from user_tbl where user_code='$user_code' ";
	$resultuser=mysql_query($sqlfe);
	$datauser=mysql_fetch_array($resultuser);
	
	
 ?>
	
	<tr  >
	<td><?php echo trim(strtoupper($j));?></td>	
	<td><b><?php echo strtoupper($data['bank_name']);?></b></td>
	<td><b><?php echo $data['app_no'];?></b></td>
	<td><b><?php echo $data['case_id'];?></b></td>
	<td><b><?php echo $data['name'];?></b></td>
	<td><b><?php echo $data['address1'];?></b></td>
	<td><b><?php echo strtoupper($datauser['first_name'].' '.$datauser['last_name']);?></b></td>
	<td><b><?php echo strtoupper($datauser['zone']);?></b></td>
	<td><b><?php echo $data['dump_date'];?></b></td>	
	<td><b><?php echo $data['report_date'];?></b></td>
	</tr>
	<?php
	$j++;  } ?>
	 
</table>

