first commit 2

This commit is contained in:
hmw1001
2026-06-11 18:47:38 +09:00
parent c768729ce6
commit 6f534e33a6
11095 changed files with 1595758 additions and 0 deletions
@@ -0,0 +1,136 @@
<?php
/**
* ScheduleGenerator 테스트 스크립트
*/
// 기본 설정
define('G5_PATH', realpath('../../'));
include_once(G5_PATH . '/common.php');
include_once('./_common.php');
// 관리자 권한 확인
if (!$is_admin) {
die('관리자만 접근할 수 있습니다.');
}
// 설치 확인
if (!is_consultant_installed()) {
die('상담 예약 시스템이 설치되지 않았습니다.');
}
echo "<h2>ScheduleGenerator 테스트</h2>";
try {
require_once('classes/ScheduleGenerator.class.php');
$generator = new ScheduleGenerator();
// 테스트할 년월
$year = 2024;
$month = 12;
echo "<h3>1. 기본 설정 확인</h3>";
// 기본 설정 확인
$duration = consultant_get_config('consultation_duration', 60);
$maxPersons = consultant_get_config('max_persons_per_slot', 2);
echo "- 상담 시간: {$duration}분<br>";
echo "- 최대 인원: {$maxPersons}명<br>";
echo "<h3>2. 요일별 설정 확인</h3>";
$days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
$dayNames = ['월요일', '화요일', '수요일', '목요일', '금요일', '토요일', '일요일'];
foreach ($days as $i => $day) {
$enabled = consultant_get_config($day . '_enabled', '1');
$start = consultant_get_config($day . '_start', '09:00');
$end = consultant_get_config($day . '_end', '18:00');
$lunchStart = consultant_get_config($day . '_lunch_start', '12:00');
$lunchEnd = consultant_get_config($day . '_lunch_end', '13:00');
echo "- {$dayNames[$i]}: ";
if ($enabled == '1') {
echo "운영 ({$start}~{$end}, 점심: {$lunchStart}~{$lunchEnd})";
} else {
echo "휴무";
}
echo "<br>";
}
echo "<h3>3. 기존 스케줄 확인</h3>";
$existingCount = sql_fetch("SELECT COUNT(*) as count FROM consultant_schedule WHERE YEAR(specific_date) = {$year} AND MONTH(specific_date) = {$month}");
echo "- 기존 스케줄: {$existingCount['count']}개<br>";
echo "<h3>4. 충돌 검사</h3>";
$conflicts = $generator->checkScheduleConflicts($year, $month);
echo "- 충돌 건수: " . count($conflicts) . "건<br>";
if (!empty($conflicts)) {
echo "<ul>";
foreach ($conflicts as $conflict) {
echo "<li>{$conflict['date']} {$conflict['time']} - {$conflict['customer']} ({$conflict['reason']})</li>";
}
echo "</ul>";
}
echo "<h3>5. 스케줄 생성 테스트</h3>";
$result = $generator->generateMonth($year, $month);
if ($result) {
$newCount = sql_fetch("SELECT COUNT(*) as count FROM consultant_schedule WHERE YEAR(specific_date) = {$year} AND MONTH(specific_date) = {$month}");
echo "<p style='color: green;'>✅ 성공: {$newCount['count']}개 스케줄 생성 완료</p>";
// 생성된 스케줄 샘플 표시
echo "<h4>생성된 스케줄 샘플 (첫 5일)</h4>";
$samples = sql_query("SELECT * FROM consultant_schedule WHERE YEAR(specific_date) = {$year} AND MONTH(specific_date) = {$month} ORDER BY specific_date, start_time LIMIT 20");
echo "<table border='1' style='border-collapse: collapse; width: 100%;'>";
echo "<tr><th>날짜</th><th>요일</th><th>시작시간</th><th>종료시간</th><th>최대인원</th><th>사용가능</th><th>타입</th><th>메모</th></tr>";
while ($row = sql_fetch_array($samples)) {
$dayOfWeek = date('N', strtotime($row['specific_date']));
$dayName = $dayNames[$dayOfWeek - 1];
$available = $row['is_available'] ? '가능' : '불가능';
$type = $row['temp_1'] ?? '일반';
$memo = $row['temp_2'] ?? '';
echo "<tr>";
echo "<td>{$row['specific_date']}</td>";
echo "<td>{$dayName}</td>";
echo "<td>{$row['start_time']}</td>";
echo "<td>{$row['end_time']}</td>";
echo "<td>{$row['max_persons']}</td>";
echo "<td>{$available}</td>";
echo "<td>{$type}</td>";
echo "<td>{$memo}</td>";
echo "</tr>";
}
echo "</table>";
// 타입별 통계
echo "<h4>생성된 스케줄 통계</h4>";
$stats = sql_query("SELECT temp_1, COUNT(*) as count FROM consultant_schedule WHERE YEAR(specific_date) = {$year} AND MONTH(specific_date) = {$month} GROUP BY temp_1");
echo "<ul>";
while ($stat = sql_fetch_array($stats)) {
$type = $stat['temp_1'] ?? '일반';
echo "<li>{$type}: {$stat['count']}개</li>";
}
echo "</ul>";
} else {
echo "<p style='color: red;'>❌ 실패: 스케줄 생성에 실패했습니다.</p>";
}
} catch (Exception $e) {
echo "<p style='color: red;'>오류: " . htmlspecialchars($e->getMessage()) . "</p>";
echo "<pre>" . htmlspecialchars($e->getTraceAsString()) . "</pre>";
}
echo "<hr>";
echo "<p><a href='../settings.php'>설정으로 돌아가기</a> | <a href='../schedule.php'>스케줄 관리</a></p>";
?>