411 lines
13 KiB
PHP
411 lines
13 KiB
PHP
<?php
|
|
$sub_menu = '710100';
|
|
include_once('./_common.php');
|
|
auth_check_menu($auth, $sub_menu, "r");
|
|
|
|
$g5['title'] = '설문 목록';
|
|
include_once(G5_ADMIN_PATH.'/admin.head.php');
|
|
|
|
// 변수 초기화
|
|
$sfl = isset($_GET['sfl']) ? clean_xss_tags($_GET['sfl']) : 'sv_title';
|
|
$stx = isset($_GET['stx']) ? clean_xss_tags($_GET['stx']) : '';
|
|
$status = isset($_GET['status']) ? clean_xss_tags($_GET['status']) : '';
|
|
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
|
|
|
// 검색 조건
|
|
$where = " WHERE 1=1 ";
|
|
$sql_search = "";
|
|
if ($stx) {
|
|
$where .= " AND $sfl LIKE '%".sql_real_escape_string($stx)."%' ";
|
|
$sql_search .= "&sfl=$sfl&stx=".urlencode($stx);
|
|
}
|
|
|
|
if ($status) {
|
|
$where .= " AND sv_status = '".sql_real_escape_string($status)."' ";
|
|
$sql_search .= "&status=".urlencode($status);
|
|
}
|
|
|
|
// 페이징
|
|
$sql_common = " FROM survey_master $where ";
|
|
$sql = " SELECT COUNT(*) as cnt $sql_common ";
|
|
$row = sql_fetch($sql);
|
|
$total_count = $row['cnt'];
|
|
|
|
$rows = 20;
|
|
$total_page = ceil($total_count / $rows);
|
|
if ($page < 1) $page = 1;
|
|
$from_record = ($page - 1) * $rows;
|
|
|
|
$sql = " SELECT * $sql_common ORDER BY sv_id DESC LIMIT $from_record, $rows ";
|
|
$result = sql_query($sql);
|
|
|
|
// 상태별 카운트
|
|
$status_counts = array();
|
|
$status_sql = "SELECT sv_status, COUNT(*) as cnt FROM survey_master GROUP BY sv_status";
|
|
$status_result = sql_query($status_sql);
|
|
while ($status_row = sql_fetch_array($status_result)) {
|
|
$status_counts[$status_row['sv_status']] = $status_row['cnt'];
|
|
}
|
|
?>
|
|
|
|
<style>
|
|
.survey-header {
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
padding: 20px;
|
|
background: linear-gradient(135deg, #AA20FF 0%, #8A1ACC 100%);
|
|
color: white;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.survey-stats {
|
|
display: flex;
|
|
gap: 20px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.stat-card {
|
|
flex: 1;
|
|
padding: 20px;
|
|
background: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
text-align: center;
|
|
border-left: 4px solid #AA20FF;
|
|
}
|
|
|
|
.stat-number {
|
|
font-size: 2em;
|
|
font-weight: bold;
|
|
color: #AA20FF;
|
|
margin-bottom: 5px;
|
|
}
|
|
|
|
.stat-label {
|
|
color: #666;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
.status-filter {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin-bottom: 20px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.status-btn {
|
|
padding: 8px 16px;
|
|
border: 1px solid #ddd;
|
|
background: white;
|
|
color: #666;
|
|
text-decoration: none;
|
|
border-radius: 20px;
|
|
font-size: 0.9em;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.status-btn:hover,
|
|
.status-btn.active {
|
|
background: #AA20FF;
|
|
color: white;
|
|
border-color: #AA20FF;
|
|
}
|
|
|
|
.survey-table {
|
|
background: white;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.survey-table table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
|
|
.survey-table th {
|
|
background: #fff;
|
|
padding: 15px 10px;
|
|
text-align: left;
|
|
font-weight: 600;
|
|
border-bottom: 1px solid #dee2e6;
|
|
}
|
|
|
|
.survey-table td {
|
|
padding: 15px 10px;
|
|
border-bottom: 1px solid #f1f3f4;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.survey-table tr:hover {
|
|
background: #fff;
|
|
}
|
|
|
|
.status-badge {
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
font-size: 0.8em;
|
|
font-weight: 500;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.status-draft { background: #e9ecef; color: #495057; }
|
|
.status-active { background: #d4edda; color: #155724; }
|
|
.status-closed { background: #f8d7da; color: #721c24; }
|
|
.status-deleted { background: #d1ecf1; color: #0c5460; }
|
|
|
|
.action-buttons {
|
|
display: flex;
|
|
gap: 5px;
|
|
}
|
|
|
|
.btn-sm {
|
|
padding: 5px 10px;
|
|
font-size: 0.8em;
|
|
border-radius: 4px;
|
|
text-decoration: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.btn-primary { background: #007bff; color: white; }
|
|
.btn-success { background: #28a745; color: white; }
|
|
.btn-warning { background: #ffc107; color: #212529; }
|
|
.btn-danger { background: #dc3545; color: white; }
|
|
.btn-info { background: #17a2b8; color: white; }
|
|
|
|
.btn-sm:hover {
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
|
}
|
|
|
|
.search-form {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.search-form .form-row {
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: center;
|
|
}
|
|
|
|
.search-form select,
|
|
.search-form input {
|
|
padding: 8px 12px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.create-btn {
|
|
position: fixed;
|
|
bottom: 30px;
|
|
right: 30px;
|
|
width: 60px;
|
|
height: 60px;
|
|
background: #AA20FF;
|
|
color: white;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
text-decoration: none;
|
|
font-size: 1.5em;
|
|
box-shadow: 0 4px 12px rgba(170, 32, 255, 0.3);
|
|
transition: all 0.3s;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.create-btn:hover {
|
|
background: #8A1ACC;
|
|
transform: scale(1.1);
|
|
color: white;
|
|
}
|
|
</style>
|
|
|
|
<div class="survey-header">
|
|
<div>
|
|
<h1><i class="fa fa-poll"></i> 설문 관리</h1>
|
|
<p>설문조사를 생성하고 관리할 수 있습니다</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="survey-stats">
|
|
<div class="stat-card">
|
|
<div class="stat-number"><?php echo number_format($status_counts['active'] ?? 0); ?></div>
|
|
<div class="stat-label">진행중인 설문</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-number"><?php echo number_format($status_counts['draft'] ?? 0); ?></div>
|
|
<div class="stat-label">작성중인 설문</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-number"><?php echo number_format($status_counts['closed'] ?? 0); ?></div>
|
|
<div class="stat-label">종료된 설문</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<div class="stat-number"><?php echo number_format($total_count); ?></div>
|
|
<div class="stat-label">전체 설문</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="search-form">
|
|
<form method="get" class="form-row">
|
|
<select name="sfl">
|
|
<option value="sv_title"<?php echo $sfl == 'sv_title' ? ' selected' : ''; ?>>제목</option>
|
|
<option value="sv_description"<?php echo $sfl == 'sv_description' ? ' selected' : ''; ?>>설명</option>
|
|
<option value="sv_created_by"<?php echo $sfl == 'sv_created_by' ? ' selected' : ''; ?>>작성자</option>
|
|
</select>
|
|
<input type="text" name="stx" value="<?php echo $stx; ?>" placeholder="검색어를 입력하세요">
|
|
<button type="submit" class="btn-sm btn-primary">
|
|
<i class="fa fa-search"></i> 검색
|
|
</button>
|
|
<?php if ($stx): ?>
|
|
<a href="?" class="btn-sm btn-warning">
|
|
<i class="fa fa-times"></i> 초기화
|
|
</a>
|
|
<?php endif; ?>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="status-filter">
|
|
<a href="?" class="status-btn <?php echo !isset($_GET['status']) ? 'active' : ''; ?>">
|
|
<i class="fa fa-list"></i> 전체
|
|
</a>
|
|
<a href="?status=draft" class="status-btn <?php echo $status == 'draft' ? 'active' : ''; ?>">
|
|
<i class="fa fa-edit"></i> 작성중 (<?php echo $status_counts['draft'] ?? 0; ?>)
|
|
</a>
|
|
<a href="?status=active" class="status-btn <?php echo $status == 'active' ? 'active' : ''; ?>">
|
|
<i class="fa fa-play"></i> 진행중 (<?php echo $status_counts['active'] ?? 0; ?>)
|
|
</a>
|
|
<a href="?status=closed" class="status-btn <?php echo $status == 'closed' ? 'active' : ''; ?>">
|
|
<i class="fa fa-stop"></i> 종료 (<?php echo $status_counts['closed'] ?? 0; ?>)
|
|
</a>
|
|
</div>
|
|
|
|
<div class="survey-table">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th width="60">ID</th>
|
|
<th>설문 제목</th>
|
|
<th width="100">상태</th>
|
|
<th width="120">응답 수</th>
|
|
<th width="150">설문 기간</th>
|
|
<th width="100">작성자</th>
|
|
<th width="120">생성일</th>
|
|
<th width="200">관리</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if (sql_num_rows($result) > 0) {
|
|
while ($row = sql_fetch_array($result)) {
|
|
$response_count = get_survey_response_count($row['sv_id'], 'completed');
|
|
$total_responses = get_survey_response_count($row['sv_id'], '');
|
|
|
|
// 상태별 클래스
|
|
$status_class = 'status-' . $row['sv_status'];
|
|
$status_text = array(
|
|
'draft' => '작성중',
|
|
'active' => '진행중',
|
|
'closed' => '종료',
|
|
'deleted' => '삭제됨'
|
|
);
|
|
?>
|
|
<tr>
|
|
<td><?php echo $row['sv_id']; ?></td>
|
|
<td>
|
|
<strong><?php echo htmlspecialchars($row['sv_title']); ?></strong>
|
|
<?php if ($row['sv_description']): ?>
|
|
<br><small style="color: #666;"><?php
|
|
if (function_exists('mb_substr')) {
|
|
echo htmlspecialchars(mb_substr($row['sv_description'], 0, 50)) . '...';
|
|
} else {
|
|
echo htmlspecialchars(substr($row['sv_description'], 0, 150)) . '...'; // mbstring이 없을 경우, 바이트 단위로 자름
|
|
}
|
|
?></small>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<span class="status-badge <?php echo $status_class; ?>">
|
|
<?php echo $status_text[$row['sv_status']]; ?>
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<strong><?php echo number_format($response_count); ?></strong>
|
|
<?php if ($total_responses > $response_count): ?>
|
|
<br><small style="color: #666;">진행중: <?php echo $total_responses - $response_count; ?></small>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<small>
|
|
<?php echo date('m/d', strtotime($row['sv_start_date'])); ?> ~<br>
|
|
<?php echo date('m/d', strtotime($row['sv_end_date'])); ?>
|
|
</small>
|
|
</td>
|
|
<td><?php echo $row['sv_created_by']; ?></td>
|
|
<td>
|
|
<small><?php echo date('Y-m-d', strtotime($row['sv_created_at'])); ?></small>
|
|
</td>
|
|
<td>
|
|
<div class="action-buttons">
|
|
<a href="survey_form.php?sv_id=<?php echo $row['sv_id']; ?>" class="btn-sm btn-primary" title="수정">
|
|
<i class="fa fa-edit"></i>
|
|
</a>
|
|
<?php if ($row['sv_status'] == 'draft'): ?>
|
|
<a href="survey_activate.php?sv_id=<?php echo $row['sv_id']; ?>" class="btn-sm btn-success" title="활성화" onclick="return confirm('설문을 활성화하시겠습니까?')">
|
|
<i class="fa fa-play"></i>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($response_count > 0): ?>
|
|
<a href="statistics.php?sv_id=<?php echo $row['sv_id']; ?>" class="btn-sm btn-info" title="통계">
|
|
<i class="fa fa-chart-bar"></i>
|
|
</a>
|
|
<a href="export.php?sv_id=<?php echo $row['sv_id']; ?>" class="btn-sm btn-warning" title="엑셀 다운로드">
|
|
<i class="fa fa-file-excel"></i>
|
|
</a>
|
|
<?php endif; ?>
|
|
<a href="survey_delete.php?sv_id=<?php echo $row['sv_id']; ?>" class="btn-sm btn-danger" title="삭제" onclick="return confirm('정말 삭제하시겠습니까?')">
|
|
<i class="fa fa-trash"></i>
|
|
</a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
} else {
|
|
?>
|
|
<tr>
|
|
<td colspan="8" style="text-align: center; padding: 50px; color: #999;">
|
|
<i class="fa fa-inbox" style="font-size: 3em; margin-bottom: 20px; display: block;"></i>
|
|
등록된 설문이 없습니다.<br>
|
|
<a href="survey_form.php" style="color: #AA20FF; margin-top: 10px; display: inline-block;">첫 설문을 만들어보세요</a>
|
|
</td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php
|
|
// 페이징
|
|
if ($total_page > 1) {
|
|
$paging = get_paging(10, $page, $total_page, "?$sql_search&page=");
|
|
echo '<div style="margin-top: 20px;">' . $paging . '</div>';
|
|
}
|
|
?>
|
|
|
|
<a href="survey_form.php" class="create-btn" title="새 설문 만들기">
|
|
<i class="fa fa-plus"></i>
|
|
</a>
|
|
|
|
<?php
|
|
include_once(G5_ADMIN_PATH.'/admin.tail.php');
|
|
?>
|