<?php
session_start();
error_reporting(0);
$id=$_GET['id'];
$usercode=$id;
date_default_timezone_set('Asia/Calcutta');
	$d=date('d-m-Y');
	$t="02:01 PM";
	$dt=$d.' '.$t;
	$unix_time= strtotime(($dt));
	$reportdate=date('m-d-Y');
		$y=date('Y');	
	include("database_connection.php");
	 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<body>
	
	<form method="post" action=" " name="view_fereportdate" id="view_fereportdate">
	
	<table style="width:100%"   align="center"> 
	<tr>
	<td align="center" style="width:85%;">
	<table  border="1" bgcolor="white" style="width:85%;" class="table table-striped" > 
	<thead>
	<tr height="25">
				<th class="center" ><b>Sr No</b></th>				
				<th class="center"><b>Bank Name</b></th>				
				<th class="center"><b>App No</b></th>
				<th class="center"><b>Ref No</b></th>
				<th class="center"><b>Type</b></th>
				<th class="center"><b>Applicant Name</b></th>
				<th class="center"><b>Address</b></th>
				<th class="center"><b>Allocation date & time</b></th>
				<th class="center"><b>Report date & time </b></th>
				<th class="center"><b>Tat </b></th>
			</tr>
		 </thead>
		 <tbody>
		<?php
		
		if($usercode)
		{
				
	$queryr="SELECT  id,bank_name,app_no,case_id,name,type,address1,date,upload_time,report_date,report_time FROM `allocation_tbl` WHERE report_date = '$reportdate'  and user_code='$usercode' and dump_date != '$reportdate'    order by address1 asc";
	$resultr = MYSQL_QUERY($queryr);
	}	
	 $j=1;
	while($data=mysql_fetch_array($resultr)) {
	$id=$data['id'];
	$reportdate1=explode('-',$data['report_date']);
	$m=$reportdate1[0];
	$d=$reportdate1[1];
	$y=$reportdate1[2];
	if($m=="01")
	{
	$m1="Jan";
	}
	elseif($m=="02")
	{
	$m1="Feb";
	}
	elseif($m=="03")
	{
	$m1="Mar";
	}
	elseif($m=="04")
	{
	$m1="Apr";
	}
	elseif($m=="05")
	{
	$m1="May";
	}
	elseif($m=="06")
	{
	$m1="Jun";
	}
	elseif($m=="07")
	{
	$m1="Jul";
	}
	elseif($m=="08")
	{
	$m1="Aug";
	}
	elseif($m=="09")
	{
	$m1="Sep";
	}
	elseif($m=="10")
	{
	$m1="Oct";
	}
	elseif($m=="11")
	{
	$m1="Nov";
	}
	elseif($m=="12")
	{
	$m1="Dec";
	}
	else
	{
	$m1='';
	}
	$reportdate=$d.'-'.$m1.'-'.$y;
	$reportdate=$d.'-'.$m1.'-'.$y;
	//$uploaddate=$data['dump_date'].' '.$data['upload_time'];
	$uploaddate=$data['date'].' '.$data['upload_time'];
	//$datevisit=$data['report_date'].' '.$data['report_time'];
	$datevisit=$reportdate.' '.$data['report_time'];
		$timestamp= strtotime($uploaddate);
		$timestamp1= strtotime($datevisit);
		 $timestamp1.','.$timestamp;
		$datet=($timestamp1-$timestamp);
		$date2=$datet;
		$fdate= floor($date2/3600);
		$fdate22= floor($date2/(24*3600));
		$fh=$fdate22*24;
		$fdate2= floor(($date2/3600)-$fh);
		//$fdate2= floor($date2/3600);
		$fdate1= floor($date2/60 % 60);
		$visit1=-$fdate.' Hr'.' '.$fdate1.' Min';	
		$visit2=$fdate22.' Days '.$fdate2.' Hr'.' '.$fdate1.' Min'; 
		if(strlen($datevisit)>2)
		{
		if($fdate22>0)
		{
		$visit2=$fdate22.' Days '.$fdate2.' Hr'.' '.$fdate1.' Min';
		}
		else
		{
		$visit2=$fdate2.' Hr'.' '.$fdate1.' Min';
		}
		}
		else
		{
		$visit2='';
		}
	if($j%2==0)
		 {
		 $color="#FFFAFA";  
		 }
		 else
		 {
		 $color="white";  
 		}
		if($pending>0)
		{
		$bg="#FFA07A";
		}
		else
		{
		$bg="white";
		}
		if($pending2>0)
		{
		$bg2="#FFFF00";
		}
		else
		{
		$bg2="white";
		}
	if($id>0)
	{
	?>

<tr  bgcolor=" <?php echo $color;?>" height="15">
<td   align="center"><font size="2"><b><?php echo $j ;?></b></font></td>
<td align="center"><font size="2"><b><?php echo strtoupper($data['bank_name']);?></b></font></td>
<td align="center"><font size="2"><b><?php echo strtoupper($data['app_no']);?></b></font></td>
<td   align="center"><font size="2"><b><?php echo $data['case_id'];?></b></font></td>
<td   align="center"><font size="2"><b><?php echo $data['type'];?></b></font></td>
<td   align="center"><font size="2"><b><?php echo $data['name'];?></b></font></td>
<td   align="center"><font size="2"><b><?php echo $data['address1'];?></b></font></td>
<td   align="center"><font size="2"><b><?php echo $data['date'].' '.$data['upload_time'];?></b></font></td>
<td   align="center"><font size="2"><b><?php echo $reportdate.' '.$data['report_time'];?></b></font></td>
<td   align="center"><font size="2"><b><?php echo $visit2;?></b></font></td>
</tr>
<?php
	$j++; } } ?>

</tbody>
 </table>
</td>
</tr>
</table>

</div>
</body>
</html>			
