-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
91 lines (89 loc) · 2.35 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=traffic.php">
<title>Traffic Report <!-- SQL Generator --></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
html,body {
font-family: sans-serif;
}
table > tbody > tr:nth-child(1) a{
display: none;
}
</style>
</head>
<body>
<!--h2>Include Dates</h2>
<table id="include" class="table">
<thead>
<tr>
<th>From</th>
<th>To</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr class="template">
<td><input type="date" class="begin" /></td>
<td><input type="date" class="end" /></td>
<td><a href="#" onclick="removeRange(this)">x</a></td>
</tr>
</tbody>
</table>
<button id="add" onclick="addInclude()">Add</button>
<h2>Exclude Dates</h2>
<table id="exclude" class="table">
<thead>
<tr>
<th>From</th>
<th>To</th>
<th> </th>
</tr>
</thead>
<tbody>
<tr class="template">
<td><input type="date" class="begin" /></td>
<td><input type="date" class="end" /></td>
<td><a href="#" onclick="removeRange(this)">x</a></td>
</tr>
</tbody>
</table>
<button id="add" onclick="addExclude()">Add</button>
<button id="go" onclick="go()">Go</button>
<pre id="result"></pre>
<script>
function addExclude(){
jQuery('#exclude .template').after((jQuery('#exclude .template').clone()).removeClass());
}
function addInclude(){
jQuery('#include .template').after((jQuery('#include .template').clone()).removeClass());
}
function removeRange(row){
jQuery(row).parent().parent().remove();
}
function go(){
var query = "select\n" +
" avg(t.level) avg,\n" +
" t.space\n" +
"from\n" +
" entries e,\n" +
" traffic t\n" +
"where \n" +
" e.entryId = t.entryId\n";
jQuery('#exclude tbody tr').each(function(){
var begin = jQuery(this).find('.begin').val();
var end = jQuery(this).find('.end').val();
query += " and e.time not between '" + begin + "' and '" + end + "'\n";
});
jQuery('#include tbody tr').each(function(){
var begin = jQuery(this).find('.begin').val();
var end = jQuery(this).find('.end').val();
query += " and e.time between '" + begin + "' and '" + end + "'\n";
});
query += "group by\n t.space"
jQuery('#result').html(query);
}
</script-->
</body>
</html>