-
Notifications
You must be signed in to change notification settings - Fork 14
/
teacher.html
477 lines (477 loc) · 23 KB
/
teacher.html
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>教师端 - 上上签</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0">
<link href="statics/css/bootstrap.min.css" rel="stylesheet">
<link href="statics/css/oneui.css" id="css-main" rel="stylesheet">
<link href="statics/css/style.css" rel="stylesheet">
<link href="statics/js/plugins/sweetalert2/sweetalert2.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="block">
<div class="block-content block-content-full text-center bg-image" style="background-image: url('statics/img/photo2.jpg');">
<img class="img-avatar img-avatar96 img-avatar-thumb" src="statics/img/avatar.jpg" id="avatar" alt="上上签">
<h3 class="h1 font-w400 text-white">教师端</h3>
<div class="font-w300 text-white">请教师开启GPS定位功能后设置签到</div>
</div>
<div class="block-content-full">
<div class="block block-opt-refresh-icon4" id="table-refresh">
<ul class="nav nav-tabs nav-justified">
<li class="active">
<a href="#sign-setting" id="setting" data-toggle="tab">签到设置</a>
</li>
<li>
<a href="#sign-report" id="report" data-toggle="tab">签到报表</a>
</li>
</ul>
<div class="block-content tab-content">
<div class="tab-pane fade in active" id="sign-setting">
<div class="form-horizontal">
<div class="form-group">
<div class="col-md-12">
<label for="room">教室号</label>
<input class="form-control" type="number" id="room" name="room" placeholder="请输入所在教室号...">
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<label for="class">上课班级</label>
<select class="form-control" id="class" name="class"></select>
<div class="help-block text-right">没找到班级?<a href="#" class="link-effect" data-toggle="modal" data-target="#modal-import" type="button">点此导入</a></div>
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label for="lat">纬度</label>
<input class="form-control" type="text" id="lat" name="lat" disabled>
</div>
<div class="col-xs-6">
<label for="long">经度</label>
<input class="form-control" type="text" id="long" name="long" disabled>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<button class="btn btn-lg btn-block btn-success" type="submit" id="setSignin">开始签到</button>
</div>
</div>
</div>
</div>
<div class="tab-pane fade push-50" id="sign-report">
<div class="row">
<div class="col-md-12">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-success">
<div class="panel-heading" role="button" data-toggle="collapse" data-parent="#accordion" href="#chartModal" aria-expanded="false" aria-controls="chartModal" id="signChart">
<h4 class="panel-title"><i class="si si-pie-chart"></i> 签到图表</h4>
</div>
<div id="chartModal" class="panel-collapse collapse" role="tabpanel" aria-labelledby="signChart">
<div class="row">
<div class="col-md-12" align="center">
<div id="signTotalChart" style="width: 100%;height: 250px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-xs-6">
<a class="block block-link-hover2" href="javascript:refresh();">
<div class="block-content block-content-full bg-flat clearfix">
<i class="si si-refresh fa-2x text-white pull-right"></i>
<span class="h4 text-white-op">刷新报表</span>
</div>
</a>
</div>
<div class="col-md-4 col-xs-6">
<a class="block block-link-hover2" href="javascript:download();">
<div class="block-content block-content-full bg-primary clearfix">
<i class="si si-cloud-download fa-2x text-white pull-right"></i>
<span class="h4 text-white-op">下载报表</span>
</div>
</a>
</div>
<div class="col-md-4 col-xs-12">
<a class="block block-link-hover2" href="javascript:void(0)" id="endSignin">
<div class="block-content block-content-full bg-warning clearfix">
<i class="fa fa-sign-out fa-2x text-white pull-right"></i>
<span class="h4 text-white-op">结束签到</span>
</div>
</a>
</div>
</div>
<table class="table table-striped" id="table-data">
<thead>
<tr>
<th>#</th>
<th>姓名</th>
<th>学号</th>
<th>状态</th>
<th class="hidden-xs">签到时间</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Import Modal -->
<div class="modal fade" id="modal-import" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-popout">
<div class="modal-content">
<div class="block block-themed block-transparent remove-margin-b">
<div class="block-header bg-primary">
<ul class="block-options">
<li>
<button data-dismiss="modal" type="button"><i class="si si-close"></i></button>
</li>
</ul>
<h3 class="block-title">导入班级花名册</h3>
</div>
<div class="block-content">
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<p><i class="fa fa-warning"></i> 注意!请使用.xls格式的Excel文件进行导入,Excel格式如下:</p>
<img src="statics/img/layout.png" height="95px" width="186px">
</div>
<form class="form-horizontal" action="api.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="importClass">
<div class="form-group">
<div class="col-md-12">
<label for="face">班级花名册</label>
<input class="form-control" type="file" name="file[]" accept="application/vnd.ms-excel">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<button class="btn btn-lg btn-block btn-primary" type="submit">点击导入</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- END Import Modal -->
<!-- Apps Modal -->
<div class="modal fade" id="apps-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-sm modal-dialog modal-dialog-popout">
<div class="modal-content">
<!-- Apps Block -->
<div class="block block-themed block-transparent">
<div class="block-header bg-primary-dark">
<ul class="block-options">
<li>
<button data-dismiss="modal" type="button"><i class="si si-close"></i></button>
</li>
</ul>
<h3 class="block-title">导航栏</h3>
</div>
<div class="block-content">
<div class="row text-center">
<div class="col-xs-6">
<a class="block block-rounded" href="index.html">
<div class="block-content text-white bg-primary-dark">
<i class="si si-rocket fa-2x"></i>
<div class="font-w600 push-15-t push-15">引导主页</div>
</div>
</a>
</div>
<div class="col-xs-6">
<a class="block block-rounded" href="face.html">
<div class="block-content text-white bg-danger">
<i class="si si-user-follow fa-2x"></i>
<div class="font-w600 push-15-t push-15">人脸注册</div>
</div>
</a>
</div>
<div class="col-xs-6">
<a class="block block-rounded" href="student.html">
<div class="block-content text-white bg-success">
<i class="si si-users fa-2x"></i>
<div class="font-w600 push-15-t push-15">学生端</div>
</div>
</a>
</div>
<div class="col-xs-6">
<a class="block block-rounded" href="teacher.html">
<div class="block-content text-white bg-info">
<i class="si si-user fa-2x"></i>
<div class="font-w600 push-15-t push-15">教师端</div>
</div>
</a>
</div>
</div>
</div>
</div>
<!-- END Apps Block -->
</div>
</div>
</div>
<!-- END Apps Modal -->
<div class="float btn-primary" data-toggle="modal" data-target="#apps-modal" type="button"><i class="fa fa-align-justify my-float"></i></div>
<footer id="page-footer" class="content-mini content-mini-full font-s12 bg-gray-lighter clearfix">
<div class="pull-right">
Crafted with <i class="fa fa-heart text-city"></i> by <a class="font-w600" href="https://sangsir.com" target="_blank">SangSir</a>
</div>
<div class="pull-left">
<a class="font-w600" href="https://sangsir.com" target="_blank">上上签</a> © 2017 - 沐码团队
</div>
</footer>
</div>
<script src="statics/js/oneui.min.js"></script>
<script src="statics/js/plugins/sweetalert2/es6-promise.auto.min.js"></script>
<script src="statics/js/plugins/sweetalert2/sweetalert2.min.js"></script>
<script src="statics/js/plugins/echarts/echarts.common.min.js"></script>
<script src="statics/js/plugins/echarts/macarons.js"></script>
<script src="statics/js/plugins/jquery.TableCSVExport.js"></script>
<script>
$(function () {
function geo_success(position) {
$('#lat').val(position.coords.latitude);
$('#long').val(position.coords.longitude);
}
function geo_error(error) {
switch (error.code) {
case error.TIMEOUT:
swal('定位错误', '获取地理位置超时,请检查GPS是否开启!', 'error');
break;
case error.PERMISSION_DENIED:
swal('定位错误', '请允许浏览器进行地理定位,或使用系统浏览器进行签到!', 'error');
break;
};
}
if (!!navigator.geolocation) {
navigator.geolocation.watchPosition(geo_success, geo_error, {
enableHighAccuracy: true,
maximumAge: 30000,
timeout: 27000
});
}else{
swal('定位错误', '浏览器不支持Geo Location API,请使用最新版浏览器!', 'error');
}
$.ajax({
type: "post",
url: "api.php",
dataType: "json",
data: {
action: "getClass"
},
success: function(data){
if (data.status == 2) {
swal('获取班级失败', '请预先导入班级花名册!', 'error');
}else{
for(var i=0;i<data.length;i++){
$("#class").append("<option value='"+data[i]['class']+"'>"+data[i]['class']+"</option>");
}
}
},
error: function(){
swal('网络错误', '网络错误,请稍后再试!', 'error');
}
});
$("#setSignin").click(function() {
$.ajax({
type: "post",
url: "api.php",
dataType: "json",
data: {
action: "setSignin",
room: $("#room").val(),
lat: $("#lat").val(),
long: $("#long").val(),
class: $("#class").val()
},
success: function(data){
if (data.status == 0) {
$("#room").attr("disabled",true);
$("#class").attr("disabled",true);
$("#setSignin").attr("disabled",true);
$("#report").tab('show');
swal('设置成功', '请通知学生进行签到!', 'success');
refresh();
signEcharts.resize();
}else{
$("#room").attr("disabled",true);
$("#class").attr("disabled",true);
$("#setSignin").attr("disabled",true);
$("#report").tab('show');
swal('设置失败', '当前教室已有老师上课,您已进入签到报表!', 'error');
refresh();
signEcharts.resize();
}
},
error: function(){
swal('网络错误', '网络错误,请稍后再试!', 'error');
}
});
});
$("#endSignin").click(function() {
$.ajax({
type: "post",
url: "api.php",
dataType: "json",
data: {
action: "endSignin",
room: $("#room").val()
},
success: function(data){
if (data.status == 0) {
swal('结束成功', '本次签到已完成,3秒后返回首页!', 'success');
setTimeout('reload()',3000);
}else{
swal('结束失败', '请检查是否存在当前教室!', 'error');
}
},
error: function(){
swal('网络错误', '网络错误,请稍后再试!', 'error');
}
});
});
});
var signEcharts = echarts.init(document.getElementById('signTotalChart'), 'macarons');
function getStudent() {
$.ajax({
type: "post",
url: "api.php",
dataType: "json",
data: {
action: "getStudent",
class: $("#class").val()
},
success: function(data){
if (data.status == 1) {
swal('获取数据失败', '请检查是否存在当前班级!', 'error');
}else{
$("tbody").html('');
$.each(data, function(i, data){
var status = '<span class="label label-primary">未签到</span>';
var newRow = '<tr><td>'+i+'</td><td>'+data['name']+'</td><td>'+data['number']+'</td><td id="'+data['name']+'-status">'+status+'</td><td id="'+data['name']+'-time" class="hidden-xs"></td></tr>';
$("tbody").append(newRow);
});
}
},
error: function(){
swal('网络错误', '网络错误,请稍后再试!', 'error');
}
});
}
function getSignin() {
App.blocks('#table-refresh', 'state_loading');
$.ajax({
type: "post",
url: "api.php",
dataType: "json",
data: {
action: "getSignin",
room: $("#room").val()
},
success: function(data){
App.blocks('#table-refresh', 'state_normal');
if (data.status == 1) {
swal('获取数据失败', '请检查是否存在当前教室!', 'error');
}else if(data.status == 2){
var nosignTotal = $('.label-primary').length;
signEcharts.setOption({
title: {
text: '总人数:'+ nosignTotal +'人',
left: 'center'
},
tooltip : {
trigger: 'item',
formatter: "{b}:{c}人 ({d}%)"
},
legend: {
bottom: 10,
left: 'center',
data: ['已签到', '未签到','已请假']
},
series : [
{
type: 'pie',
radius: '55%',
data:[
{value:nosignTotal, name:'未签到'}
]
}
]
});
signEcharts.resize();
}else{
$.each(data, function(i, field){
if(field['status']==1){
var status = '<a class="label label-danger" href="javascript:showReason(\'请假理由:'+field['reason']+'\')">已请假</a>';
}else{
var status = '<span class="label label-success">已签到</span>';
}
$("#"+field['name']+"-status").html(status);
$("#"+field['name']+"-time").text(field['time']);
var leaveTotal = $('.label-danger').length;
var signTotal = $('.label-success').length;
var nosignTotal = $('.label-primary').length;
signEcharts.setOption({
title: {
text: '总人数:'+ parseInt(signTotal + nosignTotal + leaveTotal) +'人',
left: 'center'
},
tooltip : {
trigger: 'item',
formatter: "{b}:{c}人 ({d}%)"
},
legend: {
bottom: 10,
left: 'center',
data: ['已签到', '未签到','已请假']
},
series : [
{
type: 'pie',
radius: '55%',
data:[
{value:signTotal, name:'已签到'},
{value:nosignTotal, name:'未签到'},
{value:leaveTotal, name:'已请假'}
]
}
]
});
signEcharts.resize();
});
}
},
error: function(){
App.blocks('#table-refresh', 'state_normal');
swal('网络错误', '网络错误,请稍后再试!', 'error');
}
});
}
function download() {
$('#table-data').TableCSVExport({
delivery: 'download',
filename: $("#class").val()+'签到报表.csv'
});
}
function showReason(reason) {
swal(reason);
}
function reload() {
window.location.reload();
}
function refresh() {
getStudent();
setTimeout(getSignin,30);
signEcharts.resize();
}
$(".panel-heading").click(function(){
setTimeout(signEcharts.resize,1);
});
window.onresize = signEcharts.resize;
</script>
</body>
</html>