#209 쿠폰관리 기능 추가

This commit is contained in:
chicpro
2013-06-04 14:13:49 +09:00
parent 828b2e08d1
commit cbb278bef6
11 changed files with 807 additions and 0 deletions

View File

@ -19,6 +19,7 @@ $menu['menu400'] = array (
array('400740', '배송업체관리', G4_ADMIN_URL.'/shop_admin/deliverycodelist.php', 'scf_deli_co', 1),
array('400630', '이벤트관리', G4_ADMIN_URL.'/shop_admin/itemevent.php', 'scf_event'),
array('400640', '이벤트일괄처리', G4_ADMIN_URL.'/shop_admin/itemeventlist.php', 'scf_event_mng'),
array('400650', '쿠폰관리', G4_ADMIN_URL.'/shop_admin/couponlist.php', 'scf_coupon'),
array('400700', '내용관리', G4_ADMIN_URL.'/shop_admin/contentlist.php', 'scf_contents', 1),
array('400710', 'FAQ관리', G4_ADMIN_URL.'/shop_admin/faqmasterlist.php', 'scf_faq', 1),
array('400730', '배너관리', G4_ADMIN_URL.'/shop_admin/bannerlist.php', 'scf_banner', 1),

View File

@ -0,0 +1,240 @@
<?php
$sub_menu = '400650';
include_once('./_common.php');
auth_check($auth[$sub_menu], "w");
$g4['title'] = '쿠폰관리';
if ($w == 'u') {
$html_title = '쿠폰 수정';
$sql = " select * from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$cp = sql_fetch($sql);
if (!$cp['cp_id']) alert('등록된 자료가 없습니다.');
}
else
{
$html_title = '쿠폰 입력';
$cp['cp_start'] = G4_TIME_YMD;
$cp['cp_end'] = date('Y-m-d', (G4_SERVER_TIME + 86400 * 7));
}
if($cp['cp_method'] == 1) {
$cp_target_label = '적용분류';
$cp_target_btn = '분류검색';
} else {
$cp_target_label = '적용상품';
$cp_target_btn = '상품검색';
}
include_once (G4_ADMIN_PATH.'/admin.head.php');
?>
<form name="fcouponform" action="./couponformupdate.php" method="post" onsubmit="return form_check(this);">
<input type="hidden" name="w" value="<?php echo $w; ?>">
<input type="hidden" name="cp_id" value="<?php echo $cp_id; ?>">
<section class="cbox">
<h2><?php echo $html_title; ?></h2>
<table class="frm_tbl">
<colgroup>
<col class="grid_3">
<col>
</colgroup>
<tbody>
<tr>
<th scope="row"><label for="cp_subject">쿠폰이름</label></th>
<td>
<input type="text" name="cp_subject" value="<?php echo stripslashes($cp['cp_subject']); ?>" id="cp_subject" required class="required frm_input" size="50">
</td>
</tr>
<tr>
<th scope="row"><label for="cp_method">쿠폰종류</label></th>
<td>
<select name="cp_method" id="cp_method">
<option value="0"<?php echo get_selected('0', $cp['cp_method']); ?>>개별상품할인</option>
<option value="1"<?php echo get_selected('1', $cp['cp_method']); ?>>카테고리할인</option>
<option value="2"<?php echo get_selected('2', $cp['cp_method']); ?>>주문금액할인</option>
<option value="3"<?php echo get_selected('3', $cp['cp_method']); ?>>배송비할인</option>
</select>
</td>
</tr>
<tr id="tr_cp_target">
<th scope="row"><label for="cp_target"><?php echo $cp_target_label; ?></label></th>
<td>
<input type="text" name="cp_target" value="<?php echo stripslashes($cp['cp_target']); ?>" id="cp_target" required class="required frm_input">
<button type="button" id="sch_target"><?php echo $cp_target_btn; ?></button>
</td>
</tr>
<tr>
<th scope="row"><label for="mb_id">회원아이디</label></th>
<td>
<input type="text" class="frm_input" name="mb_id" value="<?php echo stripslashes($cp['mb_id']); ?>" id="mb_id">
<button type="button" id="sch_member">회원검색</button>
<input type="checkbox" name="chk_all_mb" id="chk_all_mb" value="1">
<label for="chk_all_mb">전체회원</label>
</td>
</tr>
<tr>
<th scope="row"><label for="cp_start">사용시작일</label></th>
<td>
<input type="text" class="frm_input required" name="cp_start" value="<?php echo stripslashes($cp['cp_start']); ?>" id="cp_start" required> 입력예: <?php echo date('Y-m-d'); ?>
</td>
</tr>
<tr>
<th scope="row"><label for="cp_end">사용종료일</label></th>
<td>
<input type="text" class="frm_input required" name="cp_end" value="<?php echo stripslashes($cp['cp_end']); ?>" id="cp_end" required> 입력예: <?php echo date('Y-m-d'); ?>
</td>
</tr>
<tr>
<th scope="row"><label for="cp_type">쿠폰타입</label></th>
<td>
<select name="cp_type" id="cp_type">
<option value="0"<?php echo get_selected('0', $cp['cp_type']); ?>>정액할인(원)</option>
<option value="1"<?php echo get_selected('1', $cp['cp_type']); ?>>정률할인(%)</option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="cp_amount"><?php echo $cp['cp_type'] ? '할인비율' : '할인금액'; ?></label></th>
<td>
<input type="text" class="frm_input required" name="cp_amount" value="<?php echo stripslashes($cp['cp_amount']); ?>" id="cp_amount" required> <span id="cp_amount_unit"><?php echo $cp['cp_type'] ? '%' : '원'; ?></span>
</td>
</tr>
<tr id="tr_cp_trunc">
<th scope="row"><label for="cp_trunc">절사금액</label></th>
<td>
<select name="cp_trunc" id="cp_trunc">
<option value="1"<?php echo get_selected('1', $cp['cp_trunc']); ?>>1원단위</option>
<option value="10"<?php echo get_selected('10', $cp['cp_trunc']); ?>>10원단위</option>
<option value="100"<?php echo get_selected('100', $cp['cp_trunc']); ?>>100원단위</option>
<option value="1000"<?php echo get_selected('1000', $cp['cp_trunc']); ?>>1,000원단위</option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="cp_minimum">최소주문금액</label></th>
<td>
<input type="text" class="frm_input" name="cp_minimum" value="<?php echo stripslashes($cp['cp_minimum']); ?>" id="cp_minimum"> 원
</td>
</tr>
<tr id="tr_cp_maximum">
<th scope="row"><label for="cp_maximum">최대할인금액</label></th>
<td>
<input type="text" class="frm_input" name="cp_maximum" value="<?php echo stripslashes($cp['cp_maximum']); ?>" id="cp_maximum"> 원
</td>
</tr>
</tbody>
</table>
<div class="btn_confirm">
<input type="submit" value="확인" class="btn_submit" accesskey="s">
<a href="./couponlist.php">목록</a>
</div>
</section>
</form>
<script>
$(function() {
<?php if($cp['cp_method'] == 2 || $cp['cp_method'] == 3) { ?>
$("#tr_cp_target").hide();
$("#tr_cp_target").find("input").attr("required", false).removeClass("required");
<?php } ?>
<?php if($cp['cp_type'] != 1) { ?>
$("#tr_cp_trunc").hide();
<?php } ?>
$("#cp_method").change(function() {
var cp_method = $(this).val();
$("#sch_target_frm").hide();
if(cp_method == "0") {
$("#sch_target").text("상품검색");
$("#tr_cp_target").find("label").text("적용상품");
$("#tr_cp_target").find("input").attr("required", true).addClass("required");
$("#tr_cp_target").show();
} else if(cp_method == "1") {
$("#sch_target").text("분류검색");
$("#tr_cp_target").find("label").text("적용분류");
$("#tr_cp_target").find("input").attr("required", true).addClass("required");
$("#tr_cp_target").show();
} else {
$("#tr_cp_target").hide();
$("#tr_cp_target").find("input").attr("required", false).removeClass("required");
}
});
$("#cp_type").change(function() {
var cp_type = $(this).val();
if(cp_type == "0") {
$("#cp_amount_unit").text("원");
$("#cp_amount_unit").closest("tr").find("label").text("할인금액");
$("#tr_cp_trunc").hide();
} else {
$("#cp_amount_unit").text("%");
$("#cp_amount_unit").closest("tr").find("label").text("할인비율");
$("#tr_cp_trunc").show();
}
});
$("#sch_target").click(function() {
var cp_method = $("#cp_method").val();
var opt = "left=50,top=50,width=500,height=400";
var url = "./coupontarget.php?sch_target=";
if(cp_method == "0") {
window.open(url+"0", "win_target", opt);
} else if(cp_method == "1") {
window.open(url+"1", "win_target", opt);
} else {
return false;
}
});
$("#sch_member").click(function() {
if($("#chk_all_mb").is(":checked")) {
alert("전체회원 체크를 해제 후 이용해 주십시오.");
return false;
}
var opt = "left=50,top=50,width=500,height=400";
var url = "./couponmember.php";
window.open(url, "win_member", opt);
});
});
function form_check(f)
{
var sel_type = f.cp_type;
var cp_type = sel_type.options[sel_type.selectedIndex].value;
var cp_amount = f.cp_amount.value;
if(!f.chk_all_mb.checked && f.mb_id.value == "") {
alert("회원아이디를 입력해 주십시오.");
return false;
}
if(isNaN(cp_amount)) {
if(cp_type == "1")
alert("할인비율을 숫자로 입력해 주십시오.");
else
alert("할인금액을 숫자로 입력해 주십시오.");
return false;
}
cp_amount = parseInt(cp_amount);
if(cp_type == "1" && (cp_amount < 1 || cp_amount > 99)) {
alert("할인비율을 1과 99 사이의 숫자로 입력해 주십시오.");
return false;
}
return true;
}
</script>
<?php
include_once (G4_ADMIN_PATH.'/admin.tail.php');
?>

View File

@ -0,0 +1,123 @@
<?php
$sub_menu = '400650';
include_once('./_common.php');
auth_check($auth[$sub_menu], "w");
$_POST = array_map('trim', $_POST);
if(!$_POST['cp_subject'])
alert('쿠폰이름을 입력해 주십시오.');
if(!$_POST['cp_method'] == 0 && !$_POST['cp_target'])
alert('적용상품을 입력해 주십시오.');
if(!$_POST['cp_method'] == 1 && !$_POST['cp_target'])
alert('적용분류를 입력해 주십시오.');
if(!$_POST['mb_id'] && !$_POST['chk_all_mb'])
alert('회원아이디를 입력해 주십시오.');
if(!$_POST['cp_start'] || !$_POST['cp_end'])
alert('사용 시작일과 종료일을 입력해 주십시오.');
if($_POST['cp_start'] > $_POST['cp_end'])
alert('사용 시작일은 종료일 이전으로 입력해 주십시오.');
if($_POST['cp_end'] < G4_TIME_YMD)
alert('종료일은 오늘('.G4_TIME_YMD.')이후로 입력해 주십시오.');
if(!$_POST['cp_amount']) {
if($_POST['cp_type'])
alert('할인비율을 입력해 주십시오.');
else
alert('할인금액을 입력해 주십시오.');
}
if($_POST['cp_type'] && ($_POST['cp_amount'] < 1 || $_POST['cp_amount'] > 99))
alert('할인비율을은 1과 99사이 값으로 입력해 주십시오.');
if($_POST['cp_method'] == 0) {
$sql = " select count(*) as cnt from {$g4['shop_item_table']} where it_id = '$cp_target' ";
$row = sql_fetch($sql);
if(!$row['cnt'])
alert('입력하신 상품코드는 존재하지 않는 상품코드입니다.');
} else if($_POST['cp_method'] == 1) {
$sql = " select count(*) as cnt from {$g4['shop_category_table']} where ca_id = '$cp_target' ";
$row = sql_fetch($sql);
if(!$row['cnt'])
alert('입력하신 분류코드는 존재하지 않는 분류코드입니다.');
}
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'];
}
} else {
$arr_mb_id[] = $_POST['mb_id'];
}
$mb_id_count = count($arr_mb_id);
for($i=0; $i<$mb_id_count; $i++) {
$mb_id = $arr_mb_id[$i];
if(!$_POST['chk_all_mb']) {
$sql2 = " select mb_id from {$g4['member_table']} where mb_id = '$mb_id' and mb_leave_date = '' and mb_intercept_date = '' ";
$row2 = sql_fetch($sql2);
if(!$row2['mb_id'])
alert('입력하신 회원아이디는 존재하지 않거나 탈퇴 또는 차단된 회원아이디입니다.');
}
$j = 0;
do {
$cp_id = get_coupon_id();
$sql3 = " select count(*) as cnt from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$row3 = sql_fetch($sql3);
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_amount, 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_amount', '$cp_trunc', '$cp_minimum', '$cp_maximum', '$cp_used', '".G4_TIME_YMDHIS."' ) ";
sql_query($sql);
}
} else if($w == 'u') {
$sql = " select * from {$g4['shop_coupon_table']} where cp_id = '$cp_id' ";
$cp = sql_fetch($sql);
if(!$cp['cp_id'])
alert('쿠폰정보가 존해하지 않습니다.', './couponlist.php');
$sql = " update {$g4['shop_coupon_table']}
set cp_subject = '$cp_subject',
cp_method = '$cp_method',
cp_target = '$cp_target',
mb_id = '$cp_mb_id',
cp_start = '$cp_start',
cp_end = '$cp_end',
cp_type = '$cp_type',
cp_amount = '$cp_amount',
cp_trunc = '$cp_trunc',
cp_maximum = '$cp_maximum',
cp_minimum = '$cp_minimum'
where cp_id = '$cp_id' ";
sql_query($sql);
}
goto_url('./couponlist.php');
?>

View File

@ -0,0 +1,194 @@
<?php
$sub_menu = '400650';
include_once('./_common.php');
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) ";
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case 'mb_id' :
$sql_search .= " ({$sfl} = '{$stx}') ";
break;
default :
$sql_search .= " ({$sfl} like '%{$stx}%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "cp_no";
$sod = "desc";
}
$sql_order = " order by {$sst} {$sod} ";
$sql = " select count(*) as cnt
{$sql_common}
{$sql_search}
{$sql_order} ";
$row = sql_fetch($sql);
$total_count = $row['cnt'];
$rows = $config['cf_page_rows'];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page == '') $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select *
{$sql_common}
{$sql_search}
{$sql_order}
limit {$from_record}, {$rows} ";
$result = sql_query($sql);
$g4['title'] = '쿠폰관리';
include_once (G4_ADMIN_PATH.'/admin.head.php');
$colspan = 8;
?>
<script>
var list_update_php = '';
var list_delete_php = 'couponlist_delete.php';
</script>
<form name="fsearch" id="fsearch" method="get">
<fieldset>
<legend>쿠폰 검색</legend>
<span>
<?php echo $listall ?>
전체 <?php echo number_format($total_count) ?> 건
</span>
<select name="sfl" title="검색대상">
<option value="mb_id"<?php echo get_selected($_GET['sfl'], "mb_id"); ?>>회원아이디</option>
<option value="cp_subject"<?php echo get_selected($_GET['sfl'], "cp_subject"); ?>>쿠폰이름</option>
<option value="cp_id"<?php echo get_selected($_GET['sfl'], "cp_id"); ?>>쿠폰코드</option>
</select>
<input type="text" name="stx" value="<?php echo $stx ?>" title="검색어(필수)" required class="required frm_input">
<input type="submit" class="btn_submit" value="검색">
</fieldset>
</form>
<section class="cbox">
<h2>쿠폰 내역</h2>
<div id="btn_add">
<a href="./couponform.php" id="coupon_add">쿠폰 추가</a>
</div>
<form name="fcouponlist" id="fcouponlist" method="post" action="./couponlist_delete.php" onsubmit="return fcouponlist_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"><input type="checkbox" name="chkall" value="1" id="chkall" title="현재 페이지 쿠폰 내역 전체선택" onclick="check_all(this.form)"></th>
<th scope="col">쿠폰코드</th>
<th scope="col">쿠폰이름</th>
<th scope="col">적용대상</th>
<th scope="col"><?php echo subject_sort_link('mb_id') ?>회원아이디</a></th>
<th scope="col"><?php echo subject_sort_link('cp_end') ?>사용기한</a></th>
<th scope="col"><?php echo subject_sort_link('cp_used') ?>사용</a></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']}' ";
$row3 = sql_fetch($sql3);
$cp_target = get_text($row3['it_name']);
break;
case '1':
$sql3 = " select ca_name from {$g4['shop_category_table']} where ca_id = '{$row['cp_target']}' ";
$row3 = sql_fetch($sql3);
$cp_target = get_text($row3['ca_name']);
break;
case '2':
$cp_target = '결제금액';
break;
case '3':
$cp_target = '배송비';
break;
}
$link1 = '<a href="./orderform.php?od_id='.$row['od_id'].'">';
$link2 = '</a>';
?>
<tr>
<td class="td_chk">
<input type="hidden" id="cp_id_<?php echo $i; ?>" name="cp_id[<?php echo $i; ?>]" value="<?php echo $row['cp_id']; ?>">
<input type="checkbox" id="chk_<?php echo $i; ?>" name="chk[]" value="<?php echo $i; ?>" title="내역선택">
</td>
<td class="td_mbid"><?php echo $row['cp_id']; ?></td>
<td class="td_mbname"><?php echo $row['cp_subject']; ?></td>
<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_pt_log"><?php echo $row['cp_used'] ? '예' : '아니오'; ?></td>
<td class="td_num td_pt"><a href="./couponform.php?w=u&amp;cp_id=<?php echo $row['cp_id']; ?>&amp;<?php echo $qstr; ?>"><img src="./img/icon_mod.jpg" alt="<?php echo $row['cp_id']; ?> 수정"></a></td>
</tr>
<?php
}
if ($i == 0)
echo '<tr><td colspan="'.$colspan.'" class="empty_table">자료가 없습니다.</td></tr>';
?>
</tbody>
</table>
<div class="btn_list">
<input type="submit" name="act_button" value="선택삭제" onclick="document.pressed=this.value">
</div>
</form>
</section>
<script>
function fcouponlist_submit(f)
{
if (!is_checked("chk[]")) {
alert(document.pressed+" 하실 항목을 하나 이상 선택하세요.");
return false;
}
if(document.pressed == "선택삭제") {
if(!confirm("선택한 자료를 정말 삭제하시겠습니까?")) {
return false;
}
}
return true;
}
</script>
<?php
include_once (G4_ADMIN_PATH.'/admin.tail.php');
?>

View File

@ -0,0 +1,25 @@
<?php
$sub_menu = '400650';
include_once('./_common.php');
check_demo();
auth_check($auth[$sub_menu], 'd');
check_token();
$count = count($_POST['chk']);
if(!$count)
alert('선택삭제 하실 항목을 하나이상 선택해 주세요.');
for ($i=0; $i<$count; $i++)
{
// 실제 번호를 넘김
$k = $_POST['chk'][$i];
$sql = " delete from {$g4['shop_coupon_table']} where cp_id = '{$_POST['cp_id'][$k]}' ";
sql_query($sql);
}
goto_url('./couponlist.php');
?>

View File

@ -0,0 +1,66 @@
<?php
$sub_menu = '400650';
include_once('./_common.php');
auth_check($auth[$sub_menu], "w");
$html_title = '회원검색';
$g4['title'] = $html_title;
include_once(G4_PATH.'/head.sub.php');
if($_GET['mb_name']) {
$sql = " select mb_id, mb_name from {$g4['member_table']} where mb_leave_date = '' and mb_intercept_date ='' and mb_name like '%$mb_name%' ";
$result = sql_query($sql);
}
?>
<div id="sch_member_frm">
<form name="fmember" method="get">
<div>
<label for="mb_name">회원이름</label>
<input type="text" name="mb_name" id="mb_name" class="frm_input required" required size="20">
</div>
<?php if($_GET['mb_name']) { ?>
<table>
<tr>
<th>회원이름</th>
<th>회원아이디</th>
<th>선택</th>
</tr>
<?php
for($i=0; $row=sql_fetch_array($result); $i++) {
?>
<tr>
<td><?php echo $row['mb_name']; ?></td>
<td><?php echo $row['mb_id']; ?></td>
<td><button type="button" onclick="sel_member_id('<?php echo $row['mb_id']; ?>');">선택</button>
</tr>
<?php
}
if($i ==0)
echo '<tr><td colspan="3">검색된 자료가 없습니다.</td></tr>';
?>
</table>
<?php } ?>
<div>
<input type="submit" value="검색">
<button type="button" onclick="window.close();">닫기</button>
</div>
</form>
</div>
<script>
function sel_member_id(id)
{
var f = window.opener.document.fcouponform;
f.mb_id.value = id;
window.close();
}
</script>
<?php
include_once(G4_PATH.'/tail.sub.php');
?>

View File

@ -0,0 +1,80 @@
<?php
$sub_menu = '400650';
include_once('./_common.php');
auth_check($auth[$sub_menu], "w");
if($_GET['sch_target'] == 1) {
$html_title = '분류검색';
$t_name = '분류명';
$t_id = '분류코드';
} else {
$html_title = '상품검색';
$t_name = '상품명';
$t_id = '상품코드';
}
$g4['title'] = $html_title;
include_once(G4_PATH.'/head.sub.php');
if($_GET['sch_word']) {
if($_GET['sch_target'] == 1) {
$sql = " select ca_id as t_id, ca_name as t_name from {$g4['shop_category_table']} where ca_use = '1' and ca_name like '%$sch_word%' ";
} else {
$sql = " select it_id as t_id, it_name as t_name from {$g4['shop_item_table']} where it_use = '1' and it_name like '%$sch_word%' ";
}
$result = sql_query($sql);
}
?>
<div id="sch_target_frm">
<form name="ftarget" method="get">
<input type="hidden" name="sch_target" value="<?php echo $_GET['sch_target']; ?>">
<div>
<label for="sch_word"><?php echo $t_name; ?></label>
<input type="text" name="sch_word" id="sch_word" class="frm_input required" required size="20">
</div>
<?php if($_GET['sch_word']) { ?>
<table>
<tr>
<th><?php echo $t_name; ?></th>
<th><?php echo $t_id; ?></th>
<th>선택</th>
</tr>
<?php
for($i=0; $row=sql_fetch_array($result); $i++) {
?>
<tr>
<td><?php echo $row['t_name']; ?></td>
<td><?php echo $row['t_id']; ?></td>
<td><button type="button" onclick="sel_target_id('<?php echo $row['t_id']; ?>');">선택</button>
</tr>
<?php
}
if($i ==0)
echo '<tr><td colspan="3">검색된 자료가 없습니다.</td></tr>';
?>
</table>
<?php } ?>
<div>
<input type="submit" value="검색">
<button type="button" onclick="window.close();">닫기</button>
</div>
</form>
</div>
<script>
function sel_target_id(id)
{
var f = window.opener.document.fcouponform;
f.cp_target.value = id;
window.close();
}
</script>
<?php
include_once(G4_PATH.'/tail.sub.php');
?>

View File

@ -228,4 +228,30 @@ if(!$result) {
sql_query(" ALTER TABLE `{$g4['shop_default_table']}`
ADD `de_mileage_use` TINYINT(4) NOT NULL DEFAULT '0' AFTER `de_point_settle` ", false);
}
// 쿠폰테이블
$sql = " DESCRIBE `{$g4['shop_coupon_table']}` ";
$result = sql_query($sql, false);
if(!$result) {
sql_query(" CREATE TABLE IF NOT EXISTS `{$g4['shop_coupon_table']}` (
`cp_no` INT(11) NOT NULL AUTO_INCREMENT,
`cp_id` VARCHAR(255) NOT NULL DEFAULT '',
`cp_subject` VARCHAR(255) NOT NULL DEFAULT '',
`cp_method` TINYINT(4) NOT NULL DEFAULT '0',
`cp_target` VARCHAR(255) NOT NULL DEFAULT '',
`mb_id` VARCHAR(255) NOT NULL DEFAULT '',
`cp_start` DATE NOT NULL DEFAULT '0000-00-00',
`cp_end` DATE NOT NULL DEFAULT '0000-00-00',
`cp_type` TINYINT(4) NOT NULL DEFAULT '0',
`cp_amount` INT(11) NOT NULL DEFAULT '0',
`cp_trunc` INT(11) NOT NULL DEFAULT '0',
`cp_minimum` INT(11) NOT NULL DEFAULT '0',
`cp_maximum` INT(11) NOT NULL DEFAULT '0',
`cp_used` TINYINT(4) NOT NULL DEFAULT '0',
`cp_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`cp_no`),
UNIQUE KEY `cp_id` (`cp_id`),
KEY `mb_id` (`mb_id`)
)", false);
}
?>

View File

@ -493,6 +493,7 @@ if($shop_install) {
fwrite($f, "\$g4['shop_order_table'] = SHOP_TABLE_PREFIX.'order'; // 주문서 테이블\n");
fwrite($f, "\$g4['shop_wish_table'] = SHOP_TABLE_PREFIX.'wish'; // 보관함(위시리스트) 테이블\n");
fwrite($f, "\$g4['shop_mileage_table'] = SHOP_TABLE_PREFIX.'mileage'; // 마일리지 테이블\n");
fwrite($f, "\$g4['shop_coupon_table'] = SHOP_TABLE_PREFIX.'coupon'; // 쿠폰정보 테이블\n");
fwrite($f, "?>");
}

View File

@ -133,6 +133,34 @@ CREATE TABLE IF NOT EXISTS `shop_content` (
-- --------------------------------------------------------
--
-- Table structure for table `shop_coupon`
--
DROP TABLE IF EXISTS `shop_coupon`;
CREATE TABLE IF NOT EXISTS `shop_coupon` (
`cp_no` INT(11) NOT NULL AUTO_INCREMENT,
`cp_id` VARCHAR(255) NOT NULL DEFAULT '',
`cp_subject` VARCHAR(255) NOT NULL DEFAULT '',
`cp_method` TINYINT(4) NOT NULL DEFAULT '0',
`cp_target` VARCHAR(255) NOT NULL DEFAULT '',
`mb_id` VARCHAR(255) NOT NULL DEFAULT '',
`cp_start` DATE NOT NULL DEFAULT '0000-00-00',
`cp_end` DATE NOT NULL DEFAULT '0000-00-00',
`cp_amount` INT(11) NOT NULL DEFAULT '0',
`cp_type` TINYINT(4) NOT NULL DEFAULT '0',
`cp_trunc` INT(11) NOT NULL DEFAULT '0',
`cp_minimum` INT(11) NOT NULL DEFAULT '0',
`cp_maximum` INT(11) NOT NULL DEFAULT '0',
`cp_used` TINYINT(4) NOT NULL DEFAULT '0',
`cp_datetime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`cp_no`),
UNIQUE KEY `cp_id` (`cp_id`),
KEY `mb_id` (`mb_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `shop_default`
--

View File

@ -1116,6 +1116,29 @@ function insert_mileage($mb_id, $point, $content='', $od_id, $ct_id)
return 1;
}
// 쿠폰번호 생성함수
function get_coupon_id()
{
$len = 16;
$chars = "ABCDEFGHJKLMNPQRSTUVWXYZ123456789";
srand((double)microtime()*1000000);
$i = 0;
$str = '';
while ($i < $len) {
$num = rand() % strlen($chars);
$tmp = substr($chars, $num, 1);
$str .= $tmp;
$i++;
}
$str = preg_replace("/([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})([0-9A-Z]{4})/", "\\1-\\2-\\3-\\4", $str);
return $str;
}
//==============================================================================
// 쇼핑몰 함수 모음 끝
//==============================================================================