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

34 lines
1.1 KiB
PHP

<?php
$sub_menu = '710100';
include_once('./_common.php');
$sv_id = isset($_GET['sv_id']) ? (int) $_GET['sv_id'] : 0;
if (!$sv_id) {
alert('설문 ID가 없습니다.', './survey_list.php');
}
$survey = get_survey($sv_id);
if (!$survey) {
alert('존재하지 않는 설문입니다.', './survey_list.php');
}
// 응답이 있는 설문은 삭제 대신 상태를 'deleted'로 변경
$response_count = get_survey_response_count($sv_id, '');
if ($response_count > 0) {
// 응답이 있는 경우 소프트 삭제
if (update_survey_status($sv_id, 'deleted')) {
alert('설문이 삭제 처리되었습니다.', './survey_list.php');
} else {
alert('설문 삭제에 실패했습니다.', './survey_list.php');
}
} else {
// 응답이 없는 경우 완전 삭제
$sql = "DELETE FROM survey_master WHERE sv_id = '$sv_id'";
if (sql_query($sql)) {
alert('설문이 완전히 삭제되었습니다.', './survey_list.php');
} else {
alert('설문 삭제에 실패했습니다.', './survey_list.php');
}
}
?>