-
Notifications
You must be signed in to change notification settings - Fork 0
/
aoi_report_ajax.php
230 lines (195 loc) · 7.3 KB
/
aoi_report_ajax.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
<?php
require('sw_aoi_class.php');
require("sw_config.php");
session_start();
$aoi_name = $_POST['aoiname'];
$a = $_SESSION[$aoi_name];
$report = $_POST['report'];
$itiscode = $_POST['itiscode'];
$species = stripslashes($_POST['species']);
$reportid = $_POST['reportid'];
//echo json_encode(array("header"=>"","rep"=>$aoi_name));die();
pg_connect($pg_connect);
$query2 = "select aoi_data from aoi where name = '$aoi_name'";
$result = pg_query($query2);
$row = pg_fetch_array($result);
$aoi_data = unserialize($row['aoi_data']);
$states = explode(":", $aoi_data['state_aoi']);
$bcr = explode(":", $aoi_data['bcr_aoi']);
if($states[0] == ""){
unset($states);
}
if($bcr[0] == ""){
unset($bcr);
}
if ($aoi_data['ecosys_aoi'] == 1) {
if ($report == 'landcover'){
$query = "select report, description from sw_reports_pre where ecosys_ogc_fid = 1 and type = 'landcover'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Land Cover Report for Full Extent</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'management') {
$query = "select report, description from sw_reports_pre where ecosys_ogc_fid = 1 and type = 'management'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Management Report for Full Extent</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'owner') {
$query = "select report, description from sw_reports_pre where ecosys_ogc_fid = 1 and type = 'ownership'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Ownership Report for Full Extent</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'status') {
$query = "select report, description from sw_reports_pre where ecosys_ogc_fid = 1 and type = 'status'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI GAP Status Report for Full Extent</h1>";
$response .= "<pre>{$grass}</pre>";
}
}
//echo json_encode(array("rep"=>$bcr[0]));die();
for ($i = 0; $i < sizeof($states); $i++){
if ($report == 'landcover'){
$query = "select report, description from sw_reports_pre where states_ogc_fid = '{$states[$i]}' and type = 'landcover'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Land Cover Report for {$row['description']}</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'management') {
$query = "select report, description from sw_reports_pre where states_ogc_fid = '{$states[$i]}' and type = 'management'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Management Report for {$row['description']}</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'owner') {
$query = "select report, description from sw_reports_pre where states_ogc_fid = '{$states[$i]}' and type = 'ownership'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Ownership Report for {$row['description']}</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'status') {
$query = "select report, description from sw_reports_pre where states_ogc_fid = '{$states[$i]}' and type = 'status'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI GAP Status Report for {$row['description']}</h1>";
$response .= "<pre>{$grass}</pre>";
}
}
//die();
for ($i = 0; $i < sizeof($bcr); $i++){
//echo json_encode(array("rep"=>$bcr[0]));die();
if ($report == 'landcover'){
$query = "select report, description from sw_reports_pre where bcr_ogc_fid = '{$bcr[$i]}' and type = 'landcover'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Land Cover Report for {$row['description']}</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'management') {
$query = "select report, description from sw_reports_pre where bcr_ogc_fid = '{$bcr[$i]}' and type = 'management'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Management Report for {$row['description']}</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'owner') {
$query = "select report, description from sw_reports_pre where bcr_ogc_fid = '{$bcr[$i]}' and type = 'ownership'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI Ownership Report for {$row['description']}</h1>";
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'status') {
$query = "select report, description from sw_reports_pre where bcr_ogc_fid = '{$bcr[$i]}' and type = 'status'";
$result = pg_query($query);
$row = pg_fetch_array($result);
$grass = $row['report'];
$response .= "<h1>AOI GAP Status Report for {$row['description']}</h1>";
$response .= "<pre>{$grass}</pre>";
}
}
if ((isset($states) || isset($bcr) || $aoi_data['ecosys_aoi'] == 1) && ($report == 'landcover' || $report == 'management' || $report == 'owner'|| $report == 'status')) {
//die();
} else {
if ($report == 'landcover'){
$response = "<h1>AOI Land Cover Report</h1>";
$grass = $a->aoi_landcover();
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'management') {
$response = "<h1>AOI Management Report</h1>";
$grass = $a->aoi_management();
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'owner') {
$response = "<h1>AOI Ownership Report</h1>";
$grass = $a->aoi_ownership();
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'status') {
$response = "<h1>AOI GAP Status Report</h1>";
$grass = $a->aoi_status();
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'status_sp') {
$response = "<h1>Species GAP Status Report</h1>";
$response .= "<h3>{$species}</h3>";
$grass = $a->species_status($itiscode);
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'landcover_sp') {
$response = "<h1>Species Land Cover Report</h1>";
$response .= "<h3>{$species}</h3>";
$grass = $a->species_landcover($itiscode);
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'management_sp') {
$response = "<h1>Species Management Report</h1>";
$response .= "<h3>{$species}</h3>";
$grass = $a->species_management($itiscode);
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'owner_sp') {
$response = "<h1>Species Ownership Report</h1>";
$response .= "<h3>{$species}</h3>";
$grass = $a->species_ownership($itiscode);
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'predicted') {
$response = "<h1>Predicted Distribution Report</h1>";
$response .= "<h3>{$species}</h3>";
$grass = $a->predicted($itiscode);
$response .= "<pre>{$grass}</pre>";
}
if ($report == 'richness_report') {
$response = "<h1>Richness Report</h1>";
$spec = str_replace(":", "<br />", $species);
$response .= "<h3>{$spec}</h3>";
$grass = $a->richnessreport($species);
$response .= "<pre>{$grass}</pre>";
}
}
$response = pg_escape_string($response);
$query = "insert into sw_reports(reportid, report) values ({$reportid}, '{$response}')";
pg_query($query);
//echo json_encode(array("header"=>"$query","rep"=>$response));die();
?>