-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.php
299 lines (278 loc) · 12.5 KB
/
export.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
<?php
require_once 'get_user_info.php';
//用于检测是否登录,测试本页面时可暂时屏蔽以下几行php代码
if(!$is_login){
echo "<script> alert('Please login...');parent.location.href='./index.php'; </script>";
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>导出学生成绩</title>
<link rel="stylesheet" type="text/css" href="css/summarycss.css">
<link rel="stylesheet" href="style/placeholder.css">
<script src="js/jquery-3.2.1.js"></script>
<script src="js/layer/layer.js"></script>
<link href='http://cdn.webfont.youziku.com/webfonts/nomal/107666/45803/59b66f6ff629db133c19ab7b.css' rel='stylesheet' type='text/css' />
<link href='http://cdn.webfont.youziku.com/webfonts/nomal/107666/45803/59b7f3e3f629d80cf06cb9de.css' rel='stylesheet' type='text/css' />
<style>
#exportForm{
display: block;
width:450px;
height: 450px;
text-align: center;
line-height: 50px;
margin: 0 auto;
}
.hide{
display: none;
}
select{
border-radius:10px;
position: relative;
min-width: 200px;
width:auto;
height:40px;
margin: 0 auto;
padding: 0px;
background: #fff;
border-left: 5px solid grey;
cursor: pointer;
outline: none;
}
#exportForm{margin-top:50px;}
#downloadBtn{margin-top:40px;height:35px;font-size:20px;}
select{margin-top:20px;}
label{margin-right: 10px;}
label span{font-size: 25px;}
input[type="date"] {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
height: -webkit-calc(3em + 2px);
height: calc(3em + 2px);
margin: 0 0 1em;
padding: 1em;
border: 1px solid #cccccc;
border-radius: 1.5em;
background: #fff;
resize: none;
outline: none;
display: inline;
width: 200px;
margin: 15px;
}
input[type="date"][required]:focus {
border-color: #00bafa;
}
input[type="date"][required]:focus + label[placeholder]:before {
color: #00bafa;
}
input[type="date"][required]:focus + label[placeholder]:before,
input[type="date"][required]:valid + label[placeholder]:before {
-webkit-transition-duration: .2s;
transition-duration: .2s;
-webkit-transform: translate(0, -1.5em) scale(0.9, 0.9);
-ms-transform: translate(0, -1.5em) scale(0.9, 0.9);
transform: translate(0, -1.5em) scale(0.9, 0.9);
}
input[type="date"][required]:invalid + label[placeholder][alt]:before {
content: attr(alt);
}
input[type="date"][required] + label[placeholder] {
display: inline;
pointer-events: none;
line-height: 2.3em;
margin-bottom: -webkit-calc((3em - 1em) + 2px);
margin-bottom: calc((3em - 1em) + 2px);
}
input[type="date"][required] + label[placeholder]:before {
content: attr(placeholder);
display: inline;
margin: 0 -webkit-calc(1em + 2px);
margin: 0 calc(1em + 2px);
padding: 0 2px;
color: #898989;
white-space: nowrap;
-webkit-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#ffffff));
background-image: -webkit-linear-gradient(top, #ffffff, #ffffff);
background-image: linear-gradient(to bottom, #ffffff, #ffffff);
-webkit-background-size: 100% 5px;
background-size: 100% 5px;
background-repeat: no-repeat;
background-position: center;
}
</style>
</head>
<script>
</script>
<body>
<form id="exportForm" name="exportForm" >
<label style="font-family:'LiDeBiao-Xing3d15cc927c1a492';font-size:25px;" for="Class">选择班级</label><select id="Class" name="Class" style="width: 200px;">
<option value="" selected></option>
<?php
$userid = $_SESSION['userid'];
$find_class = "SELECT DISTINCT a.classId,className,enterYear FROM class as a,class_course_user as b where a.classId=b.classId and b.userId=".$userid;
require "mysql-connect.php";
$set=mysqli_query($db,$find_class);
while($row=mysqli_fetch_assoc($set)){
echo "<option value='".$row['classId']."'>".$row['enterYear'].$row['className']."</option>";
}
mysqli_close($db);
?>
</select>
<br>
<label style="font-family:'LiDeBiao-Xing3d15cc927c1a492';font-size:25px" for="course">选择课程</label>
<select id="course" name="course" style="width: 200px;">
<option value="" selected></option>
</select>
<br>
<label style="font-family:'LiDeBiao-Xing3d15cc927c1a492';font-size:25px;" for="gradeType">导出类型</label>
<select id="gradeType" name="gradeType" style="width: 200px;">
<option value="" selected></option>
<option value="normal" >平时成绩</option>
<option value="final" >期末成绩</option>
<option value="roster" >点名情况</option>
</select>
<br>
<div class="hide">
<label for="start" ><span class="cssd1bb9f6eb1a492">开始日期</span></label><input id="start" type="date" value="2017-09-01"/><br>
<label for="end"><span class="cssd1bb9f6eb1a492">结束日期</span></label><input id="end" type="date" value="2017-09-01"/>
</div>
<input style="margin-left:180px;" type="button" id="downloadBtn" value="下载" style="margin: 20px auto;">
</form>
<script>
$(function(){
$("#Class").change(function(){//选择班级
var value=$(this).val();
$("#course").empty();
$("#course").append("<option value='' selected></option>");
$("#gradeType").val("");
$("#start").val("");
$("#end").val("");
$(".hide").css("display","none");
if ("" != value){
$.post("phpData/return_courses.php",{classId:value,userId:<?php echo $_SESSION['userid'];?>},function(data){
$("#course").append(data);
});
}
});
$("#course").change(function(){//选择课程
$("#gradeType").val("");
$("#start").val("");
$("#end").val("");
$(".hide").css("display","none");
});
$("#gradeType").change(function(){//选择导出类型
var value=$(this).val();
if("" == $("#Class").val() || "" == $("#course").val()){
//alert("请先填写班级和课程信息");
layer.alert('请先填写班级和课程信息!', {
icon: 5,
skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则,去这里查阅
});
$(this).val("");
}
else{
if ("roster" == value){
//如果是点名情况
$.getJSON("phpData/getDate.php",{class:$("#Class").val(),course:$("#course").val(),userId:<?php echo $_SESSION['userid'];?>},function(data){
var arr;
arr=eval(data);
if(arr[0] == false && arr[1] == false){
layer.alert('无点名信息!', {
icon: 5,
skin: 'layer-ext-moon', //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则,去这里查阅
yes: function(index){
layer.close(index);
$("#gradeType").val("");
$("#start").val("");
$("#end").val("");
$(".hide").css("display","none");
}
});
}else {
$("#start").val(arr[0]);
$("#end").val(arr[1]);
$(".hide").css("display","block");
}
});
}else
$(".hide").css("display","none");
}
});
$("#downloadBtn").click(function(){
var gradeType = $("#gradeType").val();
var Class = $("#Class").val().trim();
var course = $("#course").val().trim();
if("roster" == gradeType){//如果点击了点名情况
//$(".hide").css("display","inline");
var start = $("#start").val();
var end = $("#end").val();
if("" == Class || "" == course || "" == gradeType){
//alert("请填写完信息再下载!")
layer.alert('请填写完信息再下载!', {
icon: 5,
skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则,去这里查阅
});
}else//信息都为非空时
{
console.log(Class+" "+course+" "+gradeType);
$.post("export_download.php",{Class:Class,course:course,gradeType:"roster",
userId:<?php echo $_SESSION['userid'];?>,start:start,end:end},function(data){
window.location.href = "tempExcel/"+Class+course+gradeType+".xls";
});
}
}
else{
if("" == Class || "" == course || "" == gradeType){
//alert("请填写完信息再下载!")
layer.alert('请填写完信息再下载!', {
icon: 5,
skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则,去这里查阅
});
}else
{
console.log(Class+" "+course+" "+gradeType);
$.post("export_download.php",{Class:Class,course:course,gradeType:gradeType,userId:<?php echo $_SESSION['userid'];?>},function(data){
//设计三种表格所对应的数据库视图,根据视图填充Excel表格,访问生成Excel表格的地址
if(data=="0")
{
layer.alert('没有平时成绩!', {//没有自定义字段!
icon: 5,
skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则,去这里查阅
});
}
else if(data=="1")
{
layer.alert('没有平时成绩!', {//没有录入自定义字段成绩!
icon: 5,
skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则,去这里查阅
});
}
else if(data=="2")
{
layer.alert('录入的数据不足,无法导出Excel!', {
icon: 5,
skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则,去这里查阅
});
}else if(data=="error")
{
layer.alert('出错啦!请重试!', {
icon: 5,
skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则,去这里查阅
});
}else
window.location.href = "tempExcel/"+Class+course+gradeType+".xls";
});
}
}
});//downloadBt
});//document.onload
</script>
</body>
</html>