-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
292 lines (255 loc) · 15.8 KB
/
index.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
<?php require_once "inc/header.php";
$user = User::auth();
$counter = 1;
//paginate course
$course_pagination = DB::table('courses')->orderBy('id','desc')->paginate(5);
$course = $course_pagination['data'];
//all course
$all_course = DB::table('courses')->orderBy('id','desc')->getAll();
//dashboard card
$course_count = DB::table('courses')->count();
$ins_count = DB::table('users')->where('role',"teacher")->count();
$stu_count = DB::table('users')->where('role',"student")->count();
if($_POST)
{
print_r($_POST);
}
?>
<!-- ============================================================== -->
<!-- Page wrapper -->
<!-- ============================================================== -->
<div class="page-wrapper">
<!-- ============================================================== -->
<!-- Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<div class="page-breadcrumb bg-white">
<div class="row align-items-center">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">Dashboard</h4>
</div>
<?php if(!User::auth()): ?>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<div class="d-md-flex">
<ol class="breadcrumb ms-auto">
<li><a href="login.php" class="fw-normal text-danger">Login</a></li>
</ol>
<a href="register.php"
class="btn btn-danger d-none d-md-block pull-right ms-3 hidden-xs hidden-sm waves-effect waves-light text-white">Register</a>
</div>
</div>
<?php endif ?>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- ============================================================== -->
<!-- End Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- Container fluid -->
<!-- ============================================================== -->
<div class="container-fluid">
<!-- ============================================================== -->
<!-- Three charts -->
<!-- ============================================================== -->
<div class="row justify-content-center">
<div class="col-lg-4 col-md-12">
<div class="white-box analytics-info">
<h3 class="box-title">Courses</h3>
<ul class="list-inline two-part d-flex align-items-center mb-0">
<li>
<div><i class="fas fa-chart-area fa-2x text-success"></i></div>
</li>
<li class="ms-auto"><span class="counter text-success"><?= $course_count; ?></span></li>
</ul>
</div>
</div>
<div class="col-lg-4 col-md-12">
<div class="white-box analytics-info">
<h3 class="box-title">Instructors</h3>
<ul class="list-inline two-part d-flex align-items-center mb-0">
<li>
<div><i class="fas fa-chart-line fa-2x text-purple"></i></div>
</li>
<li class="ms-auto"><span class="counter text-purple"><?= $ins_count; ?></span></li>
</ul>
</div>
</div>
<div class="col-lg-4 col-md-12">
<div class="white-box analytics-info">
<h3 class="box-title">Students</h3>
<ul class="list-inline two-part d-flex align-items-center mb-0">
<li>
<div><i class="fas fa-chart-bar fa-2x text-info"></i></div>
</li>
<li class="ms-auto"><span class="counter text-info"><?= $stu_count; ?></span>
</li>
</ul>
</div>
</div>
</div>
<!-- ============================================================== -->
<!-- RECENT COURSE -->
<!-- ============================================================== -->
<div class="row">
<div class="col-md-12 col-lg-12 col-sm-12">
<div class="white-box">
<div class="d-md-flex mb-3">
<h3 class="box-title mb-0">Recently Added Course</h3>
<div class="col-md-3 col-sm-4 col-xs-6 ms-auto">
<select class="form-select shadow-none row border-top">
<?php foreach($all_course as $c): ?>
<option><?= $c->name ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="table-responsive">
<table class="table no-wrap text-center">
<thead>
<tr>
<th class="border-top-0">#</th>
<th class="border-top-0">Name</th>
<th class="border-top-0">Description</th>
<th class="border-top-0">Instructor</th>
<th class="border-top-0">Learning Platform</th>
<th class="border-top-0">View Outline</th>
</tr>
</thead>
<tbody>
<?php foreach($course as $c):
$ins_id = DB::raw("select * from courses
left join courses_users on
courses.id = courses_users.course_id
where courses.id = $c->id
")->getOne()->user_id;
$ins_name = DB::table('users')->where('id',$ins_id)->getOne()->username; ?>
<tr>
<td><?= $counter; $counter++; ?></td>
<td><?= $c->name; ?></td>
<td><?= $c->description; ?></td>
<td><?= $ins_name;?></td>
<td><?= $c->platform; ?></td>
<td>
<a href="" class="text-success">View</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- ============================================================== -->
<!-- Recent Review -->
<!-- ============================================================== -->
<div class="row">
<!-- .col -->
<div class="col-md-12 col-lg-12 col-sm-12">
<div class="card white-box p-0">
<div class="card-body">
<h3 class="box-title mb-0">Recent Reviews</h3>
</div>
</div>
<div class="comment-widgets">
<!-- review -->
<?php if($user): ?>
<div class="d-flex flex-row comment-row p-3 mt-0">
<div class="p-2"><img src="<?= $user->image ?>" alt="user" width="40" class="rounded-circle"></div>
<div class="comment-text ps-2 ps-md-3 w-100">
<h5 class="font-medium"><?= $user->username ?></h5>
<form action="" class="form-horizontal form-material" method="POST" id="review-form">
<div class="form-group ms-3">
<div class="row">
<div class="col-sm-9 border-bottom p-0">
<input type="text" placeholder="WOW! That php basic course is great. I learned a lot from there"
class="form-control p-0 border-0" name="review" id="review">
</div>
<div class="col-sm-1 p-0">
<button class="btn" type="submit"><i class="far fa-paper-plane pt-2 text-primary" ></i></button>
</div>
</div>
</div>
<div class="comment-footer d-md-flex align-items-center">
<label name="date" class="text-dark fs-2 ms-auto mt-2 mt-md-0"><?= date('M d, Y') ?></label>
</div>
</form>
</div>
</div>
<?php endif; ?>
<hr>
<!-- all reviews -->
<div id="review-list">
<?php
$reviews = DB::table('reviews')->orderBy('id','desc')->getAll();
if($reviews):
foreach($reviews as $r):
$reviewer = DB::table('users')->where('id',$r->user_id)->getOne();
?>
<div class="d-flex flex-row comment-row p-3">
<div class="p-2"><img src="<?= $reviewer->image ?>" alt="user" width="40" class="rounded-circle"></div>
<div class="comment-text ps-2 ps-md-3 active w-100">
<h5 class="font-medium"><?= $reviewer->username; ?></h5>
<span class="mb-3 d-block col-sm-10"><?= $r->review ?> </span>
<div class="comment-footer d-md-flex align-items-center">
<span class="badge bg-success rounded">5 stars</span>
<div class="text-muted fs-2 ms-auto mt-2 mt-md-0"><?= $r->date ?></div>
</div>
</div>
</div>
<?php endforeach; endif; ?>
</div>
<!-- Comment Row
<div class="d-flex flex-row comment-row p-3">
<div class="p-2"><img src="template/plugins/images/users/ritesh.jpg" alt="user" width="50" class="rounded-circle"></div>
<div class="comment-text ps-2 ps-md-3 w-100">
<h5 class="font-medium">Johnathan Doeting</h5>
<span class="mb-3 d-block">Lorem Ipsum is simply dummy text of the printing and type setting industry.It has survived not only five centuries. </span>
<div class="comment-footer d-md-flex align-items-center">
<span class="badge rounded bg-danger">Rejected</span>
<div class="text-muted fs-2 ms-auto mt-2 mt-md-0">April 14, 2021</div>
</div>
</div>
</div> -->
</div>
</div>
</div>
<!-- /.col -->
</div>
</div>
<!-- ============================================================== -->
<!-- End Container fluid -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- footer -->
<!-- ============================================================== -->
<footer class="footer text-center"> 2021 © Ample Admin brought to you by <a
href="https://www.wrappixel.com/">wrappixel.com</a>
</footer>
<!-- ============================================================== -->
<!-- End footer -->
<!-- ============================================================== -->
</div>
<!-- ============================================================== -->
<!-- End Page wrapper -->
<!-- ============================================================== -->
<?php require_once "inc/footer.php"; ?>
<script>
var reviewForm = document.querySelector('#review-form');
var review = document.getElementById('review');
var reviewList = document.querySelector('#review-list');
reviewForm.addEventListener('submit',function(e){
e.preventDefault();
var data = new FormData();
data.append("user_id",<?= $user->id ?>)
data.append("review",review.value);
data.append("date",new Date());
console.log(data);
axios.post('api.php',data)
.then(function(res){
console.log(res.data);
review.value = "";
reviewList.innerHTML = res.data;
});
});
</script>