-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoledoosnav.php
290 lines (284 loc) · 15.1 KB
/
toledoosnav.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
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
require '/var/www/repos/includes/db.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap.grid.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="toledoosnavstyle.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>Building Navigation</title>
</head>
<body>
<!--WEBSITE CONTAINER-->
<div class="container">
<!--<div class="row">-->
<div class="col-sm-3">
<!--EMPTY-->
</div>
<div class="col-sm-12 col-sm-pull-0">
<h1 style="font-size: 30px; margin-top: 0px; margin-bottom: 10px"> Select a building to find out more information </h1>
<div class="row">
<?php
$sql = "SELECT id, name, db_link, building_type, area, custom_img FROM buildings WHERE org_id IN (SELECT org_id from users_orgs_map WHERE user_id = {$user_id}) AND custom_img IS NOT NULL AND id IN (SELECT building_id FROM meters WHERE for_orb > 0 OR timeseries_using > 0 OR bos_uuid IS NOT NULL) AND area != 0 LIMIT 6";
foreach($db->query($sql) as $building) {
$stmt = $db->prepare('SELECT id, scope, current, name, for_orb, bos_uuid, units, resource FROM meters WHERE building_id = ? ORDER BY name ASC');
$stmt->execute(array($building['id']));
$meters = $stmt->fetchAll();
?>
<div class="col-xs-4 col-sm-3 col-md-2 col-lg-2 card-col" data-title="<?php echo $building['name'] ?>" data-buildingtype="<?php echo $building['building_type'] ?>" data-consumption="<?php echo $meters[0]['current']?>">
<a class="card-hilight" href="<?php echo $building['db_link'] ?>" target="_top">
<div class="card">
<div class="side1" id="side1<?php echo $building['id']; ?>">
<img src="<?php echo $building['custom_img'] ?>" alt="<?php echo $building['name'] ?>" align="middle">
<div class="card-text">
<h1><?php echo $building['name'] ?></h1>
<h2 class="text-muted"><?php echo $building['building_type'] ?></h2>
<div class="meter-num"><p>
<?php
$count = 0;
foreach ($meters as $meter){
$count++;
}
if ($count != 1){echo $count; echo " meters";} else{echo $count; echo " meter";} ?></p>
</div>
<div class="relval">
<?php
foreach ($meters as $meter) {
if ($meter['scope'] == "Whole building"){
$stmt = $db->prepare('SELECT relative_value FROM relative_values WHERE (meter_uuid = ?) LIMIT 1');
$stmt->execute(array($meter['bos_uuid']));
if ($meter['resource'] == "Generation, Photovoltaic"){
$pvrelval = $stmt->fetchColumn();
if ($pvrelval <= 20){
echo "<img src='images/nav_images/sun1.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($pvrelval <= 40){
echo "<img src='images/nav_images/sun2.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($pvrelval <= 60){
echo "<img src='images/nav_images/sun3.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($pvrelval <= 80){
echo "<img src='images/nav_images/sun4.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else{
echo "<img src='images/nav_images/sun5.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
}
if ($meter['units'] == "Kilowatts"){
$elecrelval = $stmt->fetchColumn();
if ($elecrelval <= 20){
echo "<img src='images/nav_images/electricity1.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($elecrelval <= 40){
echo "<img src='images/nav_images/electricity2.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($elecrelval <= 60){
echo "<img src='images/nav_images/electricity3.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($elecrelval <= 80){
echo "<img src='images/nav_images/electricity4.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else{
echo "<img src='images/nav_images/electricity5.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
}
else if ($meter['units'] == "Gallons / hour"){
$waterrelval = $stmt->fetchColumn();
if ($waterrelval <= 20){
echo "<img src='images/nav_images/water1.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($waterrelval <= 40){
echo "<img src='images/nav_images/water2.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($waterrelval <= 60){
echo "<img src='images/nav_images/water3.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else if ($waterrelval <= 80){
echo "<img src='images/nav_images/water4.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
else{
echo "<img src='images/nav_images/water5.svg'
height='40px' width='20px' style='position: relative; display: inline; float: left;'>";
}
}
}
}
?>
</div>
</div>
</div>
</div>
</a>
</div>
<?php } ?>
</div>
</div>
<!--</div>-->
</div>
<div class="navbar">
<input type="text" id="search" placeholder="Search">
<!--FILTERING BUTTONS-->
<div class="btn-group">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Select Building Type
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li onClick="window.location.reload()">All</li>
<?php
foreach($db->query("SELECT DISTINCT building_type FROM buildings WHERE org_id IN (SELECT org_id from users_orgs_map WHERE user_id = {$user_id}) AND custom_img IS NOT NULL AND id IN (SELECT building_id FROM meters WHERE gauges_using > 0 OR for_orb > 0 OR timeseries_using > 0 OR bos_uuid IS NOT NULL)
ORDER BY building_type ASC") as $building) { ?>
<li class="filter-btn" data-buildingtype="<?php echo $building['building_type']; ?>"><?php echo $building['building_type']; ?></li>
<?php } ?>
</ul>
</div>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Sort By: Alphabetical
<span class="caret"></span></button>
<ul class="dropdown-menu">
<!-- <li onClick="window.location.reload()">Alphabetical</li>
--> <li class="header">Current Use</li>
<li onClick="location.href='https://oberlindashboard.org/oberlin/time-series/buildingosnavigation/currentelecfilteros.php';">Electricity</li>
<li onClick="location.href='https://oberlindashboard.org/oberlin/time-series/buildingosnavigation/currentwaterfilteros.php';">Water</li>
<li class="header">Relative Use</li>
<li onClick="location.href='https://oberlindashboard.org/oberlin/time-series/buildingosnavigation/relvalelecfilteros.php';">Electricity</li>
<li onClick="location.href='https://oberlindashboard.org/oberlin/time-series/buildingosnavigation/relvalwaterfilteros.php';">Water</li>
</ul>
</ul>
</div>
</div>
<div class="key">
<span class="notification-bubble">?</span>
<img src='images/nav_images/electricity5.svg' height='40px' width='20px'>
<div class="keydescription">
<h2 style="font-size: 18px">Electricity Relative Use</h2>
<p style="margin: 0 auto;">Low
<img src='images/nav_images/electricity1.svg' height='40px' width='20px'>
<img src='images/nav_images/electricity2.svg' height='40px' width='20px'>
<img src='images/nav_images/electricity3.svg' height='40px' width='20px'>
<img src='images/nav_images/electricity4.svg' height='40px' width='20px'>
<img src='images/nav_images/electricity5.svg' height='40px' width='20px'>
High
<div class='line-separator'></div>
<h5>Compares current levels to typical levels of use at this time of day </h5></p>
</div>
</div>
<div class="key">
<span class="notification-bubble">?</span>
<img src='images/nav_images/sun3.svg' height='40px' width='20px'>
<div class="keydescription">
<h2 style="font-size: 16px">PV Production Relative Use</h2>
<p style="margin: 0 auto;">Low
<img src='images/nav_images/sun1.svg' height='40px' width='20px'>
<img src='images/nav_images/sun2.svg' height='40px' width='20px'>
<img src='images/nav_images/sun3.svg' height='40px' width='20px'>
<img src='images/nav_images/sun4.svg' height='40px' width='20px'>
<img src='images/nav_images/sun5.svg' height='40px' width='20px'>
High
<div class='line-separator'></div>
<h5>Compares current levels to typical levels of use at this time of day </h5></p>
</div>
</div>
<div class="key">
<span class="notification-bubble">?</span>
<img src='images/nav_images/water1.svg' height='40px' width='20px'>
<div class="keydescription">
<h2 style="font-size: 18px">Water Relative Use</h2>
<p style="margin: 0 auto;">Low
<img src='images/nav_images/water1.svg' height='40px' width='20px'>
<img src='images/nav_images/water2.svg' height='40px' width='20px'>
<img src='images/nav_images/water3.svg' height='40px' width='20px'>
<img src='images/nav_images/water4.svg' height='40px' width='20px'>
<img src='images/nav_images/water5.svg' height='40px' width='20px'>
High</p>
<div class='line-separator'></div>
<h5>Compares current levels to typical levels of use at this time of day </h5>
</div>
</div>
</div>
<div id="bg" style="display: none;height: 100%;width: 100%;position: absolute;top: 0;left: 50px;right: 0;bottom: 0;padding: 20px 20px 20px 20px"></div>
<object id="object" type="image/svg+xml" data=""></object>
<img src="images/close.svg" alt="" height="75px" width="75px" id="close-timeseries" style="display: none;cursor: pointer;position: fixed;top: 7px;right: 20px;">
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<!--ANIMATING THE BUTTONS-->
<script>
$.fn.extend({
animateCss: function (animationName) {
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
this.addClass('animated ' + animationName).one(animationEnd, function() {
$(this).removeClass('animated ' + animationName);
// if (animationName === 'fadeOut') {
// $(this).addClass('hidden');
// }
});
}
});
$('#search').on('input', function() {
var query = $('#search').val().toLowerCase();
$('.card-col').each(function() {
var content = $(this).data('title') + ' ' + $(this).data('buildingtype');
if (content.toLowerCase().indexOf(query) === -1) {
$(this).addClass('hidden');
} else {
$(this).removeClass('hidden');
}
});
});
$('.filter-btn').on('click', function() {
//$('.filter-btn').removeClass('active');
$(this).addClass('active');
var buildingtype = $(this).data('buildingtype');
$('.card-col').each(function() {
if ($(this).data('buildingtype') == buildingtype) {
$(this).removeClass('hidden');
} else {
$(this).addClass('hidden');
}
});
});
$('.sort-btn').on('click', function() {
$('.sort-btn').addClass('active');
var buildingconsumption = $(this).data('buildingconsumption');
var buildingarray = $('.card-col').data('buildingconsumption');
buildingarray.sort();
});
$('.show-timeseries').on('click', function() {
var meter_id = $(this).data('meterid');
$('#object').attr('data', 'index.php?meter_id='+meter_id+'&meter_id2=' + meter_id).css('display', 'initial');
$('#close-timeseries').css('display', 'initial');
$('#bg').css('display', 'block');
});
$('#close-timeseries').on('click', function() {
$('#close-timeseries').css('display', 'none');
$('#object').css('display', 'none');
$('#bg').css('display', 'none');
});
</script>
</body>
</html>