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

?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Survey Application</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">
</script>

<script type="text/javascript">

ddsmoothmenu.init({
	mainmenuid: "smoothmenu1", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})



</script>
<style type='text/css' media='print'>
#prnt {display : none}
#header{display:none;}
#footer{display:none;}
#back {display : none}

</style>
</head>

<body class="body">

<div id="wrap" >
  
  
  <div id="top">
   
    <!--<div id="ban"><table width="1004" align="left"  >
  <tr>
    <td width="234"  align="left"  valign="top" ><img src="images/logoss.jpg" border="0" /></td>
    <td  valign="top" style="padding-top:5px;" width="758"  align="right" ><table align="left" width="707">
  <tr>
    <td width="386" align="left"><div ><a href="#" id="bantext1">REQUEST A DEMO</a></div></td>
    <td width="167" align="left"><div ><a href="#" id="bantext2">DOWNLOADS</a></div></td>
    <td width="138" align="left"><div ><a href="#" id="bantext2">DOWNLOADS</a></div></td>
  </tr>
  <tr>
    <td colspan="3" align="center" class="banquot">Be Smart and Survey Smartly </td>
  </tr>
</table></td>
    
    
  </tr>
</table>
    </div>-->
    
    </div>
    </div>
  
   <div id="contholder">
   
    
    <!--<div id="nav">
     <ul>
     <li><a href="adminhome.php" id="home_on">HOME</a></li>
        <li><a href="adminproducts.php" id="products_on">PRODUCTS</a></li>
		<li><a href="adminfeatures.php" id="features_on">FEATURES</a></li>
        <li><a href="adminadvantages.php" id="advantages_on">ADVANTAGES</a></li>
        <li><a href="adminhowitworks.php" id="howitworks_on">HOW IT WORKS</a></li>
        <li><a href="adminhelp.php" id="help_on">HELP</a></li>
        <li><a href="admincontactus.php" id="contactus_on">CONTACT US</a></li>
    
    </ul>
    
    </div>-->
    
    
    	<div id="contdata">
  <hr width="80%"></hr>
<center><font face="Verdana" size="2"><b>Date and Pincode wise report </b></font></center>
<hr width="80%"></hr>
<br>
<table border='0' width='80%'  align='center'  style='font-family:Verdana; font-size:10pt; border-collapse: collapse;'>
    <tr>
        <td align="right">
            <input type="button" value="Print" id="prnt" name="print" onClick="window.print()" align="center" >
            <a href="report_date_pin.php" id="back"style="text-decoration:none; "><input type="button" value="Cancel" name="cancel" >  </a>
        </td>
    </tr>
</table>
<br>
<?php
	if($_GET['date1']!="")
{	
	$date1=$_GET["date1"];
	$j = explode("-",$date1);
	$d1 = str_split($j[0]);
	if($d1[0]=="0")
	{
		$dates = $j[2].'-'.$j[1].'-'.$d1[1];
	}
	else
	{
		$dates = $j[2].'-'.$j[1].'-'.$j[0];
	}
	
	$date2=$_GET["date2"];
	//echo $date2;
	$i = explode("-",$date2);
	$d2 = str_split($i[0]);
	//echo $d2[0];
	if($d2[0]=="0")
	{
		$datee = $i[2].'-'.$i[1].'-'.$d2[1];
		//echo $datee;
	}
	else
	{
		$datee = $i[2].'-'.$i[1].'-'.$i[0];
	}
	
	$pincode=$_GET["pincode"];
 	$sql="SELECT * FROM input_form WHERE current_date1 between '".$dates."' and '".$datee."' and pincode='".$pincode."'  ";
	$result = mysql_query($sql);



$j=explode("-",$date1);
	$start_date = $j[2]."-".$j[1]."-".$j[0];
	//echo "new date--- ".$show_date;
	
	$i=explode("-",$date2);
	$end_date = $i[2]."-".$i[1]."-".$i[0];


echo "<center><b><font face='Verdana' size='2'>From  </font> ".$start_date ."<font face='Verdana' size='2'>$nbsp To </font> ".$end_date ."</b><br/><br/></center>";	
echo "<center><b><font face='Verdana' size='2'>Pincode </font> ".$pincode ."</b><br/><br/></center>";

$sr = 0;
while($row = mysql_fetch_array($result))
  {
	$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);
	
	$query_surveyor = mysql_query("select * from login where lid= '".$row['surveyor']."'");
	$result_surveyor = mysql_fetch_array($query_surveyor);
	
	$query1="select * from info where aid='".$row['id']."'";
 	$rest1=mysql_query($query1);
	
	$res2 = "select t.growth_speed as speed,i.age as age from info i, carbon c, tree_name t where i.age = c.age and i.tree_name = t.tid and i.aid = '".$row['id']."'";
				
	  $carbon_query = mysql_query($res2);
	
	echo "<table border='1'  align='center'  cellpadding='2' cellspacing='2' style='font-family:Verdana; font-size:8pt; border-collapse: collapse; style='width:90%; margin:15px;  '>";

echo "<tr><td colspan='20' style='padding:10px;'>
	Survey Sheet Number : ".$row['survey_sheet_no']."<br>
	Ward Name : ".$result_ward['wvalue']."<br>
	Sub Ward Name : ".$result_sub['dvalue']."<br>
	Date : ".$row['current_date1']."<br>
	Property Name : ".$row['society_name']."<br>
	Sub Area : ".$row['sub_area']."<br>
	House Owner : ".$row['owner']."<br>";
	
	if($row['type'] == "Roadside"){
		echo "Length of Road : ".$row['plot_area']."<br>";
	}
	else{
		echo "Area of Property : ".$row['plot_area']."<br>";
	}
	
	echo "Type : ".$row['type']."<br>
	Surveyor Name : ".$result_surveyor['username']."<br>
	
	</tr> <br> ";
	
	echo "<tr>
	<th style='width:10%;'>Sr. No.</th>
	
	<th style='width:10%;'>Tree Name</th>
	
	<th style='width:10%;'>Scientific Name</th>
	
	<th style='width:10%;''>GBH (cm) </th>
	
	<th style='width:10%;'> Height (ft) </th>
	
	<th style='width:10%;'>Canopy Diameter (ft) </th>
	
	<th style='width:10%;'>Age (yr)</th>
	
	<th style='width:10%;'>Condition </th>
	
	<th style='width:10%;'>Longitude </th>
	
	<th style='width:10%;'>Latitude </th>
	
	<th style='width:10%;'>Flowering Season</th>
	
	<th style='width:10%;'>Flower Color</th>
	
	<th style='width:10%;'>Fruiting Season</th>
	
	<th style='width:10%;'>Native/Exotic</th>
	
	<th style='width:10%;'>Growth Rate</th>
	
	<th style='width:10%;'>Wild/Cultivated</th>
	
	<th style='width:10%;'>Use</th>
	
	<th style='width:10%;'>Time</th>
	
	<th style='width:10%;'>Carbon Sequestration (lbs per year)</th>
	
	<th style='width:10%;'>Images</th>
	
	
	</tr>";  
	while($row1 = mysql_fetch_array($rest1))
  	{
		$sr++;
		$query_tree = mysql_query("select * from tree_name where tid= '".$row1['tree_name']."'");
	  //echo "select * from tree_name where tid= '".$row['tree_name']."'";
		$result_tree = mysql_fetch_array($query_tree);
		
		$query_image = mysql_query("SELECT info.`aid`,`image_path`.`pid` , image_path.`img_path`,info.`tree_name` FROM info
								INNER JOIN `image_path` ON info.pid = image_path.pid WHERE info.`pid`='".$row1['pid']."'");
								
		
																				
		$result_image = mysql_fetch_array($query_image);

		$time = explode("_",$row1['current_time1']);
		$b = ($time[3] == "1")? "pm" : "am";
		$time = $time[0].":".$time[1].":".$time[2]." ".$b;
	  $query_tree = mysql_query("select * from tree_name where tid= '".$row1['tree_name']."'");

	  $result_tree = mysql_fetch_array($query_tree);
	  
		
		 $res_carbon_query = mysql_fetch_array($carbon_query);
	  
		  if($res_carbon_query['speed'] != "")
		  {
		  $res3 = "select `".$res_carbon_query['speed']."` from carbon where `age` = '" .$res_carbon_query['age']."'";
	  $carbon = mysql_query($res3);
	  
	 // echo $res3;
		  
	  $res_carbon = mysql_fetch_array($carbon);
		  }
		
		echo "<tr>";

		echo "<td align ='left' style='width:10%;'>" . $sr . "</td>";
		
	  echo "<td align ='left' style='width:10%;'>" . $result_tree['tree_name'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $result_tree['scientific_name'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row1['width'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row1['height'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row1['diameter_of_tree'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row1['age'] . "</td>";

	  echo "<td align ='left' style='width:10%;'>" . $row1['con'] . "</td>";
	  
	  

	   echo "<td  ' style='width:10%;'>" . $row1['lng'] . "</td>";	  

	   echo "<td  ' style='width:10%;'>" . $row1['lat'] . "</td>";	  
	   
	   echo "<td align ='left' style='width:10%;'>" . $result_tree['flowering_season'] . "</td>";
	  
	  echo "<td align ='left' style='width:10%;'>" . $result_tree['flower_color'] . "</td>";
	
		echo "<td align ='left' style='width:10%;'>" . $result_tree['fruiting_season'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $result_tree['native'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $result_tree['growth_speed'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $result_tree['wild_cultivated'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $result_tree['use'] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $time . "</td>";
		echo "<td align ='left' style='width:10%;'>" . $res_carbon[$res_carbon_query['speed']] . "</td>";
		echo "<td align ='left' style='width:10%;'>" . "<div align='left'><img src='$result_image[img_path]' style='height:80; width:80'></div></td>";
  echo "</tr>";
	}
	
  }


?>
</table>
<?php
echo "</td>";
 
}
?>
	
		</div>
    
   
    

    	
   </div> 

<!--<div id="footer">Copyright © 2012.Smart Survey All Rights Reserved.Website Designed & Developed by Kalpak Solutions</div>-->





</body>
</html>