-
Notifications
You must be signed in to change notification settings - Fork 0
/
aoi_report3.php
161 lines (140 loc) · 4.16 KB
/
aoi_report3.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
<?php
/**
* Page uses AJAX to create GRASS reports.
*
* jQuery AJAX request is sent to aoi_report_ajax.php on page load that requests report. This request will timeout in 20 seconds. Another AJAX
* request is sent to aoi_report_ajax2.php every 5 seconds that queries if report is ready and if so then loads report on page.
*
* @package ncgap
*/
//require('sw_aoi_class.php');
session_start();
?>
<!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>
<title>AOI GRASS Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="StyleSheet" href="styles/popups.css" type="text/css" />
<link rel="stylesheet" href="styles/custom-theme/jquery-ui-1.8.6.custom.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
<script type="text/javascript" src="javascript/jquery-ui-1.8.6.custom.min.js" ></script>
<style type="text/css">
/* <![CDATA[ */
@media print {
#btncont {display: none; }
}
.ui-widget {
font-size: 11px;}
button {
width: 100px;
margin: 20px;}
/* ]]> */
</style>
<script language="javascript" type="text/javascript">
/* <![CDATA[ */
var start;
$(function() {
$("button").button();
$("#prnrep").click(function(evt) {
evt.preventDefault();
window.print();
});
$("#sprdsht").click(function(evt) {
evt.preventDefault();
spreadsheet();
});
$("#cls").click(function(evt) {
evt.preventDefault();
window.close();
});
var aoiname = $('#aoiname').val();
var report = $('#report').val();
var species = $('#species').val();
var strelcode = $('#strelcode').val();
var reportid = $('#reportid').val();
$.ajax({
type: "POST",
url: "aoi_report_ajax.php",
data: { aoiname: aoiname, report: report, species: species, strelcode: strelcode, reportid: reportid },
timeout: 20000,
dataType: "json",
complete: function(data){
$('#somecontent').append("<p>Report successfully submitted.</p>");
},
success: function(data){
//$('#somecontent').html(data);
}
});
$.post("aoi_report_ajax2.php", {reportid: reportid},
function(data){
$('#timer').html("0");
start = data.time;
timeout(reportid);
}, "json");
});
function timeout(reportidp){
$.post("aoi_report_ajax2.php", {reportid: reportidp},
function(data){
var elapsed = data.time - start;
$('#timer').html("<p>Report running time is " + elapsed + " seconds</p>");
if(data.status){
$('#somecontent').hide().html(data.rep).show("normal");
$('#timer').html("<p>Report run time was " + elapsed + " seconds</p> ");
} else {
setTimeout("timeout(" + reportidp + ")", 5000);
}
}, "json");
}
function spreadsheet(){
var pretag = document.getElementsByTagName("pre");
var content = pretag[0].innerHTML;
$.ajax({
type: "POST",
url: "aoi_report_ss.php",
data: { content: content },
dataType: "json",
success: function(data){
document.forms[0].action = "/server_temp/" + data.ssreport;
document.forms[0].submit();
}
});
}
/* ]]> */
</script>
</head>
<body>
<?php
$aoi_name = $_POST['aoi_name'];
$a = $_SESSION[$aoi_name];
$report = $_POST['report'];
$strelcode = $_POST['strelcode'];
$species = stripslashes($_POST['species']);
$reportid = rand(100000000, 999999999);
//var_dump($_POST);
?>
<div id="somecontent">
<h1>Generating report</h1>
<img alt="loading icon" src="/graphics/ncgap/ajax-loader.gif" />
<br>
<br>
</div>
<div id="timer">
</div>
<div id="btncont">
<button id="prnrep" >Print report</button>
<button id="sprdsht">Spreadsheet</button>
<button id="cls">Close</button>
</div>
<form target="_blank" method="GET">
</form>
<form >
<input type="hidden" name="aoiname" id="aoiname" value="<?php echo $aoi_name; ?>" />
<input type="hidden" name="report" id="report" value="<?php echo $report; ?>" />
<input type="hidden" name="species" id="species" value="<?php echo $species ?>" />
<input type="hidden" name="strelcode" id="strelcode" value="<?php echo $strelcode ?>" />
<input type="hidden" name="reportid" id="reportid" value="<?php echo $reportid ?>" />
<input type="hidden" name="content" />
</form>
</body>
</html>