Files
dnssash/adm/survey_manage/template_preview.php
T
2026-06-11 18:47:38 +09:00

370 lines
9.7 KiB
PHP

<?php
$sub_menu = '710300';
include_once('./_common.php');
auth_check_menu($auth, $sub_menu, "r");
$st_id = isset($_GET['st_id']) ? (int)$_GET['st_id'] : 0;
if (!$st_id) {
alert('템플릿을 선택해주세요.', 'template_list.php');
}
// 템플릿 정보 가져오기
$template = sql_fetch("SELECT * FROM survey_templates WHERE st_id = '$st_id' AND st_is_public = 1");
if (!$template) {
alert('존재하지 않는 템플릿입니다.', 'template_list.php');
}
// 템플릿 질문들 가져오기
$questions = array();
$question_sql = "SELECT * FROM survey_template_questions WHERE st_id = '$st_id' ORDER BY stq_order ASC";
$question_result = sql_query($question_sql);
while ($question = sql_fetch_array($question_result)) {
$questions[] = $question;
}
$g5['title'] = '템플릿 미리보기 - ' . $template['st_name'];
include_once(G5_ADMIN_PATH.'/admin.head.php');
?>
<style>
.preview-container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
overflow: hidden;
}
.preview-header {
background: linear-gradient(135deg, #AA20FF 0%, #8A1ACC 100%);
color: white;
padding: 30px;
text-align: center;
}
.preview-title {
font-size: 2em;
font-weight: 600;
margin-bottom: 10px;
}
.preview-description {
font-size: 1.1em;
opacity: 0.9;
line-height: 1.5;
}
.preview-meta {
background: #fff;
padding: 20px 30px;
border-bottom: 1px solid #e9ecef;
}
.meta-row {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
}
.meta-row:last-child {
margin-bottom: 0;
}
.meta-label {
font-weight: 600;
color: #666;
}
.meta-value {
color: #333;
}
.preview-content {
padding: 30px;
}
.question-item {
margin-bottom: 30px;
padding: 25px;
background: #fff;
border-radius: 8px;
border-left: 4px solid #AA20FF;
}
.question-header {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.question-number {
background: #AA20FF;
color: white;
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
margin-right: 15px;
font-size: 0.9em;
}
.question-title {
font-size: 1.2em;
font-weight: 600;
color: #333;
flex: 1;
}
.question-required {
color: #dc3545;
font-size: 0.9em;
margin-left: 10px;
}
.question-description {
color: #666;
margin-bottom: 15px;
line-height: 1.5;
}
.question-type {
display: inline-block;
background: #e9ecef;
color: #666;
padding: 4px 12px;
border-radius: 12px;
font-size: 0.8em;
font-weight: 500;
margin-bottom: 15px;
}
.question-options {
margin-top: 15px;
}
.option-item {
display: flex;
align-items: center;
margin-bottom: 8px;
padding: 8px 12px;
background: white;
border-radius: 4px;
border: 1px solid #e0e0e0;
}
.option-input {
margin-right: 10px;
}
.option-text {
color: #333;
}
.preview-actions {
padding: 30px;
background: #fff;
text-align: center;
border-top: 1px solid #e9ecef;
}
.btn-action {
display: inline-block;
padding: 12px 30px;
margin: 0 10px;
border-radius: 6px;
text-decoration: none;
font-weight: 500;
transition: all 0.3s;
}
.btn-primary {
background: #AA20FF;
color: white;
}
.btn-primary:hover {
background: #8A1ACC;
color: white;
}
.btn-secondary {
background: #6c757d;
color: white;
}
.btn-secondary:hover {
background: #545b62;
color: white;
}
.empty-state {
text-align: center;
padding: 60px 30px;
color: #666;
}
.empty-state i {
font-size: 3em;
margin-bottom: 20px;
opacity: 0.3;
}
/* 반응형 */
@media (max-width: 768px) {
.preview-container {
margin: 10px;
border-radius: 8px;
}
.preview-header {
padding: 20px;
}
.preview-title {
font-size: 1.5em;
}
.preview-content {
padding: 20px;
}
.question-item {
padding: 20px;
}
.meta-row {
flex-direction: column;
gap: 5px;
}
}
</style>
<div class="preview-container">
<div class="preview-header">
<h1 class="preview-title"><?php echo htmlspecialchars($template['st_name']); ?></h1>
<?php if ($template['st_description']): ?>
<p class="preview-description"><?php echo nl2br(htmlspecialchars($template['st_description'])); ?></p>
<?php endif; ?>
</div>
<div class="preview-meta">
<div class="meta-row">
<span class="meta-label">카테고리</span>
<span class="meta-value"><?php echo htmlspecialchars($template['st_category']); ?></span>
</div>
<div class="meta-row">
<span class="meta-label">작성자</span>
<span class="meta-value"><?php echo htmlspecialchars($template['st_created_by']); ?></span>
</div>
<div class="meta-row">
<span class="meta-label">생성일</span>
<span class="meta-value"><?php echo date('Y년 m월 d일', strtotime($template['st_created_at'])); ?></span>
</div>
<div class="meta-row">
<span class="meta-label">질문 수</span>
<span class="meta-value"><?php echo count($questions); ?>개</span>
</div>
</div>
<div class="preview-content">
<?php if (count($questions) > 0): ?>
<?php foreach ($questions as $index => $question): ?>
<div class="question-item">
<div class="question-header">
<div class="question-number"><?php echo $index + 1; ?></div>
<div class="question-title">
<?php echo htmlspecialchars($question['stq_title']); ?>
<?php if ($question['stq_required']): ?>
<span class="question-required">*</span>
<?php endif; ?>
</div>
</div>
<?php
$type_names = array(
'text' => '단답형',
'textarea' => '장문형',
'radio' => '객관식 (단일선택)',
'checkbox' => '객관식 (다중선택)',
'select' => '드롭다운',
'rating' => '평점',
'date' => '날짜',
'email' => '이메일',
'number' => '숫자'
);
?>
<div class="question-type">
<i class="fa fa-tag"></i> <?php echo $type_names[$question['stq_type']] ?? $question['stq_type']; ?>
</div>
<?php if ($question['stq_description']): ?>
<div class="question-description">
<?php echo nl2br(htmlspecialchars($question['stq_description'])); ?>
</div>
<?php endif; ?>
<?php if (in_array($question['stq_type'], ['radio', 'checkbox', 'select']) && $question['stq_options']): ?>
<div class="question-options">
<?php
$options = json_decode($question['stq_options'], true);
if (is_array($options)):
foreach ($options as $option):
?>
<div class="option-item">
<input type="<?php echo $question['stq_type'] == 'checkbox' ? 'checkbox' : 'radio'; ?>"
class="option-input" disabled>
<span class="option-text"><?php echo htmlspecialchars($option); ?></span>
</div>
<?php
endforeach;
endif;
?>
</div>
<?php elseif ($question['stq_type'] == 'rating'): ?>
<div class="question-options">
<div class="option-item">
<?php for ($i = 1; $i <= 5; $i++): ?>
<i class="fa fa-star-o" style="color: #ddd; margin-right: 5px;"></i>
<?php endfor; ?>
<span class="option-text">1-5점 평점</span>
</div>
</div>
<?php elseif ($question['stq_type'] == 'text'): ?>
<div class="question-options">
<input type="text" class="form-control" placeholder="답변을 입력하세요" disabled style="background: #fff;">
</div>
<?php elseif ($question['stq_type'] == 'textarea'): ?>
<div class="question-options">
<textarea class="form-control" rows="3" placeholder="답변을 입력하세요" disabled style="background: #fff;"></textarea>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php else: ?>
<div class="empty-state">
<i class="fa fa-question-circle"></i>
<h3>질문이 없습니다</h3>
<p>이 템플릿에는 아직 질문이 등록되지 않았습니다.</p>
</div>
<?php endif; ?>
</div>
<div class="preview-actions">
<a href="survey_form.php?template_id=<?php echo $template['st_id']; ?>" class="btn-action btn-primary">
<i class="fa fa-plus"></i> 이 템플릿으로 설문 만들기
</a>
<a href="template_list.php" class="btn-action btn-secondary">
<i class="fa fa-list"></i> 템플릿 목록으로
</a>
</div>
</div>
<?php
include_once(G5_ADMIN_PATH.'/admin.tail.php');
?>