퍼스트가든에서 사용하는 사용자 함수 및 관련파일 추가

This commit is contained in:
2025-07-02 14:14:02 +09:00
parent 68797db562
commit ec949b682d
265 changed files with 27086 additions and 0 deletions

View File

@ -0,0 +1,4 @@
<?php
include_once '../../common.php';
include_once '../config.php';
include_once '../lib/lib.php';

View File

@ -0,0 +1,144 @@
<?php
// if (!defined('_GNUBOARD_')) define('_GNUBOARD_', true); // 상위 공통파일에서 정의되어 있다면 생략 가능
// 고객에게 보내는 SMS를 통해 고객이 직접 접속하므로 주석처리
include_once('./_common.php'); // 공통 환경 로드
$isDebug = false; // 디버그 여부, 필요시 true로 변경
$b5_code = $annual_items['빅5'];
$nor_code = $annual_items['일반'];
$annu_item_code = array_values($annual_items);
// 1. 요청된 od_id 받기 (GET 또는 POST)
$od_id = isset($_REQUEST['od_id']) ? trim($_REQUEST['od_id']) : '';
if (!$od_id) {
alert('주문번호가 없습니다.');
exit;
}
// 2. 주문정보 유효성 체크
$order = sql_fetch("SELECT od_id FROM {$g5['g5_shop_order_table']} WHERE od_id = '{$od_id}'");
if (!$order) {
alert('유효하지 않은 주문번호입니다.');
exit;
}
// 4. 주문 상품별 수량 조회 (연간회원권에 해당하는 상품만)
$sql = "SELECT it_id, ct_qty FROM {$g5['g5_shop_cart_table']} WHERE od_id = '{$od_id}' AND it_id IN ('".implode("','", $annu_item_code)."')";
$result = sql_query($sql);
if (sql_num_rows($result) == 0) {
alert('연간회원권 상품 주문 내역이 없습니다.');
exit;
}
// 5. 상품별 수량 데이터 배열로 저장
$items = [];
while ($row = sql_fetch_array($result)) {
$items[] = [
'it_id' => $row['it_id'],
'ct_qty' => (int)$row['ct_qty']
];
}
// 6. 상품별 카테고리 정의
function getAnnuCaID($it_id) {
global $annual_items;
foreach ($annual_items as $name => $code) {
if ($code == $it_id) {
return [
'ca_id' => ($name == '빅5') ? 5 : 3, // 필요시 다른 로직으로 분기
'ca_name' => $name
];
}
}
return ['ca_id' => 0, 'ca_name' => '기타'];
}
// 7. HTML 출력 시작
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<title>연간회원 정보 입력</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<script src="https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
<script>
function execDaumPostcode(targetId) {
new daum.Postcode({
oncomplete: function(data) {
var addr = data.userSelectedType === 'R' ? data.roadAddress : data.jibunAddress;
document.getElementById(targetId).value = addr;
}
}).open();
}
</script>
</head>
<body>
<section class="container-sm my-5" style="max-width:800px;">
<h3>퍼스트가든 연간회원 정보입력</h3>
<form action="annual_member_insert.update.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="od_id" value="<?=htmlspecialchars($od_id)?>" readonly>
<?php
$idx = 0;
foreach ($items as $item) {
$ca = getAnnuCaID($item['it_id']);
$ca_name = $ca['ca_name'];
$ca_id = $ca['ca_id'];
for ($i = 0; $i < $item['ct_qty']; $i++, $idx++) {
?>
<div class="mb-4 p-3 border rounded">
<h5><?=$ca_name?> 회원 <?=$i+1?></h5>
<input type="hidden" name="it_id_<?=$idx?>" value="<?=htmlspecialchars($item['it_id'])?>">
<input type="hidden" name="ca_id_<?=$idx?>" value="<?=$ca_id?>">
<div class="mb-2">
<label for="name_<?=$idx?>" class="form-label">성명</label>
<input type="text" id="name_<?=$idx?>" name="name_<?=$idx?>" class="form-control" required>
</div>
<div class="mb-2">
<label class="form-label">성별</label><br>
<input type="radio" id="gender_male_<?=$idx?>" name="gender_<?=$idx?>" value="남" checked required>
<label for="gender_male_<?=$idx?>">남</label>
<input type="radio" id="gender_female_<?=$idx?>" name="gender_<?=$idx?>" value="여" required>
<label for="gender_female_<?=$idx?>">여</label>
</div>
<div class="mb-2">
<label for="tel_<?=$idx?>" class="form-label">연락처</label>
<input type="text" id="tel_<?=$idx?>" name="tel_<?=$idx?>" class="form-control" maxlength="11" required>
</div>
<div class="mb-2">
<label for="birth_<?=$idx?>" class="form-label">생년월일</label>
<input type="date" id="birth_<?=$idx?>" name="birth_<?=$idx?>" class="form-control" max="9999-12-31" required>
</div>
<div class="mb-2">
<label for="email_<?=$idx?>" class="form-label">이메일</label>
<input type="email" id="email_<?=$idx?>" name="email_<?=$idx?>" class="form-control">
</div>
<div class="mb-2">
<label for="addr_<?=$idx?>" class="form-label">주소</label>
<input type="text" id="addr_<?=$idx?>" name="addr_<?=$idx?>" class="form-control">
<button type="button" class="btn btn-primary mt-1" onclick="execDaumPostcode('addr_<?=$idx?>')">주소검색</button>
</div>
<div class="mb-2">
<label for="photofile_<?=$idx?>" class="form-label">사진첨부</label>
<input type="file" id="photofile_<?=$idx?>" name="photofile_<?=$idx?>" class="form-control" required>
</div>
</div>
<?php
}
}
?>
<button type="submit" class="btn btn-primary">등록 완료</button>
</form>
</section>
</body>
</html>

View File

@ -0,0 +1,28 @@
<?php
include_once '_common.php';
if(!$_SESSION['user_id']) exit;
// POST로 가져온 값 정리
$ca_id = trim($_POST['idx']);
$table = $fg['annual_category_table'];
// log 기록
// 그룹명 가져와서 담기
$query = "SELECT * FROM {$table} WHERE ca_id='{$ca_id}'";
$org_data = sql_fetch($query);
$time = date("Y-m-d H:i:s");
$work = "연간회원 구분 삭제";
$work_detail = "구분 : ".$org_data['name'].", 처리자 : ".$_SESSION['user_name'];
log_update($work, $work_detail, $_SESSION['user_id'], $time);
// 삭제실행
$query = "DELETE FROM {$table} WHERE ca_id='{$ca_id}'";
$result = sql_query($query);
$data = array("isSuccess" => $result);
header("Content-Type: application/json");
echo json_encode($data);

View File

@ -0,0 +1,56 @@
<?php
include_once '_common.php';
if(!$_SESSION['user_id']) exit;
$ca_id = trim($_POST['ca_id']);
$ca_name = trim($_POST['ca_name']);
$ca_used = trim($_POST['ca_used']);
$ca_info = trim($_POST['ca_info']);
$table = $fg['annual_category_table'];
// 업데이트 전 정보 불러오기
$q = "SELECT * FROM {$table} WHERE ca_id = '{$ca_id}'";
$org_data = sql_fetch($q);
// 변경된 정보 넣어주기
$w1 = "정보수정";
$w2 = "";
if($org_data['name'] != $ca_name) {
$w1 .= "/이름변경";
$w2 .= $org_data['name']."->".$ca_name;
}
if($org_data['used'] != $ca_used) {
if(!empty($w1)) {
$w1 .= ", ";
$w2 .= ", ";
}
if($org_data['used'] == 1) {
$w2 .= "사용 -> 미사용";
} else {
$w2 .= "미사용 -> 사용";
}
}
if($org_data['info'] != $ca_info) {
if(!empty($w1)) {
$w1 .= ", ";
$w2 .= ", ";
}
$w2 .= $org_data['info']."->".$ca_info;
}
// DB에 업데이트
$query = "UPDATE {$table} SET ca_name = '{$ca_name}', ca_used = '{$ca_used}', ca_info = '{$ca_info}'";
$query .= " WHERE ca_id = '{$ca_id}'";
$result = sql_query($query);
if ( $result ) {
$work_detail = $w2.", 처리자 : ".$_SESSION['user_name'];
$time = date("Y-m-d H:i:s");
log_update($w1, $work_detail, $_SESSION['user_id'], $time);
$data = array("isSuccess" => $result);
header("Content-Type: application/json");
echo json_encode($data);
}

View File

@ -0,0 +1,117 @@
<?php
// 연간회원권 구분관리
include_once "_common.php";
if (!isset($_SESSION['user_id'])) header( 'Location: FG_MANAGER_URL' ); // 로그인 되어있지 않으면 로그인 페이지로 보냄
include_once FG_MANAGER_PATH."/head.php";
$table = $fg['annual_category_table'];
$record_count = get_num_rows($table);
$ord_by = " ORDER BY ca_id ASC ";
$R = get_result($table, $ord_by, $query_limit);
?>
<div class="text-left">
전체 구분 수 : <b><?=$record_count?></b>
</div>
<div class="text-center">
<table class="table table-striped">
<colgroup>
<col width="80px">
<col width="200px">
<col />
<col width="150px">
</colgroup>
<thead>
<tr>
<th class="text-center">고유번호</th>
<th class="text-center">구분명</th>
<th class="text-center">정보</th>
<th class="text-center">관리</th>
</tr>
</thead>
<tbody>
<?php foreach($R as $R){?>
<tr class="<?=(($R['ca_used'] != 1) ? "unused" : "")?>">
<td class="text-center"><?=$R['ca_id']?></td>
<td class="text-center"><?=$R['ca_name']?></td>
<td class="text-center"><?=nl2br($R['ca_info'])?></td>
<td class="text-center">
<!-- 수정 버튼 -->
<button class="btn btn-success btn-xs" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['ca_id']?>"><i class="fa-solid fa-pen-to-square"></i></button>
<!-- 삭제버튼 -->
<?php if ($_SESSION['user_lv'] = "4"){ ?>
<a class="btn btn-danger btn-xs" href="javascript:deleteItem('<?=$R['ca_id']?>')" role="button"><i class="fa-solid fa-trash-can"></i></a>
<?php } ?>
<!-- 삭제버튼 끝 -->
<!-- 수정 모달 -->
<div id="modify_modal_<?=$R['ca_id']?>" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form class="modify">
<input type="hidden" id="ca_id_<?=$R['ca_id']?>" name="ca_id" readonly value="<?=$R['ca_id']?>">
<input type="hidden" id="name_<?=$R['ca_id']?>" name="ca_name" readonly value="<?=$R['ca_name']?>">
<div class="modal-header">
<h4 class="modal-title"><?=$R['ca_name']?> 정보 수정</h4>
</div>
<div class="modal-body">
<div class="mb-3">
<input type="radio" class="btn-check" name="ca_used" id="used_<?=$R['ca_id']?>_1" value="1" <?=($R['ca_used'] == 1) ? "checked" : "" ?> required>
<label class="btn btn-outline-primary" for="used_<?=$R['ca_id']?>_1">활성</label>
<input type="radio" class="btn-check" name="ca_used" id="used_<?=$R['ca_id']?>_0" value="0" <?=($R['ca_used'] != 1) ? "checked" : "" ?> required>
<label class="btn btn-outline-primary" for="used_<?=$R['ca_id']?>_0">비활성</label>
</div>
<div class="input-group mb-3">
<span class="input-group-text col-md-2" id="ca_info">정보</span>
<textarea class="form-control" name="ca_info" id="ca_info"><?=$R['ca_info']?></textarea>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">수정</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">닫기</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<!-- 수정 모달 끝 -->
</td>
</tr>
<?php } ?>
</tbody>
<!-- 추가버튼 위치 -->
<tfoot>
<tr>
<td colspan="4" class="text-right">
<button type="button" class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#add_modal">추가</button>
<!-- 추가 버튼을 누르면 출력한다. -->
<div id="add_modal" class="modal fade text-center"">
<div class="modal-dialog" style="width:800px;">
<div class="modal-content">
<form class="signup">
<div class="modal-header">
<h4 class="modal-title">구분 추가</h4>
</div>
<div class="modal-body text-left">
<div class="input-group mb-1">
<span class="input-group-text col-md-2" id="ca_name">구분명</span>
<input type="text" class="form-control" id="ca_name" name="ca_name" value="" required>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-2" id="ca_info">정보</span>
<textarea class="form-control" name="ca_info" id="ca_info"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="submit" id="add_submit" class="btn btn-primary">추가</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">닫기</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</td>
</tr>
</tfoot>
</table>
</div>
<? include_once FG_MANAGER_PATH."/tail.php";

View File

@ -0,0 +1,28 @@
<?php
include_once '_common.php';
if(!$_SESSION['user_id']) exit;
// 테이블 선택
$table = $fg['annual_category_table'];
// 변수 선언
$ca_name = trim($_POST['ca_name']);
$ca_info = trim($_POST['ca_info']);
$ca_used = 1;
// update query
$query = "INSERT INTO {$table}(ca_name, ca_info, ca_used)";
$query .= "VALUES('{$ca_name}', '{$ca_info}', '1') ";
$result = sql_query($query);
// log 기록
$work = '연간회원/구분추가';
$work_detail = "구분명 : ".$ca_name.", 내용 : ".$ca_info.", 처리자 : ".$_SESSION['user_name'];
$time = date("Y-m-d H:i:s");
log_update($work, $work_detail, $_SESSION['user_id'], $time);
$data = array("isSuccess" => $result);
header("Content-Type: application/json");
echo json_encode($data);

View File

@ -0,0 +1,175 @@
<?php
if( !isset($_POST['it_id']) && !$isDebug ) exit; // 디버그 중이거나 POST로 넘어온 값이 없다면 종료
include_once "_common.php";
$isDebug = false;
// 주문권종이 다를 수 있으므로 it_id를 저장함
function getAnnuOrder($od_id) {
global $g5;
$query = "SELECT it_id, ct_qty FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$od_id'";
$result = sql_query($query);
$R = array();
while($row=sql_fetch_array($result)) { // 전체 배열에 저장
array_push($R, $row);
}
return $R;
}
// 상품별로 판매되므로 상품 ID에 따라 상품을 설정해줌
function getAnnuCaID($it_id) {
if ($it_id == "1730361152" ) {
$result['ca_id'] = 3;
$result['ca_name'] = "일반";
} else if ($it_id == "1728373753") {
$result['ca_id'] = 5;
$result['ca_name'] = "빅5";
}
return $result;
}
// it_id 갯수(주문수)
function getOrdCnt($od_id) {
global $g5;
$query = "SELECT COUNT(it_id) AS it_id_cnt FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$od_id'";
$result = sql_fetch($query);
return $result;
}
// POST로 넘어온 데이터 처리
$od_id = trim($_POST['od_id']);
//$od_qty = trim($_POST['od_qty']);
// 주문수량 확인(종류)
$query = "SELECT it_id FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$od_id'";
$od_cnt_query = sql_query($query);
$od_cnt = sql_num_rows($od_cnt_query);
// DB에 동일한 주문건이 있는지 확인
$chk = "SELECT od_id, ca_id FROM {$fg['annual_member_table']} WHERE od_id = '{$od_id}'";
$chk = sql_num_rows(sql_query($chk));
if ( $isDebug ) { // 디버깅 중인 경우 넘어온 값을 모두 출력함
var_dump($_REQUEST);
echo "<br><br>";
var_dump(getAnnuOrder($od_id));
}
if ( $od_cnt > $chk ) { // 입력 수량이 주문 수량보다 적을 때 진행
// POST로 넘어온 데이터 처리
$no = trim($_POST['no']);
$it_id = trim($_POST['it_id']);
$sdate = trim($_POST['sdate']);
$name = trim($_POST['name']);
$tel = trim($_POST['tel']);
$addr = trim($_POST['addr']);
$od_cnt = getOrdCnt($od_id);
$od_cnt = $od_cnt['it_id_cnt']
?>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
<script>
function execDaumPostcode(targetId) {
new daum.Postcode({
oncomplete: function(data) {
var addr = ''; // 주소 변수
if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
addr = data.roadAddress;
} else { // 사용자가 지번 주소를 선택했을 경우
addr = data.jibunAddress;
}
document.getElementById(targetId).value = addr;
}
}).open();
}
</script>
</head>
<body>
<section class="container-sm my-5" style="max-width:800px;">
<div class="header mb-3">
<h3 class="title">퍼스트가든 연간회원 정보입력</h3>
</div>
<form action="annual_member_insert.update.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="it_id_cnt" id="it_id_cnt" value="<?=$od_cnt?>" readonly>
<input type="hidden" name="od_id" id="od_id" value="<?=$od_id?>" readonly>
<input type="hidden" name="rep_name" id="rep_name" value="<?=$name?>" readonly>
<!--
<div>
약관이 출력될 부분
</div>
약관체크
<input type="hidden" name="rep_name" id="rep_name" value="<?=$name?>" readonly>
-->
<?php // 주문 수량만큼 출력함
$i = 0;
foreach (getAnnuOrder($od_id) as $row) { // 주문 종류
$ca = getAnnuCaID($row['it_id']);
//echo '<H4>' . $i+1 .'. '.$ca['ca_name'] . '</H4>';
$ct_qty = $row['ct_qty']; // 품목별 주문수량
for ($j = 0; $j < $ct_qty; $j++) {
?>
<div class="body text-left mb-3">
<label class="form-label"><?=$ca['ca_name'] . ' - ' . $j+1?></label>
<input type="hidden" name="it_id_<?=$i.$j?>" id="it_id_<?=$i.$j?>" value="<?=$row['it_id']?>" readonly>
<input type="hidden" name="sdate_<?=$i.$j?>" id="sdate_<?=$i.$j?>" value="<?=$sdate?>" readonly>
<input type="hidden" name="ca_id_<?=$i.$j?>" id="ca_id_<?=$i.$j?>" value="<?=$ca['ca_id']?>" readonly>
<input type="hidden" name="od_qty_<?=$i.$j?>" id="od_qty_<?=$i.$j?>" value="<?=$od_qty?>" readonly>
<input type="hidden" name="ct_qty_<?=$i.$j?>" id="ct_qty_<?=$i.$j?>" value="<?=$ct_qty?>" readonly>
<!-- 아래 input은 약관동의 체크용
<input type="hidden" name="ct_qty_<?=$i.$j?>" id="ct_qty_<?=$i.$j?>" value="<?=$ct_qty?>" readonly>
-->
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="label_name_<?=$i.$j?>">성명</span>
<input type="text" class="form-control" id="name_<?=$i.$j?>" name="name_<?=$i.$j?>" value="<?=(($i == 0 && $j == 0) || $isDebug) ? $name : "" ?>" required>
<input type="radio" class="btn-check" name="gender_<?=$i.$j?>" id="gender_male_<?=$i.$j?>" value="남" checked required >
<label class="btn btn-outline-primary" for="gender_male_<?=$i.$j?>">남</label>
<input type="radio" class="btn-check" name="gender_<?=$i.$j?>" id="gender_female_<?=$i.$j?>" value="여" required>
<label class="btn btn-outline-primary" for="gender_female_<?=$i.$j?>">여</label>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="tel">연락처</span>
<input type="text" class="form-control" name="tel_<?=$i.$j?>" id="tel_<?=$i.$j?>" maxlength="11" value="<?=(($i == 0 && $j == 0) || $isDebug) ? $tel : "" ?>" required>
<span class="input-group-text col-md-3" id="birth_<?=$i.$j?>">생년월일</span>
<input type="date" class="form-control" name="birth_<?=$i.$j?>" id="birth_<?=$i.$j?>" max="9999-12-31" value="<?=($isDebug) ? "9999-12-31" : ""?>" required>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="email">이메일</span>
<input type="email" class="form-control" name="email_<?=$i.$j?>" id="email_<?=$i.$j?>" value="<?php echo $email ?>" >
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="addr">주소</span>
<input type="text" class="form-control" name="addr_<?=$i.$j?>" id="addr_<?=$i.$j?>" value="<?php echo $addr ?>" >
<button type="button" class="btn btn-primary" onclick="execDaumPostcode('addr_<?=$i.$j?>')">주소검색</button>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="photofile_<?=$i.$j?>">사진첨부</span>
<input type="file" class="form-control" name="photofile_<?=$i.$j?>" id="photofile_<?=$i.$j?>" <?=($isDebug) ? "" : "required"?>>
</div>
</div>
<?php
} // endfor
$i++;
} // endforeach
?>
<div class="footer">
<div class="d-grid gap-2">
<button type="submit" id="add_submit" class="btn btn-primary">추가</button>
</div>
</div>
</form>
</section>
</body>
</html>
<?php
} else {
alert('이미 모두 입력했습니다.');
}
?>

View File

@ -0,0 +1,168 @@
<?php
include_once '_common.php';
if(!isset($_SESSION['user_id']) && !isset($_POST['app_id'])) exit; // 관리자가 입력하거나 온라인 주문이 아닌 경우 exit
if(isset($_POST['app_id'])) {
$app_id = trim($_POST['app_id']); // 접수자, 온라인 주문의 경우 온라인으로 처리
} else {
$user_name = $user_id = "온라인 자동입력"; // 온라인 주문인 경우 log에 온라인 자동입력임을 넣어줌
$app_id = "온라인";
}
$isDebug = false;
if ($isDebug) {
var_dump($_REQUEST);
echo "<br>";
}
/*
파일 업로드를 하므로 uploadDir 경로의 권한이 777이어야 함
*/
// 기본 변수 선언
$last_editdate = $datetime = date("Y-m-d H:i:s"); // 현재시간
if(isset($_POST['od_id'])) { // 온라인 주문인 경우 자동으로 넣어줄 값
$status = "검토대기";
$od_id = trim($_POST['od_id']); // 주문 ID
$rep_name = trim($_POST['rep_name']); // 대표자 이름
} else {
$status = "정상";
$od_id = $rep_name = "";
}
// 파일 업로드 설정
$dir = "/data/annual_member_photo/"; // 업로드 디렉토리
$uploadDir = FG_MANAGER_PATH . $dir; // 업로드 디렉토리 절대경로
$maxFileSize = 10 * 1024 * 1024; // 10MB
$allowedExtensions = ["jpg", "jpeg", "png", "gif"]; // 허용되는 파일 확장자
// 주문 수량만큼 처리
$od_qty = trim($_POST['it_id_cnt']);
if ($isDebug) echo "주문건수 : " . $od_qty . "<br>";
for ($i = 0; $i < $od_qty; $i++) {
$ct_qty = $_POST['ct_qty_' . $i . '0'];
if ($isDebug) {
echo '$i : ' . $i . "<br>";
echo "주문수량 : " . $ct_qty . "<br>";
}
for ($j = 0; $j < $ct_qty; $j++) {
// 개별 변수 선언
$ca_id = trim($_POST['ca_id_' . $i . $j]);
$mem_no = isset($_POST['mem_no_' . $i . $j]) ? trim($_POST['mem_no_' . $i . $j]) : ""; // 회원번호
$mem_name = trim($_POST['name_' . $i . $j]); // 성명
$mem_gender = trim($_POST['gender_' . $i . $j]); // 성별
$mem_tel = addTelHyphen(trim($_POST['tel_' . $i . $j])); // 연락처
$mem_birth = trim($_POST['birth_' . $i . $j]); // 생일
$mem_email = trim($_POST['email_' . $i . $j]); // 이메일
$mem_addr = trim($_POST['addr_' . $i . $j]); // 주소
$mem_memo = isset($_POST['memo_' . $i . $j]) ? trim($_POST['memo_' . $i . $j]) : ""; // 메모
$mem_sdate = trim($_POST['sdate_' . $i . $j]); // 시작일
$mem_edate = getAnnualEdate($mem_sdate); // 종료일 만들어주기
// 파일 업로드 처리
$fileName = $_FILES["photofile_" . $i . $j]["name"];
$fileTmpName = $_FILES["photofile_" . $i . $j]["tmp_name"];
$fileSize = $_FILES["photofile_" . $i . $j]["size"];
$fileExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
if (in_array($fileExtension, $allowedExtensions) && $fileSize <= $maxFileSize) {
$newFileName = uniqid() . "." . $fileExtension;
$uploadPath = $uploadDir . $newFileName;
$utf8TmpFileName = mb_convert_encoding($fileTmpName, 'UTF-8', 'auto');
if (move_uploaded_file($utf8TmpFileName, $uploadPath)) {
$photo_url = FG_MANAGER_URL . $dir . $newFileName;
$photo_name = $fileName;
} else {
alert("파일 업로드 실패.");
}
} else if (!$isDebug) {
alert("지원하지 않는 파일 형식이거나 파일 크기가 너무 큽니다. jpg, jpeg, png, gif 파일만 허용되며 최대 파일 크기는 " . ($maxFileSize / (1024 * 1024)) . "MB입니다.");
}
if ($isDebug) $photo_url = $photo_name = '';
// DB에 입력
$query = "INSERT INTO {$fg['annual_member_table']} (
mem_no,
status,
ca_id,
app_id,
name,
memo,
birth,
email,
addr,
tel,
gender,
sdate,
edate,
photo_url,
photo_name,
join_datetime,
last_edit_date,
last_edit_id,
last_ent_date,
ent_count,
od_id,
rep_name
) VALUES (
'{$mem_no}',
'{$status}',
'{$ca_id}',
'{$app_id}',
'{$mem_name}',
'{$mem_memo}',
'{$mem_birth}',
'{$mem_email}',
'{$mem_addr}',
'{$mem_tel}',
'{$mem_gender}',
'{$mem_sdate}',
'{$mem_edate}',
'{$photo_url}',
'{$photo_name}',
'{$last_editdate}',
'{$last_editdate}',
'{$user_id}',
'0000-00-00 00:00:00',
0,
'{$od_id}',
'{$rep_name}'
)";
if ($isDebug) {
print_r($query); // 디버깅인 경우 출력
echo "<br>";
$result = false;
} else {
$result = sql_query($query);
}
if ($result) {
// log 기록
$work = "연간회원등록";
$work_detail = "번호 : " . $mem_no . " 처리자 : " . $user_name;
log_update($work, $work_detail, $user_id, $datetime);
} else if (!$isDebug) {
alert("저장 실패");
}
}
}
if (isset($result) && $result) { // 저장이 성공했다면
// 상태를 완료처리
$update_query = "UPDATE {$g5['g5_shop_cart_table']} SET od_status = '완료' WHERE od_id = '{$od_id}'";
$result = sql_query($update_query); // 업데이트
alert("저장 완료", false);
}

View File

@ -0,0 +1,169 @@
<?php
include_once '_common.php';
if(!isset($_SESSION['user_id']) && !isset($_POST['app_id'])) exit; // 관리자가 입력하거나 온라인 주문이 아닌 경우 exit
if(isset($_POST['app_id'])) {
$app_id = trim($_POST['app_id']); // 접수자
} else {
// 온라인 주문의 경우 온라인으로 처리하므로, app_id가 존재하지 않음.
$user_name = $user_id = "온라인 자동입력"; // 온라인 주문인 경우 log에 온라인 자동입력임을 넣어줌
$app_id = "온라인";
}
$isDebug = false;
if ($isDebug) {
var_dump($_REQUEST);
echo "<br>";
}
/*
파일 업로드를 하므로 uploadDir 경로의 권한이 777이어야 함
*/
// 기본 변수 선언
$last_editdate = $datetime = date("Y-m-d H:i:s"); // 현재시간
if(isset($_POST['od_id'])) { // 온라인 주문인 경우 자동으로 넣어줄 값
$status = "검토대기";
$od_id = trim($_POST['od_id']); // 주문 ID
$rep_name = trim($_POST['rep_name']); // 대표자 이름
} else {
$status = "정상";
$od_id = $rep_name = "";
}
// 파일 업로드 설정
$dir = "/data/annual_member_photo/"; // 업로드 디렉토리
$uploadDir = FG_MANAGER_PATH . $dir; // 업로드 디렉토리 절대경로
$maxFileSize = 10 * 1024 * 1024; // 10MB
$allowedExtensions = ["jpg", "jpeg", "png", "gif"]; // 허용되는 파일 확장자
// 주문 수량만큼 처리
$od_qty = trim($_POST['it_id_cnt']);
if ($isDebug) echo "주문건수 : " . $od_qty . "<br>";
for ($i = 0; $i < $od_qty; $i++) {
$ct_qty = $_POST['ct_qty_' . $i . '0'];
if ($isDebug) {
echo '$i : ' . $i . "<br>";
echo "주문수량 : " . $ct_qty . "<br>";
}
for ($j = 0; $j < $ct_qty; $j++) {
// 개별 변수 선언
$ca_id = trim($_POST['ca_id_' . $i . $j]);
$mem_no = isset($_POST['mem_no_' . $i . $j]) ? trim($_POST['mem_no_' . $i . $j]) : ""; // 회원번호
$mem_name = trim($_POST['name_' . $i . $j]); // 성명
$mem_gender = trim($_POST['gender_' . $i . $j]); // 성별
$mem_tel = addTelHyphen(trim($_POST['tel_' . $i . $j])); // 연락처
$mem_birth = trim($_POST['birth_' . $i . $j]); // 생일
$mem_email = trim($_POST['email_' . $i . $j]); // 이메일
$mem_addr = trim($_POST['addr_' . $i . $j]); // 주소
$mem_memo = isset($_POST['memo_' . $i . $j]) ? trim($_POST['memo_' . $i . $j]) : ""; // 메모
$mem_sdate = trim($_POST['sdate_' . $i . $j]); // 시작일
$mem_edate = getAnnualEdate($mem_sdate); // 종료일 만들어주기
// 파일 업로드 처리
$fileName = $_FILES["photofile_" . $i . $j]["name"];
$fileTmpName = $_FILES["photofile_" . $i . $j]["tmp_name"];
$fileSize = $_FILES["photofile_" . $i . $j]["size"];
$fileExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
if (in_array($fileExtension, $allowedExtensions) && $fileSize <= $maxFileSize) {
$newFileName = uniqid() . "." . $fileExtension;
$uploadPath = $uploadDir . $newFileName;
$utf8TmpFileName = mb_convert_encoding($fileTmpName, 'UTF-8', 'auto');
if (move_uploaded_file($utf8TmpFileName, $uploadPath)) {
$photo_url = FG_MANAGER_URL . $dir . $newFileName;
$photo_name = $fileName;
} else {
alert("파일 업로드 실패.");
}
} else if (!$isDebug) {
alert("지원하지 않는 파일 형식이거나 파일 크기가 너무 큽니다. jpg, jpeg, png, gif 파일만 허용되며 최대 파일 크기는 " . ($maxFileSize / (1024 * 1024)) . "MB입니다.");
}
if ($isDebug) $photo_url = $photo_name = '';
// DB에 입력
$query = "INSERT INTO {$fg['annual_member_table']} (
mem_no,
status,
ca_id,
app_id,
name,
memo,
birth,
email,
addr,
tel,
gender,
sdate,
edate,
photo_url,
photo_name,
join_datetime,
last_edit_date,
last_edit_id,
last_ent_date,
ent_count,
od_id,
rep_name
) VALUES (
'{$mem_no}',
'{$status}',
'{$ca_id}',
'{$app_id}',
'{$mem_name}',
'{$mem_memo}',
'{$mem_birth}',
'{$mem_email}',
'{$mem_addr}',
'{$mem_tel}',
'{$mem_gender}',
'{$mem_sdate}',
'{$mem_edate}',
'{$photo_url}',
'{$photo_name}',
'{$last_editdate}',
'{$last_editdate}',
'{$user_id}',
'0000-00-00 00:00:00',
0,
'{$od_id}',
'{$rep_name}'
)";
if ($isDebug) {
print_r($query); // 디버깅인 경우 출력
echo "<br>";
$result = false;
} else {
$result = sql_query($query);
}
if ($result) {
// log 기록
$work = "연간회원등록";
$work_detail = "번호 : " . $mem_no . " 처리자 : " . $user_name;
log_update($work, $work_detail, $user_id, $datetime);
} else if (!$isDebug) {
alert("저장 실패");
}
}
}
if (isset($result) && $result) { // 저장이 성공했다면
// 상태를 완료처리
$update_query = "UPDATE {$g5['g5_shop_cart_table']} SET od_status = '완료' WHERE od_id = '{$od_id}'";
$result = sql_query($update_query); // 업데이트
alert("저장 완료");
}

View File

@ -0,0 +1,175 @@
<?php
// 수동 입력 페이지. od_id가 없다면 생성할 수 없음.
// if( !isset($_POST['it_id']) && !$isDebug ) exit; // 디버그 중이거나 POST로 넘어온 값이 없다면 종료
include_once "_common.php";
$isDebug = false;
// 주문권종이 다를 수 있으므로 it_id를 저장함
function getAnnuOrder($od_id) {
global $g5;
$query = "SELECT it_id, ct_qty FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$od_id'";
$result = sql_query($query);
$R = array();
while($row=sql_fetch_array($result)) { // 전체 배열에 저장
array_push($R, $row);
}
return $R;
}
// 상품별로 판매되므로 상품 ID에 따라 상품을 설정해줌
function getAnnuCaID($it_id) {
if ($it_id == "1730361152" ) {
$result['ca_id'] = 3;
$result['ca_name'] = "일반";
} else if ($it_id == "1728373753") {
$result['ca_id'] = 5;
$result['ca_name'] = "빅5";
}
return $result;
}
// it_id 갯수(주문수)
function getOrdCnt($od_id) {
global $g5;
$query = "SELECT COUNT(it_id) AS it_id_cnt FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$od_id'";
$result = sql_fetch($query);
return $result;
}
// GET으로 데이터가 넘어왔다면..
if (isset($_GET['od_id'])) $od_id = $_GET['od_id'];
// POST로 넘어온 데이터 처리
else if(isset($_POST['od_id'])) $od_id = trim($_POST['od_id']);
else alert('주문번호 없음',false);
// 주문수량 확인(종류)
$query = "SELECT it_id FROM {$g5['g5_shop_cart_table']} WHERE od_id = '$od_id'";
$od_cnt_query = sql_query($query);
$od_cnt = sql_num_rows($od_cnt_query);
if ($od_cnt < 1) alert('주문 내역이 없습니다.');
// DB에 동일한 주문건이 있는지 확인
$chk = "SELECT od_id, ca_id FROM {$fg['annual_member_table']} WHERE od_id = '{$od_id}'";
$chk = sql_num_rows(sql_query($chk));
if ( $isDebug ) { // 디버깅 중인 경우 넘어온 값을 모두 출력함
var_dump($_REQUEST);
echo "<br><br>";
var_dump(getAnnuOrder($od_id));
}
if ( $od_cnt > $chk && !$isDebug) { // 입력 수량이 주문 수량보다 적을 때 진행
$no = $name = $tel = $addr = $email = '';
$od_cnt = getOrdCnt($od_id);
$od_cnt = $od_cnt['it_id_cnt']
?>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="https://t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
<script>
function execDaumPostcode(targetId) {
new daum.Postcode({
oncomplete: function(data) {
var addr = ''; // 주소 변수
if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
addr = data.roadAddress;
} else { // 사용자가 지번 주소를 선택했을 경우
addr = data.jibunAddress;
}
document.getElementById(targetId).value = addr;
}
}).open();
}
</script>
</head>
<body>
<section class="container-sm my-5" style="max-width:800px;">
<div class="header mb-3">
<h3 class="title">퍼스트가든 연간회원 정보입력</h3>
</div>
<form action="annual_member_insert.update.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="it_id_cnt" id="it_id_cnt" value="<?=$od_cnt?>" readonly>
<input type="hidden" name="od_id" id="od_id" value="<?=$od_id?>" readonly>
<input type="hidden" name="rep_name" id="rep_name" value="<?=$name?>" readonly>
<!--
<div>
약관이 출력될 부분
</div>
약관체크
<input type="hidden" name="rep_name" id="rep_name" value="<?=$name?>" readonly>
-->
<?php // 주문 수량만큼 출력함
$i = 0;
foreach (getAnnuOrder($od_id) as $row) { // 주문 종류
$ca = getAnnuCaID($row['it_id']);
//echo '<H4>' . $i+1 .'. '.$ca['ca_name'] . '</H4>';
$ct_qty = $row['ct_qty']; // 품목별 주문수량
for ($j = 0; $j < $ct_qty; $j++) {
?>
<div class="body text-left mb-3">
<label class="form-label"><?=$ca['ca_name'] . ' - ' . $j+1?></label>
<input type="hidden" name="it_id_<?=$i.$j?>" id="it_id_<?=$i.$j?>" value="<?=$row['it_id']?>" readonly>
<input type="hidden" name="sdate_<?=$i.$j?>" id="sdate_<?=$i.$j?>" value="<?=$sdate?>" readonly>
<input type="hidden" name="ca_id_<?=$i.$j?>" id="ca_id_<?=$i.$j?>" value="<?=$ca['ca_id']?>" readonly>
<input type="hidden" name="od_qty_<?=$i.$j?>" id="od_qty_<?=$i.$j?>" value="<?=$od_qty?>" readonly>
<input type="hidden" name="ct_qty_<?=$i.$j?>" id="ct_qty_<?=$i.$j?>" value="<?=$ct_qty?>" readonly>
<!-- 아래 input은 약관동의 체크용
<input type="hidden" name="ct_qty_<?=$i.$j?>" id="ct_qty_<?=$i.$j?>" value="<?=$ct_qty?>" readonly>
-->
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="label_name_<?=$i.$j?>">성명</span>
<input type="text" class="form-control" id="name_<?=$i.$j?>" name="name_<?=$i.$j?>" value="<?=(($i == 0 && $j == 0) || $isDebug) ? $name : "" ?>" required>
<input type="radio" class="btn-check" name="gender_<?=$i.$j?>" id="gender_male_<?=$i.$j?>" value="남" checked required >
<label class="btn btn-outline-primary" for="gender_male_<?=$i.$j?>">남</label>
<input type="radio" class="btn-check" name="gender_<?=$i.$j?>" id="gender_female_<?=$i.$j?>" value="여" required>
<label class="btn btn-outline-primary" for="gender_female_<?=$i.$j?>">여</label>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="tel">연락처</span>
<input type="text" class="form-control" name="tel_<?=$i.$j?>" id="tel_<?=$i.$j?>" maxlength="11" value="<?=(($i == 0 && $j == 0) || $isDebug) ? $tel : "" ?>" required>
<span class="input-group-text col-md-3" id="birth_<?=$i.$j?>">생년월일</span>
<input type="date" class="form-control" name="birth_<?=$i.$j?>" id="birth_<?=$i.$j?>" max="9999-12-31" value="<?=($isDebug) ? "9999-12-31" : ""?>" required>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="email">이메일</span>
<input type="email" class="form-control" name="email_<?=$i.$j?>" id="email_<?=$i.$j?>" value="<?php echo $email ?>" >
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="addr">주소</span>
<input type="text" class="form-control" name="addr_<?=$i.$j?>" id="addr_<?=$i.$j?>" value="<?php echo $addr ?>" >
<button type="button" class="btn btn-primary" onclick="execDaumPostcode('addr_<?=$i.$j?>')">주소검색</button>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="photofile_<?=$i.$j?>">사진첨부</span>
<input type="file" class="form-control" name="photofile_<?=$i.$j?>" id="photofile_<?=$i.$j?>" <?=($isDebug) ? "" : "required"?>>
</div>
</div>
<?php
} // endfor
$i++;
} // endforeach
?>
<div class="footer">
<div class="d-grid gap-2">
<button type="submit" id="add_submit" class="btn btn-primary">추가</button>
</div>
</div>
</form>
</section>
</body>
</html>
<?php
} else {
echo '이미 모두 입력했습니다.';
}
?>

View File

@ -0,0 +1,48 @@
<?php
include_once ('./_common.php');
if(!$_SESSION['user_id']) exit;
$idx = trim($_POST['idx']);
$squery = "SELECT * FROM {$fg['vip_list_table']} WHERE idx='{$idx}'";
$list = sql_fetch($squery);
$status = $list['status'];
$tday = date("Y-m-d H:i:s");
if ($status == "정상"){ // 상태가 정상이었다면
//log 변수
$work = "폐기";
$work_detail = "정상 -> 폐기 ";
// 상태 변경
$query = "UPDATE {$fg['vip_list_table']} SET status='폐기' WHERE idx='{$idx}'";
$result = sql_query($query);
// 전체 재고 DB에 업데이트
$memo = $list['vip_card_no'].' 폐기, 처리자 : '.$_SESSION['user_name'];
$query2 = "INSERT INTO vip_stock (status, dispo, date, memo) VALUES('폐기', '1','{$tday}','{$memo}')";
$update = sql_query($query2);
} else if ($status == "폐기") { // 폐기였다면
//log 변수
$work = "복구";
$work_detail = "폐기 -> 정상 ";
// 상태 변경
$query = "UPDATE {$fg['vip_list_table']} SET status='정상' WHERE idx='{$idx}'";
$result = sql_query($query);
// 전체 재고 DB에 업데이트
$memo = $list['vip_card_no'].' 복구, 처리자 : '.$_SESSION['user_name'];
$query2 = "INSERT INTO vip_stock (status, dispo, date, memo)
VALUES('복구', '-1','{$tday}','{$memo}')";
$update = sql_query($query2);
}
// log 기록
$work_detail .= "카드번호 : ".$list['vip_card_no']." 처리자 : ".$_SESSION['user_name'];
$logquery = "INSERT INTO {$fg['log_table']} (work, work_detail, id, date) VALUES ('{$work}', '{$work_detail}', '{$_SESSION['user_id']}', '{$tday}')";
$result = sql_query($logquery);
$data = array("isSuccess" => $result);
header("Content-Type: application/json");
echo json_encode($data);

View File

@ -0,0 +1,106 @@
<?php
include_once '_common.php';
if(!$_SESSION['user_id']) exit;
if ($_SERVER["REQUEST_METHOD"] == "POST") { // POST로 넘어온 값이 있다면
// 변수 선언
$ca_id = trim($_POST['ca_id']); // 권종구분
$mem_no = trim($_POST['mem_no']); // 회원번호
$name = trim($_POST['name']); // 성명
$status = trim($_POST['status']); // 상태
$gender = trim($_POST['gender']); // 성별
$tel = addTelHyphen(trim($_POST['tel'])); // 연락처
$birth = trim($_POST['birth']); // 생일
$email = trim($_POST['email']); // 이메일
$addr = trim($_POST['addr']); // 주소
$sdate = trim($_POST['sdate']); // 시작일
$edate = trim($_POST['edate']); // 종료일
$memo = trim($_POST['memo']); // 메모
$last_editdate = $datetime = date("Y-m-d H:i:s"); // 현재시간
// 기존 정보 가져오기
$q1 = "SELECT * FROM {$fg['annual_member_table']} WHERE mem_no = '{$mem_no}'";
$r = sql_fetch($q1);
// 시작일이 변경된 경우
if (isset($sdate) && $sdate != $r['sdate']) {
$edate = getAnnualEdate($sdate); // 연간회원권이므로 종료일은 1년 후로 지정한다.
}
// 파일 업로드 처리
$dir = "/data/annual_member_photo/"; // 업로드 디렉토리
$uploadDir = FG_MANAGER_PATH . $dir; // 업로드 디렉토리 절대경로
$maxFileSize = 10 * 1024 * 1024; // 10MB
$allowedExtensions = ["jpg", "jpeg", "png", "gif"]; // 허용되는 파일 확장자
$photo_url = $r['photo_url']; // 기존 파일 URL 유지
if (!empty($_FILES['photofile']['name'])) {
$fileName = $_FILES['photofile']['name'];
$fileTmpName = $_FILES['photofile']['tmp_name'];
$fileSize = $_FILES['photofile']['size'];
$fileExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
if (in_array($fileExtension, $allowedExtensions) && $fileSize <= $maxFileSize) {
$newFileName = uniqid() . "." . $fileExtension;
$uploadPath = $uploadDir . $newFileName;
if (move_uploaded_file($fileTmpName, $uploadPath)) {
$photo_url = FG_MANAGER_URL . $dir . $newFileName;
} else {
alert("파일 업로드 실패");
}
} else {
alert("지원하지 않는 파일 형식이거나 파일 크기가 너무 큽니다. jpg, jpeg, png, gif 파일만 허용되며 최대 파일 크기는 " . ($maxFileSize / (1024 * 1024)) . "MB입니다.");
}
}
// 변수 값을 DB에 업데이트
$query = "UPDATE {$fg['annual_member_table']} SET
ca_id = '{$ca_id}',
status = '{$status}',
sdate = '{$sdate}',
edate = '{$edate}',
name = '{$name}',
tel = '{$tel}',
email = '{$email}',
birth = '{$birth}',
addr = '{$addr}',
memo = '{$memo}',
gender = '{$gender}',
last_edit_id = '{$_SESSION['user_id']}',
last_edit_date = '{$datetime}',
photo_url = '{$photo_url}'";
$query .= " WHERE mem_no='{$mem_no}'";
$result = sql_query($query);
if ($result) { // DB 업데이트가 완료되면 로그를 기록한다.
// log 기록
$work = "연간회원수정";
$work_detail = "번호 : " . $mem_no . " 처리자 : " . $_SESSION['user_name'];
$work_detail .= "수정내역 : ";
if ($r['name'] != $name) $work_detail .= $r['name'] . ' -> ' . $name . ', ';
if ($r['tel'] != $tel) $work_detail .= $r['tel'] . ' -> ' . $tel . ', ';
if ($r['email'] != $email) $work_detail .= $r['email'] . ' -> ' . $email . ', ';
if ($r['birth'] != $birth) $work_detail .= $r['birth'] . ' -> ' . $birth . ', ';
if ($r['addr'] != $addr) $work_detail .= $r['addr'] . ' -> ' . $addr . ', ';
if ($r['memo'] != $memo) $work_detail .= $r['memo'] . ' -> ' . $memo . ', ';
if ($r['gender'] != $gender) $work_detail .= $r['gender'] . ' -> ' . $gender . ', ';
if ($r['ca_id'] != $ca_id) $work_detail .= $r['ca_id'] . ' -> ' . $ca_id . ', ';
if ($r['status'] != $status) $work_detail .= $r['status'] . ' -> ' . $status . ', ';
if ($r['sdate'] != $sdate) $work_detail .= $r['sdate'] . ' -> ' . $sdate . ', ';
// log 기록
$logResult = log_update($work, $work_detail, $_SESSION['user_id'], $datetime);
if ($logResult) {
//$data = array("isSuccess" => $result);
alert("데이터 저장 성공");
} else {
alert("로그 저장 실패");
}
} else {
alert("DB 업데이트 실패");
}
} else {
alert("잘못된 접근입니다");
}

View File

@ -0,0 +1,365 @@
<?php
// annual_member.php 연간회원권
include_once "_common.php";
if (!isset($_SESSION['user_id'])) header( 'Location: FG_MANAGER_URL' ); // 로그인 되어있지 않으면 로그인 페이지로 보냄
include_once FG_MANAGER_PATH."/head.php";
// 언젠가는 DB에 저장할 수 있도록 해야함
$set_annual_status = array("정상", "검토대기", "만료");
$table = "{$fg['annual_member_table']} AS a LEFT JOIN {$fg['annual_category_table']} AS b ON a.ca_id = b.ca_id ";
// 검색 변수 초기화, 검색 관련
$search_word = isset($_REQUEST["search_word"]) ? $_REQUEST["search_word"] : ""; // 검색어
$search_cat = isset($_REQUEST["search_cat"]) ? $_REQUEST["search_cat"] : ""; // 카테고리
$search_sdate = isset($_REQUEST["search_sdate"]) ? $_REQUEST["search_sdate"] : "";
$search_edate = isset($_REQUEST["search_edate"]) ? $_REQUEST["search_edate"] : "";
$search = $where = $search_count = "";
if ($search_word) $search .= " (a.name LIKE '%$search_word%' OR a.tel LIKE '%$search_word%' OR a.mem_no LIKE '%$search_word%') ";
if ($search_cat) {
if ($search_word) $search .= "AND";
$search .= " a.ca_id = $search_cat";
}
if ($search_sdate) {
if ($search_word || $search_cat) $search .= "AND";
$search .= " exp_sdate >= $search_sdate";
}
if ($search_edate) {
if ($search_word || $search_cat || $search_edate) $search .= "AND";
$search .= " exp_edate =< $search_edate";
}
if ($search) {
$where = "WHERE {$search}";
$search_count = get_num_rows($table, $where); // 검색 결과 수 구하기
}
// 검색 쿼리 만들기 끝
$record_count = get_num_rows($table); // 전체 갯수 구하기
$ord_by = "ORDER BY a.mem_no DESC "; // 시작일 기준 내림차순
$R = get_result($table, $ord_by, $query_limit, $where);
?>
<script>
document.getElementById('sdate').value = new Date().toISOString().substring(0, 10);
</script>
<style>
@media (max-width: 999px) {
.vip-member-list {
}
.no-mobile {
display: none;
}
}</style>
<!-- 검색폼 시작 -->
<div class="d-flex flex-column mb-3">
<p>검색은 구분/성명/연락처/회원번호로만 가능합니다.</p>
<form class="search" method="get" action="">
<div class="d-flex flex-row flex-wrap gap-2 mb-3">
<input type="radio" name="search_cat" id="search_cat_all" class="btn-check" value="" <?php if (empty($search_cat)) echo "checked" ?>>
<label class="btn btn-outline-primary" for="search_cat_all">전체</label>
<?php
$annual_group = getAnnualGroup();
foreach ($annual_group as $row) { // 회원구분 가져와서 뿌리기
?>
<input type="radio" name="search_cat" id="search_cat_<?=$row['ca_id']?>" class="btn-check" value="<?=$row['ca_id']?>" <?php if ($search_cat === $row['ca_id']) echo "checked" ?>>
<label class="btn btn-outline-primary" for="search_cat_<?=$row['ca_id']?>"><?=$row['ca_name']?></label>
<?php } ?>
</div>
<div class="input-group col-md-6">
<span class="input-group-text" id="search_word">회원검색</span>
<input type="text" name="search_word" class="form-control" id="search_word" aria-describedby="search_word" placeholder="검색어를 입력하세요" autofocus value="<?=$search_word ?>">
<button type="submit" class="btn btn-secondary">검색</button>
</div>
</form>
</div>
<!-- 검색폼 끝 -->
<div class="d-flex justify-content-between my-1">
<div>
<p>전체 회원 수 : <b><?=$record_count?></b> | 검색 회원 수 : <?=$search_count ? $search_count : $record_count?></p>
</div>
<div class="d-flex flex-row-reverse column-gap-2">
<form method="post" action="inc/annual_member_list_excel.php">
<button type="submit" class="btn btn-secondary" >엑셀저장</button>
</form>
<?php if($_SESSION['user_lv'] > "1"){ // 추가 권한 체크 ?>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add_modal">추가</button>
<!-- 추가 버튼을 누르면 출력한다. -->
<div id="add_modal" class="modal fade">
<div class="modal-dialog" style="width:800px;">
<div class="modal-content">
<?php //class="signup" ?>
<form action="annual_member_list.update.php" method="POST" enctype="multipart/form-data" > <!-- 폼 이름을 알려줌 -->
<div class="modal-header">
<h4 class="modal-title">추가</h4>
</div>
<div class="modal-body text-left">
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="ca_id">구분</span>
<?php foreach($annual_group as $row){
if ($row['ca_used'] != 1) continue ?>
<input type="radio" class="btn-check" name="ca_id" id="ca_id_<?=$row['ca_id']?>" value="<?=$row['ca_id']?>" required>
<label class="btn btn-outline-info" for="ca_id_<?=$row['ca_id']?>"><?=$row['ca_name']?></label>
<?php } ?>
</div>
<input type="hidden" id="app_id" name="app_id" value="<?=$_SESSION['user_id']?>" required>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="mem_no">회원번호</span>
<input type="text" class="form-control" oninput="checkDupAnnuNo(this.value)" id="mem_no" name="mem_no" placeholder="카드 번호" value="" required>
</div>
<div class="input-group mb-1 checkdup">
<span id="duplicate-no-warning"></span>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="sdate">가입일</span>
<input type="date" class="form-control" name="sdate" id="sdate" max="9999-12-31" onchange="value_reload()" required>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="name">성명</span>
<input type="text" class="form-control" id="name" name="name" value="" required>
<input type="radio" class="btn-check" name="gender" id="gender_male" value="남" <?php if($gender ==="남") echo "checked" ?>>
<label class="btn btn-outline-primary" for="gender_male">남</label>
<input type="radio" class="btn-check" name="gender" id="gender_female" value="여" <?php if($gender ==="여") echo "checked" ?>>
<label class="btn btn-outline-primary" for="gender_female">여</label>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="tel">연락처</span>
<input type="text" class="form-control" oninput="checkDupAnnuTel(this.value)" name="tel" name="tel" maxlength="11" value="" required>
</div>
<div class="input-group mb-1 checkdup">
<span id="duplicate-tel-warning"></span>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="email">이메일</span>
<input type="text" class="form-control" name="email" id="email" value="" >
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="addr">주소</span>
<input type="text" class="form-control" name="addr" id="addr" value="" >
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="birth">생년월일</span>
<input type="date" class="form-control" name="birth" id="birth" max="9999-12-31" required>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="photofile">사진첨부</span>
<input type="file" class="form-control" name="photofile" id="photofile" >
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="memo">메모</span>
<textarea class="form-control" name="memo" id="memo"></textarea>
</div>
<div id="memo" class="form-text">
기타 메모 및 발급사유를 입력합니다.
</div>
</div>
<div class="modal-footer">
<button type="submit" id="add_submit" class="btn btn-primary">추가</button>
<button type="button" class="btn btn-default" data-bs-dismiss="modal">닫기</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<?php } // endif ?>
</div>
</div>
<div class="text-center">
<table class="table table-striped align-middle table-hover vip-member-list">
<thead>
<tr class="align-middle">
<th class="text-center">회원<br>번호</th>
<th class="text-center">상태</th>
<th class="text-center">성명</th>
<th class="text-center">연락처</th>
<th class="text-center no-mobile">생년월일</th>
<th class="text-center no-mobile">시작일</th>
<th class="text-center no-mobile">종료일</th>
<th class="text-center no-mobile">이용<br>횟수</th>
<th class="text-center no-mobile">최종<br>이용일</th>
<?php if($_SESSION['user_lv'] > "1"){ ?>
<th class="text-center">작업</th>
<?php } ?>
</tr>
</thead>
<tbody class="table-group-divider">
<?php foreach($R as $R) {?>
<tr>
<td class="text-center" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><?=$R['mem_no']?></td>
<td class="text-center" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><?=$R['status']?></td>
<td class="text-center" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><?=$R['name']?></td>
<td class="text-center" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><?=$R['tel']?></td>
<td class="text-center no-mobile" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><?=$R['birth']?></td>
<td class="text-center no-mobile" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><?=$R['sdate']?></td>
<td class="text-center no-mobile" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><?=$R['edate']?></td>
<td class="text-center no-mobile" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><?=$R['ent_count']?></td>
<td class="text-center no-mobile">
<?php
$edate = $R['last_ent_date'];
echo ($edate == '0000-00-00 00:00:00') ? '미이용' : date('Y-m-d',strtotime($edate));
?></td>
<td class="text-center d-flex justify-content-center flex-wrap gap-1">
<?php
// 입장처리 버튼
if ($R['status'] == '정상' || $R['status'] == '검토대기') {
echo '<a class="btn btn-danger btn-xs" href="javascript:entMem(' . $R['mem_no'] . ')" role="button"><i class="fas fa-sign-in-alt"></i></a>';
} else {
echo '<i class="fas fa-times"></i>';
} // 입장처리 버튼 끝
// 수정
if($_SESSION['user_lv'] > "1") { // 권한이 있는 사용자에게만 수정 페이지를 보여줌
?>
<!-- 수정 버튼 -->
<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#modify_modal_<?=$R['mem_no']?>"><i class="fa-solid fa-pen-to-square"></i></button>
<!-- 수정 모달 -->
<div id="modify_modal_<?=$R['mem_no']?>" class="modal fade" tabindex="-1" aria-labelledby="modify_modal_<?=$R['mem_no']?>" aria-hidden="true">
<div class="modal-dialog modal modal-dialog-centered">
<div class="modal-content">
<form action="annual_member_list.modify.php" id="modify_<?=$R['mem_no']?>" method="POST" enctype="multipart/form-data" > <!-- 폼 이름을 알려줌 -->
<!--<form class="modify" id="modify_<?=$R['mem_no']?>">-->
<div class="modal-header">
<h5 class="modal-title">정보 보기/수정</h5>
</div>
<div class="modal-body text-start">
<div class="row mb-2">
<img class="img-fluid col-md-5" src="<?=$R['photo_url']?>" >
<div class="col-md-7">
<div class="input-group mb-1">
<span class="input-group-text col-md-5" id="rep_name_<?=$R['mem_no']?>">대표자명</span>
<input type="text" class="form-control" id="rep_name_<?=$R['mem_no']?>" name="rep_name" value="<?=$R['rep_name'] ?>" readonly>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-5" id="mem_no_<?=$R['mem_no']?>">회원번호</span>
<input type="text" class="form-control" id="mem_no_<?=$R['mem_no']?>" name="mem_no" value="<?=$R['mem_no'] ?>" readonly>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-5" id="ca_id_<?=$R['mem_no']?>">권종구분</span>
<?php
foreach($annual_group as $row){
if ($row['ca_used'] != 1) continue ?>
<input type="radio" class="btn-check" name="ca_id" id="ca_id_<?=$R['mem_no']?>_<?=$row['ca_id']?>" value="<?=$row['ca_id']?>" <?php if( $R['ca_id'] == $row['ca_id'] ) echo "checked" ?> required>
<label class="btn btn-outline-info" for="ca_id_<?=$R['mem_no']?>_<?=$row['ca_id']?>"><?=$row['ca_name']?></label>
<?php } ?>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-5" id="status_<?=$R['mem_no']?>">상태</span>
<select class="form-select" id="status_<?=$R['mem_no']?>" name="status">
<option vaule="<?=$R['status']?>"><?=$R['status']?></option>
<?php
foreach( $set_annual_status as $row ) {
if ( $R['status'] == $row ) continue;
?>
<option vaule="<?=$row?>"><?=$row?></option>
<?php } ?>
</select>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-5" id="sdate_<?=$R['mem_no']?>">시작일</span>
<input type="text" class="form-control" id="sdate_<?=$R['mem_no']?>" name="sdate" value="<?=$R['sdate'] ?>" >
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-5" id="edate_<?=$R['mem_no']?>">종료일</span>
<input type="text" class="form-control" id="edate_<?=$R['mem_no']?>" name="edate" value="<?=$R['edate']?>" readonly>
</div>
</div>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-2" id="name_<?=$R['mem_no']?>">성명</span>
<input type="text" class="form-control" id="name_<?=$R['mem_no']?>" name="name" value="<?=$R['name']?>" required <?=$ro?>>
<input type="radio" class="btn-check" name="gender" id="gender_<?=$R['mem_no']?>_male" value="남" <?php if($R['gender'] == "남") echo "checked" ?> required>
<label class="btn btn-outline-primary" for="gender_<?=$R['mem_no']?>_male">남</label>
<input type="radio" class="btn-check" name="gender" id="gender_<?=$R['mem_no']?>_female" value="여" <?php if($R['gender'] =="여") echo "checked" ?> required>
<label class="btn btn-outline-primary" for="gender_<?=$R['mem_no']?>_female">여</label>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-2" id="tel_<?=$R['mem_no']?>">연락처</span>
<input type="text" onkeydown='return onlyNumber(event)' onkeyup='removeChar(event)' class="form-control" id="tel_<?=$R['mem_no']?>" name="tel" value="<?=$R['tel'] ?>" required <?=$ro?>>
<span class="input-group-text col-md-2" id="birth_<?=$R['mem_no']?>">생일</span>
<input type="date" class="form-control" id="birth_<?=$R['mem_no']?>" name="birth" value="<?=$R['birth']?>" <?=$ro?>>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-2" id="email_<?=$R['mem_no']?>">E-Mail</span>
<input type="text" class="form-control" id="email_<?=$R['mem_no']?>" name="email" value="<?=$R['email'] ?>" <?=$ro?>>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-2" id="addr_<?=$R['mem_no']?>">주소</span>
<input type="text" class="form-control" id="addr_<?=$R['mem_no']?>" name="addr" value="<?=$R['addr']?>" <?=$ro?>>
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-3" id="photofile">사진첨부(변경시에만 입력)</span>
<input type="file" class="form-control" name="photofile" id="photofile" >
</div>
<div class="input-group mb-1">
<span class="input-group-text col-md-2" id="memo_<?=$R['mem_no']?>">메모</span>
<textarea class="form-control" id="memo_<?=$R['mem_no']?>" name="memo" <?=$ro?>><?=$R['memo']?></textarea>
</div>
<?php if($R['last_edit_id']) { ?>
<div class="input-group mb-1">
<span class="input-group-text col-md-2" id="last_edit_date_<?=$R['mem_no']?>">수정일</span>
<input type="text" class="form-control" id="last_edit_date_<?=$R['mem_no']?>" name="last_edit_date" value="<?=$R['last_edit_date'] ?>" disabled>
<span class="input-group-text col-md-2" id="last_edit_id_<?=$R['mem_no']?>">수정</span>
<input type="text" class="form-control" id="last_edit_id_<?=$R['mem_no']?>" name="last_edit_id" value="<?=$R['last_edit_id'] ?>" disabled>
</div>
<?php } ?>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">수정</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" aria-label="Close" data-bs-target="#modify_modal_<?=$R['mem_no']?>">닫기</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<!-- 수정 모달 끝 -->
<?php } // end if
// 폐기, 재발급
if( $_SESSION['user_lv'] === "4" ) { // 폐기나 재발급은 관리자만
// 재발급
if ( $R['status'] === "정상" ) { // 정상인 경우에만 출력 ?>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#renew_modal_<?=$R['mem_no']?>"><i class="fa-solid fa-repeat"></i></button>
<!-- 재발급 모달 -->
<div id="renew_modal_<?=$R['mem_no']?>" class="modal fade text-center ">
<div class="modal-dialog">
<div class="modal-content">
<form class="renew" id="renew_<?=$R['mem_no']?>">
<input type="hidden" id="mem_no_<?=$R['mem_no']?>" name="mem_no" value="<?=$R['mem_no']?>" readonly>
<input type="hidden" id="last_edit_id_<?=$R['mem_no']?>" name="last_edit_id" value="<?=$_SESSION['user_name']?>" readonly>
<div class="modal-header">
<h5 class="modal-title">재발급</h4>
</div>
<div class="modal-body text-start">
<div class="input-group">
<span class="input-group-text col-md-4" id="re_no_<?=$R['mem_no']?>">재발급 카드번호</span>
<input type="number" class="form-control" oninput="checkDupRc(this.value)" id="rc_no_<?=$R['mem_no']?>" name="rc_no" maxlength="6" value="" required>
</div>
<div class="input-group checkdup">
<span id="duplicate-rc-warning"></span>
</div>
</div>
<div class="modal-footer">
<button type="submit" id="renew_submit" class="btn btn-primary">확인</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" aria-label="Close" data-bs-target="#renew_modal_<?=$R['mem_no']?>">닫기</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<!-- 재발급 모달 끝 -->
<?php } // end if ?>
<!-- 삭제 버튼 -->
<a class="btn btn-danger" href="javascript:deleteItem('<?=$R['mem_no']?>')" role="button"><?=($R['status'] == '정상')? '<i class="fa-solid fa-trash-can"></i>' : '<i class="fa-solid fa-trash-can-arrow-up"></i>'?></a>
<?php } // end if ?>
</td>
</tr>
<? } // end foreach ?>
</tbody>
</table>
</div>
<?php include_once FG_MANAGER_PATH."/tail.php";

View File

@ -0,0 +1,48 @@
<?php
include_once '_common.php';
if(!$_SESSION['user_id']) exit;
// 변수선언
$idx = $_POST['idx'];
$rc_no = trim($_POST['rc_no']);
$last_edit_name = trim($_POST['last_edit_name']);
// 현재 시간 저장
$time = date("Y-m-d H:i:s");
// 기존 카드 정보 가져오기
$q1 = "SELECT * FROM {$fg['vip_list_table']} WHERE idx = '{$idx}'";
$r = sql_fetch($q1);
if ($r) {
// 전체 재고 DB에 업데이트
$memo = $r['vip_card_no'].' 재발급, 처리자 : '.$_SESSION['user_name'];
$query2 = "INSERT INTO {$fg['card_stock_table']} (status, output, date, memo)
VALUES('재발급', '1','{$time}','{$memo}')";
$update = sql_query($query2);
$vip_memo = $r['vip_memo'].' 재발급, 기존카드번호('.$r['vip_card_no'].')';
// 기존 카드 상태 변경
$query = "UPDATE {$fg['vip_list_table']} SET status='재발급' WHERE idx='{$idx}'";
$update = sql_query($query);
// DB에 넣을 쿼리문 작성
$query = "INSERT INTO {$fg['vip_list_table']} (vip_name, status, rec_team, rec_name, gr_id, vip_birth, vip_tel, vip_email, vip_addr, vip_memo, vip_card_no, app_name, vip_gender, vip_date, join_datetime)";
// 값 지정
$query .= " VALUES('{$r['vip_name']}', '정상', '{$_SESSION['user_team']}', '{$r['rec_name']}', '{$r['gr_id']}', '{$r['vip_birth']}', '{$r['vip_tel']}', '{$r['vip_email']}', '{$r['vip_addr']}', '{$vip_memo}', '{$rc_no}', '{$last_edit_name}', '{$r['vip_gender']}', '{$r['vip_date']}', '{$time}') ";
$result = sql_query($query);
// log 만들기
$work_detail = "기존카드번호 : ".$r['vip_card_no']." |신규카드번호 : ".$rc_no." |처리자 : ".$_SESSION['user_name'];
// log 기록
$logquery = "INSERT INTO {$fg['log_table']} (work, work_detail, id, date) VALUES ('재발급', '{$work_detail}', '{$_SESSION['user_id']}', '{$time}')";
$logresult = sql_query($logquery);
$data = array("isSuccess" => $result);
}
header("Content-Type: application/json");
echo json_encode($data);

View File

@ -0,0 +1,163 @@
<?php
include_once '_common.php';
if(!isset($_SESSION['user_id']) && !isset($_POST['app_id'])) exit; // 관리자가 업력하거나 온라인 주문이 아닌 경우 exit
if(isset($_POST['app_id'])) $user_name = $user_id = "온라인 자동입력"; // 온라인 주문인 경우 log에 온라인 자동입력임을 넣어줌
/*
파일 업로드를 하므로 uploadDir 경로의 권한이 777이어야 함
*/
// 변수 선언
$ca_id = trim($_POST['ca_id']); // 회원구분
$app_id = trim($_POST['app_id']); // 접수자, 온라인 주문의 경우 온라인으로 처리
$mem_no = isset($_POST['mem_no']) ? trim($_POST['mem_no']) : ""; // 회원번호
$mem_name = trim($_POST['name']); // 성명
$mem_gender = trim($_POST['gender']); // 성별
$mem_tel = addTelHyphen(trim($_POST['tel'])); // 연락처
$mem_birth = trim($_POST['birth']); // 생일
$mem_email = trim($_POST['email']); // 이메일
$mem_addr = trim($_POST['addr']); // 주소
$mem_memo = trim($_POST['memo']); // 메모
$mem_sdate = trim($_POST['sdate']); // 시작일
$mem_edate = getAnnualEdate($mem_sdate); // 종료일 만들어주기
$last_editdate = $datetime = date("Y-m-d H:i:s"); // 현재시간
if( isset($_POST['od_id']) ) { // 온라인 주문인 경우 자동으로 넣어줄 값
// 온라인 주문이므로 관리자가 한번 더 확인해야 함
$status = "검토대기";
// 주문정보
$od_qty = trim($_POST['od_qty']);
$od_id = trim($_POST['od_id']);
// 주문자 이름이 대표자명이 됨
$rep_name = trim($_POST['rep_name']);
} else {
// 관리자가 입력하는 경우
$status = "정상";
// 온라인 정보 없음
$od_qty = $od_id = $rep_name = "";
}
// 파일 업로드
if (isset($_FILES)) {
// 업로드 디렉토리를 설정
$dir = "/data/annual_member_photo/"; // 업로드 디렉토리
$uploadDir = FG_MANAGER_PATH.$dir; // 업로드 디렉토리 절대경로
$maxFileSize = 10 * 1024 * 1024; // 10MB
// 업로드된 파일의 정보 가져오기
$fileName = $_FILES["photofile"]["name"];
$fileTmpName = $_FILES["photofile"]["tmp_name"];
$fileSize = $_FILES["photofile"]["size"];
// 파일 확장자를 체크하고 허용되는 확장자를 지정
$allowedExtensions = ["jpg", "jpeg", "png", "gif"];
$fileExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
if (in_array($fileExtension, $allowedExtensions)) {
// 파일 크기를 체크하고 원하는 크기로 제한
if ($fileSize <= $maxFileSize) {
// 새로운 파일 이름을 생성
$newFileName = uniqid() . "." . $fileExtension;
$uploadPath = $uploadDir . $newFileName;
// 임시 파일의 경로를 UTF-8로 변환
$utf8TmpFileName = mb_convert_encoding($fileTmpName, 'UTF-8', 'auto');
// 파일을 이동
if (move_uploaded_file($utf8TmpFileName, $uploadPath)) {
$photo_url = FG_MANAGER_URL.$dir.$newFileName;
$photo_name = $fileName;
} else {
alert("파일 업로드 실패.");
}
} else {
alert("파일 크기가 너무 큽니다. 최대 파일 크기는 " . ($maxFileSize / (1024 * 1024)) . "MB입니다.");
}
} else if ($_SESSION['user_id'] != 'abc'){ // 최고관리자의 경우 체크 안함
alert("지원하지 않는 파일 형식입니다. jpg, jpeg, png, gif 파일만 허용됩니다.");
}
} else if ($_SESSION['user_id'] != 'abc') { // 최고관리자의 경우 체크 안함
alert("파일이 존재하지 않습니다");
}
// 파일 업로드 끝
// DB에 입력
// DB에 넣을 쿼리문 작성
$query = "INSERT INTO {$fg['annual_member_table']} (
mem_no,
status,
ca_id,
app_id,
name,
memo,
birth,
email,
addr,
tel,
gender,
sdate,
edate,
photo_url,
photo_name,
join_datetime,
last_edit_date,
last_edit_id,
last_ent_date,
ent_count,
od_id,
od_qty,
rep_name
)";
// 값 지정
$query .= "VALUES(
'{$mem_no}',
'{$status}',
'{$ca_id}',
'{$app_id}',
'{$mem_name}',
'{$mem_memo}',
'{$mem_birth}',
'{$mem_email}',
'{$mem_addr}',
'{$mem_tel}',
'{$mem_gender}',
'{$mem_sdate}',
'{$mem_edate}',
'{$photo_url}',
'{$photo_name}',
'{$last_editdate}',
'{$last_editdate}',
'{$user_id}',
'0000-00-00 00:00:00',
0,
'{$od_id}',
'{$od_qty}',
'{$rep_name}'
) ";
// 쿼리실행
$result = sql_query($query);
/*
// 전체 재고 DB에 업데이트
$memo = $mem_no.' 불출, 처리자 : '.$_SESSION['user_name'];
$update_query = "INSERT INTO {$fg['card_stock_table']} (status, output, date, memo) VALUES('출고', '1','{$time}','{$memo}')";
$update = sql_query($update_query);
*/
if ( $result ) { // DB 업데이트가 완료되면 로그를 기록한다.
// log 기록
$work = "연간회원등록";
$work_detail = "번호 : ".$mem_no." 처리자 : ".$user_name;
$logquery = "INSERT INTO {$fg['log_table']} (work, work_detail, id, date) VALUES ('카드불출', '{$work_detail}', '{$user_id}', '{$datetime}')";
$logResult = log_update($work, $work_detail, $user_id, $datetime);
if ( $logResult ) {
if( $status == "검토대기" ) { // 온라인 주문의 경우 마이페이지로 넘겨줌
alert("저장 완료", "/firstgarden/shop/mypage.php");
}
alert("저장 완료", false);
} else {
alert("로그 저장 실패");
}
} else {
alert("저장 실패");
}

View File

@ -0,0 +1,33 @@
<?php
include_once ('./_common.php');
if(!$_SESSION['user_id']) exit;
if(isset($_POST['mode']) && trim($_POST['mode']) === "enter") {
$mem_no = trim($_POST['idx']);
$getItemQuery = "SELECT * FROM {$fg['annual_member_table']} WHERE mem_no='{$mem_no}'";
$list = sql_fetch($getItemQuery);
$ent_count = ++$list['ent_count']; // 입장처리시 방문카운트 증가
$date = date("Y-m-d");
$datetime = date("Y-m-d H:i:s");
// 리스트 DB에 최종사용일자 업데이트
$updateQuery = "UPDATE {$fg['annual_member_table']} SET last_ent_date='{$date}', ent_count='{$ent_count}' WHERE mem_no='{$mem_no}'";
$update = sql_query($updateQuery);
// 사용처리 목록 DB에 업데이트
$entQuery = "INSERT INTO {$fg['enter_table']} (cat_name, mem_no, ent_datetime, adm)
VALUES('연간회원', '{$list['mem_no']}', '{$datetime}','{$_SESSION['user_id']}')";
$entUpdate = sql_query($entQuery);
// log 기록
$work = "연간회원입장";
$work_detail = "회원번호 : ".$list['mem_no']." 처리자 : ".$_SESSION['user_name'];
log_update($work, $work_detail, $_SESSION['user_id'], $datetime);
$data = array("isSuccess" => $update);
}
header("Content-Type: application/json");
echo json_encode($data);

View File

@ -0,0 +1,95 @@
<?php
// 연간회원 입장처리 페이지
include_once "_common.php";
if (!isset($_SESSION['user_id'])) header( 'Location: FG_MANAGER_URL' ); // 로그인 되어있지 않으면 로그인 페이지로 보냄
include_once FG_MANAGER_PATH."/head.php";
?>
<div class="searchform">
<p>회원 검색은 성명/연락처/회원번호로 가능합니다.</p>
<form class="vipsearch" method="get" action="">
<label for="search_word" class="form-label">회원검색</label>
<input type="text" name="search_word" class="form-control" placeholder="검색어를 입력하세요" style="width: 200px; display: inline-block; margin: 5px 10px 5px 10px; " value="<?=isset($search_word)?$search_word:""?>" autofocus >
<button type="submit" class="btn btn-primary" style="display: inline-block; margin: 0; ">검색</button>
</form>
</div>
<?php
if( isset($search_word) && $search_word ) { // 검색어가 있을때만 돌림
$table = "{$fg['annual_member_table']} AS a LEFT JOIN {$fg['annual_category_table']} AS b ON a.ca_id = b.ca_id ";
$search = "name LIKE '%$search_word%' OR tel LIKE '%$search_word%' OR mem_no LIKE '%$search_word%'";
$where = "WHERE {$search}";
$ord_by = "ORDER BY name"; // 이름 오름차순
$record_count = get_num_rows($table, $where); // 전체 갯수 구하기
if ($record_count) { // 검색 결과가 있으면
$R = get_result($table, $ord_by, $query_limit, $where);
?>
<div>
<p>검색 회원 수 : <?=$record_count?></p>
</div>
<div class="text-center">
<table class="table table-striped align-middle table-hover">
<colgroup>
<col width="10%">
<col width="5%">
<col width="12%">
<col width="13%">
<col width="12%">
<col width="15%">
<col width="15%">
<col width="10%">
<col width="10%">
<col width="10%">
<col >
</colgroup>
<thead>
<tr class="align-middle">
<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>
<th class="text-center">입장횟수</th>
<th class="text-center">최종입장일</th>
<th class="text-center">만료일</th>
<th class="text-center">입장확인</th>
</tr>
</thead>
<tbody class="table-group-divider">
<?php foreach($R as $R) { ?>
<tr class="<?=($R['status'] == '정상') ? "" : "unused" ?>">
<td class="text-center"><?=sprintf("%06d",$R['mem_no'])?></td>
<td class="text-center"><?=$R['status']?></td>
<td class="text-center"><?=$R['ca_name']?></td>
<td class="text-center"><?=$R['rep_name']?></td>
<td class="text-center"><?=$R['name']?></td>
<td class="text-center"><?=$R['tel']?></td>
<td class="text-center"><?=$R['ent_count']?></td>
<td class="text-center">
<?=($R['last_ent_date'] == '0000-00-00 00:00:00') ? '미이용' : date('Y-m-d',strtotime($R['last_ent_date'])); ?>
</td>
<td class="text-center">
<?=$R['edate']; ?>
</td>
<td class="text-center">
<?php if ($R['status'] == '정상' || $R['status'] == '검토대기') { ?>
<a class="btn btn-danger btn-xs" href="javascript:entMem('<?=$R['mem_no']?>')" role="button"><i class="fas fa-sign-in-alt"></i></a>
<?php } else { ?>
<i class="fas fa-times"></i>
<?php } ?>
</td>
</tr>
<?php } // endforeach ?>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
<?php } else { // 결과가 없으면 없다고 출력
echo '<h2 style="margin-top: 30px; text-align: center;">검색 결과가 없습니다.</h2>'.PHP_EOL;
}
}
include_once FG_MANAGER_PATH."/tail.php";