PageRenderTime 59ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/all-files-as-on-july1-moved-here/seasonwatch/listobservations.php

https://github.com/pavanesh2009/seasonwatch
PHP | 301 lines | 242 code | 45 blank | 14 comment | 19 complexity | 31a2caf08afa60fa16c21eeecf36393b MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. include './includes/dbc.php';
  3. mysql_select_db("ncbs_test");
  4. page_protect();
  5. //print_r($HTTP_POST_VARS);
  6. ?>
  7. <!--delete code from user-->
  8. <?php
  9. if($_GET['id']!= "")
  10. {
  11. $usertreeid=($_GET['id']);
  12. $observationid=($_GET['observationId']);
  13. //echo observationid;
  14. $sql1 = "DELETE FROM user_tree_observations
  15. WHERE user_tree_id= '$usertreeid' AND observation_id='$observationid'";
  16. //echo "sql1";
  17. mysql_query($sql1,$link)or die("Insertion Failed:" .mysql_error());
  18. echo "<div class=\"notice\">Successfully Deleted</div>";
  19. }
  20. ?>
  21. <html lang="en">
  22. <head>
  23. <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
  24. <title>Edit Observation</title>
  25. <link type="text/css" rel="stylesheet" href="js/thickbox/thickbox.css"></link>
  26. <script language="javascript" src="js/thickbox/thickbox.js"></script>
  27. <link rel="stylesheet" href="blueprint/screen.css" type="text/css" media="screen, projection">
  28. <link rel="stylesheet" href="blueprint/print.css" type="text/css" media="print">
  29. <link rel="stylesheet" href="blueprint/plugins/fancy-type/screen.css" type="text/css" media="screen, projection">
  30. <script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
  31. <link rel="stylesheet" href="css/styles_new.css" type="text/css">
  32. <link type="text/css" rel="stylesheet" href="js/thickbox/thickbox.css"></link>
  33. <script language="javascript" src="js/thickbox/thickbox.js"></script>
  34. <link type="text/css" href="js/calendar/themes/blitzer/ui.datepicker.css" rel="stylesheet" />
  35. <script language="javascript" src="js/calendar/ui/ui.core.js"></script>
  36. <script language="javascript" src="js/calendar/ui/ui.datepicker.js"></script>
  37. <link type="text/css" href="js/calendar/demos.css" rel="stylesheet" />
  38. <!--datepicker Script-->
  39. <script type="text/javascript">
  40. $(function() {
  41. $("#obdate").datepicker({minDate: -120, maxDate: '0M +0D', dateFormat: 'yy-mm-dd'});
  42. });
  43. $(function() {
  44. $("#obdate1").datepicker({minDate: -120, maxDate: '0M +0D', dateFormat: 'yy-mm-dd'});
  45. });
  46. </script>
  47. <script type = "text/javascript">
  48. function confirmDelete(delUrl,observationid) {
  49. if (confirm("Are you sure you want to delete")) {
  50. // alert(observationid);
  51. url = 'listobservations.php?id='+delUrl+'&observationId='+observationid;
  52. //alert(url);
  53. window.document.location = url;
  54. }
  55. else
  56. {
  57. url = 'listobservations.php';
  58. window.document.location = url;
  59. }
  60. }
  61. </script>
  62. <?php
  63. include ("contribheader_head.php");
  64. ?>
  65. </head>
  66. <body>
  67. <?php
  68. include ("contribheader_body.php");
  69. ?>
  70. <div class="container first_image" style="-moz-border-radius-bottomleft: 10px; -moz-border-radius-bottomright: 10px;">
  71. <table>
  72. <tbody>
  73. <tr>
  74. <td/>
  75. </tr>
  76. </tbody>
  77. </table>
  78. <div>
  79. <hr/>
  80. </div>
  81. <table>
  82. <tr>
  83. <td>
  84. <p>Filter by Tree Name</p>
  85. <form method="POST" action=<?php echo $_SERVER['PHP_SELF'];?> name="filterform">
  86. <?php
  87. $sql=mysql_query("SELECT DISTINCT(species_primary_common_name), Species_master.species_id FROM Species_master JOIN (trees, user_tree_table) ON trees.tree_id = user_tree_table.tree_id AND trees.species_id = Species_master.species_id AND user_tree_table.user_id = '$_SESSION[user_id]'");
  88. $data1="<SELECT name=species_control>";
  89. while($row=mysql_fetch_array($sql))
  90. {
  91. $data1 .= "<option value=".$row['species_id'].">".$row['species_primary_common_name']."</option>";
  92. }
  93. $data1 .= "</select>";
  94. echo $data1;
  95. ?>
  96. <input type="submit" name="Submit" id="Submit" value="Submit" class=buttonstyle>
  97. </td>
  98. </form>
  99. <td>
  100. <div>Filter By Date</div>
  101. <form method="POST" action="datefilter.php" name="filterform1">
  102. <div class="demo">
  103. From-:<input id="obdate" name="obdate" type="text"/>
  104. </div>
  105. <div style="display: none;" class="demo-description">
  106. </div>
  107. </td>
  108. <td>
  109. <div class="demo1">
  110. To-:<input id="obdate1" name="obdate1" type="text"/>
  111. </div>
  112. <div style="display: none;" class="demo-description">
  113. </div>
  114. </td>
  115. <td>
  116. <input type="submit" name="Submit" id="Submit" value="Submit" class=buttonstyle>
  117. </td>
  118. </tr>
  119. </table>
  120. </form>
  121. <table id="table1" class="tablesorter" cellspacing="0" cellpadding="3" style="width: 930px; margin-left: auto; margin-right: auto;">
  122. <colgroup>
  123. <col style="width: 5px;"/>
  124. <col style="width: 790px;"/>
  125. <col style="width: 650px;"/>
  126. <col style="width: 750px;"/>
  127. <col style="width: 750px;"/>
  128. <col style="width: 650px;"/>
  129. <col style="width: 650px;"/>
  130. <col style="width: 650px;"/>
  131. <col style="width: 650px;"/>
  132. </colgroup>
  133. <thead>
  134. <tr>
  135. <th class="header">No</th>
  136. <th class="header">Primary Common Name</th>
  137. <th class="header">Tree Nickname</th>
  138. <th class="header">Observation Date</th>
  139. <th class="header">Is Leaf Fresh</th>
  140. <th class="header">Is Flower Open</th>
  141. <th class="header">Is Fruit Ripe</th>
  142. <th>Edit</th>
  143. <th>Delete</th>
  144. </tr>
  145. </thead>
  146. <tbody>
  147. <?php
  148. $speciesid="";
  149. $speciesid=$_POST['species_control'];
  150. //echo $speciesid;
  151. $count=0;
  152. print "<tr class='delboxtr'>";
  153. //$user_tree_table_settings = mysql_query("SELECT tree_nickname, tree_id FROM user_tree_table WHERE user_id='".$_SESSION[user_id]."'");
  154. if($speciesid=="")
  155. {
  156. $user_tree_table_settings = mysql_query("SELECT user_tree_table.user_tree_id,tree_nickname,
  157. user_tree_observations.observation_id,
  158. user_tree_observations.date,
  159. is_leaf_fresh, is_flower_open, is_fruit_ripe,
  160. Species_master.species_primary_common_name
  161. FROM user_tree_observations
  162. INNER JOIN (users, user_tree_table, trees,Species_master)
  163. ON user_tree_table.user_tree_id = user_tree_observations.user_tree_id
  164. AND user_tree_table.user_id='$_SESSION[user_id]'
  165. AND users.user_id=user_tree_table.user_id
  166. AND user_tree_table.tree_id=trees.tree_id
  167. AND trees.species_id=Species_master.species_id
  168. ORDER BY user_tree_table.tree_id");
  169. }
  170. else
  171. {
  172. $user_tree_table_settings = mysql_query("SELECT user_tree_table.user_tree_id,tree_nickname,
  173. user_tree_observations.observation_id,user_tree_observations.date,
  174. is_leaf_fresh, is_flower_open, is_fruit_ripe,
  175. Species_master.species_primary_common_name
  176. FROM user_tree_observations INNER JOIN (users, user_tree_table, trees,Species_master)
  177. ON user_tree_table.user_tree_id = user_tree_observations.user_tree_id
  178. AND user_tree_table.user_id='$_SESSION[user_id]'
  179. AND users.user_id=user_tree_table.user_id
  180. AND user_tree_table.tree_id=trees.tree_id
  181. AND trees.species_id=Species_master.species_id
  182. AND trees.species_id='$speciesid'
  183. ORDER BY user_tree_table.tree_id");
  184. }
  185. while ($row_settings = mysql_fetch_array($user_tree_table_settings))
  186. {
  187. print "<tr>";
  188. $count++;
  189. print "<td style='width:220px'>".$count."</td>";
  190. print "<td>".$row_settings['species_primary_common_name']."</td>";
  191. print "<td>".$row_settings['tree_nickname']."</td>";
  192. $printdate = date("d-m-Y",strtotime($row_settings['date']));
  193. //echo $printdate;
  194. print "<td>".$printdate. "</td>";
  195. //print "<td>".$row_settings[observation_id]. "</td>";
  196. //print "<td>".$row_settings['user_tree_id']. "</td>";
  197. $fresh_status = $row_settings['is_leaf_fresh'];
  198. if($fresh_status == '1')
  199. {
  200. $fresh_status = 'Yes';
  201. }
  202. else
  203. {
  204. if($fresh_status == '0')
  205. {
  206. $fresh_status = 'No';
  207. }
  208. else
  209. $fresh_status='Dont know';
  210. }
  211. echo "<td>" . $fresh_status . "</td>";
  212. //print "<td>".$row_settings['is_leaf_fresh']. "</td>";
  213. $open_status = $row_settings['is_flower_open'];
  214. if($open_status == '1')
  215. $open_status = 'Yes';
  216. else
  217. if($open_status == '0')
  218. $open_status = 'No';
  219. else
  220. if($open_status == '2')
  221. $open_status = 'Dont know';
  222. echo "<td>" . $open_status . "</td>";
  223. //print "<td>".$row_settings['is_flower_open']. "</td>";
  224. $ripe_status = $row_settings['is_fruit_ripe'];
  225. if($ripe_status == '1')
  226. $ripe_status = 'Yes';
  227. else
  228. if($ripe_status == '0')
  229. $ripe_status = 'No';
  230. else
  231. if($ripe_status== '2')
  232. $ripe_status = 'Dont know';
  233. echo "<td>" . $ripe_status . "</td>";
  234. //print "<td>".$row_settings['is_fruit_ripe']. "</td>";
  235. $editobservationLink = "<a class=thickbox rel=gallery-plants href=\"editobservations.php?usertreeid=".$row_settings['user_tree_id']."&observationid=".$row_settings['observation_id']."&TB_iframe=true&height=500&width=700\">Edit</a>";
  236. print "<td>$editobservationLink</td>";
  237. $var=$row_settings['user_tree_id'];
  238. $var1=$row_settings['observation_id'];
  239. $deleteobservationLink = "<a href='listobservations.php' onclick=confirmDelete('$var','$var1');>Delete</a>";
  240. //$deletetreelink="<a class=thickbox href=\"deleteobservation.php?usertreeid=".$row_settings['user_tree_id']."&observationid=".$row_settings['observation_id']."&TB_iframe=true&height=500&width=700\">Delete</a>";
  241. print "<td>$deleteobservationLink</td>";
  242. print "</tr>";
  243. }
  244. echo "</tbody></table>";
  245. ?>
  246. <html>
  247. <p align="center">
  248. <input name="doRefresh" type="button" id="doRefresh" value="Refresh All" onClick="location.reload();">
  249. </p>
  250. </div>
  251. </div>
  252. <div class="container bottom">
  253. <?php mysql_close($link);?>
  254. </div>
  255. </body>
  256. </html>