176 lines
8.4 KiB
PHP
176 lines
8.4 KiB
PHP
<?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 '이미 모두 입력했습니다.';
|
|
}
|
|
?>
|