-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplans.php
More file actions
323 lines (319 loc) · 10.1 KB
/
plans.php
File metadata and controls
323 lines (319 loc) · 10.1 KB
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
<!DOCTYPE html>
<?php
require_once __DIR__ . '/vendor/owasp/csrf-protector-php/libs/csrf/csrfprotector.php';
csrfProtector::init();
require('config/config.php');
$admin = isset($_GET['admin']);
if ($admin) {
$sthyear = $G["db"]->prepare("SELECT MIN(`year`) AS 'minyear',MAX(`year`) AS 'maxyear' FROM `plan`");
$sth = $G["db"]->prepare("SELECT * FROM `plan` ORDER BY `year` DESC, `type` ASC, `name` ASC");
} else {
$sthyear = $G["db"]->prepare("SELECT MIN(`year`) AS 'minyear',MAX(`year`) AS 'maxyear' FROM `plan` WHERE `inuse` = 1");
$sth = $G["db"]->prepare("SELECT * FROM `plan` WHERE `inuse` = 1 ORDER BY `year` DESC, `type` ASC, `name` ASC");
}
$sthyear->execute();
$row = $sthyear->fetch(PDO::FETCH_ASSOC);
$minyear = $row["minyear"];
$maxyear = $row["maxyear"];
$sth->execute();
$planlist = $sth->fetchAll(PDO::FETCH_ASSOC);
?>
<html lang="zh-Hant-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
require __DIR__ . '/commonhead.php';
?>
<title><?=$C["titlename"]?>/<?=($admin?"管理":"查詢")?>教案</title>
<style type="text/css">
body {
padding-top: 4.5rem;
}
.filtericon {
width: 18px;
text-align: center;
}
</style>
</head>
<body>
<?php
require("header.php");
$showform = true;
if ($admin && !$U["islogin"]) {
?>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
此功能需要驗證帳號,請<a href="<?=$C["path"]?>/login/">登入</a>
</div>
<?php
$showform = false;
}
if ($showform) {
?>
<script type="text/javascript">
function alltag(){
for (var i = 0; i < filter_tag.length; i++) {
filter_tag[i].checked = true;
}
if (tagor.checked) {
filter_notag.checked = true;
}
}
function notag(){
for (var i = 0; i < filter_tag.length; i++) {
filter_tag[i].checked = false;
}
filter_notag.checked = false;
}
function changeandor(){
if (tagand.checked) {
filter_notag.checked = false;
filter_notag.disabled = true;
filter_notag.classList.add("disabled");
} else {
filter_notag.disabled = false;
filter_notag.classList.remove("disabled");
}
}
function filter(){
console.log("filter");
var year1 = parseInt(filter_year1.value);
var year2 = parseInt(filter_year2.value);
var plantablelen = plantable.children.length-1;
for (var i = 0; i < plantablelen; i++) {
plantable.children[i].hidden = false;
}
if (!isNaN(year1)) {
for (var i = 0; i < plantablelen; i++) {
if (parseInt(plantable.children[i].children[0].innerText) < year1) {
plantable.children[i].hidden = true;
}
}
}
if (!isNaN(year2)) {
for (var i = 0; i < plantablelen; i++) {
if (parseInt(plantable.children[i].children[0].innerText) > year2) {
plantable.children[i].hidden = true;
}
}
}
var plantype = [];
for (var i = 0; i < filter_plantype.length; i++) {
plantype[filter_plantype[i].value] = filter_plantype[i].checked;
}
for (var i = 0; i < plantablelen; i++) {
if (!plantype[plantable.children[i].children[1].innerText]) {
plantable.children[i].hidden = true;
}
}
if (filter_name.value != "") {
for (var i = 0; i < plantablelen; i++) {
if (plantable.children[i].children[2].innerText.search(filter_name.value) == -1) {
plantable.children[i].hidden = true;
}
}
}
var tag = [];
var tagisand = tagand.checked;
var tagno = filter_notag.checked;
for (var i = 0; i < filter_tag.length; i++) {
if (filter_tag[i].checked) {
tag.push(filter_tag[i].value);
}
}
for (var i = 0; i < plantablelen; i++) {
var tagtemp = [];
for (var j = 0; j < plantable.children[i].children[4].children.length; j++) {
tagtemp.push(plantable.children[i].children[4].children[j].innerText);
}
var show;
if (tagtemp.length == 0 && tagno) {
show = true;
} else if (tagisand) {
show = true;
for (var j = 0; j < tag.length; j++) {
if (tagtemp.indexOf(tag[j]) == -1) {
show = false;
}
}
} else {
show = false;
for (var j = 0; j < tag.length; j++) {
if (tagtemp.indexOf(tag[j]) != -1) {
show = true;
}
}
}
if (!show) {
plantable.children[i].hidden = true;
}
}
}
function multiaction(){
var ids = [];
for (var i = 0; i < multi.length; i++) {
if (multi[i].checked) {
ids.push(multi[i].value);
}
}
if (ids.length == 0) {
multiview.classList.add("disabled");
if (window.multiedit !== undefined) {
multiedit.classList.add("disabled");
}
} else {
multiview.classList.remove("disabled");
if (window.multiedit !== undefined) {
multiedit.classList.remove("disabled");
}
}
multiview.href = "<?=$C["path"]?>/plan/"+ids.join(",")+"/";
if (window.multiedit !== undefined) {
multiedit.href = "<?=$C["path"]?>/editplans/"+ids.join(",")+"/";
}
}
</script>
<div class="container">
<h2>教案<?=($admin?"管理":"查詢")?><?php if($admin){ ?> <a class="btn btn-sm btn-primary" href="<?=$C["path"]?>/newplan/" role="button"><i class="fa fa-plus" aria-hidden="true"></i> 新增</a><?php }?></h2>
<div class="row">
<label class="col-sm-3 col-md-2 form-control-label"><i class="fa fa-calendar filtericon" aria-hidden="true"></i> 學年度</label>
<div class="col-sm-9 col-md-10 form-inline">
<input type="number" class="form-control" placeholder="起始" id="filter_year1" value="<?=$minyear?>" oninput="filter()" style="max-width: 45%;">
<span class="form-control-static">至</span>
<input type="number" class="form-control" placeholder="結束" id="filter_year2" value="<?=$maxyear?>" oninput="filter()" style="max-width: 45%;">
</div>
</div>
<div class="row">
<label class="col-sm-3 col-md-2 form-control-label"><i class="fa fa-bookmark filtericon" aria-hidden="true"></i> 分類</label>
<div class="col-sm-9 col-md-10">
<div class="checkbox">
<?php
require("func/plantype.php");
foreach ($D['plantype'] as $id => $plantype) {
?><label class="checkbox-inline">
<input type="checkbox" id="filter_plantype" value="<?=$plantype?>" checked onchange="filter()"><?=$plantype?>
</label> <?php
}
?>
</div>
</div>
</div>
<div class="row">
<label class="col-sm-3 col-md-2 form-control-label" for="filter_name"><i class="fa fa-header filtericon" aria-hidden="true"></i> 標題</label>
<div class="col-sm-9 col-md-10">
<input type="text" class="form-control" id="filter_name" oninput="filter()">
</div>
</div>
<div class="row">
<label class="col-sm-3 col-md-2 form-control-label"><i class="fa fa-tags filtericon" aria-hidden="true"></i> 標籤</label>
<div class="col-sm-9 col-md-10">
<div class="checkbox">
<?php
require('func/tag.php');
// 重大議題
foreach ($D['tagNoImportant'] as $tag => $cnt) {
?><label class="checkbox-inline" onchange="filter()">
<input type="checkbox" id="filter_tag" value="<?=htmlentities($tag)?>" checked><mark><?=htmlentities($tag)?></mark>
</label> <?php
}
?>
</div>
</div>
</div>
<!-- 重大議題 start -->
<div class="row">
<label class="col-sm-3 col-md-2 form-control-label"><i class="fa fa-tags filtericon" aria-hidden="true"></i> 重大議題</label>
<div class="col-sm-9 col-md-10">
<div class="checkbox">
<?php
foreach ($D['tagImportant'] as $tag) {
?><label class="checkbox-inline" onchange="filter()">
<input type="checkbox" id="filter_tag" value="<?=htmlentities($tag)?>" checked><mark><?=htmlentities($tag)?></mark>
</label> <?php
}
?>
<br>
<label class="checkbox-inline" onchange="filter()" data-toggle="tooltip" data-placement="bottom" title="僅在OR模式作用">
<input type="checkbox" id="filter_notag" checked>無指定標籤
</label>
<label class="checkbox-inline" data-toggle="tooltip" data-placement="bottom" title="同時包含這些標籤">
<input type="radio" name="tagandor" id="tagand" value="and" onchange="changeandor();filter();">AND
</label>
<label class="checkbox-inline" data-toggle="tooltip" data-placement="bottom" title="包含任一標籤">
<input type="radio" name="tagandor" id="tagor" value="or" checked onchange="changeandor();filter();">OR
</label>
<button type="button" class="btn btn-default btn-sm" onclick="alltag();filter();">全選</button>
<button type="button" class="btn btn-default btn-sm" onclick="notag();filter();">全不選</button>
</div>
</div>
</div>
<!-- 重大議題 end -->
<div class="table-responsive">
<table class="table">
<thead>
<th>學年度</th>
<th>分類</th>
<th>標題</th>
<th>冊別</th>
<th>標籤</th>
<th>動作</th>
</thead>
<tbody id="plantable">
<?php
foreach ($planlist as $plan) {
?>
<tr>
<td><?=$plan['year']?></td>
<td><?=$D['plantype'][$plan['type']]?></td>
<td><?=htmlentities($plan['name'])?></td>
<td><?=htmlentities($plan['volume'])?></td>
<td><?php
$plan['tag'] = json_decode($plan['tag'], true);
foreach ($plan['tag'] as $key => $tag) {
echo ($key?"、":"")."<mark>".htmlentities($tag)."</mark>";
}
?></td>
<td>
<a class="btn btn-sm btn-success" href="<?=$C["path"]?>/plan/<?=$plan['id']?>/" role="button"><i class="fa fa-eye" aria-hidden="true"></i> 查看</a>
<?php
if ($admin) {
?>
<a class="btn btn-sm btn-primary" href="<?=$C["path"]?>/editplan/<?=$plan['id']?>/" role="button"><i class="fa fa-pencil" aria-hidden="true"></i> 編輯</a>
<?php
}
?>
<label><input type="checkbox" id="multi" value="<?=$plan['id']?>" onchange="multiaction()">多筆</label>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="5"></td>
<td>
<a class="btn btn-sm btn-success disabled" id="multiview" href="<?=$C["path"]?>/plan//" role="button" target="_blank"><i class="fa fa-eye" aria-hidden="true"></i> 多筆查看</a>
<?php
if ($admin) {
?>
<a class="btn btn-sm btn-primary disabled" id="multiedit" href="<?=$C["path"]?>/editplans//" role="button" target="_blank"><i class="fa fa-pencil" aria-hidden="true"></i> 多筆編輯</a>
<?php
}
?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
}
require("footer.php");
?>
<script type="text/javascript">
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
</body>
</html>