first commit 2
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* 스케줄 생성 AJAX 처리
|
||||
*/
|
||||
|
||||
include_once('./_common.php');
|
||||
|
||||
// 관리자 권한 확인
|
||||
if (!$is_admin) {
|
||||
die(json_encode(['success' => false, 'message' => '권한이 없습니다.']));
|
||||
}
|
||||
|
||||
// 설치 확인
|
||||
if (!is_consultant_installed()) {
|
||||
die(json_encode(['success' => false, 'message' => '상담 예약 시스템이 설치되지 않았습니다.']));
|
||||
}
|
||||
|
||||
$action = $_POST['action'] ?? '';
|
||||
$year = (int) ($_POST['year'] ?? date('Y'));
|
||||
$month = (int) ($_POST['month'] ?? date('n'));
|
||||
|
||||
require_once('classes/ScheduleGenerator.class.php');
|
||||
|
||||
try {
|
||||
$generator = new ScheduleGenerator();
|
||||
|
||||
switch ($action) {
|
||||
case 'generate_month':
|
||||
$result = $generator->generateMonth($year, $month);
|
||||
if ($result) {
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => "{$year}년 {$month}월 스케줄이 생성되었습니다."
|
||||
]);
|
||||
} else {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => '스케줄 생성에 실패했습니다.'
|
||||
]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'check_conflicts':
|
||||
$conflicts = $generator->checkScheduleConflicts($year, $month);
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'conflicts' => $conflicts,
|
||||
'message' => count($conflicts) > 0 ?
|
||||
count($conflicts) . '개의 충돌이 발견되었습니다.' :
|
||||
'충돌이 없습니다.'
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'regenerate_next_month':
|
||||
$nextMonth = date('n') == 12 ? 1 : date('n') + 1;
|
||||
$nextYear = date('n') == 12 ? date('Y') + 1 : date('Y');
|
||||
|
||||
$result = $generator->generateMonth($nextYear, $nextMonth);
|
||||
if ($result) {
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => "다음 달({$nextYear}년 {$nextMonth}월) 스케줄이 재생성되었습니다."
|
||||
]);
|
||||
} else {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => '다음 달 스케줄 재생성에 실패했습니다.'
|
||||
]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
echo json_encode(['success' => false, 'message' => '잘못된 요청입니다.']);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => '오류가 발생했습니다: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user