<?php include("session_start.php");
include("session_check.php");include("database.php");
if($_GET['q']!="")
{	
	$q=$_GET["q"];
	$j = explode("-",$q);
	$d1 = str_split($j[0]);
	//echo $d1[0]."/".$d1[1];
	if($d1[0]=="0")
	{
		$date1=$j[2]."-".$j[1]."-".$d1[1];
		//echo $date1;
	}
	else
	{
		$date1=$j[2]."-".$j[1]."-".$j[0];
	}
	$q1=$_GET["q1"];
	$j1 = explode("-",$q1);
	$d2 = str_split($j1[0]);
	if($d2[0]=="0")
	{
		$dateq1=$j1[2]."-".$j1[1]."-".$d2[1];
	}
	else
	{
	$dateq1=$j1[2]."-".$j1[1]."-".$j1[0];
	}
	//echo $dateq1;
	 $sql="SELECT * FROM input_form WHERE current_date1 between '".$date1."' and '".$dateq1."' ";
	 //echo $sql;
	$rest=mysql_query($sql);
	$num = @mysql_num_rows($rest); if($num >0){?>
   	<a href="print_datewise_report.php?x=<?php echo $date1?>&y=<?php echo $dateq1?>"style="text-decoration:none"> <input type="button" bgcolor="#a9c1de"  name="print" id="print" value="Print"   class="button_c" onClick=""></a><br />
    <table border="1" cellpadding="2" cellspacing="2" width="100%" align="center" bordercolor="#bcd5e7" >
	   <br />
	 <tr>
    	 
        <td align="left" ><font class="font4"><b>View</font></td>
 	    <td align="left"><font class="font4"><b>Ward Office</font></td>
        <td align="left"><font class="font4"><b>Ward</font></td>
        <td align="left"><font class="font4"><b>Date</font></td>
        <td align="left"><font class="font4"><b>Society Name</font></td>
        <td align="left"><font class="font4"><b>Tree Records</font>
        
        
        </td>
     </tr>
     <?php
   while ($row =@mysql_fetch_object($rest)) 
{
	$query_ward = mysql_query("select * from master_ward where wid= '".$row->ward_office."'");
	$result_ward = mysql_fetch_array($query_ward);
	
	$query_sub = mysql_query("select * from master_ward_drop where did= '".$row->ward."'");
	$result_sub = mysql_fetch_array($query_sub);
	
	$date = $row->current_date1;
	//echo $date;
	$j=explode("-",$date);
	$show_date = $j[2]."-".$j[1]."-".$j[0];
	echo "<tr>";
	
	echo "<td align='left' style='vertical-align:top'><a href='view_records.php?id=$row->id'><font class='font4'>"."<img src='images/view.png' border='0'>"."</font></div></td>";


echo "<td  align='left' style='vertical-align:top'>"."<div align='left' style='vertical-align:top'>"."<font class='font4'>".$result_ward['wvalue']."</font></div></td>";
echo "<td  align='left' style='vertical-align:top'>"."<div align='left' style='vertical-align:top'>"."<font class='font4'>".$result_sub['dvalue']."</font></div></td>";
echo "<td  align='left' style='vertical-align:top'>"."<div align='left' style='vertical-align:top'>"."<font class='font4'>".$show_date."</font></div></td>";
echo "<td  align='left' style='vertical-align:top'>"."<div align='left' style='vertical-align:top'>"."<font class='font4'>".$row->society_name."</font></div></td>";
echo "<td>";
?>
	<table align="center" border="1" width="100%" bordercolor="#bcd5e7">
    	<tr>
        	
        	
            <td align="left" ><font class="font4"/><b> Tree Name </td>
            <td align="left" ><font class="font4"/><b> Scientific Name </td>
            <td align="left" ><font class="font4"/><b> Longitude </td>
            <td align="left" ><font class="font4"/><b> Latitude </td>
         </tr>
<?php
$query1="select * from info where aid='".$row->id."'";
 $rest1=mysql_query($query1);
while($row1 = @mysql_fetch_object($rest1))
{
	$query_tree = mysql_query("select * from tree_name where tid= '".$row1->tree_name."'");
	$result_tree = mysql_fetch_array($query_tree);
echo "
		
			<tr>
				
				
				<td align='left' style='vertical-align:top'>"."<div align='left'>"."<font class='font4'>".$result_tree['tree_name']."</font></div></td>
				<td align='left' style='vertical-align:top'>"."<div align='left'>"."<font class='font4'>".$result_tree['scientific_name']."</font></div></td>
				<td align='left' style='vertical-align:top'>"."<div align='left'>"."<font class='font4'>".$row1->lng."</font></div></td>
				<td align='left' style='vertical-align:top'>"."<div align='left'>"."<font class='font4'>".$row1->lat."</font></div></td>
			</tr>
		
	";
}?>
</table>
<?php
echo "</td>";
}

?>

</table>
    
<?php }else
{
	echo "No Records To Display";
}
}


?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Survey Application</title>
</head>

<body>
</body>
</html>