건별로 적립된 포인트를 조회할 수 있도록 수정
This commit is contained in:
@ -108,7 +108,8 @@ if(!sql_query(" select cf_point_term from {$g4['config_table']} ", false)) {
|
||||
sql_query(" ALTER TABLE `{$g4['point_table']}`
|
||||
ADD `po_use_point` int(11) NOT NULL DEFAULT '0' AFTER `po_point`,
|
||||
ADD `po_expired` tinyint(4) NOT NULL DEFAULT '0' AFTER `po_use_point`,
|
||||
ADD `po_expire_date` date NOT NULL DEFAULT '0000-00-00' AFTER `po_expired` ", false);
|
||||
ADD `po_expire_date` date NOT NULL DEFAULT '0000-00-00' AFTER `po_expired`
|
||||
ADD `po_mb_point` int(11) NOT NULL DEFAULT '0' AFTER `po_expire_date` ", false);
|
||||
}
|
||||
|
||||
$g4['title'] = '환경설정';
|
||||
|
||||
@ -113,28 +113,16 @@ function point_clear()
|
||||
<li><?php echo subject_sort_link('po_point') ?>포인트<span class="sound_only"> 순 정렬</span></a></li>
|
||||
</ul>
|
||||
|
||||
<form name="fpointlist" id="fpointlist" method="post" action="./point_list_delete.php" onsubmit="return fpointlist_submit(this);">
|
||||
<input type="hidden" name="sst" value="<?php echo $sst ?>">
|
||||
<input type="hidden" name="sod" value="<?php echo $sod ?>">
|
||||
<input type="hidden" name="sfl" value="<?php echo $sfl ?>">
|
||||
<input type="hidden" name="stx" value="<?php echo $stx ?>">
|
||||
<input type="hidden" name="page" value="<?php echo $page ?>">
|
||||
<input type="hidden" name="token" value="<?php echo $token ?>">
|
||||
|
||||
<table class="tbl_pt_list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
<label for="chkall" class="sound_only">포인트 내역 전체</label>
|
||||
<input type="checkbox" name="chkall" value="1" id="chkall" onclick="check_all(this.form)">
|
||||
</th>
|
||||
<th scope="col">회원아이디</th>
|
||||
<th scope="col">이름</th>
|
||||
<th scope="col">별명</th>
|
||||
<th scope="col">일시</th>
|
||||
<th scope="col">포인트 내용</th>
|
||||
<th scope="col">포인트</th>
|
||||
<th scope="col">만료</th>
|
||||
<th scope="col">일시</th>
|
||||
<th scope="col">만료일</th>
|
||||
<th scope="col">포인트합</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -156,20 +144,14 @@ function point_clear()
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="td_chk">
|
||||
<input type="hidden" name="mb_id[<?php echo $i ?>]" value="<?php echo $row['mb_id'] ?>" id="mb_id_<?php echo $i ?>">
|
||||
<input type="hidden" name="po_id[<?php echo $i ?>]" value="<?php echo $row['po_id'] ?>" id="po_id_<?php echo $i ?>">
|
||||
<label for="chk_<?php echo $i; ?>" class="sound_only">내역</label>
|
||||
<input type="checkbox" name="chk[]" value="<?php echo $i ?>" id="chk_<?php echo $i ?>">
|
||||
</td>
|
||||
<td class="td_mbid"><a href="?sfl=mb_id&stx=<?php echo $row['mb_id'] ?>"><?php echo $row['mb_id'] ?></a></td>
|
||||
<td class="td_mbname"><?php echo $row2['mb_name'] ?></td>
|
||||
<td class="td_name sv_use"><div><?php echo $mb_nick ?></div></td>
|
||||
<td class="td_time"><?php echo $row['po_datetime'] ?></td>
|
||||
<td class="td_pt_log"><?php echo $link1 ?><?php echo $row['po_content'] ?><?php echo $link2 ?></td>
|
||||
<td class="td_num td_pt"><?php echo number_format($row['po_point']) ?></td>
|
||||
<td><?php echo $row['po_expired'] == 1 ? '예' : '아니오'; ?></td>
|
||||
<td class="td_bignum td_pt"><?php echo number_format($row2['mb_point']) ?></td>
|
||||
<td class="td_time"><?php echo $row['po_datetime'] ?></td>
|
||||
<td><?php echo $row['po_expire_date'] == '0000-00-00' ? ' ' : $row['po_expire_date']; ?></td>
|
||||
<td class="td_bignum td_pt"><?php echo number_format($row['po_mb_point']) ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
@ -180,12 +162,6 @@ function point_clear()
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="btn_list">
|
||||
<input type="submit" name="act_button" value="선택삭제" onclick="document.pressed=this.value">
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<?php echo get_paging(G4_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, "{$_SERVER['PHP_SELF']}?$qstr&page="); ?>
|
||||
@ -236,24 +212,6 @@ function point_clear()
|
||||
|
||||
</section>
|
||||
|
||||
<script>
|
||||
function fpointlist_submit(f)
|
||||
{
|
||||
if (!is_checked("chk[]")) {
|
||||
alert(document.pressed+" 하실 항목을 하나 이상 선택하세요.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(document.pressed == "선택삭제") {
|
||||
if(!confirm("선택한 자료를 정말 삭제하시겠습니까?")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
include_once ('./admin.tail.php');
|
||||
?>
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
$sub_menu = "200200";
|
||||
include_once('./_common.php');
|
||||
|
||||
check_demo();
|
||||
|
||||
auth_check($auth[$sub_menu], 'd');
|
||||
|
||||
check_token();
|
||||
|
||||
$count = count($_POST['chk']);
|
||||
if(!$count)
|
||||
alert($_POST['act_button']." 하실 항목을 하나 이상 체크하세요.");
|
||||
|
||||
for ($i=0; $i<$count; $i++)
|
||||
{
|
||||
// 실제 번호를 넘김
|
||||
$k = $_POST['chk'][$i];
|
||||
|
||||
$sql = " select * from {$g4['point_table']} where po_id = '{$_POST['po_id'][$k]}' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
if(!$row['po_id'])
|
||||
continue;
|
||||
|
||||
// 삭제 내역이 차감일 경우 그에 해당하는 포인트 추가 지급하고
|
||||
// 아니면 만료되지 않았을 경우 사용포인트가 있으면 남은 포인트에 반영
|
||||
if($row['po_point'] < 0) {
|
||||
if($row['po_expire_date'] == '0000-00-00' || $row['po_expire_date'] >= G4_TIME_YMD) {
|
||||
$mb_id = $row['mb_id'];
|
||||
$po_point = abs($row['po_point']);
|
||||
|
||||
delete_use_point($mb_id, $po_point);
|
||||
}
|
||||
} else {
|
||||
if($row['po_expired'] != 1 && $row['po_use_point'] > 0) {
|
||||
insert_use_point($row['mb_id'], $row['po_use_point'], $row['po_id']);
|
||||
}
|
||||
}
|
||||
|
||||
// 포인트 내역삭제
|
||||
$sql = " delete from {$g4['point_table']} where po_id = '{$_POST['po_id'][$k]}' ";
|
||||
sql_query($sql);
|
||||
|
||||
$sum_point = get_point_sum($_POST['mb_id'][$k]);
|
||||
|
||||
$sql= " update {$g4['member_table']} set mb_point = '{$sum_point}' where mb_id = '{$_POST['mb_id'][$k]}' ";
|
||||
sql_query($sql);
|
||||
}
|
||||
|
||||
goto_url('./point_list.php?'.$qstr);
|
||||
?>
|
||||
@ -73,8 +73,7 @@ while ($row = sql_fetch_array($result))
|
||||
if (!$row['wr_is_comment'])
|
||||
{
|
||||
// 원글 포인트 삭제
|
||||
if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '쓰기'))
|
||||
insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "{$board['bo_subject']} {$row['wr_id']} 글삭제");
|
||||
insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "{$board['bo_subject']} {$row['wr_id']} 글삭제");
|
||||
|
||||
// 업로드된 파일이 있다면 파일삭제
|
||||
$sql2 = " select * from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' ";
|
||||
@ -101,8 +100,7 @@ while ($row = sql_fetch_array($result))
|
||||
else
|
||||
{
|
||||
// 코멘트 포인트 삭제
|
||||
if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '코멘트'))
|
||||
insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_id']}-{$row['wr_id']} 코멘트삭제");
|
||||
insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_id']}-{$row['wr_id']} 코멘트삭제");
|
||||
|
||||
$count_comment++;
|
||||
}
|
||||
|
||||
@ -84,8 +84,7 @@ for ($i=count($tmp_array)-1; $i>=0; $i--)
|
||||
if (!$row['wr_is_comment'])
|
||||
{
|
||||
// 원글 포인트 삭제
|
||||
if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '쓰기'))
|
||||
insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "{$board['bo_subject']} {$row['wr_id']} 글 삭제");
|
||||
insert_point($row['mb_id'], $board['bo_write_point'] * (-1), "{$board['bo_subject']} {$row['wr_id']} 글 삭제");
|
||||
|
||||
// 업로드된 파일이 있다면
|
||||
$sql2 = " select * from {$g4['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row['wr_id']}' ";
|
||||
@ -114,8 +113,7 @@ for ($i=count($tmp_array)-1; $i>=0; $i--)
|
||||
else
|
||||
{
|
||||
// 코멘트 포인트 삭제
|
||||
if (!delete_point($row['mb_id'], $bo_table, $row['wr_id'], '코멘트'))
|
||||
insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_id']}-{$row['wr_id']} 코멘트삭제");
|
||||
insert_point($row['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_id']}-{$row['wr_id']} 코멘트삭제");
|
||||
|
||||
$count_comment++;
|
||||
}
|
||||
|
||||
@ -59,8 +59,7 @@ if ($row['cnt'] && !$is_admin)
|
||||
alert('이 코멘트와 관련된 답변코멘트가 존재하므로 삭제 할 수 없습니다.');
|
||||
|
||||
// 코멘트 삭제
|
||||
if (!delete_point($write['mb_id'], $bo_table, $comment_id, '댓글'))
|
||||
insert_point($write['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_parent']}-{$comment_id} 코멘트삭제");
|
||||
insert_point($write['mb_id'], $board['bo_comment_point'] * (-1), "{$board['bo_subject']} {$write['wr_parent']}-{$comment_id} 코멘트삭제");
|
||||
|
||||
// 코멘트 삭제
|
||||
sql_query(" delete from {$write_table} where wr_id = '{$comment_id}' ");
|
||||
|
||||
@ -495,7 +495,8 @@ CREATE TABLE IF NOT EXISTS `g4s_point` (
|
||||
`po_point` int(11) NOT NULL default '0',
|
||||
`po_use_point` int(11) NOT NULL default '0',
|
||||
`po_expired` tinyint(4) NOT NULL default '0',
|
||||
`po_expire_date` date NOT NULL default '0000-00-00',
|
||||
`po_expire_date` date NOT NULL default '0000-00-00',
|
||||
`po_mb_point` int(11) NOT NULL default '0',
|
||||
`po_rel_table` varchar(20) NOT NULL default '',
|
||||
`po_rel_id` varchar(20) NOT NULL default '',
|
||||
`po_rel_action` varchar(255) NOT NULL default '',
|
||||
|
||||
@ -881,11 +881,6 @@ function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $r
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 포인트를 사용한 경우 포인트 내역에 사용금액 기록
|
||||
if($point < 0) {
|
||||
insert_use_point($mb_id, $point);
|
||||
}
|
||||
|
||||
// 포인트 건별 생성
|
||||
$po_expire_date = '0000-00-00';
|
||||
if($config['cf_point_term'] > 0) {
|
||||
@ -896,8 +891,10 @@ function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $r
|
||||
}
|
||||
|
||||
$po_expired = 0;
|
||||
if($point < 0)
|
||||
if($point < 0) {
|
||||
$po_expired = 1;
|
||||
$po_expire_date = G4_TIME_YMD;
|
||||
}
|
||||
|
||||
$sql = " insert into {$g4['point_table']}
|
||||
set mb_id = '$mb_id',
|
||||
@ -911,11 +908,23 @@ function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $r
|
||||
po_rel_id = '$rel_id',
|
||||
po_rel_action = '$rel_action' ";
|
||||
sql_query($sql);
|
||||
$po_id = mysql_insert_id();
|
||||
|
||||
$sum_point = get_point_sum($mb_id);
|
||||
// 포인트를 사용한 경우 포인트 내역에 사용금액 기록
|
||||
if($point < 0) {
|
||||
insert_use_point($mb_id, $point);
|
||||
}
|
||||
|
||||
// 회원포인트
|
||||
$sum_mb_point = get_point_sum($mb_id);
|
||||
|
||||
// 포인트 UPDATE
|
||||
$sql = " update {$g4['member_table']} set mb_point = '$sum_point' where mb_id = '$mb_id' ";
|
||||
$sql = " update {$g4['member_table']} set mb_point = '$sum_mb_point' where mb_id = '$mb_id' ";
|
||||
sql_query($sql);
|
||||
|
||||
$sql = " update {$g4['point_table']}
|
||||
set po_mb_point = '$sum_mb_point'
|
||||
where po_id = '$po_id' ";
|
||||
sql_query($sql);
|
||||
|
||||
return 1;
|
||||
@ -957,53 +966,23 @@ function insert_use_point($mb_id, $point, $po_id='')
|
||||
}
|
||||
}
|
||||
|
||||
function delete_use_point($mb_id, $point)
|
||||
{
|
||||
global $g4;
|
||||
|
||||
$point1 = abs($point);
|
||||
$sql = " select po_id, po_use_point, po_expired, po_expire_date
|
||||
from {$g4['point_table']}
|
||||
where mb_id = '$mb_id'
|
||||
and po_use_point > 0
|
||||
order by po_id desc ";
|
||||
$result = sql_query($sql);
|
||||
for($i=0; $row=sql_fetch_array($result); $i++) {
|
||||
$point2 = $row['po_use_point'];
|
||||
|
||||
$po_expired = $row['po_expired'];
|
||||
if($row['po_expired'] == 100 && ($row['po_expire_date'] == '0000-00-00' || $row['po_expire_date'] >= G4_TIME_YMD))
|
||||
$po_expired = 0;
|
||||
|
||||
if($point2 >= $point1) {
|
||||
$sql = " update {$g4['point_table']}
|
||||
set po_use_point = po_use_point - '$point1',
|
||||
po_expired = '$po_expired'
|
||||
where po_id = '{$row['po_id']}' ";
|
||||
sql_query($sql);
|
||||
break;
|
||||
} else {
|
||||
$sql = " update {$g4['point_table']}
|
||||
set po_use_point = '0',
|
||||
po_expired = '$po_expired'
|
||||
where po_id = '{$row['po_id']}' ";
|
||||
sql_query($sql);
|
||||
|
||||
$point1 -= $point2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 포인트 내역 합계
|
||||
function get_point_sum($mb_id)
|
||||
{
|
||||
global $g4, $config;
|
||||
|
||||
// 유효기간이 있을 때 기간이 지난 포인트 expired 체크
|
||||
if($config['cf_point_term'] > 0) {
|
||||
// 소멸포인트가 있으면 내역 추가
|
||||
$expire_point = get_expire_point($mb_id);
|
||||
if($expire_point > 0) {
|
||||
insert_point($mb_id, -1*$expire_point, '포인트 소멸', '@expire', $mb_id, 'expire'.'-'.uniqid(''));
|
||||
}
|
||||
|
||||
// 유효기간이 있을 때 기간이 지난 포인트 expired 체크
|
||||
$sql = " update {$g4['point_table']}
|
||||
set po_expired = '1'
|
||||
where mb_id = '$mb_id'
|
||||
and po_expired <> '1'
|
||||
and po_expire_date <> '0000-00-00'
|
||||
and po_expire_date < '".G4_TIME_YMD."' ";
|
||||
sql_query($sql);
|
||||
@ -1016,46 +995,29 @@ function get_point_sum($mb_id)
|
||||
and po_expired = '0' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
return $row['sum_po_point'];
|
||||
if($row['sum_po_point'] < 0)
|
||||
return 0;
|
||||
else
|
||||
return $row['sum_po_point'];
|
||||
}
|
||||
|
||||
// 포인트 삭제
|
||||
function delete_point($mb_id, $rel_table, $rel_id, $rel_action)
|
||||
// 소멸 포인트
|
||||
function get_expire_point($mb_id)
|
||||
{
|
||||
global $g4;
|
||||
global $g4, $config;
|
||||
|
||||
$result = false;
|
||||
if ($rel_table || $rel_id || $rel_action)
|
||||
{
|
||||
// 포인트정보
|
||||
$sql = " select po_id, mb_id, po_use_point, po_expired
|
||||
from {$g4['point_table']}
|
||||
where mb_id = '$mb_id'
|
||||
and po_rel_table = '$rel_table'
|
||||
and po_rel_id = '$rel_id'
|
||||
and po_rel_action = '$rel_action' ";
|
||||
$row = sql_fetch($sql);
|
||||
if($config['cf_point_term'] == 0)
|
||||
return 0;
|
||||
|
||||
$result = sql_query(" delete from {$g4['point_table']}
|
||||
where mb_id = '$mb_id'
|
||||
and po_rel_table = '$rel_table'
|
||||
and po_rel_id = '$rel_id'
|
||||
and po_rel_action = '$rel_action' ", false);
|
||||
$sql = " select sum(po_point - po_use_point) as sum_point
|
||||
from {$g4['point_table']}
|
||||
where mb_id = '$mb_id'
|
||||
and po_expired = '0'
|
||||
and po_expire_date <> '0000-00-00'
|
||||
and po_expire_date < '".G4_TIME_YMD."' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
// 포인트 사용 값이 있으면 다른 포인트 내역으로 이동시킴
|
||||
if($result && $row['po_expired'] != 1 && $row['po_use_point'] > 0) {
|
||||
insert_use_point($row['mb_id'], $row['po_use_point'], $row['po_id']);
|
||||
}
|
||||
|
||||
// 포인트 내역의 합을 구하고
|
||||
$sum_point = get_point_sum($mb_id);
|
||||
|
||||
// 포인트 UPDATE
|
||||
$sql = " update {$g4['member_table']} set mb_point = '$sum_point' where mb_id = '$mb_id' ";
|
||||
$result = sql_query($sql, false);
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $row['sum_point'];
|
||||
}
|
||||
|
||||
// 회원 레이어
|
||||
|
||||
Reference in New Issue
Block a user