ListCard.php
12.3 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
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
<?php
define('EmpireCMSAdmin','1');
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/functions.php");
require "../".LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//驗證用戶
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//ehash
$ecms_hashur=hReturnEcmsHashStrAll();
//驗證權限
CheckLevel($logininid,$loginin,$classid,"card");
//增加點卡
function AddCard($add,$userid,$username){
global $empire,$dbtbpre;
if(!$add[card_no]||!$add[password]||!$add[money])
{printerror("EmptyCard","history.go(-1)");}
//驗證權限
CheckLevel($userid,$username,$classid,"card");
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewscard where card_no='$add[card_no]' limit 1");
if($num)
{printerror("ReCard","history.go(-1)");}
$cardtime=date("Y-m-d H:i:s");
$add[cardfen]=(int)$add[cardfen];
$add[money]=(int)$add[money];
$add[carddate]=(int)$add[carddate];
$add[cdgroupid]=(int)$add[cdgroupid];
$add[cdzgroupid]=(int)$add[cdzgroupid];
$sql=$empire->query("insert into {$dbtbpre}enewscard(card_no,password,cardfen,money,cardtime,endtime,carddate,cdgroupid,cdzgroupid) values('$add[card_no]','$add[password]',$add[cardfen],$add[money],'$cardtime','$add[endtime]',$add[carddate],$add[cdgroupid],$add[cdzgroupid]);");
$cardid=$empire->lastid();
if($sql)
{
//操作日誌
insert_dolog("cardid=$cardid&card_no=$add[card_no]&cardfen=$add[cardfen]&carddate=$add[carddate]");
printerror("AddCardSuccess","AddCard.php?enews=AddCard".hReturnEcmsHashStrHref2(0));
}
else
{printerror("DbError","history.go(-1)");}
}
//批量增加點卡
function AddMoreCard($add,$userid,$username){
global $empire,$dbtbpre;
$donum=(int)$add['donum'];
$cardnum=(int)$add['cardnum'];
$passnum=(int)$add['passnum'];
$add[cardfen]=(int)$add[cardfen];
$add[money]=(int)$add[money];
$add[carddate]=(int)$add[carddate];
$add[cdgroupid]=(int)$add[cdgroupid];
$add[cdzgroupid]=(int)$add[cdzgroupid];
if(!$donum||!$cardnum||!$passnum||!$add[money])
{printerror("EmptyMoreCard","history.go(-1)");}
//驗證權限
CheckLevel($userid,$username,$classid,"card");
$cardtime=date("Y-m-d H:i:s");
//寫入卡號
$no=1;
while($no<=$donum)
{
$card_no=strtolower(no_make_password($cardnum));
$password=strtolower(no_make_password($passnum));
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewscard where card_no='$card_no' limit 1");
if(!$num)
{
$sql=$empire->query("insert into {$dbtbpre}enewscard(card_no,password,cardfen,money,cardtime,endtime,carddate,cdgroupid,cdzgroupid) values('$card_no','$password',$add[cardfen],$add[money],'$cardtime','$add[endtime]',$add[carddate],$add[cdgroupid],$add[cdzgroupid]);");
$no+=1;
}
}
if($sql)
{
//操作日誌
insert_dolog("cardnum=$donum&cardfen=$add[cardfen]&carddate=$add[carddate]");
printerror("AddMoreCardSuccess","AddMoreCard.php".hReturnEcmsHashStrHref2(1));
}
else
{printerror("DbError","history.go(-1)");}
}
//修改點卡
function EditCard($add,$userid,$username){
global $empire,$time,$dbtbpre;
$add[cardid]=(int)$add[cardid];
if(!$add[card_no]||!$add[password]||!$add[money]||!$add[cardid])
{printerror("EmptyCard","history.go(-1)");}
//驗證權限
CheckLevel($userid,$username,$classid,"card");
$num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewscard where card_no='$add[card_no]' and cardid<>".$add[cardid]." limit 1");
if($num)
{printerror("ReCard","history.go(-1)");}
$add[cardfen]=(int)$add[cardfen];
$add[money]=(int)$add[money];
$add[carddate]=(int)$add[carddate];
$add[cdgroupid]=(int)$add[cdgroupid];
$add[cdzgroupid]=(int)$add[cdzgroupid];
$sql=$empire->query("update {$dbtbpre}enewscard set card_no='$add[card_no]',password='$add[password]',cardfen=$add[cardfen],money=$add[money],endtime='$add[endtime]',carddate=$add[carddate],cdgroupid=$add[cdgroupid],cdzgroupid=$add[cdzgroupid] where cardid='$add[cardid]'");
if($sql)
{
//操作日誌
insert_dolog("cardid=$add[cardid]&card_no=$add[card_no]&cardfen=$add[cardfen]&carddate=$add[carddate]");
printerror("EditCardSuccess","ListCard.php?time=$time".hReturnEcmsHashStrHref2(0));
}
else
{printerror("DbError","history.go(-1)");}
}
//刪除點卡
function DelCard($cardid,$userid,$username){
global $empire,$time,$dbtbpre;
$cardid=(int)$cardid;
if(!$cardid)
{printerror("NotChangeCardid","history.go(-1)");}
//驗證權限
CheckLevel($userid,$username,$classid,"card");
$r=$empire->fetch1("select card_no,cardfen,carddate from {$dbtbpre}enewscard where cardid='$cardid'");
$sql=$empire->query("delete from {$dbtbpre}enewscard where cardid='$cardid'");
if($sql)
{
//操作日誌
insert_dolog("cardid=$cardid&card_no=$r[card_no]&cardfen=$r[cardfen]&carddate=$r[carddate]");
printerror("DelCardSuccess","ListCard.php?time=$time".hReturnEcmsHashStrHref2(0));
}
else
{printerror("DbError","history.go(-1)");}
}
//批量刪除點卡
function DelCard_all($add,$userid,$username){
global $empire,$time,$dbtbpre;
$cardid=$add[cardid];
$count=count($cardid);
if(!$count)
{
printerror("NotChangeCardid","history.go(-1)");
}
//驗證權限
CheckLevel($userid,$username,$classid,"card");
$ids='';
$dh='';
for($i=0;$i<$count;$i++)
{
$ids.=$dh.intval($cardid[$i]);
$dh=',';
}
$sql=$empire->query("delete from {$dbtbpre}enewscard where cardid in (".$ids.")");
if($sql)
{
//操作日誌
insert_dolog("");
printerror("DelCardSuccess","ListCard.php?time=$add[time]".hReturnEcmsHashStrHref2(0));
}
else
{printerror("DbError","history.go(-1)");}
}
$enews=$_POST['enews'];
if(empty($enews))
{$enews=$_GET['enews'];}
if($enews)
{
hCheckEcmsRHash();
}
//增加點卡
if($enews=="AddCard")
{
$add=$_POST['add'];
AddCard($add,$logininid,$loginin);
}
//修改點卡
elseif($enews=="EditCard")
{
$time=(int)$_POST['time'];
$add=$_POST['add'];
EditCard($add,$logininid,$loginin);
}
//刪除點卡
elseif($enews=="DelCard")
{
$time=(int)$_GET['time'];
$cardid=$_GET['cardid'];
DelCard($cardid,$logininid,$loginin);
}
elseif($enews=="AddMoreCard")//批量增加點卡
{
$add=$_POST;
AddMoreCard($add,$logininid,$loginin);
}
elseif($enews=="DelCard_all")//批量刪除點卡
{
DelCard_all($_POST,$logininid,$loginin);
}
$search=$ecms_hashur['ehref'];
$time=$_GET['time'];
if(empty($time))
{$time=$_POST['time'];}
$time=RepPostStr($time,1);
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$line=25;
$page_line=25;
$add="";
//搜索
$sear=$_POST['sear'];
if(empty($sear))
{$sear=$_GET['sear'];}
$sear=RepPostStr($sear,1);
if($sear)
{
$show=$_POST['show'];
if(empty($show))
{$show=$_GET['show'];}
$show=RepPostStr($show,1);
$keyboard=$_POST['keyboard'];
if(empty($keyboard))
{$keyboard=$_GET['keyboard'];}
$keyboard=RepPostVar2($keyboard);
if($show==1)
{$add=" where card_no like '%$keyboard%'";}
elseif($show==2)
{$add=" where money='$keyboard'";}
elseif($show==3)
{$add=" where cardfen='$keyboard'";}
else
{$add=" where carddate='$keyboard'";}
$search.="&sear=1&show=$show&keyboard=$keyboard";
}
//過期
if($time)
{
$today=date("Y-m-d");
$search.="&time=$time";
if($add)
{$add.=" and endtime<>'0000-00-00' and endtime<'$today'";}
else
{$add.=" where endtime<>'0000-00-00' and endtime<'$today'";}
}
$offset=$line*$page;
$totalquery="select count(*) as total from {$dbtbpre}enewscard".$add;
$num=$empire->gettotal($totalquery);
$query="select cardid,card_no,password,cardfen,money,endtime,cardtime,carddate from {$dbtbpre}enewscard".$add;
$query.=" order by cardid desc limit $offset,$line";
$sql=$empire->query($query);
$returnpage=page2($num,$line,$page_line,$start,$page,$search);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>管理點卡</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
<script>
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name != 'chkall')
e.checked = form.chkall.checked;
}
}
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td width="50%">位置:<a href="ListCard.php<?=$ecms_hashur['whehref']?>">管理點卡</a></td>
<td><div align="right" class="emenubutton">
<input type="button" name="Submit5" value="增加點卡" onclick="self.location.href='AddCard.php?enews=AddCard<?=$ecms_hashur['ehref']?>';">
<input type="button" name="Submit52" value="批量增加點卡" onclick="self.location.href='AddMoreCard.php<?=$ecms_hashur['whehref']?>';">
<input type="button" name="Submit53" value="管理過期點卡" onclick="self.location.href='ListCard.php?time=1<?=$ecms_hashur['ehref']?>';">
</div></td>
</tr>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="1">
<form name=search method=get action=ListCard.php>
<?=$ecms_hashur['eform']?>
<tr bgcolor="#FFFFFF">
<td height="25" colspan="6"> 搜索:
<input name="keyboard" type="text" id="keyboard"> <select name="show" id="show">
<option value="1">卡號</option>
<option value="2">金額</option>
<option value="3">點數</option>
<option value="4">天數</option>
</select> <input type="submit" name="Submit" value="搜索"> <input name="sear" type="hidden" id="sear" value="1">
<input name="time" type="hidden" id="time" value="<?=$time?>"> </td>
</tr>
</form>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="tableborder">
<form name="listcardform" method="post" action="ListCard.php" onsubmit="return confirm('確認要刪除?');">
<?=$ecms_hashur['form']?>
<input type="hidden" name="enews" value="DelCard_all">
<input name="time" type="hidden" id="time" value="<?=$time?>">
<tr class="header">
<td width="4%"><div align="center"></div></td>
<td width="7%" height="25"> <div align="center">ID</div></td>
<td width="36%" height="25"> <div align="center">卡號</div></td>
<td width="14%" height="25"> <div align="center">金額(元)</div></td>
<td width="12%"><div align="center">有效期</div></td>
<td width="12%" height="25"> <div align="center">點數</div></td>
<td width="15%" height="25"> <div align="center">操作</div></td>
</tr>
<?
while($r=$empire->fetch($sql))
{
?>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
<td><div align="center">
<input name="cardid[]" type="checkbox" id="cardid[]" value="<?=$r[cardid]?>">
</div></td>
<td height="25"> <div align="center">
<?=$r[cardid]?>
</div></td>
<td height="25"> <div align="center"> <a alt="End Time:<?=$r[endtime]?><br>Add Time:<?=$r[cardtime]?>">
<?=$r[card_no]?>
</a> </div></td>
<td height="25"> <div align="center">
<?=$r[money]?>
</div></td>
<td><div align="center"><?=$r[carddate]?></div></td>
<td height="25"> <div align="center">
<?=$r[cardfen]?>
</div></td>
<td height="25"> <div align="center">[<a href="AddCard.php?enews=EditCard&cardid=<?=$r[cardid]?>&time=<?=$time?><?=$ecms_hashur['ehref']?>">修改</a>] [<a href="ListCard.php?enews=DelCard&cardid=<?=$r[cardid]?>&time=<?=$time?><?=$ecms_hashur['href']?>" onclick="return confirm('確認要刪除?');">刪除</a>]</div></td>
</tr>
<?
}
?>
<tr bgcolor="#FFFFFF">
<td height="25"> <div align="center">
<input type=checkbox name=chkall value=on onclick="CheckAll(this.form)">
</div></td>
<td height="25" colspan="6">
<?=$returnpage?>
<input type="submit" name="Submit2" value="刪除選中"> </td>
</tr>
</form>
</table>
</body>
</html>
<?
db_close();
$empire=null;
?>