-
Notifications
You must be signed in to change notification settings - Fork 0
/
courses.php
executable file
·238 lines (229 loc) · 12 KB
/
courses.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
<?php
require_once "start.php";
$request = new Request();
if (!session_id()) session_start();
if (!empty($_SESSION["auth_login"]) && !empty($_SESSION["auth_password"])) {
$username = $_SESSION["auth_login"];
$password = $_SESSION["auth_password"];
$user = UserDB::authUser($request->username, $request->password);
$user_id = $user->getID();
$fields = MixedDB::getMixedObjects($user_id);
$courses = CourseDB::getAllOnUserID($user_id);
}
else {
//print "4";
$newURL = "login.php";
header('Location: '.$newURL);
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php $header = new Header("Teachman"); ?>
<?=Header::getTitle()?>
<?=Header::getMeta("utf-8")?>
<?=Header::getMeta(null,"IE=edge","X-UA-Compatible")?>
<?=Header::getMeta("viewport","width=device-width, initial-scale=1",null)?>
<?=Header::getLink("styles/custom.css")?>
<!-- Bootstrap -->
<?=Header::getLink("styles/bootstrap/css/bootstrap-select.css")?>
<?=Header::getLink("styles/bootstrap/css/bootstrap.min.css")?>
<?=Header::getScript("scripts/jquery.min.js")?>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<?=Header::getScript("scripts/bootstrap.min.js")?>
<?=Header::getScript("scripts/bootstrap/jquery.js")?>
<!-- JQUERY SCRIPTS -->
<!-- CUSTOM SCRIPTS -->
<?=Header::getScript("scripts/custom.js")?>
<?=Header::getScript("scripts/table.js")?>
<!-- METISMENU SCRIPTS -->
<?=Header::getScript("scripts/dataTables/jquery.dataTables.js")?>
<?=Header::getScript("scripts/dataTables/dataTables.bootstrap.js")?>
<!-- CUSTOM SCRIPTS -->
<?=Header::getScript("scripts/custom.js")?>
</head>
<body>
<div id="wrapper">
<nav class="navbar navbar-default navbar-cls-top " role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div style="color: white; padding: 15px 50px 5px 50px; float: right;
font-size: 16px;">
<a href="dashboard.php?logoutid=<?=$user_id?>" class="btn btn-danger square-btn-adjust">Logout</a>
</div>
</nav>
<!-- /. NAV TOP -->
<nav class="navbar-default navbar-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav" id="main-menu">
<li class="text-center">
<img src="<?=$user->img?>" class="user-image img-responsive"/>
</li>
<li>
<a href="dashboard.php"><i class="glyphicon glyphicon-dashboard"></i> Dashboard</a>
</li>
</li>
<?php foreach($fields as $field) { ?>
<li>
<a <?php if($field->name == "Courses") { ?> class="active-menu" <?php } ?> href="<?=$field->link?>"><i class="glyphicon glyphicon-<?=$field->img?>"></i><?=$field->name?></a>
</li>
<?php } ?>
</ul>
</div>
</nav>
<!-- /. NAV SIDE -->
<div id="page-wrapper" >
<div id="page-inner">
<div class="row">
<div class="col-md-12">
<h2>Courses </h2>
<h5>Welcome <?=$user->firstname?> <?=$user->lastname?> , Love to see you back. </h5>
</div>
</div>
<!-- ROW -->
<hr />
<div class="row">
<div class="col-md-12">
<div class="panel panel-info">
<div class="panel-heading" style="font-size:20px">
Course Management
<div class="text-right">
<?php if (!$user->isAdmin()) { ?> <button data-target="#modalCourse" class="btn btn-info text-right" data-toggle="modal">ADD</button> <?php } ?>
</div>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Course</th>
<th>Course Alias</th>
<th>Course Description</th>
<?php $t = "Course Category"; if ($user->isAdmin()) $t = "User Name"; { ?> <th><?=$t?></th> <?php } ?>
<th></th>
</tr>
</thead>
<tbody>
<?php $odd=0; foreach ($courses as $course) { ?>
<?php if ($odd % 2 == 0) $c = "odd"; else $c="even"; ?> <tr class="<?=$c?>" id="row<?=$course->id?>">
<td><?=$course->course_name?></td>
<td><?=$course->course_shortname?></td>
<td><?=$course->course_description?></td>
<?php $t = $course->category->category_name; if ($user->isAdmin()) $t = $course->category->user->firstname." ".$course->category->user->lastname; ?> <td><?=$t?></td>
<td class="center">
<?php if (!$user->isAdmin()){ ?> <span class="glyphicon glyphicon-edit hov" data-target="#modalEditCourse" data-toggle="modal"></span> <?php } ?>
<span class="delete glyphicon glyphicon-remove hov" onclick="delete_row_course('<?=$course->id?>')"></span>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<!--End Tables -->
</div>
</div>
</div>
<!-- /. PAGE INNER -->
</div>
<!-- /. PAGE WRAPPER -->
</div>
<!-- /. WRAPPER -->
<!-- MODAL COURSE -->
<div id="modalCourse" class="modal fade" style="font-size:14px">
<div class="modal-dialog" role="document">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title text-center">Course</h4>
</div>
<div class="modal-body">
<form id="crsFrm" class="form-horizontal" method="post" action="submit.php">
<div class="form-group">
<label for="courseFname" class="control-label col-sm-3">Course FullName:</label>
<div class="col-sm-9">
<input type="text" id="courseFname" class="form-control" name="CourseForName" placeholder="Full Name of your Course">
</div>
</div>
<div class="form-group">
<label for="crsSname" class="control-label col-sm-3">Course ShortName:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="crsSname" name="CourseShortName" placeholder="Short Name of your Course">
</div>
</div>
<div class="form-group">
<label for="selCrsCat" class="control-label col-sm-3">Select Course Category:</label>
<div class="col-sm-9">
<select id="selCrsCat" class="form-control" name="CourseCategory" >
<option value="Category1">Category 1</option>
<option value="Category2">Category 2</option>
<option value="Category3">Category 3</option>
</select>
</div>
</div>
<input type="submit" class="btn btn-success" value="Submit">
</form>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- MODAL EDIT COURSE -->
<div id="modalEditCourse" class="modal fade" style="font-size:14px">
<div class="modal-dialog" role="document">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title text-center">Course</h4>
</div>
<div class="modal-body">
<form id="crsFrm" class="form-horizontal" method="post" action="submit.php">
<div class="form-group row">
<label for="courseFname" class="control-label col-sm-3">Course FullName:</label>
<div class="col-sm-9">
<input type="text" id="courseFname" class="form-control" name="CourseForName" value=" Course">
</div>
</div>
<div class="form-group row">
<label for="crsSname" class="control-label col-sm-3">Course ShortName:</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="crsSname" name="CourseShortName" value="Short Name ">
</div>
</div>
<div class="form-group row">
<label for="selCrsCat" class="control-label col-sm-3">Select Course Category:</label>
<div class="col-sm-9">
<select id="selCrsCat" class="form-control" name="CourseCategory" >
<option value="Category1">Category 1</option>
<option value="Category2">Category 2</option>
<option value="Category3">Category 3</option>
</select>
</div>
</div>
<input type="submit" class="btn btn-success" value="Save">
</form>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
$('#dataTables-example').dataTable();
});
</script>
</body>
</html>