#292 쿠폰 로그 테이블 추가하여 내역을 기록함

This commit is contained in:
chicpro
2013-09-12 11:39:43 +09:00
parent 5b622a1e32
commit e5758b4466
12 changed files with 241 additions and 150 deletions

View File

@ -50,56 +50,38 @@ if($_POST['cp_method'] == 0) {
}
if($w == '') {
$arr_mb_id = array();
if($_POST['chk_all_mb']) {
$sql = " select mb_id from {$g4['member_table']} where mb_id <> '{$config['cf_admin']}' and mb_leave_date = '' and mb_intercept_date = '' ";
$result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++) {
$arr_mb_id[] = $row['mb_id'];
}
if($i == 0)
alert('관리자를 제외한 쿠폰 발급 가능 회원이 없습니다.');
$mb_id = '전체회원';
} else {
if($_POST['mb_id'] == $config['cf_admin'])
alert('관리자를 제외한 회원의 아이디를 입력해 주십시오.');
$sql2 = " select mb_id from {$g4['member_table']} where mb_id = '{$_POST['mb_id']}' and mb_leave_date = '' and mb_intercept_date = '' ";
$row2 = sql_fetch($sql2);
if(!$row2['mb_id'])
$sql = " select mb_id from {$g4['member_table']} where mb_id = '{$_POST['mb_id']}' and mb_leave_date = '' and mb_intercept_date = '' ";
$row = sql_fetch($sql);
if(!$row['mb_id'])
alert('입력하신 회원아이디는 존재하지 않거나 탈퇴 또는 차단된 회원아이디입니다.');
$arr_mb_id[] = $_POST['mb_id'];
$mb_id = $_POST['mb_id'];
}
$mb_id_count = count($arr_mb_id);
$j = 0;
do {
$cp_id = get_coupon_id();
for($i=0; $i<$mb_id_count; $i++) {
$mb_id = $arr_mb_id[$i];
$sql3 = " select count(*) as cnt from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$row3 = sql_fetch($sql3);
$j = 0;
do {
$cp_id = get_coupon_id();
if(!$row3['cnt'])
break;
else {
if($j > 20)
die('Coupon ID Error');
}
} while(1);
$sql3 = " select count(*) as cnt from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$row3 = sql_fetch($sql3);
$sql = " INSERT INTO {$g4['shop_coupon_table']}
( cp_id, cp_subject, cp_method, cp_target, mb_id, cp_start, cp_end, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum, cp_used, cp_datetime )
VALUES
( '$cp_id', '$cp_subject', '$cp_method', '$cp_target', '$mb_id', '$cp_start', '$cp_end', '$cp_type', '$cp_price', '$cp_trunc', '$cp_minimum', '$cp_maximum', '$cp_used', '".G4_TIME_YMDHIS."' ) ";
if(!$row3['cnt'])
break;
else {
if($j > 20)
die('Coupon ID Error');
}
} while(1);
$sql = " INSERT INTO {$g4['shop_coupon_table']}
( cp_id, cp_subject, cp_method, cp_target, mb_id, cp_start, cp_end, cp_type, cp_price, cp_trunc, cp_minimum, cp_maximum, cp_used, cp_datetime )
VALUES
( '$cp_id', '$cp_subject', '$cp_method', '$cp_target', '$mb_id', '$cp_start', '$cp_end', '$cp_type', '$cp_price', '$cp_trunc', '$cp_minimum', '$cp_maximum', '$cp_used', '".G4_TIME_YMDHIS."' ) ";
sql_query($sql);
}
sql_query($sql);
} else if($w == 'u') {
$sql = " select * from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$cp = sql_fetch($sql);
@ -107,6 +89,10 @@ if($w == '') {
if(!$cp['cp_id'])
alert('쿠폰정보가 존해하지 않습니다.', './couponlist.php');
if($_POST['chk_all_mb']) {
$mb_id = '전체회원';
}
$sql = " update {$g4['shop_coupon_table']}
set cp_subject = '$cp_subject',
cp_method = '$cp_method',

View File

@ -6,11 +6,6 @@ auth_check($auth[$sub_menu], "r");
$token = get_token();
// 사용하지 않고 사용종료일이 초과된 쿠폰삭제
$end_date = date('Y-m-d', (G4_SERVER_TIME - (86400 * 7)));
$sql = " delete from {$g4['shop_coupon_table']} where cp_used = '0' and cp_end < '$end_date' ";
sql_query($sql);
$sql_common = " from {$g4['shop_coupon_table']} ";
$sql_search = " where (1) ";
@ -109,20 +104,13 @@ $colspan = 8;
<th scope="col">적용대상</th>
<th scope="col">회원아이디</a></th>
<th scope="col">사용기한</a></th>
<th scope="col">사용</th>
<th scope="col">사용회수</th>
<th scope="col">관리</th>
</tr>
</thead>
<tbody>
<?php
for ($i=0; $row=sql_fetch_array($result); $i++) {
if ($i==0 || ($row2['mb_id'] != $row['mb_id'])) {
$sql2 = " select mb_id, mb_name, mb_nick, mb_email, mb_homepage from {$g4['member_table']} where mb_id = '{$row['mb_id']}' ";
$row2 = sql_fetch($sql2);
}
$mb_nick = get_sideview($row['mb_id'], $row2['mb_nick'], $row2['mb_email'], $row2['mb_homepage']);
switch($row['cp_method']) {
case '0':
$sql3 = " select it_name from {$g4['shop_item_table']} where it_id = '{$row['cp_target']}' ";
@ -144,6 +132,11 @@ $colspan = 8;
$link1 = '<a href="./orderform.php?od_id='.$row['od_id'].'">';
$link2 = '</a>';
// 쿠폰사용회수
$sql = " select count(*) as cnt from {$g4['shop_coupon_log_table']} where cp_id = '{$row['cp_id']}' ";
$tmp = sql_fetch($sql);
$used_count = $tmp['cnt'];
?>
<tr>
@ -156,7 +149,7 @@ $colspan = 8;
<td><?php echo $cp_target; ?></td>
<td class="td_name sv_use"><div><?php echo $row['mb_id']; ?></div></td>
<td class="td_time"><?php echo substr($row['cp_start'], 2, 8); ?> ~ <?php echo substr($row['cp_end'], 2, 8); ?></td>
<td class="td_boolean"><?php echo $row['cp_used'] ? '예' : '아니오'; ?></td>
<td class="td_boolean"><?php echo number_format($used_count); ?></td>
<td class="td_smallmng">
<a href="./couponform.php?w=u&amp;cp_id=<?php echo $row['cp_id']; ?>&amp;<?php echo $qstr; ?>"><span class="sound_only"><?php echo $row['cp_id']; ?> </span>수정</a>
</td>