148 lines
4.1 KiB
PHP
148 lines
4.1 KiB
PHP
<?php
|
|
if (!defined('_GNUBOARD_')) exit;
|
|
|
|
// 디버깅: config.php 로드됨
|
|
error_log('survey_form config.php loaded');
|
|
|
|
// 설문 목록 가져오기
|
|
$survey_options = array();
|
|
$survey_sql = "SELECT sv_id, sv_title, sv_status FROM survey_master ORDER BY sv_created_at DESC";
|
|
$survey_result = sql_query($survey_sql);
|
|
while ($survey = sql_fetch_array($survey_result)) {
|
|
$status_text = '';
|
|
switch($survey['sv_status']) {
|
|
case 'active': $status_text = ' (진행중)'; break;
|
|
case 'draft': $status_text = ' (임시저장)'; break;
|
|
case 'closed': $status_text = ' (종료)'; break;
|
|
}
|
|
$survey_options[$survey['sv_id']] = $survey['sv_title'] . $status_text;
|
|
}
|
|
|
|
// 현재 설정값 가져오기
|
|
$current_sv_id = '';
|
|
if (isset($row_mod['md_custom_survey_key']) && $row_mod['md_custom_survey_key']) {
|
|
$custom_options = json_decode($row_mod['md_custom_survey_key'], true);
|
|
if (isset($custom_options['sv_id'])) {
|
|
$current_sv_id = $custom_options['sv_id'];
|
|
}
|
|
}
|
|
?>
|
|
|
|
<div class="module-config-section">
|
|
<h4><i class="fa fa-clipboard"></i> 설문 폼 모듈 설정</h4>
|
|
|
|
<div class="form-group">
|
|
<label for="survey_select">표시할 설문 선택:</label>
|
|
<select name="custom_options[sv_id]" id="survey_select" class="form-control">
|
|
<option value="">-- 설문을 선택하세요 --</option>
|
|
<?php foreach ($survey_options as $sv_id => $sv_title): ?>
|
|
<option value="<?php echo $sv_id; ?>" <?php echo ($current_sv_id == $sv_id) ? 'selected' : ''; ?>>
|
|
<?php echo htmlspecialchars($sv_title); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<small class="form-text text-muted">
|
|
설문을 선택하지 않으면 사용자가 직접 설문을 선택할 수 있는 인터페이스가 표시됩니다.
|
|
</small>
|
|
</div>
|
|
|
|
<?php if (empty($survey_options)): ?>
|
|
<div class="alert alert-info">
|
|
<i class="fa fa-info-circle"></i>
|
|
등록된 설문이 없습니다.
|
|
<a href="<?php echo G5_ADMIN_URL; ?>/survey_manage/survey_form.php" target="_blank">새 설문 만들기</a>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="form-group">
|
|
<label>모듈 사용법:</label>
|
|
<ul class="usage-list">
|
|
<li>위에서 설문을 선택하면 해당 설문이 자동으로 표시됩니다.</li>
|
|
<li>설문을 선택하지 않으면 사용자가 설문을 선택할 수 있는 목록이 표시됩니다.</li>
|
|
<li>URL에 <code>?sv_id=설문번호</code>를 추가하면 특정 설문을 강제로 표시할 수 있습니다.</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.module-config-section {
|
|
padding: 20px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 8px;
|
|
background: #f9f9f9;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.module-config-section h4 {
|
|
margin-top: 0;
|
|
color: #333;
|
|
border-bottom: 2px solid #AA20FF;
|
|
padding-bottom: 10px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
font-weight: 600;
|
|
margin-bottom: 5px;
|
|
color: #333;
|
|
}
|
|
|
|
.form-control {
|
|
width: 100%;
|
|
padding: 8px 12px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.form-text {
|
|
font-size: 12px;
|
|
color: #666;
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.alert {
|
|
padding: 12px 15px;
|
|
border-radius: 4px;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.alert-info {
|
|
background-color: #d1ecf1;
|
|
border-color: #bee5eb;
|
|
color: #0c5460;
|
|
}
|
|
|
|
.usage-list {
|
|
margin: 0;
|
|
padding-left: 20px;
|
|
}
|
|
|
|
.usage-list li {
|
|
margin-bottom: 5px;
|
|
color: #666;
|
|
}
|
|
|
|
.usage-list code {
|
|
background: #f1f1f1;
|
|
padding: 2px 4px;
|
|
border-radius: 3px;
|
|
font-family: monospace;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const surveySelect = document.getElementById('survey_select');
|
|
if (surveySelect) {
|
|
surveySelect.addEventListener('change', function() {
|
|
// 설문 선택 시 미리보기나 추가 정보를 표시할 수 있습니다.
|
|
console.log('선택된 설문 ID:', this.value);
|
|
});
|
|
}
|
|
});
|
|
</script>
|