-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_cluster_jun18.php
executable file
·886 lines (729 loc) · 32.3 KB
/
data_cluster_jun18.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
<?php
session_start();
include("db.php");
$strSpecies='Type a species name';
$strLocation='Type a location name';
$page_title="MigrantWatch: Data";
include("main_includes.php");
$kml_text="<span class='help_text_content'><h4>KML</h4>KML is a file format used to display geographic data in an earth browser, such as Google Earth, Google Maps</span>";
?>
<?
include("header.php");
include("google_maps_api.php");
$where_clause = "";
$sql = "";
$sql = "SELECT l1.id,s.common_name,l.location_name,l.city,st.state,u.user_name,l1.sighting_date,l1.obs_type,l1.frequency,l1.obs_start,l1.user_friend,";
$sql .= "l.latitude,l.longitude,l.location_id";
$sql .= " FROM migwatch_l1 l1 INNER JOIN migwatch_users u ON l1.user_id=u.user_id ";
$sql .= " INNER JOIN migwatch_locations l ON l.location_id=l1.location_id ";
$sql .= " INNER JOIN migwatch_species s ON s.species_id=l1.species_id ";
$sql .= " INNER JOIN migwatch_states st ON st.state_id = l.state_id ";
if( ( $_GET['species'] != "All" ) || $_GET['species'] != "" ) {
$species = $_GET['species'];
} else {
$species = "All";
}
if( $species && is_numeric($species) ) {
//$where_clause = " WHERE l1.species_id=". $species;
$tempsql = "select common_name from migwatch_species where species_id=".$species;
$result = mysql_query($tempsql);
if($result) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$strSpecies = $row{'common_name'};
}
}
}
if($species){
if($species != 'All' )
if ($where_clause == ""){
$where_clause = " WHERE l1.species_id = ". $species;
} else {
$where_clause .= " AND l1.species_id=".$species;
}
}
if( ($_GET['location'] != 'All') || ($_GET['location'] != '') || ($_GET['location'] != $locationHintText )) {
$location = $_GET['location'];
} else {
$location = 'All';
}
if( $location && is_numeric($location) ) {
//$where_clause = " WHERE l1.location_id=". $location;
$tempsql = "select location_name, city,district from migwatch_locations where location_id='$location'";
$result = mysql_query($tempsql);
if($result) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$strLocation = $row{'location_name'};
if( $row['city'] != "" ) {
$strLocation .= ", ". $row['city'];
}
if( $row['district'] != "" ) {
$strLocation .= ", " . $row['district'];
}
}
}
}
if($location){
if($location != 'All' )
if ($where_clause == ""){
$where_clause = " WHERE l1.location_id = ".$location;
} else {
$where_clause .= " AND l1.location_id=".$location;
}
}
if( $_GET['season'] != '') {
if ( $_GET['season'] != 'All' ) {
$season = $_GET['season'];
}
}else {
$season = getCurrentSeason();
}
$seasonArr = explode('-',$season);
$seasonStart = $seasonArr[0];
$seasonEnd = $seasonArr[1];
if ($where_clause == "") {
$where_clause = " WHERE l1.obs_start BETWEEN '$seasonStart-07-01' AND '$seasonEnd-06-30' AND l1.obs_start <> '1999-11-30' AND l1.obs_start <> '0000-00-00' ";
} else {
$where_clause .= " AND l1.obs_start BETWEEN '$seasonStart-07-01' AND '$seasonEnd-06-30' AND l1.obs_start <> '1999-11-30' AND l1.obs_start <> '0000-00-00' ";
}
if( ($_GET['user'] != 'All') || ($_GET['user'] != '')) {
$user = $_GET['user'];
} else {
$user = 'All';
}
if ($user){
if($user != 'All')
if ($where_clause == "") {
$where_clause = " WHERE l1.user_id = ".$_GET['user'];
} else {
$where_clause .= " AND l1.user_id = ".$_GET['user'];
}
$tempsql = "Select user_name from migwatch_users where user_id=".$_GET['user'];
$result = mysql_query($tempsql);
$strUserName = "";
if($result){
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
$strUserName = $row{'user_name'};
}
}
if( is_numeric($_GET['state']) ) {
$state = $_GET['state'];
} else {
$state = 'All';
}
if( is_numeric($state)) {
if($where_clause == '') {
$where_clause = " WHERE st.state_id = ".$_GET['state'];
} else {
$where_clause .= " AND st.state_id = ".$_GET['state'];
}
}
if ($_GET['obsfrq'] != "1"){
if($where_clause == ""){
switch($_GET['obsfrq']){
case 2:
$where_clause = " WHERE l1.frequency = 'Daily' ";
$strFrequency = "Daily only";
break;
case 3:
$where_clause = " WHERE l1.frequency in ('Weekly','Daily','Twice a week') ";
$strFrequency = "Weekly or more frequent";
break;
case 4:
$where_clause = " WHERE l1.frequency in ('Fortnightly','Weekly','Daily','Twice a week') ";
$strFrequency = "Fortnightly or more frequent";
break;
case 5:
$where_clause = " WHERE l1.frequency in ('Monthly','Fortnightly','Weekly','Daily','Twice a week') ";
$strFrequency = "Monthly or more frequent";
break;
default:
$where_clause = "";
break;
}
} else {
switch($_GET['obsfrq']){
case 2:
$where_clause .= " AND l1.frequency = 'Daily' ";
$strFrequency = "Daily only";
break;
case 3:
$where_clause .= " AND l1.frequency in ('Weekly','Daily','Twice a week') ";
$strFrequency = "Weekly or more frequent";
break;
case 4:
$where_clause .= " AND l1.frequency in ('Fortnightly','Weekly','Daily','Twice a week') ";
$strFrequency = "Fortnightly or more frequent";
break;
case 5:
$where_clause .= " AND l1.frequency in ('Monthly','Fortnightly','Weekly','Daily','Twice a week') ";
$strFrequency = "Monthly or more frequent";
break;
default:
$where_clause .= "";
break;
}
}
}
else
$strFrequency = "Any";
if($_GET['type'] != 'All' || $_GET['type'] != '') {
$type = $_GET['type'];
} else {
$type = 'All';
}
if($type) {
if($type != 'All') {
if ($where_clause == "")
$where_clause = " WHERE l1.valid = 1 AND deleted = '0' AND l1.obs_type = '$type' ";
else
$where_clause .= " AND l1.valid = 1 AND deleted = '0' AND l1.obs_type = '$type' ";
}
} /*else {
if ($where_clause == "")
$where_clause = " WHERE l1.valid = 1 AND deleted = '0'";
else
$where_clause .= " AND l1.valid = 1 AND deleted = '0'";
}*/
if ($_SESSION['dev_entries'] == 1) {
// Show all entries : including the ones from developer
} else {
$where_clause .= " AND u.user_name != 'Developer'";
}
$where_clause .= " AND s.Active = '1' order by l.latitude,l.longitude";
$sql .= $where_clause;
?>
<script type="text/javascript">
function createMarker(map, point,icon) {
var marker = new GMarker(point,icon);
return marker;
}
function createPop(marker, html_content) {
GEvent.addListener(marker, "click", function() {
marker.openExtInfoWindow(
map,
"custom_info_window_red",
"<div>Loading...</div>",
{
ajaxUrl: "getcontent.php?" + html_content,
beakOffset: 3
}
);
});
return marker;
}
var map=null;
var markers = [];
var markerClusterer = null;
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById('map'));
map.setCenter(new GLatLng(20.21,77.86), 4);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
var icon1 = new GIcon(G_DEFAULT_ICON);
icon1.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|1e8a94";
var icon2 = new GIcon(G_DEFAULT_ICON);
icon2.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|e86b1f";
var icon3 = new GIcon(G_DEFAULT_ICON);
icon3.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|2aa212";
var icon4 = new GIcon(G_DEFAULT_ICON);
icon4.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|634f00";
var icon5 = new GIcon(G_DEFAULT_ICON);
icon5.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|941e23";
var icon6 = new GIcon(G_DEFAULT_ICON);
icon6.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|7a941e";
var icon7 = new GIcon(G_DEFAULT_ICON);
icon7.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|ffe400";
var icon8 = new GIcon(G_DEFAULT_ICON);
icon8.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|768066";
var icon9 = new GIcon(G_DEFAULT_ICON);
icon9.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|8f627a";
var icon10 = new GIcon(G_DEFAULT_ICON);
icon10.image = "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|6a1744";
<?
$table_sql = $sql;
$result = mysql_query($table_sql);
$i = 1;
list($startSeason,$endSeason) = explode('-',$season);
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$lat= $line['latitude'];
$lng = $line['longitude'];
if($line['latitude']) {
if(($lat == $oldlat) && ($lng == $oldlng)) {
} else {
echo "var point = new GLatLng(" . $line['latitude'] . "," . $line['longitude'] .");\n";
if (strtotime($line['sighting_date']) >= strtotime("$startSeason-07-01") && strtotime($line['sighting_date']) <= strtotime("$startSeason-07-31")) {
print "var marker_get = createMarker(map, point, icon10);\n\n";
print "markers.push(marker_get);\n\n";
}
elseif (strtotime($line['sighting_date']) > strtotime("$startSeason-08-01") && strtotime($line['sighting_date']) <= strtotime("$startSeason-08-15")) {
print "var marker_get = createMarker(map, point, icon9);\n\n";
print "markers.push(marker_get);\n\n";
}
elseif (strtotime($line['sighting_date']) > strtotime("$startSeason-08-15") && strtotime($line['sighting_date']) <= strtotime("$startSeason-08-31")) {
print "var marker_get = createMarker(map, point, icon8);\n\n"; print "markers.push(marker_get);\n\n";
}
elseif (strtotime($line['sighting_date']) > strtotime("$startSeason-08-31") && strtotime($line['sighting_date']) <= strtotime("$startSeason-09-15")) {
print "var marker_get = createMarker(map, point, icon7);\n\n"; print "markers.push(marker_get);\n\n";
}
elseif (strtotime($line['sighting_date']) > strtotime("$startSeason-09-15") && strtotime($line['sighting_date']) <= strtotime("$startSeason-09-30")) {
print "var marker_get = createMarker(map, point,icon6);\n\n"; print "markers.push(marker_get);\n\n";
}
elseif (strtotime($line['sighting_date']) > strtotime("$startSeason-09-30") && strtotime($line['sighting_date']) <= strtotime("$startSeason-10-15")) {
print "var marker_get = createMarker(map, point, icon5);\n\n"; print "markers.push(marker_get);\n\n";
}
elseif (strtotime($line['sighting_date']) > strtotime("$startSeason-10-15") && strtotime($line['sighting_date']) <= strtotime("$startSeason-10-31")) {
print "var marker_get = createMarker(map, point, icon4);\n\n"; print "markers.push(marker_get);\n\n";
}
elseif (strtotime($line['sighting_date']) > strtotime("$startSeason-10-31") && strtotime($line['sighting_date']) <= strtotime("$startSeason-11-15")) {
print "var marker_get = createMarker(map, point, icon3);\n\n"; print "markers.push(marker_get);\n\n";
}
elseif (strtotime($line['sighting_date']) > strtotime("$startSeason-11-15") && strtotime($line['sighting_date']) <= strtotime("$startSeason-11-30")) {
print "var marker_get = createMarker(map, point, icon2);\n\n"; print "markers.push(marker_get);\n\n";
} else {
print "var marker_get = createMarker(map, point, icon1);\n\n"; print "markers.push(marker_get);\n\n";
}
$location_id_get = $line['location_id'];
$url_add = '';
if($_GET) {
foreach( $_GET as $key => $value ) {
//if( strtolower($value) != 'all' && $value !='' ) {
if(!$_GET['location']) {
$url_add .="&location=" . $location_id_get;
} elseif($key == 'location') {
$url_add .="&location=" . $location_id_get;
}
$url_add .="&" . $key . "=" . $value;
}
} else {
$url_add = "location=" . $location_id_get;
}
print "var final_content = '" . $url_add . "';";
print "createPop(marker_get,final_content);";
?>
GEvent.addDomListener(map, 'extinfowindowupdate',function(){
$('.ticker').each(function() {
var ticker = $(this);
$(this).cycle({
fx: 'fade',
speed: 'fast',
timeout: 0,
next: '#next2',
prev: '#prev2'
});
});
});
<?
$oldlat = $lat;
$oldlng = $lng;
}
}
}
?>
refreshMap();
}
}
function refreshMap() {
if (markerClusterer != null) {
markerClusterer.clearMarkers();
}
//var zoom = parseInt(-1, 10);
var zoom = 12;
var size = parseInt(-1, 10);
var style = -1;
zoom = zoom == -1 ? null : zoom;
size = size == -1 ? null : size;
style = style == "-1" ? null: parseInt(style, 10);
markerClusterer = new MarkerClusterer(map, markers, {maxZoom: zoom, gridSize: size});
}
</script>
<body onload="load()" onunload="GUnload()">
<script src='http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/src/markerclusterer.js' type='text/javascript'></script>
<script src="http://gmaps-utility-library-dev.googlecode.com/svn/trunk/extinfowindow/src/extinfowindow.js" type="text/javascript"></script>
<link type="text/css" rel="Stylesheet" media="screen" href="http://gmaps-utility-library-dev.googlecode.com/svn/trunk/extinfowindow/examples/css/redInfoWindow.css"/>
<link type="text/css" rel="Stylesheet" media="screen" href="http://gmaps-utility-library-dev.googlecode.com/svn/trunk/extinfowindow/examples/css/blueInfoWindow.css"/>
<link type="text/css" rel="Stylesheet" media="screen" href="http://gmaps-utility-library-dev.googlecode.com/svn/trunk/extinfowindow/examples/css/bubbleInfoWindow.css"/>
<script src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.72.js" type="text/javascript"></script>
<style>
<style>
.ticker { width:250px; height:100px; border:1px solid #aaaaaa; overflow:auto; }
.ticker dt { font:normal 14px Georgia; padding:0 10px 5px 10px; background-color:#e5e5e5; padding-top:10px; border:1px solid #ffffff; border-bottom:none; border-right:none; position:relative; }
.ticker dd { margin-left:0; font:normal 11px Verdana; padding:0 10px 10px 10px; border-bottom:1px solid #aaaaaa; background-color:#e5e5e5; border-left:1px solid #ffffff; position:relative; }
.ticker dd.last { border-bottom:1px solid #ffffff; }
.ticker div { margin-top:0; }
</style>
<div class="container first_image">
<FORM name="reports" action="data.php" method="GET">
<table class="filter">
<tr>
<td style=''>season</td>
<td>sighting type</td>
<td>species</td>
<td>participant</td>
</tr>
<td style="width:190px;">
<select style="width:85%;font-size:12px;" name='season'>
<option value='All'>All seasons</option>
<?php
/**
* Use the current month and year to find out the last season to be
* displayed in the drop down. (Season : 1st July - 31st Aug)
*/
$currentMonth = date('m');
$currentYear = date('Y');
/**
* If the current month is greater than June i.e July and onwords only then display
* the current year in the season
*/
if ($currentMonth > 6) {
$endSeason = $currentYear;
} else {
$endSeason = $currentYear - 1;
}
// The sighting started in 2007-2008 so start from this season
for ($i = 2007;$i <= $endSeason; $i++) {
$fromTo = "$i-".($i+1);
echo '<option value="' . $fromTo . '"';
if (empty($_GET)) {
echo ' selected>';
} else {
echo ($_GET['season'] == $fromTo) ? ' selected>' : '>';
}
echo $fromTo;
echo '</option>';
}
?>
</select>
<? $current_season = getCurrentSeason();
if( $_GET['season'] != '' && $_GET['season'] != $current_season ) {
?>
<a title="remove season" href="#" onClick="get_remove('season');">X</a>
<? } ?>
</td> <td style="width:190px;">
<select name="type" style="width:85%">
<option value="All">All</option>
<option value="first"<?php if($type == 'first') print("selected"); ?>>First</option>
<option value="general"<?php if($type == 'general') print("selected"); ?>>General</option>
<option value="last"<?php if($type == 'last') print("selected"); ?>>Last</option>
</select>
<? if( $_GET['type'] != "All" && $_GET['type'] != '') { ?>
<a title="remove sighting type" href="#" onclick="get_remove('type');">X</a>
<? } ?>
</td>
<td style="width:300px;">
<input type='text' id='species' size="25" style="width:85%;border:solid 1px #666;padding:2px" value="<? echo $strSpecies; ?>">
<input type='hidden' id='species_hidden' name='species' value="<? echo $species; ?>">
<? if( is_numeric($_GET['species'] )) { ?>
<a title="remove species" href="#" onclick="get_remove('species');">X</a>
<? } ?>
</td>
<td style="width:240px;">
<select name=user style="width:85%">
<option value='All'>-- Select --</option>
<?php
// The current season..
$today = getdate();
$currentSeason = ($today['mon'] > 6) ? $today['year'] : $today['year'] - 1;
$season = (isset($_POST['season'])) ? substr($_POST['season'], 0, 4) : $currentSeason;
$seasonEnd = (int)$season + 1;
$sql = "SELECT DISTINCT u.user_name, u.user_id from migwatch_users u INNER JOIN migwatch_l1 l1 ON ";
$sql .= "l1.user_id=u.user_id WHERE l1.valid=1 ";
//$sql .= "AND l1.obs_start BETWEEN '$season-07-01' AND '$seasonEnd-06-30' ";
$sql .= "ORDER BY u.user_name";
$result = mysql_query($sql);
if(mysql_num_rows($result) <= 0) {
$sql = "SELECT DISTINCT u.user_name, u.user_id from migwatch_users u INNER JOIN migwatch_l1 l1 ON ";
$sql .= "l1.user_id=u.user_id WHERE l1.valid=1 ORDER BY u.user_name";
$result = mysql_query($sql);
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
print "<option value=".$row{'user_id'};
if (($_GET['user'] != "") && ($_GET['user'] == $row{'user_id'}))
print " selected ";
print ">".$row{'user_name'}."</option>";
}
?>
</select>
</div>
<? if( is_numeric( $_GET['user'] )) { ?>
<a href="#" onclick="get_remove('user');">X</a>
<? } ?>
</td>
</tr>
<tr>
<td colspan="2">state</td>
<td colspan="2">location</td>
</tr>
<tr>
<td colspan="2" style="">
<select style="width:93%;" id="state" name=state >
<option value="all">All the States</option>
<?php
$result = mysql_query("SELECT state_id, state FROM migwatch_states order by state");
if($result){
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
if($row['state'] != 'Not In India') {
print "<option value=".$row{'state_id'};
if (($_GET['state'] != "") && ($_GET['state'] == $row{'state_id'}))
print " selected ";
print ">".$row{'state'}."</option>";
} else {
$other_id = $row['state_id'];
$other = $row['state'];
}
}
print("<option value=".$other_id);
if($other_id == $state_id)
print " selected ";
print ">".$other."</option>\n";
}
?></select>
<? if( is_numeric($_GET['state'] )) { ?>
<a title="remove state" href="#" onclick="get_remove('state');">X</a>
<? } ?>
</td>
<td style="width:400px;">
<input type='text' id='location' value="<? echo $strLocation; ?>" style="padding:2px;width:85%;border:solid 1px #666">
<input type='hidden' id='location_hidden' name='location' value="<? echo $location; ?>">
<? if( is_numeric($_GET['location'] )) { ?>
<a title="remove location" href="#" onclick="get_remove('location');">X</a>
<? } ?>
</td>
<td style='width:200px;text-align:right;'><a href='data.php' title='unselect all the filters' class='submit unselect'>unselect all</a> <input type='submit' class='submit' value='go'> </td>
</form>
</tr>
</table>
<?
$url = '';
foreach( $_GET as $key => $value ) {
if( strtolower($value) != 'all' && $value !='' ) {
$url_add .="&" . $key . "=" . $value;
}
}
$result = mysql_query($table_sql);
if (mysql_num_rows($result) > 0) {
if($_SESSION['userid']) {
?>
<div class='container page_layout' style='height:50px; font-size:14px;'>
<b>Download data</b> <a title='Download data below as KML' href='download.php?output=kml<? echo $url_add; ?>'>KML</a>
(<a class='help_text' title="<? echo $kml_text; ?>" href='#'>read more</a>)
| <a title='Download data below as CSV' href='download.php?output=csv<? echo $url_add; ?>'>CSV</a>
</div>
<?
}
?>
<div class='container' style="width:930px;margin-left:auto;margin-right:auto;border-top:solid 1px #d95c15" id='tab-set'>
<ul class='tabs'>
<li style='margin-left:0'><a href='#text1' class='selected'>map</a></li>
<li style='margin-left:0'><a href='#text2'>tabular</a></li>
</ul>
<div id='text1'>
<div id="map" style="width:930px;height:500px;">Loading maps. This might take some time</div><br><br>
</div>
<div id='text2'>
<table id="table1" class="tablesorter">
<thead>
<tr>
<th style="width:50px"> No</th>
<th style='width:200px;'>Common Name</th>
<th style='width:200px'>Location</th>
<th style='width:100px'>Date</th>
<th style='width:100px'>Sighting type</th>
<th style='width:50px'>Count</th>
<th style='width:200px'>Reported by</th>
</tr>
</thead>
<tbody>
<?
$i=1;
list($startSeason,$endSeason) = explode('-',$_GET['season']);
//if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
print "<tr>";
print "<td style='text-align:center'><a href='sighting.php?id=" . $row{'id'} ."'>" . $i . "</a></td>";
print "<td>".$row{'common_name'}."</td>";
print "<td>".$row{'location_name'}.", ".$row{'city'}.", ".$row{'state'}."</td>";
print "<td>".date("Y-m-d",strtotime($row{'sighting_date'}))."</td>";
print "<td>" . ucfirst($row{'obs_type'}) . "</td>";
($row['number'] > 0 ) ? print "<td>".$row{'number'}."</td>" : print "<td> -- </td>";
print "<td style='border-right:solid 1px #ffcb1a'>".$row{'user_name'}."</td>";
print "</tr>";
$i++;
}
?>
</tbody>
</table>
<div id="pager" class="column span-7" style="" >
<form name="" action="" method="post">
<table >
<tr>
<td><img src='pager/icons/first.png' class='first'/></td>
<td><img src='pager/icons/prev.png' class='prev'/></td>
<td><input type='text' size='8' class='pagedisplay'/></td>
<td><img src='pager/icons/next.png' class='next'/></td>
<td><img src='pager/icons/last.png' class='last'/></td>
<td>
<select class='pagesize'>
<option selected='selected' value='10'>10</option>
<option value='20'>20</option>
<option value='30'>30</option>
<option value='40'>40</option>
</select>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
<? } else { ?>
<div class='container notice' style="width:900px;margin-left:auto;margin-right:auto;">No results</div>
<? }
include("credits.php");
?>
</div>
</div>
</div>
<div class="container bottom">
</div>
<? include("tab_include.php"); ?>
<script type='text/javascript'>
$().ready(function() {
var state_val = $('#state').val();
$('#species').emptyonclick();
$('#location').emptyonclick();
$("#species").autocomplete("autocomplete_reports.php", {
width: 260,
selectFirst: false,
matchSubset :0,
mustMatch: true,
});
$("#species").result(function(event , data, formatted) {
if (data) {
document.getElementById('species_hidden').value = data[1];
}
});
$('#location').autocomplete("auto_location_watchlist.php", {
width: 400,
selectFirst: false,
matchSubset :0,
cache:false,
mustMatch: true,
extraParams: {state: function() { return $("#state").val(); } },
});
$("#location").result(function(event , data, formatted) {
if (data) {
document.getElementById('location_hidden').value = data[1];
}
});
});
function get_remove(parameter) {
<?
if($_GET['type']){
$remove_type = $_GET['type'];
}
if($_GET['species']){
$remove_species = $_GET['species'];
}
if($_GET['user']){
$remove_user = $_GET['user'];
}
if($_GET['state']){
$remove_state = $_GET['state'];
}
if($_GET['location']){
$remove_location = $_GET['location'];
}
if($_GET['season']){
$remove_season = $_GET['season'];
}
?>
var remove_season = '<? echo $remove_season; ?>';
var remove_type = '<? echo $remove_type; ?>';
var remove_species = '<? echo $remove_species; ?>';
var remove_user = '<? echo $remove_user; ?>';
var remove_state = '<? echo $remove_state; ?>';
var remove_location = '<? echo $remove_location; ?>';
if ( parameter == 'season') {
remove_season = '<? echo getCurrentSeason(); ?>';
}
if ( parameter == 'type') {
remove_type = 'All';
}
if (parameter == 'species') {
remove_species = 'All';
}
if (parameter == 'user') {
remove_user = 'All';
}
if (parameter == 'location') {
remove_location = 'All';
}
if ( parameter == 'state') {
remove_state = 'All';
}
var url = "data.php?season=" + remove_season + "&type=" + remove_type + "&species=" + remove_species + "&user=" + remove_user + "&state=" + remove_state + "&location=" + remove_location;
window.location = url;
}
function formatItem(row) {
var completeRow;
completeRow = new String(row);
var scinamepos = completeRow.lastIndexOf("(");
var rest = substr(completeRow,0,scinamepos);
var sciname = substr(completeRow,scinamepos);
var commapos = sciname.lastIndexOf(",");
sciname = substr(sciname,0,commapos);
var newrow = rest + ' <i>' + sciname + '</i>';
return newrow;
}
function isEmpty(s){
return ((s == null) || (s.length == 0))
}
// BOI, followed by one or more whitespace characters, followed by EOI.
var reWhitespace = /^\s+$/
// BOI, followed by one or more characters, followed by @,
// followed by one or more characters, followed by .,
// followed by one or more characters, followed by EOI.
var reEmail = /^.+\@.+\..+$/
var defaultEmptyOK = false
// Returns true if string s is empty or
// whitespace characters only.
function isWhitespace (s)
{ // Is s empty?
return (isEmpty(s) || reWhitespace.test(s));
}
function substr( f_string, f_start, f_length ) {
// http://kevin.vanzonneveld.net
// + original by: Martijn Wieringa
// * example 1: substr("abcdef", 0, -1);
// * returns 1: "abcde"
if(f_start < 0) {
f_start += f_string.length;
}
if(f_length == undefined) {
f_length = f_string.length;
} else if(f_length < 0){
f_length += f_string.length;
} else {
f_length += f_start;
}
if(f_length < f_start) {
f_length = f_start;
}
return f_string.slice(f_start,f_length);
}
</script>
<? include("footer.php"); ?>
<script type="text/javascript">
$(function() {
$("#table1")
.tablesorter({ headers: {
5: { sorter: false }, 6: { sorter: false }, 7 : { sorter: false }, 8: { sorter: false } },widthFixed: true, widgets: ['zebra']})
.tablesorterPager({container: $("#pager"), positionFixed: false});
$("#table2")
.tablesorter({widthFixed: true, widgets: ['zebra']})
.tablesorterPager({container: $("#pager2"), positionFixed: false});
});
</script>
</body>
</html>