-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.php
373 lines (344 loc) · 14 KB
/
dashboard.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
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?php
ob_start();
session_start();
require_once 'dbconnect.php';
// redirect to login if not logged in
if( !isset($_SESSION['user']) ) {
header("Location: login.php");
exit;
}
function getCluster($val){
if ($val == "PBM" || $val == "PMK" ||$val == "PFN" || $val == "PHT"){
return "Principles";
} elseif ($val == "PFL" || $val == "ACT" ||$val == "FTDM" || $val == "BFS"){
return "Finance";
} elseif ($val == "BTDM" || $val == "MTDM" ||$val == "STDM"){
return "Marketing-Teams";
} elseif ($val == "AAM"|| $val == "AASM"|| $val == "BSM"|| $val == "FMS"|| $val == "MCS"|| $val == "RMS"|| $val == "SEM"){
return "Marketing-Singles";
} elseif ($val == "HLM" || $val == "QSRM" ||$val == "RFSM" || $val == "HTDM"|| $val == "TTDM"){
return "Hospitality";
} elseif ($val == "BLTDM" || $val == "HRM"){
return "Business-Admin";
}
}
// select logged in users detail
$res = mysql_query("SELECT * FROM users WHERE userId=" . $_SESSION['user']);
$userRow = mysql_fetch_array($res);
$exec = false;
// assign executive privleges
if ($userRow["userEmail"] == "[email protected]" || $userRow["userEmail"] == "[email protected]"){
$exec = true;
$clusterManaging = "Principles";
} elseif ($userRow["userEmail"] == "[email protected]" || $userRow["userEmail"] == "[email protected]"){
$exec = true;
$clusterManaging = "Finance";
} elseif ($userRow["userEmail"] == "[email protected]" || $userRow["userEmail"] == "[email protected]"){
$exec = true;
$clusterManaging = "Marketing-Teams";
} elseif ($userRow["userEmail"] == "[email protected]" || $userRow["userEmail"] == "[email protected]"){
$exec = true;
$clusterManaging = "Marketing-Singles";
} elseif ($userRow["userEmail"] == "[email protected]" || $userRow["userEmail"] == "[email protected]"){
$exec = true;
$clusterManaging = "Hospitality";
} elseif ($userRow["userEmail"] == "[email protected]" || $userRow["userEmail"] == "[email protected]"){
$exec = true;
$clusterManaging = "Business-Admin";
} elseif ($userRow["userEmail"] == "[email protected]"){
$admin = true;
$clusterManaging = "N/A";
}
// assign a user cluster
$currentCluster = getCluster($userRow["userEventAssigned"]);
// handle announcement delete
$deleteId = $_GET['delId'];
if ($deleteId !== undefined && $exec){
$delete_request = mysql_query('DELETE FROM announcements WHERE announceId='.$deleteId);
}
// assign homework
if ($currentCluster == "Principles"){
$homework= "Principles_6_Whole_Homework.php";
} elseif ($currentCluster == "Finance") {
$homework= "Finance_2_Split_Homework.php";
} elseif ($currentCluster == "Business-Admin") {
$homework= "Business-Admin_3_Split_Homework.php";
} elseif ($currentCluster == "Marketing-Teams" || $currentCluster == "Marketing-Singles") {
$homework= "Marketing_1_Split_Homework.php";
} elseif ($currentCluster == "Hospitality") {
$homework= "Hospitality_3_Split_Homework.php";
}
// assign score for the week
$week = "score_6";
$res_exam_check = mysql_query("SELECT * FROM exams WHERE userId=" . $_SESSION['user']);
$exam_check = mysql_fetch_array($res_exam_check);
if ($exam_check[$week] !== "0"){
$exam_status="img/complete.png";
} else {
$exam_status="img/incomplete.png";
}
?>
<!--
/$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$$ /$$$$$$ /$$ /$$
|_ $$_/| $$__ $$| $$__ $$ /$$__ $$| $$ | $$|_ $$_/| $$$ /$$$ |_ $$_/| $$__ $$| $$_____//$$__ $$| $$$ | $$
| $$ | $$ \ $$| $$ \ $$| $$ \ $$| $$ | $$ | $$ | $$$$ /$$$$ | $$ | $$ \ $$| $$ | $$ \ $$| $$$$| $$
| $$ | $$$$$$$ | $$$$$$$/| $$$$$$$$| $$$$$$$$ | $$ | $$ $$/$$ $$ | $$ | $$$$$$$/| $$$$$ | $$$$$$$$| $$ $$ $$
| $$ | $$__ $$| $$__ $$| $$__ $$| $$__ $$ | $$ | $$ $$$| $$ | $$ | $$__ $$| $$__/ | $$__ $$| $$ $$$$
| $$ | $$ \ $$| $$ \ $$| $$ | $$| $$ | $$ | $$ | $$\ $ | $$ | $$ | $$ \ $$| $$ | $$ | $$| $$\ $$$
/$$$$$$| $$$$$$$/| $$ | $$| $$ | $$| $$ | $$ /$$$$$$| $$ \/ | $$ /$$$$$$| $$ | $$| $$ | $$ | $$| $$ \ $$
|______/|_______/ |__/ |__/|__/ |__/|__/ |__/|______/|__/ |__/ |______/|__/ |__/|__/ |__/ |__/|__/ \__/
/$$$$$$ /$$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$$ /$$$$$$ /$$$$$$
|_ $$_/| $$__ $$| $$ | $$ /$$__ $$ | $$__ $$| $$_____/ /$$__ $$ /$$__ $$
| $$ | $$ \ $$| $$ | $$| $$ \__/ | $$ \ $$| $$ | $$ \__/| $$ \ $$
| $$ | $$$$$$$/| $$$$$$$$| $$$$$$ | $$ | $$| $$$$$ | $$ | $$$$$$$$
| $$ | $$__ $$| $$__ $$ \____ $$ | $$ | $$| $$__/ | $$ | $$__ $$
| $$ | $$ \ $$| $$ | $$ /$$ \ $$ | $$ | $$| $$ | $$ $$| $$ | $$
/$$$$$$| $$ | $$| $$ | $$| $$$$$$/ | $$$$$$$/| $$$$$$$$| $$$$$$/| $$ | $$
|______/|__/ |__/|__/ |__/ \______/ |_______/ |________/ \______/ |__/ |__/
-->
<html>
<head>
<title> IRHS DECA </title>
<!-- Add jQuery library -->
<link rel="icon" href="img/favicon.ico" sizes="16x16">
<link rel="stylesheet" type="text/css" href="css/main.css">
</link>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/cssmenu/styles.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.blue_grey-red.min.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script>
</head>
<body>
<div id="wrapper">
<!-- Mobile menu -->
<div id="mobile_menu">
<img id="menu-logo" src="img/logo2.png" height="40" align="left">
<img id="menu-bars" src="img/menu_bars.png" height="32" align="right">
</div>
<!-- Mobile dropdown -->
<ul id="mobile_dropdown" style="display: none;">
<li><a href='index.php'><span>Home</span></a></li>
<li class="active"><a href='about.php'><span>About DECA</span></a></li>
<li><a href='events.php'><span>Events</span></a></li>
<li><a href='dashboard.php'><span>Dashboard</span></a></li>
<li><a href='announcements.php'><span>Announcements</span></a></li>
<li><a href='dates.php'><span>Schedules</span></a></li>
<!-- Display menu according to user login -->
<?php if (!isset($_SESSION['user'])) { ?>
<li><a href='register.php'><span>Register</span></a></li>
<li class='last'><a href='login.php'><span>Login</span></a></li>
<?php } else { ?>
<li><a href='exams.php'><span>Exams</span></a></li>
<li class='last'><a href='logout.php?logout'><span>Logout</span></a></li>
<?php
}
?>
</ul>
<!-- Desktop menu -->
<div id='cssmenu'>
<ul>
<li><a href='index.php'><span>Home</span></a></li>
<li><a href='about.php'><span>About DECA</span></a></li>
<li><a href='events.php'><span>Events</span></a></li>
<li class="active"><a href='dashboard.php'><span>Dashboard</span></a></li>
<li><a href='announcements.php'><span>Announcements</span></a></li>
<li><a href='dates.php'><span>Schedules</span></a></li>
<li><a href='exams.php'><span>Exams</span></a></li>
<li class='last'><a href='logout.php?logout'><span>Logout</span></a></li>
</ul>
</div>
</br>
<br/>
<!-- Store userid in DOM -->
<div class='userid_block' style='display: none;'><?php echo $_SESSION['user']; ?></div>
<!-- show user profile bar -->
<div class="content">
<div class= "profile">
<img src="img/avatar.png" align="left" height="140"/>
<h3><?php echo $userRow['userFName']; echo " "; echo $userRow['userLName'] ?> </h3>
<h4 id="event_assigned_code"></h4>
</div>
<br/>
<!-- Show weekly homework -->
<div id="homework">
<h4>Your Weekly Homework:</h4>
<img id="complete" src="<?php echo $exam_status; ?>" align="right" height="35" />
<h5 id="exam_link"><u><a href='<?php echo $homework;?>' style="color: black;">
<?php echo $currentCluster; echo " Exam";?></a></u></h5>
</div>
<br/>
<?php
if ($exec || $admin) {
?>
<!-- if the user is exec, show exam scores for the cluster -->
<h4> Exam Scores for <?php echo $clusterManaging; ?></h4>
<table class="mdl-data-table mdl-js-data-table" id="exam_scores">
<thead>
<tr>
<td width="100%">User</td>
<td>Week 1</td>
<td>Week 2</td>
<td>Week 3</td>
<td>Week 4</td>
<td>Week 5</td>
<td>Week 6</td>
</tr>
</thead>
<tbody>
<?php
// select exams detail based on privleges
if ($admin){
$res = mysql_query("SELECT * FROM exams");
} else {
$res = mysql_query("SELECT * FROM exams WHERE cluster='$clusterManaging'");
}
// display exam scores
while ($abc = mysql_fetch_array($res, MYSQL_ASSOC)) {
?>
<tr><td>
<!-- User name -->
<?php
$res_users = mysql_query("SELECT * FROM users WHERE userId=". $abc["userId"]);
$user_exams = mysql_fetch_array($res_users);
echo $user_exams["userFName"];
echo " ";
echo $user_exams["userLName"];
?>
<!-- Display every score -->
<?php for ($w = 1; $w <= 6; $w++){ ?>
<td>
<?php
if ($abc["score_" . $w] !== "0"){
echo $abc["score_" . $w]; echo "%";
} else {
echo "-";
}
?>
</td>
<?php } ?>
</tr>
<?php
}
mysql_free_result($res);
?>
</tbody></table>
<!-- Handle announcement post request -->
<?php
if(isset($_POST['submit'])) {
// escape the data
$title = mysql_real_escape_string(strip_tags(trim($_POST['title'])));
$body = mysql_real_escape_string(strip_tags(trim($_POST['body'])));
$error = false;
// Error check
if (empty($title) || empty($body)){
$error = true;
$msg = "You must complete all fields.";
}
if (!$error){
// remove all quotations to sanitize, then insert to db
$new_body = str_replace("'", "''", "$body");
$new_body = str_replace("\n", "", "$new_body");
$query = "INSERT INTO announcements(title, body, cluster) VALUES('$title', '$new_body', '$clusterManaging')";
$res = mysql_query($query);
}
}
}
if ($exec && !$admin) { ?>
<!-- Form to post announcements for cluster -->
<h4><?php echo $clusterManaging; echo " Announcements "; echo $msg; ?></h4>
<h5 style="color: red;"><?php echo $msg ?></h5>
<form id="post_announcements" method="post">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="title" name="title">
<label class="mdl-textfield__label" for="title">Title</label>
</div>
</br></br>
<div class="mdl-textfield mdl-js-textfield">
<textarea class="mdl-textfield__input" type="text" rows="3" id="body" name="body"></textarea>
<label class="mdl-textfield__label" for="body">Body</label>
</div>
<input id="submit_ann" name="submit" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="submit" value="Post">
</input>
</form>
<?php
// display the posted announcements for the cluster managing
$res_cm = mysql_query("SELECT * FROM announcements WHERE cluster='".$clusterManaging."'");
while ($ann = mysql_fetch_array($res_cm, MYSQL_ASSOC)) {
$data[] = $ann;
}
$data = array_reverse($data,true);
foreach ($data as $announcement){
?>
<div class="announce wordwrap">
<img class="delete_ann" src="img/x.png" onClick="self.location='http://www.irhsdeca.xyz/dashboard.php?delId=<?php echo $announcement['announceId']; ?>'">
<h4 id="ann-title"><?php echo $announcement["title"]; ?></h4>
<h5 id="ann-body"><?php echo $announcement["body"]; ?></h5>
<h6 id="ann-date"><?php echo $announcement["datePosted"]; ?></h6>
</div>
<?php
}
mysql_free_result($res_cm);
// display the participating cluster as well
if ($currentCluster !== $clusterManaging){
?>
<h4><?php echo $currentCluster; echo " Announcements";?></h4>
<?php
$res_cc = mysql_query("SELECT * FROM announcements WHERE cluster='".$currentCluster."'");
while ($ann = mysql_fetch_array($res_cc, MYSQL_ASSOC)) {
$data2[] = $ann;
}
$data2 = array_reverse($data3,true);
foreach ($data2 as $announcement){
?>
<div class="announce wordwrap">
<h4 id="ann-title"><?php echo $announcement["title"]; ?></h4>
<h5 id="ann-body"><?php echo $announcement["body"]; ?></h5>
<h6 id="ann-date"><?php echo $announcement["datePosted"]; ?></h6>
</div>
<?php
}
mysql_free_result($res_cc);
}
} else {
?>
<!-- Display participating cluster announcements for non-execs -->
<h4><?php echo $currentCluster; echo " Announcements"; ?></h4>
<?php
$res_cc = mysql_query("SELECT * FROM announcements WHERE cluster='".$currentCluster."'");
while ($ann = mysql_fetch_array($res_cc, MYSQL_ASSOC)) {
$data3[] = $ann;
}
$data3 = array_reverse($data2,true);
foreach ($data3 as $announcement){
?>
<div class="announce wordwrap">
<h4 id="ann-title"><?php echo $announcement["title"]; ?></h4>
<h5 id="ann-body"><?php echo $announcement["body"]; ?></h5>
<h6 id="ann-date"><?php echo $announcement["datePosted"]; ?></h6>
</div>
<?php
}
mysql_free_result($res_cc);
}
?>
</div>
<!-- Footer -->
<div class="footer">
<img id="altlogo" src="img/logo_alt.png" align="left" />
<img id="fbimg" src="img/facebook-box.png" align="right" />
<h6><a href="http://www.ibrahimirfan.com" style="color: white;">Ibrahim Irfan</a></h6>
</div>
</div>
</body>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript">
// handle the users event
var user_event = "<?php echo $userRow['userEventAssigned']; ?>";
var user_event_code = user_event.substring(user_event.lastIndexOf("(")+1,user_event.lastIndexOf(")"));
document.getElementById('event_assigned_code').innerHTML = user_event;
</script>
</html>