- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
281 lines
8.6 KiB
PHP
281 lines
8.6 KiB
PHP
<?php
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/load_header.php");
|
|
require_once(__DIR__ . '/../lib/mydb.php');
|
|
|
|
// 권한 체크 (레벨 5 이하만 접근)
|
|
if ($level > 5) {
|
|
echo "<script>alert('접근 권한이 없습니다.'); history.back();</script>";
|
|
exit;
|
|
}
|
|
|
|
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
|
|
|
if ($id <= 0) {
|
|
echo "<script>alert('잘못된 접근입니다.'); location.href='list.php';</script>";
|
|
exit;
|
|
}
|
|
|
|
$pdo = db_connect();
|
|
|
|
// 데이터 조회
|
|
$sql = "SELECT * FROM biz_cert WHERE id = :id";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->bindValue(':id', $id, PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
$data = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$data) {
|
|
echo "<script>alert('데이터를 찾을 수 없습니다.'); location.href='list.php';</script>";
|
|
exit;
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>사업자등록증 정보 수정</title>
|
|
<style>
|
|
.edit-container {
|
|
max-width: 800px;
|
|
margin: 20px auto;
|
|
padding: 20px;
|
|
background: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
}
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
.form-group label {
|
|
display: block;
|
|
font-weight: bold;
|
|
margin-bottom: 8px;
|
|
color: #333;
|
|
}
|
|
.form-group input,
|
|
.form-group textarea {
|
|
width: 100%;
|
|
padding: 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
font-size: 14px;
|
|
box-sizing: border-box;
|
|
}
|
|
.form-group input:focus,
|
|
.form-group textarea:focus {
|
|
outline: none;
|
|
border-color: #0d6efd;
|
|
}
|
|
.form-group textarea {
|
|
min-height: 80px;
|
|
resize: vertical;
|
|
}
|
|
.form-group small {
|
|
display: block;
|
|
color: #666;
|
|
margin-top: 4px;
|
|
font-size: 12px;
|
|
}
|
|
.btn {
|
|
padding: 10px 24px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
}
|
|
.btn-primary {
|
|
background: #0d6efd;
|
|
color: white;
|
|
}
|
|
.btn-primary:hover {
|
|
background: #0b5ed7;
|
|
}
|
|
.btn-secondary {
|
|
background: #6c757d;
|
|
color: white;
|
|
}
|
|
.btn-secondary:hover {
|
|
background: #5c636a;
|
|
}
|
|
.button-group {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-top: 30px;
|
|
padding-top: 20px;
|
|
border-top: 1px solid #dee2e6;
|
|
}
|
|
.validation-error {
|
|
color: #dc3545;
|
|
font-size: 12px;
|
|
margin-top: 4px;
|
|
display: none;
|
|
}
|
|
.header-section {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: 20px;
|
|
padding-bottom: 15px;
|
|
border-bottom: 2px solid #dee2e6;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<?php include $_SERVER['DOCUMENT_ROOT'] . "/myheader.php"; ?>
|
|
|
|
<div class="edit-container">
|
|
<div class="header-section">
|
|
<h3><i class="bi bi-pencil"></i> 사업자등록증 정보 수정</h3>
|
|
<div>
|
|
<a href="list.php" class="btn btn-secondary">
|
|
<i class="bi bi-list-ul"></i> 목록으로
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<form id="editForm" method="post" action="update.php">
|
|
<input type="hidden" name="id" value="<?php echo htmlspecialchars($data['id']); ?>">
|
|
|
|
<div class="form-group">
|
|
<label for="biz_no">
|
|
사업자등록번호 <span style="color: #dc3545;">*</span>
|
|
</label>
|
|
<input type="text" id="biz_no" name="biz_no"
|
|
value="<?php echo htmlspecialchars($data['biz_no']); ?>"
|
|
placeholder="000-00-00000" maxlength="12" required>
|
|
<small>형식: 000-00-00000 (10자리)</small>
|
|
<div class="validation-error" id="biz_no_error"></div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="company_name">
|
|
상호명 (법인명) <span style="color: #dc3545;">*</span>
|
|
</label>
|
|
<input type="text" id="company_name" name="company_name"
|
|
value="<?php echo htmlspecialchars($data['company_name']); ?>"
|
|
placeholder="주식회사 홍길동" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="representative">
|
|
대표자명 <span style="color: #dc3545;">*</span>
|
|
</label>
|
|
<input type="text" id="representative" name="representative"
|
|
value="<?php echo htmlspecialchars($data['representative']); ?>"
|
|
placeholder="홍길동" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="open_date">개업일자</label>
|
|
<input type="date" id="open_date" name="open_date"
|
|
value="<?php echo htmlspecialchars($data['open_date']); ?>">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="address">본점 소재지</label>
|
|
<textarea id="address" name="address"
|
|
placeholder="서울특별시 강남구..."><?php echo htmlspecialchars($data['address']); ?></textarea>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="type">업태</label>
|
|
<input type="text" id="type" name="type"
|
|
value="<?php echo htmlspecialchars($data['type']); ?>"
|
|
placeholder="제조업, 도소매업 등">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="item">종목</label>
|
|
<input type="text" id="item" name="item"
|
|
value="<?php echo htmlspecialchars($data['item']); ?>"
|
|
placeholder="건축자재, 전자제품 등">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="issue_date">발급일자</label>
|
|
<input type="date" id="issue_date" name="issue_date"
|
|
value="<?php echo htmlspecialchars($data['issue_date']); ?>">
|
|
</div>
|
|
|
|
<div class="button-group">
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="bi bi-check-circle"></i> 저장
|
|
</button>
|
|
<a href="list.php" class="btn btn-secondary">
|
|
<i class="bi bi-x-circle"></i> 취소
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
// 사업자번호 자동 하이픈 추가
|
|
document.getElementById('biz_no').addEventListener('input', function(e) {
|
|
let value = e.target.value.replace(/[^0-9]/g, '');
|
|
if (value.length > 10) value = value.substr(0, 10);
|
|
|
|
if (value.length >= 3) {
|
|
value = value.substr(0, 3) + '-' + value.substr(3);
|
|
}
|
|
if (value.length >= 6) {
|
|
value = value.substr(0, 6) + '-' + value.substr(6);
|
|
}
|
|
|
|
e.target.value = value;
|
|
});
|
|
|
|
// 사업자번호 검증
|
|
function validateBizNo(bizNo) {
|
|
const cleaned = bizNo.replace(/[^0-9]/g, '');
|
|
if (cleaned.length !== 10) return false;
|
|
|
|
const checksum = [1, 3, 7, 1, 3, 7, 1, 3, 5];
|
|
let sum = 0;
|
|
|
|
for (let i = 0; i < 9; i++) {
|
|
sum += parseInt(cleaned[i]) * checksum[i];
|
|
}
|
|
|
|
sum += Math.floor((parseInt(cleaned[8]) * 5) / 10);
|
|
const lastDigit = (10 - (sum % 10)) % 10;
|
|
|
|
return lastDigit === parseInt(cleaned[9]);
|
|
}
|
|
|
|
// 폼 제출 전 검증
|
|
document.getElementById('editForm').addEventListener('submit', function(e) {
|
|
const bizNo = document.getElementById('biz_no').value;
|
|
const errorDiv = document.getElementById('biz_no_error');
|
|
|
|
if (!validateBizNo(bizNo)) {
|
|
e.preventDefault();
|
|
errorDiv.textContent = '올바른 사업자등록번호가 아닙니다. 형식과 체크섬을 확인해주세요.';
|
|
errorDiv.style.display = 'block';
|
|
document.getElementById('biz_no').focus();
|
|
return false;
|
|
}
|
|
|
|
errorDiv.style.display = 'none';
|
|
return true;
|
|
});
|
|
|
|
// 페이지 로드 완료 시 loader 숨기기
|
|
window.addEventListener('load', function() {
|
|
const loadingOverlay = document.getElementById('loadingOverlay');
|
|
if (loadingOverlay) {
|
|
loadingOverlay.style.display = 'none';
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
|