381 lines
22 KiB
PHP
381 lines
22 KiB
PHP
<?php
|
|
/**
|
|
* 상담 예약 시스템 통합 설정 관리
|
|
*/
|
|
|
|
$sub_menu = '850610'; // 메뉴 코드 (기본/운영 설정)
|
|
include_once('./_common.php');
|
|
|
|
// 권한 확인
|
|
auth_check_menu($auth, $sub_menu, 'w');
|
|
|
|
// 설치 확인
|
|
if (!is_consultant_installed()) {
|
|
alert('상담 예약 시스템이 설치되지 않았습니다.', 'install.php');
|
|
}
|
|
|
|
$g5['title'] = '상담 예약 설정';
|
|
|
|
// 현재 탭 확인
|
|
$current_tab = $_GET['tab'] ?? 'basic';
|
|
|
|
// 폼 처리
|
|
if (isset($_POST['action']) && $_POST['action']) {
|
|
try {
|
|
// 기본 설정 저장
|
|
if ($_POST['action'] == 'save_basic_settings') {
|
|
$basic_settings = [
|
|
'consultation_duration' => (int) ($_POST['consultation_duration'] ?? 60),
|
|
'max_persons_per_slot' => (int) ($_POST['max_persons_per_slot'] ?? 2),
|
|
'consultation_fee' => (int) ($_POST['consultation_fee'] ?? 50000),
|
|
'account_info' => trim($_POST['account_info'] ?? ''),
|
|
'max_advance_days' => (int) ($_POST['max_advance_days'] ?? 30),
|
|
'min_advance_hours' => (int) ($_POST['min_advance_hours'] ?? 24),
|
|
'cancel_deadline_hours' => (int) ($_POST['cancel_deadline_hours'] ?? 24)
|
|
];
|
|
|
|
// 유효성 검증 (생략)
|
|
|
|
foreach ($basic_settings as $key => $value) {
|
|
consultant_set_config($key, $value);
|
|
}
|
|
alert('기본 설정이 저장되었습니다.', $_SERVER['PHP_SELF'] . '?tab=basic');
|
|
}
|
|
|
|
// 요일별 설정 저장
|
|
if ($_POST['action'] == 'save_weekly_settings') {
|
|
$days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
|
foreach ($days as $day) {
|
|
consultant_set_config($day . '_enabled', $_POST[$day . '_enabled'] ?? '0');
|
|
consultant_set_config($day . '_start', $_POST[$day . '_start'] ?? '09:00');
|
|
consultant_set_config($day . '_end', $_POST[$day . '_end'] ?? '18:00');
|
|
consultant_set_config($day . '_lunch_start', $_POST[$day . '_lunch_start'] ?? '12:00');
|
|
consultant_set_config($day . '_lunch_end', $_POST[$day . '_lunch_end'] ?? '13:00');
|
|
}
|
|
alert('요일별 설정이 저장되었습니다.', $_SERVER['PHP_SELF'] . '?tab=weekly');
|
|
}
|
|
|
|
// 알림 설정 저장
|
|
if ($_POST['action'] == 'save_notification_settings') {
|
|
consultant_set_config('notification_enabled', $_POST['notification_enabled'] ?? '0');
|
|
alert('알림 설정이 저장되었습니다.', $_SERVER['PHP_SELF'] . '?tab=notification');
|
|
}
|
|
|
|
// 💡 [추가] 고급 설정 저장 처리
|
|
if ($_POST['action'] == 'save_advanced_settings') {
|
|
$config_values = $_POST['config_value'] ?? [];
|
|
$config_descs = $_POST['config_desc'] ?? [];
|
|
|
|
foreach ($config_values as $key => $value) {
|
|
$sql = "UPDATE consultant_config
|
|
SET config_value = '" . sql_real_escape_string($value) . "',
|
|
config_desc = '" . sql_real_escape_string($config_descs[$key] ?? '') . "'
|
|
WHERE config_key = '" . sql_real_escape_string($key) . "'";
|
|
sql_query($sql);
|
|
}
|
|
alert('고급 설정이 저장되었습니다.', $_SERVER['PHP_SELF'] . '?tab=advanced');
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
alert('설정 저장 중 오류가 발생했습니다: ' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
|
|
// --- 데이터 조회 ---
|
|
// 기본 설정
|
|
$consultation_duration = consultant_get_config('consultation_duration', '60');
|
|
$max_persons_per_slot = consultant_get_config('max_persons_per_slot', '2');
|
|
$consultation_fee = consultant_get_config('consultation_fee', '50000');
|
|
$account_info = consultant_get_config('account_info', '국민은행 123-456-789 (주)상담센터');
|
|
$notification_enabled = consultant_get_config('notification_enabled', '1');
|
|
$max_advance_days = consultant_get_config('max_advance_days', '30');
|
|
$min_advance_hours = consultant_get_config('min_advance_hours', '24');
|
|
$cancel_deadline_hours = consultant_get_config('cancel_deadline_hours', '24');
|
|
|
|
// 요일별 설정
|
|
$days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
|
$day_names = ['월요일', '화요일', '수요일', '목요일', '금요일', '토요일', '일요일'];
|
|
$weekly_settings = [];
|
|
foreach ($days as $i => $day) {
|
|
$weekly_settings[$day] = [
|
|
'name' => $day_names[$i],
|
|
'enabled' => consultant_get_config($day . '_enabled', $day == 'saturday' || $day == 'sunday' ? '0' : '1'),
|
|
'start' => consultant_get_config($day . '_start', '09:00'),
|
|
'end' => consultant_get_config($day . '_end', '18:00'),
|
|
'lunch_start' => consultant_get_config($day . '_lunch_start', '12:00'),
|
|
'lunch_end' => consultant_get_config($day . '_lunch_end', '13:00')
|
|
];
|
|
}
|
|
|
|
// 💡 [추가] 고급 설정 데이터 조회
|
|
$advanced_configs = [];
|
|
$result = sql_query("SELECT * FROM consultant_config ORDER BY id");
|
|
while ($row = sql_fetch_array($result)) {
|
|
$advanced_configs[] = $row;
|
|
}
|
|
|
|
|
|
include_once(G5_ADMIN_PATH . '/admin.head.php');
|
|
?>
|
|
|
|
<div class="settings-container">
|
|
<div class="settings-header">
|
|
<h2><?php echo $g5['title']; ?></h2>
|
|
<div>
|
|
<a href="dashboard.php" class="header-btn">📊 대시보드</a>
|
|
<a href="schedule_generate.php" class="header-btn primary">📅 빠른 스케줄 관리</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 탭 네비게이션 -->
|
|
<div class="settings-tabs">
|
|
<a href="?tab=basic" class="tab-button <?php echo $current_tab == 'basic' ? 'active' : ''; ?>">⚙️ 기본 설정</a>
|
|
<a href="?tab=weekly" class="tab-button <?php echo $current_tab == 'weekly' ? 'active' : ''; ?>">📅 요일별 운영시간</a>
|
|
<a href="?tab=advanced" class="tab-button <?php echo $current_tab == 'advanced' ? 'active' : ''; ?>">🛠️ 고급 설정</a>
|
|
<a href="?tab=notification" class="tab-button <?php echo $current_tab == 'notification' ? 'active' : ''; ?>">🔔 알림 설정</a>
|
|
</div>
|
|
|
|
<!-- 기본 설정 탭 -->
|
|
<div class="tab-content <?php echo $current_tab == 'basic' ? 'active' : ''; ?>">
|
|
<div class="alert alert-info">
|
|
<strong>기본 설정:</strong> 1회 상담시간, 최대인원, 상담비 등 기본적인 상담 조건을 설정합니다.
|
|
</div>
|
|
<form method="post" class="settings-form">
|
|
<input type="hidden" name="action" value="save_basic_settings">
|
|
|
|
<div class="section-title">⏰ 상담 기본 조건</div>
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="consultation_duration">1회 상담 시간 (분)</label>
|
|
<select id="consultation_duration" name="consultation_duration">
|
|
<?php
|
|
for ($i = 15; $i <= 480; $i += 15) {
|
|
$selected = ($consultation_duration == $i) ? 'selected' : '';
|
|
echo "<option value=\"{$i}\" {$selected}>{$i}분</option>";
|
|
}
|
|
?>
|
|
</select>
|
|
<small>15분~480분 사이로 설정 가능합니다. (15분 단위)</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="max_persons_per_slot">1회 상담 최대 인원 (명)</label>
|
|
<input type="number" id="max_persons_per_slot" name="max_persons_per_slot" value="<?php echo htmlspecialchars($max_persons_per_slot); ?>" min="1" max="50" placeholder="2">
|
|
<small>1명~50명 사이로 설정 가능합니다.</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section-title">💰 결제 정보</div>
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="consultation_fee">상담 비용 (원)</label>
|
|
<input type="number" id="consultation_fee" name="consultation_fee" value="<?php echo htmlspecialchars($consultation_fee); ?>" min="0" step="1000" placeholder="50000">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="account_info">입금 계좌 정보</label>
|
|
<textarea id="account_info" name="account_info" placeholder="예: 국민은행 123-456-789 (주)상담센터"><?php echo htmlspecialchars($account_info); ?></textarea>
|
|
</div>
|
|
|
|
<div class="section-title">📅 예약 제한 설정</div>
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="max_advance_days">최대 예약 가능 일수</label>
|
|
<input type="number" id="max_advance_days" name="max_advance_days" value="<?php echo htmlspecialchars($max_advance_days); ?>" min="1" max="365">
|
|
<small>오늘부터 몇 일 후까지 예약 가능한지 설정</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="min_advance_hours">최소 예약 시간 (시간)</label>
|
|
<input type="number" id="min_advance_hours" name="min_advance_hours" value="<?php echo htmlspecialchars($min_advance_hours); ?>" min="1" max="168">
|
|
<small>최소 몇 시간 전에 예약해야 하는지 설정</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="cancel_deadline_hours">예약 취소 마감 (시간)</label>
|
|
<input type="number" id="cancel_deadline_hours" name="cancel_deadline_hours" value="<?php echo htmlspecialchars($cancel_deadline_hours); ?>" min="1" max="168">
|
|
<small>상담 시작 몇 시간 전까지 고객이 직접 취소할 수 있는지 설정</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="text-align: center; margin-top: 40px;">
|
|
<button type="submit" class="btn btn-primary">기본 설정 저장</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- 요일별 운영시간 탭 -->
|
|
<div class="tab-content <?php echo $current_tab == 'weekly' ? 'active' : ''; ?>">
|
|
<div class="alert alert-info">
|
|
<strong>요일별 운영시간:</strong> 각 요일의 상담 운영 여부와 시간을 설정합니다. '운영'을 선택해야 해당 요일의 스케줄이 생성됩니다.
|
|
</div>
|
|
<form method="post" class="settings-form">
|
|
<input type="hidden" name="action" value="save_weekly_settings">
|
|
|
|
<?php foreach ($weekly_settings as $day => $setting): ?>
|
|
<div class="day-setting">
|
|
<div class="day-header">
|
|
<div class="checkbox-wrapper">
|
|
<input type="hidden" name="<?php echo $day; ?>_enabled" value="0">
|
|
<input type="checkbox" id="<?php echo $day; ?>_enabled" name="<?php echo $day; ?>_enabled" value="1" <?php echo $setting['enabled'] == '1' ? 'checked' : ''; ?> onchange="toggleDayTimes('<?php echo $day; ?>')">
|
|
<label for="<?php echo $day; ?>_enabled" class="day-name"><?php echo $setting['name']; ?></label>
|
|
</div>
|
|
</div>
|
|
<div class="day-times" id="<?php echo $day; ?>_times">
|
|
<div class="form-group">
|
|
<label for="<?php echo $day; ?>_start">업무 시작</label>
|
|
<input type="time" id="<?php echo $day; ?>_start" name="<?php echo $day; ?>_start" value="<?php echo htmlspecialchars($setting['start']); ?>">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="<?php echo $day; ?>_end">업무 종료</label>
|
|
<input type="time" id="<?php echo $day; ?>_end" name="<?php echo $day; ?>_end" value="<?php echo htmlspecialchars($setting['end']); ?>">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="<?php echo $day; ?>_lunch_start">점심 시작</label>
|
|
<input type="time" id="<?php echo $day; ?>_lunch_start" name="<?php echo $day; ?>_lunch_start" value="<?php echo htmlspecialchars($setting['lunch_start']); ?>">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="<?php echo $day; ?>_lunch_end">점심 종료</label>
|
|
<input type="time" id="<?php echo $day; ?>_lunch_end" name="<?php echo $day; ?>_lunch_end" value="<?php echo htmlspecialchars($setting['lunch_end']); ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<div style="text-align: center; margin-top: 40px;">
|
|
<button type="submit" class="btn btn-primary">요일별 설정 저장</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- 💡 [추가] 고급 설정 탭 -->
|
|
<div class="tab-content <?php echo $current_tab == 'advanced' ? 'active' : ''; ?>">
|
|
<div class="alert alert-info">
|
|
<strong>고급 설정:</strong> 시스템의 모든 설정값을 직접 관리합니다. <strong>'Key'는 시스템에서 사용하는 고유값이므로 변경할 수 없습니다.</strong><br>
|
|
'Value'는 실제 적용되는 값이며, 'Description'은 관리자가 참고하기 위한 설명입니다.
|
|
</div>
|
|
<form method="post" class="settings-form">
|
|
<input type="hidden" name="action" value="save_advanced_settings">
|
|
<div class="tbl_head01 tbl_wrap">
|
|
<table>
|
|
<caption>고급 설정 목록</caption>
|
|
<colgroup>
|
|
<col style="width: 25%;">
|
|
<col style="width: 40%;">
|
|
<col style="width: 35%;">
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">Key (변경불가)</th>
|
|
<th scope="col">Value (설정값)</th>
|
|
<th scope="col">Description (설명)</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($advanced_configs as $config_item): ?>
|
|
<tr>
|
|
<td>
|
|
<label for="config_value_<?php echo $config_item['config_key']; ?>">
|
|
<code style="font-size: 13px; font-weight: bold;"><?php echo htmlspecialchars($config_item['config_key']); ?></code>
|
|
</label>
|
|
</td>
|
|
<td>
|
|
<?php if (strlen($config_item['config_value']) > 50 || strpos($config_item['config_value'], "\n") !== false): ?>
|
|
<textarea class="form-control" id="config_value_<?php echo $config_item['config_key']; ?>" name="config_value[<?php echo $config_item['config_key']; ?>]" rows="2"><?php echo htmlspecialchars($config_item['config_value']); ?></textarea>
|
|
<?php else: ?>
|
|
<input type="text" class="form-control" id="config_value_<?php echo $config_item['config_key']; ?>" name="config_value[<?php echo $config_item['config_key']; ?>]" value="<?php echo htmlspecialchars($config_item['config_value']); ?>">
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<input type="text" class="form-control" name="config_desc[<?php echo $config_item['config_key']; ?>]" value="<?php echo htmlspecialchars($config_item['config_desc']); ?>">
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div style="text-align: center; margin-top: 40px;">
|
|
<button type="submit" class="btn btn-primary">고급 설정 저장</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- 알림 설정 탭 -->
|
|
<div class="tab-content <?php echo $current_tab == 'notification' ? 'active' : ''; ?>">
|
|
<div class="alert alert-info">
|
|
<strong>알림 설정:</strong> 예약 관련 알림 기능을 설정합니다.
|
|
</div>
|
|
<form method="post" class="settings-form">
|
|
<input type="hidden" name="action" value="save_notification_settings">
|
|
<div class="section-title">🔔 알림 기능</div>
|
|
<div class="form-group">
|
|
<div class="checkbox-wrapper">
|
|
<input type="checkbox" id="notification_enabled" name="notification_enabled" value="1" <?php echo $notification_enabled == '1' ? 'checked' : ''; ?>>
|
|
<label for="notification_enabled">알림 기능 사용</label>
|
|
</div>
|
|
<small>예약 확정, 취소 등의 상황에서 고객에게 알림을 발송합니다.</small>
|
|
</div>
|
|
<div style="text-align: center; margin-top: 40px;">
|
|
<button type="submit" class="btn btn-primary">알림 설정 저장</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 💡 [복구] 깨진 화면을 복구하기 위해 CSS와 JS를 파일 내에 다시 포함합니다. -->
|
|
<style>
|
|
.settings-container { max-width: 1000px; margin: 0 auto; padding: 20px; }
|
|
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
|
.settings-header div { display: flex; gap: 8px; }
|
|
.settings-tabs { display: flex; border-bottom: 2px solid #ddd; margin-bottom: 30px; }
|
|
.tab-button { padding: 16px 28px; border: none; background: none; cursor: pointer; font-size: 16px; font-weight: 600; color: #666; text-decoration: none; border-bottom: 3px solid transparent; transition: all 0.3s; }
|
|
.tab-button.active { color: #007bff; border-bottom-color: #007bff; }
|
|
.tab-button:hover { color: #007bff; background: #fff; }
|
|
.tab-content { display: none; }
|
|
.tab-content.active { display: block; }
|
|
.settings-form { background: white; border: 1px solid #ddd; border-radius: 8px; padding: 30px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); }
|
|
.form-group { margin-bottom: 20px; }
|
|
.form-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #333; }
|
|
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 12px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; box-sizing: border-box; min-height: 44px; line-height: 1.4; }
|
|
.form-group textarea { height: auto; resize: vertical; }
|
|
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
|
|
.btn { padding: 16px 32px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 16px; text-decoration: none; display: inline-block; transition: all 0.2s; text-align: center; min-height: 50px; line-height: 1.4; box-sizing: border-box; vertical-align: middle; }
|
|
.btn-primary { background: #007bff; color: white; }
|
|
.btn-primary:hover { background: #0056b3; }
|
|
.alert { padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px; }
|
|
.alert-info { color: #0c5460; background-color: #d1ecf1; border-color: #bee5eb; }
|
|
.section-title { font-size: 18px; font-weight: bold; margin: 30px 0 15px 0; padding-bottom: 8px; border-bottom: 2px solid #007bff; color: #333; }
|
|
.section-title:first-child { margin-top: 0; }
|
|
.day-setting { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 20px; margin-bottom: 15px; }
|
|
.day-header { display: flex; align-items: center; margin-bottom: 15px; gap: 15px; }
|
|
.day-name { font-weight: bold; font-size: 16px; color: #333; min-width: 80px; }
|
|
.day-times { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 15px; }
|
|
.day-times.disabled { opacity: 0.5; pointer-events: none; }
|
|
.checkbox-wrapper { display: flex; align-items: center; gap: 8px; }
|
|
.checkbox-wrapper input[type="checkbox"] { width: 18px; height: 18px; margin: 0; }
|
|
.form-group small { display: block; margin-top: 5px; font-size: 12px; color: #666; line-height: 1.3; }
|
|
.header-btn { padding: 8px 16px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer; font-weight: 500; font-size: 14px; text-decoration: none; display: inline-block; transition: all 0.2s; text-align: center; min-height: auto; line-height: 1.2; box-sizing: border-box; background: #fff; color: #333; }
|
|
.header-btn:hover { background: #fff; border-color: #adb5bd; color: #333; }
|
|
.header-btn.primary { background: #e3f2fd; border-color: #90caf9; color: #1976d2; }
|
|
.header-btn.primary:hover { background: #bbdefb; border-color: #64b5f6; }
|
|
</style>
|
|
|
|
<script>
|
|
function toggleDayTimes(day) {
|
|
const checkbox = document.getElementById(day + '_enabled');
|
|
const timesDiv = document.getElementById(day + '_times');
|
|
if (checkbox?.checked) {
|
|
timesDiv.classList.remove('disabled');
|
|
} else {
|
|
timesDiv?.classList.add('disabled');
|
|
}
|
|
}
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
|
days.forEach(function (day) {
|
|
toggleDayTimes(day);
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<?php
|
|
include_once(G5_ADMIN_PATH . '/admin.tail.php');
|
|
?>
|