<?php include("session_start.php");

include("session_check.php");

include("database.php");

if($_GET['plot_area_from']!="")

{	

	$td1=$_GET["td1"];
	$sb2=$_GET["sb2"];
	$plot_area_to=$_GET["plot_area_to"];
	$plot_area_from=$_GET["plot_area_from"];
	$measure = $_GET["measure"];
	
	$cnt =1;	
	$sql3 = "select * from input_form where ward_office ='$td1'";
 
 	//echo $sql3;
 //exit;
 	$res = mysql_query($sql3);
	
	$num = @mysql_num_rows($res); if($num >0)
	{?>
    
    	<a href="print_plot_area_wise.php?td1=<?php echo $td1?>&sb2=<?php echo $sb2?>&plot_area_to=<?php echo $plot_area_to?>&plot_area_from=<?php echo $plot_area_from?>&measure=<?php echo $measure?>" style="text-decoration:none"> <input type="button" bgcolor="#a9c1de"  name="print" id="print" value="Print"   class="button_c" onClick=""></a><br />
        <!--<b>Total Number of Records : <?php echo $cnt ?>-->
        
        <table border="1" cellpadding="2" cellspacing="2" width="100%" align="center" bordercolor="#bcd5e7">
        <tr>
        
        <td align="center" ><font class="font4"><b>View</font></td>
        <td align="center"><font class="font4"><b>Ward Office</font></td>

        <td align="center"><font class="font4"><b>Ward</font></td>

        <td align="center"><font class="font4"><b>Date</font></td>

        <td align="center"><font class="font4"><b>Society Name</font></td>

        <td align="center"><font class="font4"><b>Tree Records</font>

        </td>
        </tr>
        
        <?php 
			while($row =@mysql_fetch_object($res))
			{
				
				$sql = mysql_query("select * from info where aid = '". $row->id."'");
				//echo "select * from info where aid = '". $row->id."'";
			
				$flag = true;
				$flag2 = true;
				$plot = $row->plot_area;
				if($plot_area_to != "")
				{
					if($measure == "sq.ft")
					{
						if(strpos($plot,"sq.ft") != false)
						{
							$plot = str_replace("sq.ft","",$plot);
						}
						else
						{
							$flag = false;
						}
					}
					else
					{
						if(strpos($plot,"m") != false)
						{
							$plot = str_replace("m","",$plot);
						}
						else
						{
							$flag = false;
						}
					}
					
					$plot = (int)$plot;
					
					if(!($plot_area_from <= $plot && $plot <= $plot_area_to))
					{
						$flag2 = false;
					}
				}
				
				//echo $flag."----".$flag2;
				if($flag2 && $flag)
				{
				$cnt++;
				//$res_sql = mysql_fetch_array($res);
				
				
				//echo $plot;
							
								
				$query_ward = mysql_query("select * from master_ward where wid= '".$row->ward_office."'");
				
				//echo "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_office."'");
			
				$result_sub = mysql_fetch_array($query_sub);
							
				echo "<tr>";
				
				echo "<td align='center' valign='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='center' valign='top'>"."<div align='center'>"."<font class='font4'>".$result_ward['wvalue']."</font></div></td>";
				
				echo "<td  align='center' valign='top'>"."<div align='center'>"."<font class='font4'>".$result_sub['dvalue']."</font></div></td>";
				
				echo "<td  align='center' valign='top'>"."<div align='center'>"."<font class='font4'>".$row->current_date1."</font></div></td>";
				
				echo "<td  align='center' valign='top'>"."<div align='center'>"."<font class='font4'>".$row->society_name."</font></div></td>";
				
				echo "<td>"; ?>
					
                    <table align="center" border="1" width="100%" bordercolor="#bcd5e7">
                     <tr>
                        <td align="center" ><font class="font4"/><b> Tree Name </td>
            
                        <td align="center" ><font class="font4"/><b> Scientific Name </td>
            
                        <td align="center" ><font class="font4"/><b> Longitude </td>
            
                        <td align="center" ><font class="font4"/><b> Latitude </td>
            
                     </tr>
                     <?php
					 
					 
	  
                     while($row1 = @mysql_fetch_object($sql))
					 {
						 
						 $query_tree = mysql_query("select * from tree_name where tid= '".$row1->tree_name."'");
					 $result_tree = mysql_fetch_array($query_tree);
						echo "	<tr>

				<td align='center'>"."<div align='center'>"."<font class='font4'>".$result_tree['tree_name']."</font></div></td>

				<td align='center'>"."<div align='center'>"."<font class='font4'>".$result_tree['scientific_name']."</font></div></td>

				<td align='center'>"."<div align='center'>"."<font class='font4'>".$row1->lng."</font></div></td>

				<td align='center'>"."<div align='center'>"."<font class='font4'>".$row1->lat."</font></div></td>

			</tr>

		

	";

					 }
					 ?>
                    
                    </table>
					
				
				
<?php				echo "</td>";
				
				echo "</tr>";
			}
				
			} 
		?>
        
       
        </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>