forked from Avinm/QuickSlots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.php
281 lines (278 loc) · 12.8 KB
/
manage.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
<?php
/**
* Restricted to dean level users, provides interface and back end routines to manage departments, faculty, batches and rooms
* @author Avin E.M
*/
require_once('functions.php');
if(!sessionCheck('level','dean'))
{
header("Location: ./login.php");
die();
}
require_once ('connect_db.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<title>QuickSlots</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
<link rel="stylesheet" type="text/css" href="css/styles.css">
<link rel="stylesheet" type="text/css" href="css/dashboard.css">
<link rel="stylesheet" type="text/css" href="css/chosen.css">
<script type="text/javascript" src="js/jquery.min.js" ></script>
<script type="text/javascript" src="js/form.js"></script>
<script type="text/javascript" src="js/chosen.js"></script>
<script>
$(function()
{
$("#main_menu a").each(function() {
if($(this).prop('href') == window.location.href || window.location.href.search($(this).prop('href'))>-1)
{
$(this).parent().addClass('current');
document.title+= " | " + this.innerHTML;
$("#shadowhead").html(this.innerHTML);
return false;
}
})
$("select").chosen();
$("#fac_level").change(function(){
$("input[value="+ $("option:selected",this).attr('class') +"]",this.parentNode).attr('checked','checked');
})
})
</script>
</head>
<body style="white-space:nowrap">
<div id="header">
<div id="account_info">
<div class="infoTab"><div class="fixer"></div><div class="dashIcon usr"></div><div id="fName"><?=$_SESSION['fName']?></div></div>
<div class="infoTab"><div class="fixer"></div><a href="logout.php" id="logout"><div class="dashIcon logout"></div><div>Logout</div></a></div>
</div>
<div id="header_text">QuickSlots v1.0</div>
</div>
<div id="shadowhead"></div>
<div id="nav_bar">
<ul class="main_menu" id="main_menu">
<li class="limenu"><a href="dean.php">Manage Timetables</a></li>
<li class="limenu"><a href="manage.php?action=departments">Manage Departments</a></li>
<li class="limenu"><a href="manage.php?action=faculty">Manage Faculty</a></li>
<li class="limenu"><a href="manage.php?action=batches">Manage Batches</a></li>
<li class="limenu"><a href="manage.php?action=rooms">Manage Rooms</a></li>
<li class="limenu"><a href="faculty.php">Manage Courses</a></li>
<li class="limenu"><a href="allocate.php">Allocate Timetable</a></li>
<li class="limenu"><a href="./">View Timetable</a></li>
</ul>
</div>
<div id="content">
<?php if(valueCheck('action','faculty')) : ?>
<div class="box">
<div class="boxbg"></div>
<div class="avatar"><div class="icon add"></div></div>
<div class="title">Add Faculty</div>
<div class="elements">
<form method="post" action="register.php">
<input type="text" name="fullName" class="styled uInfo" required pattern=".{6,50}" title="6 to 50 characters" placeholder="Full Name" />
<input type="text" name="uName" class="styled username" required pattern="[^ ]{3,25}" title="3 to 25 characters without spaces" placeholder="Username" />
<select name="dept" class="stretch" data-placeholder="Choose Department..." required>
<option label="Choose Department..."></option>
<?php
foreach($db->query('SELECT * FROM depts') as $dept)
echo "<option value=\"{$dept['dept_code']}\">{$dept['dept_name']} ({$dept['dept_code']})</option>";
?>
</select>
<input type="password" name="pswd" class="styled pwd" required pattern="[^ ]{8,32}" title="8 to 32 characters without spaces" placeholder="Password" />
<input type="password" class="styled pwd" required pattern="[^ ]{8,32}" title="8 to 32 characters without spaces" placeholder="Confirm password" />
<div style="text-align: justify;height: 18px">
<div class="inline">
<input type="radio" class="styled" name="level" id="addFaculty" value="faculty" checked><label for="addFaculty">Faculty</label>
</div>
<div class="inline">
<input type="radio" class="styled" name="level" id="addHOD" value="hod"><label for="addHOD">HOD</label>
</div>
<div class="inline">
<input type="radio" class="styled" name="level" id="addDean" value="dean"><label for="addDean">Dean</label>
</div>
<span class="inline stretch"></span>
</div>
<div class="blocktext info"></div>
<div class="center button">
<button>Register</button>
</div>
</form>
</div>
</div>
<div class="box">
<div class="boxbg"></div>
<div class="avatar"><div class="icon key"></div></div>
<div class="title">Change Faculty Access</div>
<div class="elements">
<form method="post" action="register.php?action=changeLevel">
<select name="uName" id="fac_level" class="updateSelect stretch" data-placeholder="Choose Faculty..." required>
<option label="Choose Faculty..."></option>
<?php
foreach($db->query('SELECT * FROM faculty') as $fac)
echo "<option value=\"{$fac['uName']}\" class=\"{$fac['level']}\">{$fac['fac_name']} ({$fac['uName']})</option>"
?>
</select>
<div style="text-align: justify;height: 18px">
<div class="inline">
<input type="radio" class="styled" name="level" id="changeFaculty" value="faculty"><label for="changeFaculty">Faculty</label>
</div>
<div class="inline">
<input type="radio" class="styled" name="level" id="changeHOD" value="hod"><label for="changeHOD">HOD</label>
</div>
<div class="inline">
<input type="radio" class="styled" name="level" id="changeDean" value="dean"><label for="changeDean">Dean</label>
</div>
<span class="inline stretch"></span>
</div>
<div class="blocktext info"></div>
<div class="center button">
<button>Change</button>
</div>
</form>
</div>
</div>
<div class="box">
<div class="boxbg"></div>
<div class="avatar"><div class="icon remove"></div></div>
<div class="title">Delete Faculty</div>
<div class="elements">
<form method="post" action="register.php?action=deleteFaculty" class="confirm">
<select name="uName" class="updateSelect stretch" data-placeholder="Choose Faculty..." required>
<option label="Choose Faculty..."></option>
<?php
foreach($db->query('SELECT * FROM faculty') as $fac)
echo "<option value=\"{$fac['uName']}\">{$fac['fac_name']} ({$fac['uName']})</option>"
?>
</select>
<input type="hidden" id="confirm_msg" value="Are you sure you want to delete the selected faculty?">
<div class="blocktext info"></div>
<div class="center button">
<button>Delete</button>
</div>
</form>
</div>
</div>
<?php elseif(valueCheck('action','departments')) : ?>
<div class="box">
<div class="boxbg"></div>
<div class="information"><div class="icon add"></div></div>
<div class="title">Add Department</div>
<div class="elements">
<form method="post" action="depts.php?action=add">
<input type="text" name="dept_code" class="styled details" required pattern="[^ ]{2,5}" title="2 to 5 characters" placeholder="Department Code" />
<input type="text" name="dName" class="styled details" required pattern=".{6,50}" title="6 to 50 characters" placeholder="Department Name" />
<div class="blocktext info"></div>
<div class="center button">
<button>Add</button>
</div>
</form>
</div>
</div>
<div class="box">
<div class="boxbg"></div>
<div class="information"><div class="icon remove"></div></div>
<div class="title">Delete Department</div>
<div class="elements">
<form method="post" action="depts.php?action=delete">
<select name="dept_code" class="updateSelect stretch" data-placeholder="Choose Department..." required>
<option label="Choose Department..."></option>
<?php
foreach($db->query('SELECT * FROM depts') as $dept)
echo "<option value=\"{$dept['dept_code']}\">{$dept['dept_name']} ({$dept['dept_code']})</option>";
?>
</select>
<div class="blocktext info"></div>
<div class="center button">
<button>Delete</button>
</div>
</form>
</div>
</div>
<?php elseif(valueCheck('action','batches')) : ?>
<div class="box">
<div class="boxbg"></div>
<div class="information"><div class="icon add"></div></div>
<div class="title">Add Batch</div>
<div class="elements">
<form method="post" action="batches.php?action=add">
<input type="text" name="batch_name" class="styled uInfo" required pattern="[^:]{2,30}" title="2 to 30 alphanumeric characters" placeholder="Batch Name" />
<select name="dept" class="stretch" data-placeholder="Choose Department..." required>
<option label="Choose Department..."></option>
<?php
foreach($db->query('SELECT * FROM depts') as $dept)
echo "<option value=\"{$dept['dept_code']}\">{$dept['dept_name']} ({$dept['dept_code']})</option>";
?>
</select>
<input type="text" name="size" class="styled details" required pattern="[0-9]{1,3}" title="Number less than 1000, this will be used to suggest rooms" placeholder="Batch Size" />
<div class="blocktext info"></div>
<div class="center button">
<button>Add</button>
</div>
</form>
</div>
</div>
<div class="box">
<div class="boxbg"></div>
<div class="information"><div class="icon remove"></div></div>
<div class="title">Delete Batch</div>
<div class="elements">
<form method="post" action="batches.php?action=delete" class="confirm">
<select name="batch" class="updateSelect stretch" data-placeholder="Choose Batch..." required>
<option label="Choose Batch..."></option>
<?php
foreach($db->query('SELECT * FROM batches') as $batch)
echo "<option value=\"{$batch['batch_name']} : {$batch['batch_dept']}\">{$batch['batch_name']} : {$batch['batch_dept']} ({$batch['size']})</option>";
?>
</select>
<input type="hidden" id="confirm_msg" value="Are you sure you want to delete the selected batch?">
<div class="blocktext info"></div>
<div class="center button">
<button>Delete</button>
</div>
</form>
</div>
</div>
<?php else: ?>
<div class="box">
<div class="boxbg"></div>
<div class="information"><div class="icon add"></div></div>
<div class="title">Add Room</div>
<div class="elements">
<form method="post" action="rooms.php?action=add">
<input type="text" name="room_name" class="styled details" required pattern="[^:]{2,25}" title="2 to 25 alphanumeric characters" placeholder="Room Name" />
<input type="text" name="capacity" class="styled details" required pattern="[0-9]{1,3}" title="Number less than 1000" placeholder="Capacity" />
<div class="blocktext info"></div>
<div class="center button">
<button>Add</button>
</div>
</form>
</div>
</div>
<div class="box">
<div class="boxbg"></div>
<div class="information"><div class="icon remove"></div></div>
<div class="title">Delete Room</div>
<div class="elements">
<form method="post" action="rooms.php?action=delete" class="confirm">
<select name="room_name" class="updateSelect stretch" data-placeholder="Choose Room..." required>
<option label="Choose Room..."></option>
<?php
foreach($db->query('SELECT * FROM rooms') as $room)
echo "<option value=\"{$room['room_name']}\">{$room['room_name']} ({$room['capacity']})</option>";
?>
</select>
<div class="blocktext info"></div>
<input type="hidden" id="confirm_msg" value="Are you sure you want to delete the selected room?">
<div class="center button">
<button>Delete</button>
</div>
</form>
</div>
</div>
<?php endif; ?>
</div>
<div id="footer">Powered by <a href="https://github.com/0verrider/QuickSlots">QuickSlots v1.0</a></div>
</body>
</html>