413 lines
11 KiB
PHP
413 lines
11 KiB
PHP
<?php
|
|
$sub_menu = '710310';
|
|
include_once('./_common.php');
|
|
|
|
auth_check_menu($auth, $sub_menu, "r");
|
|
|
|
$sr_id = isset($_GET['sr_id']) ? (int)$_GET['sr_id'] : 0;
|
|
|
|
if (!$sr_id) {
|
|
alert('응답을 선택해주세요.', 'response_list.php');
|
|
}
|
|
|
|
// 응답 정보 가져오기
|
|
$response = sql_fetch("
|
|
SELECT sr.*, sm.sv_title, sm.sv_description
|
|
FROM survey_responses sr
|
|
LEFT JOIN survey_master sm ON sr.sv_id = sm.sv_id
|
|
WHERE sr.sr_id = '$sr_id'
|
|
");
|
|
|
|
if (!$response) {
|
|
alert('존재하지 않는 응답입니다.', 'response_list.php');
|
|
}
|
|
|
|
$survey = get_survey($response['sv_id']);
|
|
$questions = get_survey_questions($response['sv_id']);
|
|
|
|
// 답변 데이터 가져오기
|
|
$answers = array();
|
|
$answer_sql = "SELECT * FROM survey_answers WHERE sr_id = '$sr_id' ORDER BY sq_id";
|
|
$answer_result = sql_query($answer_sql);
|
|
while ($answer_row = sql_fetch_array($answer_result)) {
|
|
if (!isset($answers[$answer_row['sq_id']])) {
|
|
$answers[$answer_row['sq_id']] = array();
|
|
}
|
|
$answers[$answer_row['sq_id']][] = $answer_row;
|
|
}
|
|
|
|
$g5['title'] = '응답 상세보기 - ' . $response['sv_title'];
|
|
include_once(G5_ADMIN_PATH.'/admin.head.php');
|
|
|
|
// 응답 시간 계산
|
|
$response_time = 0;
|
|
if ($response['sr_completed_at'] && $response['sr_started_at']) {
|
|
$start = strtotime($response['sr_started_at']);
|
|
$end = strtotime($response['sr_completed_at']);
|
|
$response_time = round(($end - $start) / 60, 1); // 분 단위
|
|
}
|
|
?>
|
|
|
|
<style>
|
|
.response-view-container {
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.response-header {
|
|
background: linear-gradient(135deg, #AA20FF 0%, #8A1ACC 100%);
|
|
color: white;
|
|
padding: 30px;
|
|
border-radius: 15px;
|
|
margin-bottom: 30px;
|
|
text-align: center;
|
|
}
|
|
|
|
.response-header h1 {
|
|
margin: 0 0 10px 0;
|
|
font-size: 2em;
|
|
}
|
|
|
|
.response-info {
|
|
background: white;
|
|
border-radius: 12px;
|
|
padding: 25px;
|
|
margin-bottom: 30px;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.info-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 20px;
|
|
}
|
|
|
|
.info-item {
|
|
text-align: center;
|
|
padding: 15px;
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.info-label {
|
|
font-size: 0.9em;
|
|
color: #666;
|
|
margin-bottom: 5px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.info-value {
|
|
font-size: 1.2em;
|
|
font-weight: 600;
|
|
color: #333;
|
|
}
|
|
|
|
.status-badge {
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
font-size: 0.8em;
|
|
font-weight: 500;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.status-completed { background: #d4edda; color: #155724; }
|
|
.status-started { background: #fff3cd; color: #856404; }
|
|
.status-abandoned { background: #f8d7da; color: #721c24; }
|
|
|
|
.answers-container {
|
|
background: white;
|
|
border-radius: 12px;
|
|
padding: 30px;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.answer-item {
|
|
margin-bottom: 30px;
|
|
padding-bottom: 25px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
|
|
.answer-item:last-child {
|
|
border-bottom: none;
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.question-header {
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.question-number {
|
|
display: inline-block;
|
|
width: 25px;
|
|
height: 25px;
|
|
background: #AA20FF;
|
|
color: white;
|
|
border-radius: 50%;
|
|
text-align: center;
|
|
line-height: 25px;
|
|
font-weight: bold;
|
|
font-size: 0.8em;
|
|
margin-right: 10px;
|
|
}
|
|
|
|
.question-title {
|
|
font-size: 1.1em;
|
|
font-weight: 600;
|
|
color: #333;
|
|
display: inline;
|
|
}
|
|
|
|
.question-type {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
background: #e9ecef;
|
|
color: #666;
|
|
border-radius: 10px;
|
|
font-size: 0.7em;
|
|
font-weight: 500;
|
|
text-transform: uppercase;
|
|
margin-left: 10px;
|
|
}
|
|
|
|
.answer-content {
|
|
margin-left: 35px;
|
|
padding: 15px 20px;
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
border-left: 4px solid #AA20FF;
|
|
}
|
|
|
|
.answer-value {
|
|
color: #333;
|
|
line-height: 1.5;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.answer-text {
|
|
color: #666;
|
|
font-style: italic;
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.multiple-answers {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.answer-chip {
|
|
display: inline-block;
|
|
padding: 5px 12px;
|
|
background: #AA20FF;
|
|
color: white;
|
|
border-radius: 15px;
|
|
font-size: 0.9em;
|
|
margin-right: 8px;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.no-answer {
|
|
color: #999;
|
|
font-style: italic;
|
|
}
|
|
|
|
.action-buttons {
|
|
display: flex;
|
|
gap: 15px;
|
|
justify-content: center;
|
|
margin-top: 30px;
|
|
padding-top: 20px;
|
|
border-top: 1px solid #f0f0f0;
|
|
}
|
|
|
|
.btn {
|
|
padding: 12px 24px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 1em;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
text-decoration: none;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.btn-info {
|
|
background: #17a2b8;
|
|
color: white;
|
|
}
|
|
|
|
.btn-info:hover {
|
|
background: #138496;
|
|
color: white;
|
|
}
|
|
|
|
/* 반응형 */
|
|
@media (max-width: 768px) {
|
|
.response-view-container {
|
|
padding: 10px;
|
|
}
|
|
|
|
.info-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.action-buttons {
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
|
|
.btn {
|
|
width: 100%;
|
|
max-width: 250px;
|
|
justify-content: center;
|
|
}
|
|
|
|
.answer-content {
|
|
margin-left: 0;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<div class="response-view-container">
|
|
<div class="response-header">
|
|
<h1><i class="fa fa-eye"></i> 응답 상세보기</h1>
|
|
<p><?php echo htmlspecialchars($response['sv_title']); ?></p>
|
|
</div>
|
|
|
|
<div class="response-info">
|
|
<div class="info-grid">
|
|
<div class="info-item">
|
|
<div class="info-label">응답 ID</div>
|
|
<div class="info-value"><?php echo $response['sr_id']; ?></div>
|
|
</div>
|
|
<div class="info-item">
|
|
<div class="info-label">응답자</div>
|
|
<div class="info-value"><?php echo $response['sr_mb_id'] ?: '익명'; ?></div>
|
|
</div>
|
|
<div class="info-item">
|
|
<div class="info-label">IP 주소</div>
|
|
<div class="info-value"><?php echo $response['sr_ip']; ?></div>
|
|
</div>
|
|
<div class="info-item">
|
|
<div class="info-label">상태</div>
|
|
<div class="info-value">
|
|
<span class="status-badge status-<?php echo $response['sr_status']; ?>">
|
|
<?php
|
|
$status_text = array(
|
|
'started' => '진행중',
|
|
'completed' => '완료',
|
|
'abandoned' => '중단'
|
|
);
|
|
echo $status_text[$response['sr_status']];
|
|
?>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="info-item">
|
|
<div class="info-label">시작 시간</div>
|
|
<div class="info-value">
|
|
<small><?php echo date('Y-m-d H:i:s', strtotime($response['sr_started_at'])); ?></small>
|
|
</div>
|
|
</div>
|
|
<div class="info-item">
|
|
<div class="info-label">완료 시간</div>
|
|
<div class="info-value">
|
|
<?php if ($response['sr_completed_at']): ?>
|
|
<small><?php echo date('Y-m-d H:i:s', strtotime($response['sr_completed_at'])); ?></small>
|
|
<?php else: ?>
|
|
<span class="no-answer">미완료</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php if ($response_time > 0): ?>
|
|
<div class="info-item">
|
|
<div class="info-label">응답 시간</div>
|
|
<div class="info-value"><?php echo $response_time; ?>분</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="answers-container">
|
|
<h2><i class="fa fa-list-alt"></i> 응답 내용</h2>
|
|
|
|
<?php foreach ($questions as $index => $question): ?>
|
|
<div class="answer-item">
|
|
<div class="question-header">
|
|
<span class="question-number"><?php echo $index + 1; ?></span>
|
|
<h3 class="question-title"><?php echo htmlspecialchars($question['sq_title']); ?></h3>
|
|
<span class="question-type"><?php echo $question['sq_type']; ?></span>
|
|
</div>
|
|
|
|
<div class="answer-content">
|
|
<?php if (isset($answers[$question['sq_id']]) && !empty($answers[$question['sq_id']])): ?>
|
|
<?php if (count($answers[$question['sq_id']]) > 1): ?>
|
|
<!-- 다중 답변 (체크박스) -->
|
|
<div class="multiple-answers">
|
|
<?php foreach ($answers[$question['sq_id']] as $answer): ?>
|
|
<span class="answer-chip"><?php echo htmlspecialchars($answer['sa_value']); ?></span>
|
|
<?php if ($answer['sa_text']): ?>
|
|
<div class="answer-text"><?php echo htmlspecialchars($answer['sa_text']); ?></div>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<!-- 단일 답변 -->
|
|
<div class="answer-value">
|
|
<?php echo nl2br(htmlspecialchars($answers[$question['sq_id']][0]['sa_value'])); ?>
|
|
</div>
|
|
<?php if ($answers[$question['sq_id']][0]['sa_text']): ?>
|
|
<div class="answer-text">
|
|
<?php echo nl2br(htmlspecialchars($answers[$question['sq_id']][0]['sa_text'])); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
<?php else: ?>
|
|
<div class="no-answer">답변 없음</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<div class="action-buttons">
|
|
<a href="response_list.php?sv_id=<?php echo $response['sv_id']; ?>" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left"></i> 목록으로
|
|
</a>
|
|
<a href="statistics.php?sv_id=<?php echo $response['sv_id']; ?>" class="btn btn-info">
|
|
<i class="fa fa-chart-bar"></i> 통계 보기
|
|
</a>
|
|
<a href="export.php?sv_id=<?php echo $response['sv_id']; ?>&format=excel" class="btn btn-primary">
|
|
<i class="fa fa-file-excel"></i> 엑셀 다운로드
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
include_once(G5_ADMIN_PATH.'/admin.tail.php');
|
|
?>
|