<?php
$id=$_GET['id'];

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 = "Image Upload Manual 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>Image Uploaded By</th>
		<th>Count</th>				
	</tr>
	<?php
	$dump_date=$id;
	$queryr="SELECT distinct(image_uploadedby),count(id) as num FROM `allocation_tbl` WHERE image_uploaddate='$dump_date' and image_uploadedby!='' group by  image_uploadedby  ";
 
	$resultr = MYSQL_QUERY($queryr);
		
	 $j=1;
	while($data=mysql_fetch_array($resultr)) {	
	$image_uploadedby=$data['image_uploadedby'];
	$count=$data[1];
	
	$total +=$count;
	if($total>0)
	{
 ?>
	
	<tr  >
	<td><?php echo trim(strtoupper($j));?></td>	
	<td><b><?php echo strtoupper($data['image_uploadedby']);?></b></td>
	<td><b><?php echo strtoupper($count);?></b></td>
	</tr>
	<?php
	$j++; } } ?>
	 <tr >
<td align="center"><font size="2"><b></b></font></td>
<td align="center"><font size="2"><b>Total</b></font></td>
<td  align="center" ><font size="4"><b><?php echo $total;?></b></font></td>
</tr>
</table>
<table border="">
	<tr> 
		<th></th>
		<th></th>
		<th></th>				
	</tr>
	<tr> 
		<th></th>
		<th></th>
		<th></th>				
	</tr>
	<tr> 
		<th></th>
		<th>Details</th>
		<th></th>				
	</tr>
	<tr> 
		<th></th>
		<th></th>
		<th></th>				
	</tr>
	<tr> 
		<th></th>
		<th></th>
		<th></th>				
	</tr>
	<tr> 
		<th></th>
		<th></th>
		<th></th>				
	</tr>
	</table>
	<table border="1">
	<tr> 
		<th>Sr No</th>
		<th>Client Name</th>
		<th>Customer Name</th>
		<th>App No</th>
		<th>Ref No</th>
		<th>Type</th>
		<th>Image Uploaded By</th>	
		<th>Image Uploaded Time</th>					
	</tr>
	<?php
	$dump_date=$id;
	$queryr="SELECT  bank_name,name,app_no,case_id,type,image_uploadedby,image_uploadtime FROM `allocation_tbl` WHERE image_uploaddate='$dump_date' and image_uploadedby!=''    ";
 
	$resultr = MYSQL_QUERY($queryr);
		
	 $i=1;
	while($data=mysql_fetch_array($resultr)) {	
	$image_uploadedby=$data['image_uploadedby'];
	
 ?>
	
	<tr  >
	<td><?php echo trim(strtoupper($i));?></td>
	<td><b><?php echo strtoupper($data['bank_name']);?></b></td>	
	<td><b><?php echo strtoupper($data['name']);?></b></td>
	<td><b><?php echo strtoupper($data['app_no']);?></b></td>
	<td><b><?php echo strtoupper($data['case_id']);?></b></td>
	<td><b><?php echo strtoupper($data['type']);?></b></td>
	<td><b><?php echo strtoupper($data['image_uploadedby']);?></b></td>
	<td><b><?php echo strtoupper($data['image_uploadtime']);?></b></td>
	</tr>
	<?php
	$i++;  } ?>

