Feat: VIP 만료일 관리 기능 추가 - 테이블에 만료일 컬럼 추가, 입장 시 자동 만료일 설정, 일괄 설정 페이지 추가
This commit is contained in:
@ -157,6 +157,7 @@ $table = "{$fg['vip_list_table']} AS a LEFT JOIN {$fg['vip_category_table']} AS
|
||||
<col width="130px">
|
||||
<col width="100px">
|
||||
<col width="90px">
|
||||
<col width="90px">
|
||||
<col width="50px">
|
||||
<col width="100px">
|
||||
</colgroup>
|
||||
@ -167,6 +168,7 @@ $table = "{$fg['vip_list_table']} AS a LEFT JOIN {$fg['vip_category_table']} AS
|
||||
<th class="text-center">성명</th>
|
||||
<th class="text-center">연락처</th>
|
||||
<th class="text-center">생년월일</th>
|
||||
<th class="text-center">만료일</th>
|
||||
<th class="text-center">최종이용일</th>
|
||||
<th class="text-center">방문횟수</th>
|
||||
<?php if($_SESSION['user_lv'] > "1"){ ?>
|
||||
@ -182,6 +184,7 @@ $table = "{$fg['vip_list_table']} AS a LEFT JOIN {$fg['vip_category_table']} AS
|
||||
<td class="text-center"><?=$R['vip_name']?></td>
|
||||
<td class="text-center"><?=$R['vip_tel']?></td>
|
||||
<td class="text-center"><?=$R['vip_birth']?></td>
|
||||
<td class="text-center"><?=($R['vip_date'] == '9999-12-31')? '평생' : $R['vip_date']?></td>
|
||||
<td class="text-center">
|
||||
<?php
|
||||
$edate = $R['last_ent_date'];
|
||||
|
||||
@ -14,9 +14,19 @@ if(isset($_POST['mode']) && trim($_POST['mode']) === "enter") {
|
||||
|
||||
$date = date("Y-m-d");
|
||||
$datetime = date("Y-m-d H:i:s");
|
||||
|
||||
// 만료일 설정 로직
|
||||
// 방문횟수가 0이면 등록일 + 1년, 1 이상이면 최종이용일 + 1년
|
||||
if ($ent_count == 1) {
|
||||
// 첫 입장: 등록일 + 1년
|
||||
$vip_date = date("Y-m-d", strtotime($list['join_datetime'] . " +1 year"));
|
||||
} else {
|
||||
// 재입장: 현재 최종이용일 + 1년
|
||||
$vip_date = date("Y-m-d", strtotime($date . " +1 year"));
|
||||
}
|
||||
|
||||
// 리스트 DB에 최종사용일자 업데이트
|
||||
$listquery = "UPDATE {$fg['vip_list_table']} SET last_ent_date='{$date}', ent_count='{$ent_count}' WHERE idx='{$idx}'";
|
||||
// 리스트 DB에 최종사용일자 및 만료일 업데이트
|
||||
$listquery = "UPDATE {$fg['vip_list_table']} SET last_ent_date='{$date}', ent_count='{$ent_count}', vip_date='{$vip_date}' WHERE idx='{$idx}'";
|
||||
$result = sql_query($listquery);
|
||||
|
||||
$data = array("isSuccess" => $result);
|
||||
@ -30,7 +40,7 @@ if(isset($_POST['mode']) && trim($_POST['mode']) === "enter") {
|
||||
|
||||
// log 기록
|
||||
$work = "VIP입장";
|
||||
$work_detail = "카드번호 : ".$list['vip_card_no']." 처리자 : ".$_SESSION['user_name'];
|
||||
$work_detail = "카드번호 : ".$list['vip_card_no']." 만료일 설정 : ".$vip_date." 처리자 : ".$_SESSION['user_name'];
|
||||
|
||||
$logUpdate = log_update($work, $work_detail, $_SESSION['user_id'], $datetime);
|
||||
if ($isDebug && !$logUpdate) echo '로그 등록 실패\n';
|
||||
|
||||
117
manager/vip/vip_list_expire_date.php
Normal file
117
manager/vip/vip_list_expire_date.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* VIP 만료일 설정 페이지
|
||||
* 방문횟수가 0인 경우 등록일 +1년을 만료일로 설정
|
||||
* 방문횟수가 1 이상인 경우 최종이용일 +1년을 만료일로 설정
|
||||
*/
|
||||
|
||||
include_once ('./_common.php');
|
||||
if(!$_SESSION['user_id']) exit;
|
||||
|
||||
$isDebug = false; // 디버그 출력용 변수
|
||||
|
||||
if(isset($_POST['mode'])) {
|
||||
$mode = trim($_POST['mode']);
|
||||
|
||||
if ($mode === "set_expire_date") {
|
||||
$idx = trim($_POST['idx']);
|
||||
|
||||
$squery = "SELECT * FROM {$fg['vip_list_table']} WHERE idx='{$idx}'";
|
||||
$list = sql_fetch($squery);
|
||||
|
||||
if ($list) {
|
||||
$ent_count = $list['ent_count'];
|
||||
$datetime = date("Y-m-d H:i:s");
|
||||
|
||||
// 만료일 설정 로직
|
||||
if ($ent_count == 0) {
|
||||
// 방문횟수가 0: 등록일 + 1년
|
||||
$vip_date = date("Y-m-d", strtotime($list['join_datetime'] . " +1 year"));
|
||||
$logic_desc = "등록일 기준";
|
||||
} else {
|
||||
// 방문횟수가 1 이상: 최종이용일 + 1년
|
||||
$vip_date = date("Y-m-d", strtotime($list['last_ent_date'] . " +1 year"));
|
||||
$logic_desc = "최종이용일 기준";
|
||||
}
|
||||
|
||||
// DB 업데이트
|
||||
$updateQuery = "UPDATE {$fg['vip_list_table']} SET vip_date='{$vip_date}' WHERE idx='{$idx}'";
|
||||
$result = sql_query($updateQuery);
|
||||
|
||||
$data = array(
|
||||
"isSuccess" => $result,
|
||||
"vip_date" => $vip_date,
|
||||
"logic" => $logic_desc,
|
||||
"ent_count" => $ent_count
|
||||
);
|
||||
|
||||
// log 기록
|
||||
$work = "VIP만료일설정";
|
||||
$work_detail = "카드번호 : ".$list['vip_card_no']." 만료일 : ".$vip_date." (".$logic_desc.") 처리자 : ".$_SESSION['user_name'];
|
||||
|
||||
$logUpdate = log_update($work, $work_detail, $_SESSION['user_id'], $datetime);
|
||||
if ($isDebug && !$logUpdate) echo '로그 등록 실패\n';
|
||||
} else {
|
||||
$data = array("isSuccess" => false, "error" => "존재하지 않는 VIP입니다.");
|
||||
}
|
||||
} else if ($mode === "bulk_set_expire_date") {
|
||||
/**
|
||||
* 일괄 만료일 설정
|
||||
*/
|
||||
$status = isset($_POST['status']) ? trim($_POST['status']) : "정상";
|
||||
$gr_id = isset($_POST['gr_id']) ? trim($_POST['gr_id']) : "";
|
||||
|
||||
// 검색 조건 만들기
|
||||
$where = " WHERE status='{$status}'";
|
||||
if (!empty($gr_id)) {
|
||||
$where .= " AND gr_id='{$gr_id}'";
|
||||
}
|
||||
|
||||
$squery = "SELECT * FROM {$fg['vip_list_table']}{$where}";
|
||||
$result_list = sql_query($squery);
|
||||
|
||||
$updated_count = 0;
|
||||
$error_count = 0;
|
||||
$datetime = date("Y-m-d H:i:s");
|
||||
|
||||
while($list = sql_fetch_array($result_list)) {
|
||||
$ent_count = $list['ent_count'];
|
||||
|
||||
// 만료일 설정 로직
|
||||
if ($ent_count == 0) {
|
||||
// 방문횟수가 0: 등록일 + 1년
|
||||
$vip_date = date("Y-m-d", strtotime($list['join_datetime'] . " +1 year"));
|
||||
} else {
|
||||
// 방문횟수가 1 이상: 최종이용일 + 1년
|
||||
$vip_date = date("Y-m-d", strtotime($list['last_ent_date'] . " +1 year"));
|
||||
}
|
||||
|
||||
// DB 업데이트
|
||||
$updateQuery = "UPDATE {$fg['vip_list_table']} SET vip_date='{$vip_date}' WHERE idx='{$list['idx']}'";
|
||||
$update_result = sql_query($updateQuery);
|
||||
|
||||
if ($update_result) {
|
||||
$updated_count++;
|
||||
} else {
|
||||
$error_count++;
|
||||
}
|
||||
|
||||
// log 기록
|
||||
$work = "VIP만료일일괄설정";
|
||||
$work_detail = "카드번호 : ".$list['vip_card_no']." 만료일 : ".$vip_date." 처리자 : ".$_SESSION['user_name'];
|
||||
|
||||
$logUpdate = log_update($work, $work_detail, $_SESSION['user_id'], $datetime);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
"isSuccess" => true,
|
||||
"updated_count" => $updated_count,
|
||||
"error_count" => $error_count
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$data = array("isSuccess" => false, "error" => "요청이 없습니다.");
|
||||
}
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($data);
|
||||
Reference in New Issue
Block a user