355 lines
13 KiB
PHP
355 lines
13 KiB
PHP
<?php
|
|
$sub_menu = '710700';
|
|
include_once('./_common.php');
|
|
|
|
auth_check_menu($auth, $sub_menu, "w");
|
|
|
|
$g5['title'] = '템플릿 데이터 설치';
|
|
include_once(G5_ADMIN_PATH.'/admin.head.php');
|
|
|
|
if (isset($_POST['install_templates']) && $_POST['install_templates'] == '1') {
|
|
check_admin_token();
|
|
|
|
// 기존 템플릿 데이터 삭제 (선택사항)
|
|
if (isset($_POST['clear_existing'])) {
|
|
sql_query("DELETE FROM survey_template_questions");
|
|
sql_query("DELETE FROM survey_templates");
|
|
sql_query("ALTER TABLE survey_templates AUTO_INCREMENT = 1");
|
|
sql_query("ALTER TABLE survey_template_questions AUTO_INCREMENT = 1");
|
|
}
|
|
|
|
$success_count = 0;
|
|
$error_count = 0;
|
|
$errors = [];
|
|
|
|
// 기본 템플릿 데이터 삽입
|
|
$templates = [
|
|
[
|
|
'name' => '고객 만족도 조사',
|
|
'description' => '제품이나 서비스에 대한 고객 만족도를 측정하는 기본 템플릿입니다.',
|
|
'category' => '고객서비스',
|
|
'questions' => [
|
|
[
|
|
'order' => 1,
|
|
'type' => 'rating',
|
|
'title' => '전반적인 서비스 만족도를 평가해주세요.',
|
|
'description' => '1점(매우 불만족)부터 5점(매우 만족)까지 평가해주세요.',
|
|
'required' => 1,
|
|
'options' => null
|
|
],
|
|
[
|
|
'order' => 2,
|
|
'type' => 'radio',
|
|
'title' => '우리 서비스를 다른 사람에게 추천하시겠습니까?',
|
|
'description' => '',
|
|
'required' => 1,
|
|
'options' => '["매우 추천", "추천", "보통", "추천하지 않음", "절대 추천하지 않음"]'
|
|
],
|
|
[
|
|
'order' => 3,
|
|
'type' => 'checkbox',
|
|
'title' => '어떤 부분이 가장 만족스러우셨나요? (복수선택 가능)',
|
|
'description' => '',
|
|
'required' => 0,
|
|
'options' => '["제품 품질", "고객 서비스", "배송 속도", "가격", "사용 편의성", "기타"]'
|
|
],
|
|
[
|
|
'order' => 4,
|
|
'type' => 'textarea',
|
|
'title' => '개선이 필요한 부분이나 추가 의견이 있으시면 자유롭게 작성해주세요.',
|
|
'description' => '',
|
|
'required' => 0,
|
|
'options' => null
|
|
]
|
|
]
|
|
],
|
|
[
|
|
'name' => '제품 피드백 설문',
|
|
'description' => '새로운 제품에 대한 사용자 피드백을 수집하는 템플릿입니다.',
|
|
'category' => '제품개발',
|
|
'questions' => [
|
|
[
|
|
'order' => 1,
|
|
'type' => 'radio',
|
|
'title' => '이 제품을 어떻게 알게 되셨나요?',
|
|
'description' => '',
|
|
'required' => 1,
|
|
'options' => '["검색엔진", "소셜미디어", "친구/지인 추천", "광고", "기타"]'
|
|
],
|
|
[
|
|
'order' => 2,
|
|
'type' => 'rating',
|
|
'title' => '제품의 사용 편의성은 어떠셨나요?',
|
|
'description' => '1점(매우 어려움)부터 5점(매우 쉬움)까지 평가해주세요.',
|
|
'required' => 1,
|
|
'options' => null
|
|
],
|
|
[
|
|
'order' => 3,
|
|
'type' => 'radio',
|
|
'title' => '제품의 가격은 적정하다고 생각하시나요?',
|
|
'description' => '',
|
|
'required' => 1,
|
|
'options' => '["매우 비쌈", "비쌈", "적정함", "저렴함", "매우 저렴함"]'
|
|
],
|
|
[
|
|
'order' => 4,
|
|
'type' => 'checkbox',
|
|
'title' => '어떤 기능을 가장 자주 사용하시나요?',
|
|
'description' => '',
|
|
'required' => 0,
|
|
'options' => '["기본 기능", "고급 기능", "설정 기능", "공유 기능", "분석 기능"]'
|
|
],
|
|
[
|
|
'order' => 5,
|
|
'type' => 'textarea',
|
|
'title' => '추가하고 싶은 기능이나 개선사항이 있다면 알려주세요.',
|
|
'description' => '',
|
|
'required' => 0,
|
|
'options' => null
|
|
]
|
|
]
|
|
],
|
|
[
|
|
'name' => '마케팅 캠페인 효과 측정',
|
|
'description' => '마케팅 캠페인의 효과를 측정하고 개선점을 찾는 템플릿입니다.',
|
|
'category' => '마케팅',
|
|
'questions' => [
|
|
[
|
|
'order' => 1,
|
|
'type' => 'radio',
|
|
'title' => '최근 우리 브랜드의 광고를 본 적이 있나요?',
|
|
'description' => '',
|
|
'required' => 1,
|
|
'options' => '["예, 여러 번 봤습니다", "예, 한두 번 봤습니다", "아니오, 본 적 없습니다"]'
|
|
],
|
|
[
|
|
'order' => 2,
|
|
'type' => 'checkbox',
|
|
'title' => '어떤 채널에서 우리 광고를 보셨나요? (복수선택 가능)',
|
|
'description' => '',
|
|
'required' => 0,
|
|
'options' => '["TV", "온라인 광고", "소셜미디어", "옥외광고", "라디오", "기타"]'
|
|
],
|
|
[
|
|
'order' => 3,
|
|
'type' => 'rating',
|
|
'title' => '광고가 제품에 대한 관심을 높이는데 도움이 되었나요?',
|
|
'description' => '1점(전혀 도움 안됨)부터 5점(매우 도움됨)까지 평가해주세요.',
|
|
'required' => 1,
|
|
'options' => null
|
|
],
|
|
[
|
|
'order' => 4,
|
|
'type' => 'radio',
|
|
'title' => '광고를 본 후 실제로 제품을 구매하셨나요?',
|
|
'description' => '',
|
|
'required' => 1,
|
|
'options' => '["예, 구매했습니다", "아니오, 하지만 구매를 고려중입니다", "아니오, 구매할 계획이 없습니다"]'
|
|
],
|
|
[
|
|
'order' => 5,
|
|
'type' => 'textarea',
|
|
'title' => '광고에 대한 전반적인 의견이나 개선사항을 알려주세요.',
|
|
'description' => '',
|
|
'required' => 0,
|
|
'options' => null
|
|
]
|
|
]
|
|
]
|
|
];
|
|
|
|
foreach ($templates as $template_data) {
|
|
// 템플릿 삽입
|
|
$sql = "INSERT INTO survey_templates
|
|
(st_name, st_description, st_category, st_is_public, st_created_by, st_created_at)
|
|
VALUES
|
|
('".sql_real_escape_string($template_data['name'])."',
|
|
'".sql_real_escape_string($template_data['description'])."',
|
|
'".sql_real_escape_string($template_data['category'])."',
|
|
1,
|
|
'admin',
|
|
NOW())";
|
|
|
|
if (sql_query($sql)) {
|
|
$st_id = sql_insert_id();
|
|
$success_count++;
|
|
|
|
// 템플릿 질문들 삽입
|
|
foreach ($template_data['questions'] as $question) {
|
|
$options_value = $question['options'] ? "'".sql_real_escape_string($question['options'])."'" : 'NULL';
|
|
|
|
$question_sql = "INSERT INTO survey_template_questions
|
|
(st_id, stq_order, stq_type, stq_title, stq_description, stq_required, stq_options, stq_created_at)
|
|
VALUES
|
|
('$st_id',
|
|
'{$question['order']}',
|
|
'".sql_real_escape_string($question['type'])."',
|
|
'".sql_real_escape_string($question['title'])."',
|
|
'".sql_real_escape_string($question['description'])."',
|
|
'{$question['required']}',
|
|
$options_value,
|
|
NOW())";
|
|
|
|
if (sql_query($question_sql)) {
|
|
$success_count++;
|
|
} else {
|
|
$error_count++;
|
|
$errors[] = "질문 삽입 실패: " . $question['title'];
|
|
}
|
|
}
|
|
} else {
|
|
$error_count++;
|
|
$errors[] = "템플릿 삽입 실패: " . $template_data['name'];
|
|
}
|
|
}
|
|
|
|
echo '<div class="alert alert-success">';
|
|
echo '<h4>템플릿 데이터 설치 완료!</h4>';
|
|
echo '<p>성공: '.$success_count.'개, 실패: '.$error_count.'개</p>';
|
|
if (!empty($errors)) {
|
|
echo '<details><summary>오류 상세</summary>';
|
|
foreach ($errors as $error) {
|
|
echo '<p style="color: red;">'.$error.'</p>';
|
|
}
|
|
echo '</details>';
|
|
}
|
|
echo '<p><a href="template_list.php" class="btn btn-primary">템플릿 목록 확인하기</a></p>';
|
|
echo '</div>';
|
|
} else {
|
|
// 현재 템플릿 상태 확인
|
|
$template_count = sql_fetch("SELECT COUNT(*) as cnt FROM survey_templates")['cnt'];
|
|
$question_count = sql_fetch("SELECT COUNT(*) as cnt FROM survey_template_questions")['cnt'];
|
|
?>
|
|
|
|
<style>
|
|
.install-container {
|
|
max-width: 800px;
|
|
margin: 20px auto;
|
|
padding: 20px;
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.status-info {
|
|
background: #fff;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
border-left: 4px solid #17a2b8;
|
|
}
|
|
|
|
.install-form {
|
|
background: #fff;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
border: 1px solid #e0e0e0;
|
|
}
|
|
|
|
.checkbox-item {
|
|
margin: 15px 0;
|
|
}
|
|
|
|
.checkbox-item input[type="checkbox"] {
|
|
margin-right: 8px;
|
|
transform: scale(1.2);
|
|
}
|
|
|
|
.btn {
|
|
padding: 12px 24px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
display: inline-block;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: #AA20FF;
|
|
color: white;
|
|
}
|
|
|
|
.btn-warning {
|
|
background: #ffc107;
|
|
color: #212529;
|
|
}
|
|
|
|
.btn:hover {
|
|
opacity: 0.9;
|
|
}
|
|
|
|
.alert {
|
|
padding: 15px;
|
|
margin: 20px 0;
|
|
border-radius: 5px;
|
|
}
|
|
|
|
.alert-success {
|
|
background-color: #d4edda;
|
|
border: 1px solid #c3e6cb;
|
|
color: #155724;
|
|
}
|
|
|
|
.alert-warning {
|
|
background-color: #fff3cd;
|
|
border: 1px solid #ffeaa7;
|
|
color: #856404;
|
|
}
|
|
</style>
|
|
|
|
<div class="install-container">
|
|
<h1><i class="fa fa-magic"></i> 템플릿 데이터 설치</h1>
|
|
|
|
<div class="status-info">
|
|
<h3>현재 상태</h3>
|
|
<p><strong>템플릿 수:</strong> <?php echo number_format($template_count); ?>개</p>
|
|
<p><strong>템플릿 질문 수:</strong> <?php echo number_format($question_count); ?>개</p>
|
|
|
|
<?php if ($template_count == 0 || $question_count == 0): ?>
|
|
<div class="alert alert-warning">
|
|
<strong>주의:</strong> 템플릿 데이터가 부족합니다. 아래 버튼을 클릭하여 기본 템플릿을 설치하세요.
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="install-form">
|
|
<h3>기본 템플릿 설치</h3>
|
|
<p>다음 3개의 기본 템플릿과 질문들이 설치됩니다:</p>
|
|
|
|
<ul>
|
|
<li><strong>고객 만족도 조사</strong> - 4개 질문 (평점, 객관식, 체크박스, 주관식)</li>
|
|
<li><strong>제품 피드백 설문</strong> - 5개 질문 (객관식, 평점, 체크박스, 주관식)</li>
|
|
<li><strong>마케팅 캠페인 효과 측정</strong> - 5개 질문 (객관식, 체크박스, 평점, 주관식)</li>
|
|
</ul>
|
|
|
|
<form method="post" onsubmit="return confirm('템플릿 데이터를 설치하시겠습니까?');">
|
|
<input type="hidden" name="install_templates" value="1">
|
|
<input type="hidden" name="token" value="<?php echo get_token(); ?>">
|
|
|
|
<?php if ($template_count > 0): ?>
|
|
<div class="checkbox-item">
|
|
<input type="checkbox" name="clear_existing" id="clearExisting">
|
|
<label for="clearExisting">기존 템플릿 데이터를 모두 삭제하고 새로 설치</label>
|
|
<small style="display: block; color: #666; margin-top: 5px;">
|
|
체크하지 않으면 기존 데이터에 추가로 설치됩니다.
|
|
</small>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fa fa-download"></i> 기본 템플릿 설치하기
|
|
</button>
|
|
|
|
<a href="template_list.php" class="btn btn-warning">
|
|
<i class="fa fa-list"></i> 템플릿 목록 보기
|
|
</a>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
}
|
|
include_once(G5_ADMIN_PATH.'/admin.tail.php');
|
|
?>
|