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

165 lines
6.2 KiB
PHP

<?php
$sub_menu = '710300';
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']) : 'st_name';
$stx = isset($_GET['stx']) ? clean_xss_tags($_GET['stx']) : '';
$category = isset($_GET['category']) ? clean_xss_tags($_GET['category']) : '';
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
// 검색 조건
$where = " WHERE st_is_public = 1 ";
$sql_search = "";
if ($stx) {
$where .= " AND $sfl LIKE '%".sql_real_escape_string($stx)."%' ";
$sql_search .= "&sfl=$sfl&stx=".urlencode($stx);
}
if ($category) {
$where .= " AND st_category = '".sql_real_escape_string($category)."' ";
$sql_search .= "&category=".urlencode($category);
}
// 페이징
$sql_common = " FROM survey_templates $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 st_created_at DESC LIMIT $from_record, $rows ";
$result = sql_query($sql);
// 카테고리별 카운트
$category_counts = [];
$category_sql = "SELECT st_category, COUNT(*) as cnt FROM survey_templates WHERE st_is_public = 1 GROUP BY st_category";
$category_result = sql_query($category_sql);
while ($category_row = sql_fetch_array($category_result)) {
$category_counts[$category_row['st_category']] = $category_row['cnt'];
}
?>
<!-- CSS는 template_list.css 파일에서 자동 로드됩니다 -->
<div class="template-header">
<div>
<h1><i class="fa fa-magic"></i> 템플릿 관리</h1>
<p>미리 만들어진 설문 템플릿을 관리하고 새로운 템플릿을 만들 수 있습니다</p>
</div>
</div>
<div class="template-stats">
<div class="stat-card">
<div class="stat-number"><?php echo number_format($category_counts['고객서비스'] ?? 0); ?></div>
<div class="stat-label">고객서비스</div>
</div>
<div class="stat-card">
<div class="stat-number"><?php echo number_format($category_counts['마케팅'] ?? 0); ?></div>
<div class="stat-label">마케팅</div>
</div>
<div class="stat-card">
<div class="stat-number"><?php echo number_format($category_counts['제품개발'] ?? 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="st_name"<?php echo $sfl == 'st_name' ? ' selected' : ''; ?>>템플릿명</option>
<option value="st_description"<?php echo $sfl == 'st_description' ? ' selected' : ''; ?>>설명</option>
<option value="st_category"<?php echo $sfl == 'st_category' ? ' 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="category-filter">
<a href="?" class="category-btn <?php echo !isset($_GET['category']) ? 'active' : ''; ?>">
<i class="fa fa-list"></i> 전체
</a>
<a href="?category=고객서비스" class="category-btn <?php echo $category == '고객서비스' ? 'active' : ''; ?>">
<i class="fa fa-users"></i> 고객서비스 (<?php echo $category_counts['고객서비스'] ?? 0; ?>)
</a>
<a href="?category=마케팅" class="category-btn <?php echo $category == '마케팅' ? 'active' : ''; ?>">
<i class="fa fa-bullhorn"></i> 마케팅 (<?php echo $category_counts['마케팅'] ?? 0; ?>)
</a>
<a href="?category=제품개발" class="category-btn <?php echo $category == '제품개발' ? 'active' : ''; ?>">
<i class="fa fa-cogs"></i> 제품개발 (<?php echo $category_counts['제품개발'] ?? 0; ?>)
</a>
</div>
<?php if (sql_num_rows($result) > 0): ?>
<div class="template-grid">
<?php while ($template = sql_fetch_array($result)): ?>
<div class="template-card">
<div class="template-card-header">
<h3 class="template-title"><?php echo htmlspecialchars($template['st_name']); ?></h3>
<span class="template-category"><?php echo htmlspecialchars($template['st_category']); ?></span>
</div>
<p class="template-description"><?php echo htmlspecialchars($template['st_description']); ?></p>
<div class="template-meta">
<span><i class="fa fa-user"></i> <?php echo $template['st_created_by']; ?></span>
<span><i class="fa fa-calendar"></i> <?php echo date('Y-m-d', strtotime($template['st_created_at'])); ?></span>
</div>
<div class="template-actions">
<a href="survey_form.php?template_id=<?php echo $template['st_id']; ?>" class="btn-template btn-use">
<i class="fa fa-plus"></i> 사용하기
</a>
<a href="template_preview.php?st_id=<?php echo $template['st_id']; ?>" class="btn-template btn-preview">
<i class="fa fa-eye"></i> 미리보기
</a>
</div>
</div>
<?php endwhile; ?>
</div>
<?php
// 페이징
if ($total_page > 1) {
$paging = get_paging(10, $page, $total_page, "?$sql_search&page=");
echo '<div class="pagination-wrapper">' . $paging . '</div>';
}
?>
<?php else: ?>
<div class="empty-state">
<i class="fa fa-magic"></i>
<h3>등록된 템플릿이 없습니다</h3>
<p>새로운 템플릿을 만들어보세요.</p>
</div>
<?php endif; ?>
<a href="template_form.php" class="create-btn" title="새 템플릿 만들기">
<i class="fa fa-plus"></i>
</a>
<?php
include_once(G5_ADMIN_PATH.'/admin.tail.php');
?>