-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
320 lines (271 loc) · 12.7 KB
/
dashboard.php
File metadata and controls
320 lines (271 loc) · 12.7 KB
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
<?php include "header.php";
if(!isset($_SESSION['UserID'])){
header("location: /");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>VTRAK</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="css/styles.css" rel="stylesheet">
<link href="jquery-ui.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<style>
#validationMsg{font-weight: normal;font-size: medium; float:right; margin-top:5px; color:#FF0000;}
.asterisk{color:#FF0000;font-size:14px;}
</style>
</head>
<body class="myDashboard">
<!-- Top Banner Start -->
<nav class="navbar navbar-default">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#" data-target="home" id="vtrakButton">vTrak</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<?php
// Find current user First and Last Name
$thisUserID = $_SESSION['UserID'];
$NameQuery = "SELECT FName, LName FROM user WHERE UserID='" . $thisUserID . "'";
$Name = mysqli_query($conn, $NameQuery);
if (mysqli_num_rows($Name) > 0)
{
$row = mysqli_fetch_assoc($Name);
echo '<li><p class="navbar-text">Welcome, ' . sanitizeXSS($row['FName']) . " " . sanitizeXSS($row['LName']) . '!</p></li>';
}
// Just in case it doesn't work, default greeting
else
{
echo '<li><p class="navbar-text">Welcome!</p></li>';
}
?>
<li class="drowpdown"><a class="dropbtn" id="signUpRibbon">Account</a>
<div id="myDropdown" class="dropdown-content defaultHidden">
<a href="#" id="goalDrop">Update Goal</a>
<!--<a href="#" id="pwDrop">Change Password</a>-->
</div></li>
<li><a href="logout.php" data-target="login" id="loginRibbon">Log Out</a></li>
</ul>
</div>
</div>
</nav>
<!-- Top Banner End -->
<!--<div id="fireworks" style="display:none">
<style>
#firework{background:#000;margin:0;}
canvas{cursor: crosshair;display: block;}
</style>
<canvas id="canvas"></canvas>
<script src="fireworks.js"></script>
</div>-->
<div class="row-eq-height" id="content">
<div class="col-sm-4">
<!-- Progress bar -->
<div class="progress-bar-label">
<h2>
<span class="label label-default">Goal</span>
<?php
$thisUserID = $_SESSION['UserID'];
$sql = "SELECT goal, IFNULL(SUM(hours),0) AS hours FROM user LEFT JOIN experiences on user.userID = experiences.userID WHERE user.userID = ".$thisUserID. " GROUP BY user.userID";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result)){
/*echo '<p>Current hours:'.$row['hours'].'</p>';*/
//echo '<span class="pull-right">'. $row['hours'].' of '.$row['goal'].'</span>';
echo '<span id="hoursOfGoal" class="pull-right"><span id="hoursLabel">' . sanitizeXSS($row['hours']) . '</span> of <span id="goalLabel">' . sanitizeXSS($row['goal']) . '</span> hours</span>';
if($row['hours'] >= $row['goal'])
{
echo '<script>$(document).ready(function(){$("#goalCongrats").dialog();});</script>';
}
}
}
?>
</h2>
</div>
<?php
$thisUserID = $_SESSION['UserID'];
$sql = "SELECT goal, IFNULL(SUM(hours),0) AS hours FROM user LEFT JOIN experiences on user.userID = experiences.userID WHERE user.userID = ".$thisUserID. " GROUP BY user.userID";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result)){
$val = (int)($row['hours']/$row['goal']*100);
echo '<div class="progress"><div class="progress-bar" role="progressbar" aria-valuenow="'.sanitizeXSS($row['hours']).'" aria-value-min="0" aria-valuemax="'.sanitizeXSS($row['goal']).'" style="width:'.$val.'%">'.'<div class="progress-bar-title"></div>'.'</div></div>';
}
}
?>
<!--Add activity-->
<div id="addNew" class="panel panel-default" >
<div class="panel-heading">Add Activity<span class="defaultHidden" id="validationMsg">Please enter required fields.</span></div>
<div class="panel-body">
<!--<form>-->
<div class="form-group">
<label for="newName">Name <span class="asterisk">*</span>:</label>
<input type="text" class="form-control" id="newName">
</div>
<label for="newDate">Date <span class="asterisk">*</span>:</label>
<div class="form-group">
<div class='input-group date'>
<input type='date' class="form-control" id="newDate"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<span>
<div class="form-group">
<label for="newHours">Hours <span class="asterisk">*</span>:</label>
<input type="number" class="form-control" id="newHours">
</div>
</span>
<div class="form-group">
<label for="comment">Notes:</label>
<textarea class="form-control" rows="4" id="newNotes"></textarea>
</div>
<button type="button" class="btn btn-default" id="newSubmit">Submit</button>
<!--</form>-->
</div>
</div>
</div>
<div class="col-sm-4">
<h2><span class="label label-default">Recent Activity</span></h2>
<div>
<input id="searchBox" type="text" class="form-control" placeholder="Search" style="margin-bottom:20px">
<!--<button id="searchButton" type="button" class="btn btn-default">Search</button>-->
</div>
<div class="panel panel-default">
<div class="panel-body pre-scrollable" style="max-height: 75vh">
<table id="recent" class="table" border="1">
<tbody>
<?php
$thisUserID = $_SESSION['UserID'];
$sql = "SELECT experienceID, name, expDate, hours, notes FROM experiences WHERE userID = ".$thisUserID ." ORDER BY expDate DESC";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result)){
echo '<tr id="e' . sanitizeXSS($row['experienceID']) . '" data-note="'.sanitizeXSS($row['notes']).'"><td><p class="header">' . sanitizeXSS($row['name']) . '</strong></p><p>' . sanitizeXSS($row['expDate']) . '</p><p>' . sanitizeXSS($row['hours']) . ' hours</p><p>' . sanitizeXSS($row['notes']) . '</p></td></tr>';
}
echo '<tr id="noActivity" class="defaultHidden"><td><p>No activity to show.</p></td></tr>';
}
else echo '<tr id="noActivity"><td><p>No activity to show.</p></td></tr>';
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-sm-4">
<h2><span class="label label-default">Recommendations</span></h2>
<div class="panel panel-default">
<div class="panel-body">
<table class="table" border="1">
<tbody>
<?php
$thisUserID = $_SESSION['UserID'];
$sql = "SELECT orgID, orgName, orgWebsite FROM organizations INNER JOIN user ON organizations.orgZip = user.userZip AND user.userID = ".$thisUserID ." where approved=1";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result)){
//echo '<div id="o'. $row['orgID'] . '" class="panel"><div class="name">' . $row['orgName'] . '</div><div class="type">' . $row['orgType'] . '</div><div class="webaddress">' . $row['orgWebsite'] . '</div></div>';
echo '<tr><td><p id="o'. sanitizeXSS($row['orgID']) . '" class="header">' . sanitizeXSS($row['orgName']) . '</p><p>' . sanitizeXSS($row['orgWebsite']) . '</p></td></tr>';
}
}
else {
echo '<tr><td><p id="noRec">No organizations match your area/interests.</p></td></tr>';
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div id="goalCongrats" title="Update Goal" style="display:none">
<p> Congratulations! You've met your goal!</p>
<label=>Keeping going? Enter your new goal</label>
<input id="newGoalCongrats" type="text" placeholder="New Goal">
<input id="submitNewGoalCongrats" type="Submit" class="signUpButton" value="Submit">
</div>
<div id="goalDialog" title="Update Goal" style="display:none">
<label for="newGoal">Enter your new goal</label>
<input id="newGoal" type="text" placeholder="New Goal">
<input id="submitNewGoal" type="Submit" class="signUpButton" value="Submit">
</div>
<div id="pwDialog" title="Change Password" style="display:none">
<label for="newGoal">Enter your new password</label>
<input id="password1" class="passwordBox" type="password" placeholder=" Password" name="PWHash" required>
<input id="password2" class="passwordBox" type="password" placeholder=" Retype Password" name="PWHash2" required>
<input id="submitNewGoal" type="Submit" class="signUpButton" value="Submit">
</div>
</div>
<!--<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>-->
<script src="API/webAJAX.js"></script>
<script>
// When you click "submit" for new experiences, add the experience and update the recent activity list
$("#newSubmit").on("click",function(){addExperience()});
// Clicking the "change password" or "update goal" options pulls up their dialogs
$("#goalDrop").on("click",function(){$("#goalDialog").dialog()});
$("#pwDrop").on("click",function(){$("#pwDialog").dialog()});
// Goal can be changed with the dropdown from account or the dialog that pops up when you reach your goal
$("#submitNewGoal").on("click",function(){$("#goalDialog").dialog("close");updateGoal();$('#newGoal').val("");});
$("#submitNewGoalCongrats").on("click",function(){$("#goalCongrats").dialog("close");updateGoal();$('#newGoalCongrats').val("");});
$("#goalDialog").keyup(function(event){if(event.keyCode == 13){$("#goalDialog").dialog("close");updateGoal();$('#newGoal').val("");}});
$("#goalCongrats").keyup(function(event){if(event.keyCode == 13){$("#goalCongrats").dialog("close");updateGoal();$('#newGoalCOngrats').val("");}});
// close the dialog when the user clicks on update password
$("#submitNewPW").on("click",function(){$("#pwDialog").dialog("close")});
// if the dialog is closed via the X, whatever's typed in it will be removed
$( "#goalDialog" ).on("dialogclose", function(event) {if(event.which == 1)$('#newGoal').val("")} );
$( "#goalCongrats" ).on("dialogclose", function(event) {if(event.which == 1)$('#newGoalCongrats').val("")} );
//
function searchExperiences(searchTerm){
$("#recent tr").not("#noActivity").each(
function(){
var name = $(this).find(".header").html();
var note = $(this).attr("data-note");
var inName = name.toLowerCase().includes(searchTerm.toLowerCase());
var inNote = note.toLowerCase().includes(searchTerm.toLowerCase());
$(this).toggle(inName || inNote);
}
);
if($("#recent tr:visible").not("#noActivity").length == 0)
{
$("#noActivity").removeClass("defaultHidden");
}
else {
if($("#noActivity").not(":hidden"))
$("#noActivity").addClass("defaultHidden");
}
}
$("#searchBox").keyup(function(e){searchExperiences(this.value)});
// Toggle dropdown menu when "account is clicked"
// Close the dropdown menu if the user clicks anywhere else
window.onclick = function(event) {
if (event.target.matches('#signUpRibbon')) {
$("#myDropdown").toggleClass("defaultHidden")
}
else {
if($(".signUpPage").not(":hidden"))
$("#myDropdown").addClass("defaultHidden")
}
}
</script>
</body>
</html>