-
Notifications
You must be signed in to change notification settings - Fork 0
/
account-management.php
425 lines (407 loc) · 19.4 KB
/
account-management.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>账目管理</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="stylesheet" href="css/sm.min.css">
<link rel="stylesheet" href="css/sm-extend.min.css">
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/account-management.css">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<div class="page">
<header class="bar bar-nav">
<h1 class="title">账目管理</h1>
</header>
<?php
$cookie = isset($_COOKIE['identity']) ? $_COOKIE['identity'] : null;
if ($cookie == null) {
echo '<script>alert("请先登录!");location.href="login.html"</script>';
} else if ($cookie == 1) {
echo '<nav class="bar bar-tab">
<a class="tab-item external" href="home.php">
<span class="icon icon-home"></span>
<span class="tab-label">主页</span>
</a>
<a class="tab-item external active" href="account-management.html">
<span class="icon icon-edit"></span>
<span class="tab-label">账目</span>
</a>
<a class="tab-item external" href="both-management.php">
<span class="icon icon-settings"></span>
<span class="tab-label">管理</span>
</a>
<a class="tab-item external" href="me.php">
<span class="icon icon-me"></span>
<span class="tab-label">我</span>
</a>
</nav>';
} else if ($cookie == 2) {
echo '<nav class="bar bar-tab">
<a class="tab-item external" href="home.php">
<span class="icon icon-home"></span>
<span class="tab-label">主页</span>
</a>
<a class="tab-item external active" href="account-management.html">
<span class="icon icon-edit"></span>
<span class="tab-label">账目</span>
</a>
<a class="tab-item external" href="admin-management.php">
<span class="icon icon-settings"></span>
<span class="tab-label">管理</span>
</a>
<a class="tab-item external" href="me.php">
<span class="icon icon-me"></span>
<span class="tab-label">我</span>
</a>
</nav>';
}
?>
<div class="content">
<div class="content-block">
<p><a href="#" class="open-popup button button-fill button-success button-big" data-popup=".popup-add">
<i class="fa fa-plus fa-fw"></i>
添加账目</a></p>
</div>
<div class="list-block media-list">
<ul id="list">
<li v-for="item in items">
<a class="item-link item-content">
<div class="item-inner">
<div class="item-subtitle">{{item.time}}</div>
<div class="item-title-row">
<div class="item-title">{{item.title}}</div>
<input type="hidden" :value="item.type">
<div class="item-after">¥<span class="money">{{item.money}}</span></div>
</div>
<div class="item-text detail">{{item.detail}}</div>
</div>
</a>
<div class="content-button">
<input type="hidden" :value="item.id">
<input type="hidden" :value="item.title">
<input type="hidden" :value="item.time">
<input type="hidden" :value="item.type">
<input type="hidden" :value="item.money">
<input type="hidden" :value="item.detail">
<p class="buttons-row">
<a href="#" class="open-popup button button-fill modify-button" data-popup=".popup-modify">
<i class="fa fa-pencil fa-fw"></i>
编辑</a>
<form action="management-account.php?action=deleteAccount" method="post">
<input type="hidden" :value="item.id" name="id">
<a href="#" class="button button-danger button-fill delete-button">
<i class="fa fa-trash fa-fw"></i>
删除</a>
</form>
</p>
</div>
</li>
</ul>
</div>
</div>
<!--添加账目的popup-->
<div class="popup popup-add">
<div class="content-block">
<form action="management-account.php?action=addAccount" id="addForm" method="post">
<div class="list-block">
<ul>
<!-- Text inputs -->
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-name"></i></div>
<div class="item-inner">
<div class="item-title label">账目项目</div>
<div class="item-input">
<input type="text" placeholder="account name" id="title" name="title">
</div>
</div>
</div>
</li>
<!-- Date -->
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-calendar"></i></div>
<div class="item-inner">
<div class="item-title label">产生日期</div>
<div class="item-input">
<input type="text" class='datetime-picker' id="time" name="time">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-password"></i></div>
<div class="item-inner">
<div class="item-title label">账目类型</div>
<div class="item-input">
<input type="text" class="picker" id="type" name="type">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-password"></i></div>
<div class="item-inner">
<div class="item-title label">金额</div>
<div class="item-input">
<input type="text" id="money" name="money">
</div>
</div>
</div>
</li>
<li class="align-top">
<div class="item-content">
<div class="item-media"><i class="icon icon-form-comment"></i></div>
<div class="item-inner">
<div class="item-title label">账目详情</div>
<div class="item-input">
<textarea name="detail" form="addForm"></textarea>
</div>
</div>
</div>
</li>
<!-- <li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-password"></i></div>
<div class="item-inner">
<div class="item-title label" style="width: 25%">凭据</div>
<div class="item-input">
<input type="file" class="" multiple>
</div>
</div>
</div>
</li>-->
</ul>
</div>
<div class="content-block">
<div class="row">
<div class="col-50"><a href="#" class="button button-big button-fill button-danger close-popup">取消</a>
</div>
<div class="col-50"><a href="#" class="button button-big button-fill button-success"
onclick="submit()">提交</a></div>
</div>
</div>
</form>
</div>
</div>
<!--修改账目的popup-->
<div class="popup popup-modify">
<div class="content-block">
<form action="management-account.php?action=modifyAccount" id="form-modify" method="post">
<div class="list-block">
<ul>
<!-- Text inputs -->
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-name"></i></div>
<div class="item-inner">
<div class="item-title label">账目项目</div>
<div class="item-input">
<input type="hidden" name="id" id="id-modify">
<input type="text" placeholder="account name" id="title-modify" name="title">
</div>
</div>
</div>
</li>
<!-- Date -->
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-calendar"></i></div>
<div class="item-inner">
<div class="item-title label">产生日期</div>
<div class="item-input">
<input type="text" class='datetime-picker' id="time-modify" name="time">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-password"></i></div>
<div class="item-inner">
<div class="item-title label">账目类型</div>
<div class="item-input">
<input type="text" class="picker" id="type-modify" name="type">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-password"></i></div>
<div class="item-inner">
<div class="item-title label">金额</div>
<div class="item-input">
<input type="text" placeholder="金额" name="money" id="money-modify">
</div>
</div>
</div>
</li>
<li class="align-top">
<div class="item-content">
<div class="item-media"><i class="icon icon-form-comment"></i></div>
<div class="item-inner">
<div class="item-title label">账目详情</div>
<div class="item-input">
<textarea name="detail" form="form-modify" id="detail-modify"></textarea>
</div>
</div>
</div>
</li>
<!--<li>
<div class="item-content">
<div class="item-media"><i class="icon icon-form-password"></i></div>
<div class="item-inner">
<div class="item-title label" style="width: 25%">凭据</div>
<div class="item-input">
<input type="file" class="" multiple name="file" id="file">
</div>
</div>
</div>
</li>-->
</ul>
</div>
<div class="content-block">
<div class="row">
<div class="col-50"><a href="#" class="button button-big button-fill button-danger close-popup">取消</a>
</div>
<div class="col-50"><a href="#" class="button button-big button-fill button-success"
onclick="submitModify()">提交</a></div>
</div>
</div>
</form>
</div>
</div>
<script src="js/jquery-3.0.0.js"></script>
<script src="js/vue.min.js"></script>
<script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='js/sm.js' charset='utf-8'></script>
<script type='text/javascript' src='js/sm-extend.min.js' charset='utf-8'></script>
<script>
window.$$=window.Zepto = Zepto;
$$(".picker").picker({
toolbarTemplate: '<header class="bar bar-nav">\
<button class="button button-link pull-right close-picker">确定</button>\
<h1 class="title">账目类型</h1>\
</header>',
cols: [
{
textAlign: 'center',
values: ['支出', '收入']
}
]
});
$$(".datetime-picker").calendar({
dateFormat: 'yyyy-mm-dd'
});
</script>
<script>
function submit() {
var form = document.getElementById('addForm');
form.submit();
}
function submitModify() {
var form = document.getElementById('form-modify');
form.submit();
}
//获取总览信息
jQuery.get('management-account.php?action=getTotal',function (data) {
if(data==='SQL执行失败0'){
return false;
}
var totalData=JSON.parse(data);
var getData=new Vue({
el:'#list',
data:{
items:totalData
}
});
//过滤金额颜色及正负
function filter() {
var items=document.getElementsByClassName('money');
for(var i=0;i<items.length;i++){
if(items[i].parentNode.previousSibling.previousSibling.value==='1'){
items[i].className='money money-income';
items[i].innerText='+ '+items[i].innerText;
}
else{
items[i].className='money money-expend';
items[i].innerText='- '+items[i].innerText;
}
}
}
filter();
//简介截取一定字符显示
(function () {
var items = document.getElementsByClassName('detail');
for(var i = 0;i<items.length;i++){
if(items[i].innerText.length>12){
items[i].innerText=items[i].innerText.substring(0,12)+'....';
}
}
})();
//给所有项目加上提交功能
(function () {
var items = document.getElementsByClassName('submit');
for(var i = 0;i<items.length;i++){
items[i].onclick=function () {
console.log("in");
this.parentNode.submit();
}
}
})();
//给删除按钮绑定功能
(function bindDelete() {
var deleteButton=document.querySelectorAll('.delete-button');
for(var i=0;i<deleteButton.length;i++){
deleteButton[i].onclick=function () {
var form=this.parentNode;
form.submit();
}
}
})();
//给修改按键绑定功能
(function () {
//获取修改表单元素
var id=document.getElementById('id-modify');
var title=document.getElementById('title-modify');
var time=document.getElementById('time-modify');
var type=document.getElementById('type-modify');
var money=document.getElementById('money-modify');
var detail=document.getElementById('detail-modify');
//获取点击元素的信息
var modifyButton=document.getElementsByClassName('modify-button');
for(var i=0;i<modifyButton.length;i++) {
modifyButton[i].onclick = function () {
var inputId = this.parentNode.parentNode.childNodes[0];
var inputTitle = this.parentNode.parentNode.childNodes[2];
var inputTime = this.parentNode.parentNode.childNodes[4];
var inputType = this.parentNode.parentNode.childNodes[6];
var inputMoney = this.parentNode.parentNode.childNodes[8];
var inputDetail = this.parentNode.parentNode.childNodes[10];
id.value = inputId.value;
title.value = inputTitle.value;
time.value = inputTime.value;
if(inputType.value==='1'){
type.value='收入';
}
else if(inputType.value==='0'){
type.value='支出';
}
money.value = inputMoney.value;
detail.innerText = inputDetail.value;
}
}
})();
});
</script>
</body>
</html>