Initial commit: 교육 프로젝트 배포
This commit is contained in:
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
//=========================
|
||||
//개인정보 + 최신연도 학습레벨 + 배지
|
||||
//=========================
|
||||
require_once __DIR__ . '/db_conn.php';
|
||||
|
||||
if (!function_exists('mypage_h')) {
|
||||
function mypage_h(?string $str): string
|
||||
{
|
||||
return htmlspecialchars((string)$str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mypage_level_meta')) {
|
||||
function mypage_level_meta(?string $level): array
|
||||
{
|
||||
$level = trim((string)$level);
|
||||
|
||||
$map = [
|
||||
'MASTER' => [
|
||||
'code' => 'Master',
|
||||
'class' => 'master',
|
||||
'label' => 'Master',
|
||||
'icon' => '/edu/img/ico/ico_level_master.svg',
|
||||
],
|
||||
'ELITE' => [
|
||||
'code' => 'Elite',
|
||||
'class' => 'elite',
|
||||
'label' => 'Elite',
|
||||
'icon' => '/edu/img/ico/ico_level_elite.svg',
|
||||
],
|
||||
'LEARNER' => [
|
||||
'code' => 'Learner',
|
||||
'class' => 'learner',
|
||||
'label' => 'Learner',
|
||||
'icon' => '/edu/img/ico/ico_level_learner.svg',
|
||||
],
|
||||
'ROOKIE' => [
|
||||
'code' => 'Rookie',
|
||||
'class' => 'rookie',
|
||||
'label' => 'Rookie',
|
||||
'icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
],
|
||||
];
|
||||
|
||||
$key = strtoupper($level);
|
||||
|
||||
return $map[$key] ?? [
|
||||
'code' => 'Rookie',
|
||||
'class' => 'rookie',
|
||||
'label' => 'Rookie',
|
||||
'icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mypage_badge_map')) {
|
||||
function mypage_badge_map(string $badgeCode): array
|
||||
{
|
||||
$badgeCode = strtoupper(trim($badgeCode));
|
||||
|
||||
$BADGE_ICON_MAP = [
|
||||
// 실제 운영 시 코드값 확정되면 여기만 교체
|
||||
'BG001' => [
|
||||
'slot' => 'hat',
|
||||
'img' => '/edu/img/mypage/ico_school.png',
|
||||
'name' => '학습 배지',
|
||||
],
|
||||
'BG002' => [
|
||||
'slot' => 'pencil',
|
||||
'img' => '/edu/img/mypage/ico_pencil.png',
|
||||
'name' => '작성 배지',
|
||||
],
|
||||
'BG003' => [
|
||||
'slot' => 'pick',
|
||||
'img' => '/edu/img/mypage/ico_pick_2.png',
|
||||
'name' => 'Pick 배지',
|
||||
],
|
||||
];
|
||||
|
||||
return $BADGE_ICON_MAP[$badgeCode] ?? [
|
||||
'slot' => 'pick',
|
||||
'img' => '/edu/img/mypage/ico_pick_2.png',
|
||||
'name' => '기본 배지',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 실제 로그인 세션 연동 후 교체
|
||||
$memberId = 'U001';
|
||||
$sysCompCode = 'COMP01';
|
||||
|
||||
$profileData = [
|
||||
'member_id' => $memberId,
|
||||
'sys_comp_code' => $sysCompCode,
|
||||
'name' => '사용자',
|
||||
'rank_name' => '',
|
||||
'working_comp' => '',
|
||||
'join_date' => '',
|
||||
'latest_stats_year' => '',
|
||||
'learning_level' => 'Rookie',
|
||||
'level_class' => 'rookie',
|
||||
'level_icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
'total_minutes' => 0,
|
||||
'profile_image' => '/edu/img/insight/profile.png', // 현재는 기본 이미지 고정
|
||||
];
|
||||
|
||||
$profileBadges = [
|
||||
'hat' => null,
|
||||
'pencil' => null,
|
||||
'pick' => null,
|
||||
];
|
||||
|
||||
try {
|
||||
$pdo = db_conn();
|
||||
$pdo->exec("SET NAMES 'utf8mb4'");
|
||||
|
||||
// 최신년도 학습통계 우선
|
||||
$sql = "
|
||||
SELECT
|
||||
u.member_id,
|
||||
u.sys_comp_code,
|
||||
u.name,
|
||||
u.rank_name,
|
||||
u.working_comp,
|
||||
u.join_date,
|
||||
ys.stats_year,
|
||||
ys.learning_level,
|
||||
ys.total_minutes
|
||||
FROM edu_users u
|
||||
LEFT JOIN edu_yearly_learning_stats ys
|
||||
ON ys.member_id = u.member_id
|
||||
AND ys.sys_comp_code = u.sys_comp_code
|
||||
AND ys.stats_year = (
|
||||
SELECT MAX(stats_year)
|
||||
FROM edu_yearly_learning_stats
|
||||
WHERE member_id = u.member_id
|
||||
AND sys_comp_code = u.sys_comp_code
|
||||
)
|
||||
WHERE u.member_id = :member_id
|
||||
AND u.sys_comp_code = :sys_comp_code
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
$levelMeta = mypage_level_meta($row['learning_level'] ?? '');
|
||||
|
||||
$profileData = [
|
||||
'member_id' => $row['member_id'],
|
||||
'sys_comp_code' => $row['sys_comp_code'],
|
||||
'name' => $row['name'] ?? '사용자',
|
||||
'rank_name' => $row['rank_name'] ?? '',
|
||||
'working_comp' => $row['working_comp'] ?? '',
|
||||
'join_date' => $row['join_date'] ?? '',
|
||||
'latest_stats_year' => $row['stats_year'] ?? '',
|
||||
'learning_level' => $levelMeta['label'],
|
||||
'level_class' => $levelMeta['class'],
|
||||
'level_icon' => $levelMeta['icon'],
|
||||
'total_minutes' => (int)($row['total_minutes'] ?? 0),
|
||||
'profile_image' => '/edu/img/insight/profile.png',
|
||||
];
|
||||
}
|
||||
|
||||
// 최신통계가 없으면 누적 이력 합계 fallback
|
||||
if ((int)$profileData['total_minutes'] === 0) {
|
||||
$stmtFallback = $pdo->prepare("
|
||||
SELECT COALESCE(SUM(watch_tm), 0) AS total_minutes
|
||||
FROM edu_learning_histories
|
||||
WHERE member_id = :member_id
|
||||
AND sys_comp_code = :sys_comp_code
|
||||
");
|
||||
$stmtFallback->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
$fallbackMin = (int)$stmtFallback->fetchColumn();
|
||||
if ($fallbackMin > 0) {
|
||||
$profileData['total_minutes'] = $fallbackMin;
|
||||
}
|
||||
}
|
||||
|
||||
// 배지 조회
|
||||
$stmtBadge = $pdo->prepare("
|
||||
SELECT badge_code, issued_at
|
||||
FROM edu_user_badges
|
||||
WHERE member_id = :member_id
|
||||
AND sys_comp_code = :sys_comp_code
|
||||
ORDER BY issued_at DESC, seq DESC
|
||||
");
|
||||
$stmtBadge->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
foreach ($stmtBadge->fetchAll(PDO::FETCH_ASSOC) as $badgeRow) {
|
||||
$badgeInfo = mypage_badge_map($badgeRow['badge_code'] ?? '');
|
||||
$slot = $badgeInfo['slot'];
|
||||
|
||||
if (!isset($profileBadges[$slot]) || $profileBadges[$slot] !== null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$profileBadges[$slot] = [
|
||||
'badge_code' => $badgeRow['badge_code'],
|
||||
'slot' => $slot,
|
||||
'img' => $badgeInfo['img'],
|
||||
'name' => $badgeInfo['name'],
|
||||
'issued_at' => $badgeRow['issued_at'],
|
||||
];
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
// 운영 시 로깅 권장
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
//=========================
|
||||
//개인정보 + 최신연도 학습레벨 + 배지
|
||||
//=========================
|
||||
require_once __DIR__ . '/db_conn.php';
|
||||
|
||||
if (!function_exists('mypage_h')) {
|
||||
function mypage_h(?string $str): string
|
||||
{
|
||||
return htmlspecialchars((string)$str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mypage_level_meta')) {
|
||||
function mypage_level_meta(?string $level): array
|
||||
{
|
||||
$level = trim((string)$level);
|
||||
|
||||
$map = [
|
||||
'MASTER' => [
|
||||
'code' => 'Master',
|
||||
'class' => 'master',
|
||||
'label' => 'Master',
|
||||
'icon' => '/edu/img/ico/ico_level_master.svg',
|
||||
],
|
||||
'ELITE' => [
|
||||
'code' => 'Elite',
|
||||
'class' => 'elite',
|
||||
'label' => 'Elite',
|
||||
'icon' => '/edu/img/ico/ico_level_elite.svg',
|
||||
],
|
||||
'LEARNER' => [
|
||||
'code' => 'Learner',
|
||||
'class' => 'learner',
|
||||
'label' => 'Learner',
|
||||
'icon' => '/edu/img/ico/ico_level_learner.svg',
|
||||
],
|
||||
'ROOKIE' => [
|
||||
'code' => 'Rookie',
|
||||
'class' => 'rookie',
|
||||
'label' => 'Rookie',
|
||||
'icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
],
|
||||
];
|
||||
|
||||
$key = strtoupper($level);
|
||||
|
||||
return $map[$key] ?? [
|
||||
'code' => 'Rookie',
|
||||
'class' => 'rookie',
|
||||
'label' => 'Rookie',
|
||||
'icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mypage_badge_map')) {
|
||||
function mypage_badge_map(string $badgeCode): array
|
||||
{
|
||||
$badgeCode = strtoupper(trim($badgeCode));
|
||||
|
||||
$BADGE_ICON_MAP = [
|
||||
// 실제 운영 시 코드값 확정되면 여기만 교체
|
||||
'BG001' => [
|
||||
'slot' => 'hat',
|
||||
'img' => '/edu/img/mypage/ico_school.png',
|
||||
'name' => '학습 배지',
|
||||
],
|
||||
'BG002' => [
|
||||
'slot' => 'pencil',
|
||||
'img' => '/edu/img/mypage/ico_pencil.png',
|
||||
'name' => '작성 배지',
|
||||
],
|
||||
'BG003' => [
|
||||
'slot' => 'pick',
|
||||
'img' => '/edu/img/mypage/ico_pick_2.png',
|
||||
'name' => 'Pick 배지',
|
||||
],
|
||||
];
|
||||
|
||||
return $BADGE_ICON_MAP[$badgeCode] ?? [
|
||||
'slot' => 'pick',
|
||||
'img' => '/edu/img/mypage/ico_pick_2.png',
|
||||
'name' => '기본 배지',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 실제 로그인 세션 연동 후 교체
|
||||
$memberId = 'U001';
|
||||
$sysCompCode = 'COMP01';
|
||||
|
||||
$profileData = [
|
||||
'member_id' => $memberId,
|
||||
'sys_comp_code' => $sysCompCode,
|
||||
'name' => '사용자',
|
||||
'rank_name' => '',
|
||||
'working_comp' => '',
|
||||
'join_date' => '',
|
||||
'latest_stats_year' => '',
|
||||
'learning_level' => 'Rookie',
|
||||
'level_class' => 'rookie',
|
||||
'level_icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
'total_minutes' => 0,
|
||||
'profile_image' => '/edu/img/insight/profile.png', // 현재는 기본 이미지 고정
|
||||
];
|
||||
|
||||
$profileBadges = [
|
||||
'hat' => null,
|
||||
'pencil' => null,
|
||||
'pick' => null,
|
||||
];
|
||||
|
||||
try {
|
||||
$pdo = db_conn();
|
||||
$pdo->exec("SET NAMES 'utf8mb4'");
|
||||
|
||||
// 최신년도 학습통계 우선
|
||||
$sql = "
|
||||
SELECT
|
||||
u.member_id,
|
||||
u.sys_comp_code,
|
||||
u.name,
|
||||
u.rank_name,
|
||||
u.working_comp,
|
||||
u.join_date,
|
||||
ys.stats_year,
|
||||
ys.learning_level,
|
||||
ys.total_minutes
|
||||
FROM edu_users u
|
||||
LEFT JOIN edu_yearly_learning_stats ys
|
||||
ON ys.member_id = u.member_id
|
||||
AND ys.sys_comp_code = u.sys_comp_code
|
||||
AND ys.stats_year = (
|
||||
SELECT MAX(stats_year)
|
||||
FROM edu_yearly_learning_stats
|
||||
WHERE member_id = u.member_id
|
||||
AND sys_comp_code = u.sys_comp_code
|
||||
)
|
||||
WHERE u.member_id = :member_id
|
||||
AND u.sys_comp_code = :sys_comp_code
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
$levelMeta = mypage_level_meta($row['learning_level'] ?? '');
|
||||
|
||||
$profileData = [
|
||||
'member_id' => $row['member_id'],
|
||||
'sys_comp_code' => $row['sys_comp_code'],
|
||||
'name' => $row['name'] ?? '사용자',
|
||||
'rank_name' => $row['rank_name'] ?? '',
|
||||
'working_comp' => $row['working_comp'] ?? '',
|
||||
'join_date' => $row['join_date'] ?? '',
|
||||
'latest_stats_year' => $row['stats_year'] ?? '',
|
||||
'learning_level' => $levelMeta['label'],
|
||||
'level_class' => $levelMeta['class'],
|
||||
'level_icon' => $levelMeta['icon'],
|
||||
'total_minutes' => (int)($row['total_minutes'] ?? 0),
|
||||
'profile_image' => '/edu/img/insight/profile.png',
|
||||
];
|
||||
}
|
||||
|
||||
// 최신통계가 없으면 누적 이력 합계 fallback
|
||||
if ((int)$profileData['total_minutes'] === 0) {
|
||||
$stmtFallback = $pdo->prepare("
|
||||
SELECT COALESCE(SUM(watch_tm), 0) AS total_minutes
|
||||
FROM edu_learning_histories
|
||||
WHERE member_id = :member_id
|
||||
AND sys_comp_code = :sys_comp_code
|
||||
");
|
||||
$stmtFallback->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
$fallbackMin = (int)$stmtFallback->fetchColumn();
|
||||
if ($fallbackMin > 0) {
|
||||
$profileData['total_minutes'] = $fallbackMin;
|
||||
}
|
||||
}
|
||||
|
||||
// 배지 조회
|
||||
$stmtBadge = $pdo->prepare("
|
||||
SELECT badge_code, issued_at
|
||||
FROM edu_user_badges
|
||||
WHERE member_id = :member_id
|
||||
AND sys_comp_code = :sys_comp_code
|
||||
ORDER BY issued_at DESC, seq DESC
|
||||
");
|
||||
$stmtBadge->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
foreach ($stmtBadge->fetchAll(PDO::FETCH_ASSOC) as $badgeRow) {
|
||||
$badgeInfo = mypage_badge_map($badgeRow['badge_code'] ?? '');
|
||||
$slot = $badgeInfo['slot'];
|
||||
|
||||
if (!isset($profileBadges[$slot]) || $profileBadges[$slot] !== null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$profileBadges[$slot] = [
|
||||
'badge_code' => $badgeRow['badge_code'],
|
||||
'slot' => $slot,
|
||||
'img' => $badgeInfo['img'],
|
||||
'name' => $badgeInfo['name'],
|
||||
'issued_at' => $badgeRow['issued_at'],
|
||||
];
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
// 운영 시 로깅 권장
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
//=========================
|
||||
// 개인정보 + 배지
|
||||
//=========================
|
||||
require_once __DIR__ . '/db_conn.php';
|
||||
|
||||
if (!function_exists('mypage_h')) {
|
||||
function mypage_h(?string $str): string
|
||||
{
|
||||
return htmlspecialchars((string)$str, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mypage_level_meta')) {
|
||||
function mypage_level_meta(?string $level): array
|
||||
{
|
||||
$level = trim((string)$level);
|
||||
|
||||
$map = [
|
||||
'MASTER' => [
|
||||
'code' => 'Master',
|
||||
'class' => 'master',
|
||||
'label' => 'Master',
|
||||
'icon' => '/edu/img/ico/ico_level_master.svg',
|
||||
],
|
||||
'ELITE' => [
|
||||
'code' => 'Elite',
|
||||
'class' => 'elite',
|
||||
'label' => 'Elite',
|
||||
'icon' => '/edu/img/ico/ico_level_elite.svg',
|
||||
],
|
||||
'LEARNER' => [
|
||||
'code' => 'Learner',
|
||||
'class' => 'learner',
|
||||
'label' => 'Learner',
|
||||
'icon' => '/edu/img/ico/ico_level_learner.svg',
|
||||
],
|
||||
'ROOKIE' => [
|
||||
'code' => 'Rookie',
|
||||
'class' => 'rookie',
|
||||
'label' => 'Rookie',
|
||||
'icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
],
|
||||
];
|
||||
|
||||
$key = strtoupper($level);
|
||||
|
||||
return $map[$key] ?? [
|
||||
'code' => 'Rookie',
|
||||
'class' => 'rookie',
|
||||
'label' => 'Rookie',
|
||||
'icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mypage_badge_map')) {
|
||||
function mypage_badge_map(string $badgeCode): array
|
||||
{
|
||||
$badgeCode = strtoupper(trim($badgeCode));
|
||||
|
||||
$BADGE_ICON_MAP = [
|
||||
// 실제 운영 시 코드값 확정되면 여기만 교체
|
||||
'BG001' => [
|
||||
'slot' => 'hat',
|
||||
'img' => '/edu/img/mypage/ico_school.png',
|
||||
'name' => '학습 배지',
|
||||
],
|
||||
'BG002' => [
|
||||
'slot' => 'pencil',
|
||||
'img' => '/edu/img/mypage/ico_pencil.png',
|
||||
'name' => '작성 배지',
|
||||
],
|
||||
'BG003' => [
|
||||
'slot' => 'pick',
|
||||
'img' => '/edu/img/mypage/ico_pick_2.png',
|
||||
'name' => 'Pick 배지',
|
||||
],
|
||||
];
|
||||
|
||||
return $BADGE_ICON_MAP[$badgeCode] ?? [
|
||||
'slot' => 'pick',
|
||||
'img' => '/edu/img/mypage/ico_pick_2.png',
|
||||
'name' => '기본 배지',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 실제 로그인 세션 연동 후 교체
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
$memberId = $_SESSION['member_id'] ?? '';
|
||||
$sysCompCode = $_SESSION['sys_comp_code'] ?? '';
|
||||
//$memberId = 'U001';
|
||||
//$sysCompCode = 'COMP01';
|
||||
|
||||
//echo "memberId===".$memberId."<br>";
|
||||
//echo "sysCompCode===".$sysCompCode."<br>";exit;
|
||||
//$memberId = 'U001';
|
||||
//$sysCompCode = 'COMP01';
|
||||
|
||||
|
||||
// ★ 선택년도 수집
|
||||
$selectedYear = trim((string)($_GET['selected_year'] ?? date('Y')));
|
||||
|
||||
if ($selectedYear === '' || !preg_match('/^\d{4}$/', $selectedYear)) {
|
||||
$selectedYear = date('Y');
|
||||
}
|
||||
$profileFileName = $memberId . '_' . $sysCompCode . '.png';
|
||||
$profileFilePath = __DIR__ . '/../img/profile/' . $profileFileName;
|
||||
$profileImageUrl = '/edu/img/profile/' . $profileFileName;
|
||||
|
||||
|
||||
|
||||
if (file_exists($profileFilePath)) {
|
||||
$profileImage = $profileImageUrl;
|
||||
/*
|
||||
if($memberId=="M21420"){
|
||||
echo 11111111;
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
/*
|
||||
if($memberId=="M21420"){
|
||||
echo 222222222222;
|
||||
exit;
|
||||
}*/
|
||||
|
||||
$profileImage = '/edu/img/ico/ico_profile.svg';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (file_exists($profileFilePath)) {
|
||||
$profileImage = $profileImageUrl;
|
||||
} else {
|
||||
$profileImage = '/edu/img/ico/ico_profile.svg';
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
$profileData = [
|
||||
'member_id' => $memberId,
|
||||
'sys_comp_code' => $sysCompCode,
|
||||
'name' => '사용자',
|
||||
'rank_name' => '',
|
||||
'working_comp' => '',
|
||||
'join_date' => '',
|
||||
'latest_stats_year' => $selectedYear,
|
||||
'learning_level' => 'Rookie',
|
||||
'level_class' => 'rookie',
|
||||
'level_icon' => '/edu/img/ico/ico_level_rookie.svg',
|
||||
'total_minutes' => 0,
|
||||
'profile_image' => $profileImage, // 현재는 기본 이미지 고정
|
||||
];
|
||||
|
||||
$profileBadges = [
|
||||
'hat' => null,
|
||||
'pencil' => null,
|
||||
'pick' => null,
|
||||
];
|
||||
|
||||
try {
|
||||
$pdo = db_conn();
|
||||
$pdo->exec("SET NAMES 'utf8mb4'");
|
||||
|
||||
// ★ 선택년도 학습통계 기준
|
||||
$sql = "
|
||||
SELECT
|
||||
u.member_id,
|
||||
u.sys_comp_code,
|
||||
u.name,
|
||||
u.rank_name,
|
||||
u.working_comp,
|
||||
u.join_date,
|
||||
|
||||
ec.code,
|
||||
ec.code_name,
|
||||
|
||||
ys.stats_year,
|
||||
ys.learning_level,
|
||||
ys.total_minutes
|
||||
FROM edu_users u
|
||||
LEFT JOIN edu_yearly_learning_stats ys
|
||||
ON ys.member_id = u.member_id
|
||||
AND ys.sys_comp_code = u.sys_comp_code
|
||||
AND ys.stats_year = :selected_year
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT code,code_name FROM edu_codes WHERE group_code = 'CO100'
|
||||
) ec
|
||||
ON ec.code = u.belong_comp
|
||||
WHERE u.member_id = :member_id
|
||||
AND u.sys_comp_code = :sys_comp_code
|
||||
LIMIT 1
|
||||
";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
':selected_year' => (int)$selectedYear,
|
||||
]);
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row) {
|
||||
$levelMeta = mypage_level_meta($row['learning_level'] ?? '');
|
||||
|
||||
$profileData = [
|
||||
'member_id' => $row['member_id'],
|
||||
'sys_comp_code' => $row['sys_comp_code'],
|
||||
'name' => $row['name'] ?? '사용자',
|
||||
'rank_name' => $row['rank_name'] ?? '',
|
||||
'belong_comp_code' => $row['code'] ?? '',
|
||||
'belong_comp_name' => $row['code_name'] ?? '',
|
||||
'working_comp' => $row['working_comp'] ?? '',
|
||||
'join_date' => $row['join_date'] ?? '',
|
||||
'latest_stats_year' => $row['stats_year'] ?? $selectedYear,
|
||||
'learning_level' => $levelMeta['label'],
|
||||
'level_class' => $levelMeta['class'],
|
||||
'level_icon' => $levelMeta['icon'],
|
||||
'total_minutes' => (int)($row['total_minutes'] ?? 0),
|
||||
'profile_image' => $profileImage, // 현재는 기본 이미지 고정
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
// ★ 선택년도 통계가 없으면 선택년도 학습이력 합계 fallback
|
||||
if ((int)$profileData['total_minutes'] === 0) {
|
||||
$stmtFallback = $pdo->prepare("
|
||||
SELECT COALESCE(SUM(watch_tm), 0) AS total_minutes
|
||||
FROM edu_learning_histories
|
||||
WHERE member_id = :member_id
|
||||
AND sys_comp_code = :sys_comp_code
|
||||
AND YEAR(last_viewed_at) = :selected_year
|
||||
");
|
||||
$stmtFallback->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
':selected_year' => (int)$selectedYear,
|
||||
]);
|
||||
|
||||
$fallbackMin = (int)$stmtFallback->fetchColumn();
|
||||
if ($fallbackMin > 0) {
|
||||
$profileData['total_minutes'] = $fallbackMin;
|
||||
}
|
||||
}
|
||||
|
||||
// 배지 조회
|
||||
$stmtBadge = $pdo->prepare("
|
||||
SELECT badge_code, issued_at
|
||||
FROM edu_user_badges
|
||||
WHERE member_id = :member_id
|
||||
AND sys_comp_code = :sys_comp_code
|
||||
ORDER BY issued_at DESC, seq DESC
|
||||
");
|
||||
$stmtBadge->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
foreach ($stmtBadge->fetchAll(PDO::FETCH_ASSOC) as $badgeRow) {
|
||||
$badgeInfo = mypage_badge_map($badgeRow['badge_code'] ?? '');
|
||||
$slot = $badgeInfo['slot'];
|
||||
|
||||
if (!isset($profileBadges[$slot]) || $profileBadges[$slot] !== null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$profileBadges[$slot] = [
|
||||
'badge_code' => $badgeRow['badge_code'],
|
||||
'slot' => $slot,
|
||||
'img' => $badgeInfo['img'],
|
||||
'name' => $badgeInfo['name'],
|
||||
'issued_at' => $badgeRow['issued_at'],
|
||||
];
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
// 운영 시 로깅 권장
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
//=========================
|
||||
// 컨텐츠 제안하기 기본값 + 제안현황
|
||||
//=========================
|
||||
require_once __DIR__ . '/db_conn.php';
|
||||
|
||||
// TODO: 실제 로그인 세션 연동 후 교체
|
||||
$memberId = 'U001';
|
||||
$sysCompCode = 'COMP01';
|
||||
|
||||
$offerDefaultTypeCode = 'OF10001'; // 제안
|
||||
$offerDefaultStatusCode = 'OF10002'; // 검토중
|
||||
|
||||
$offerStatusMap = [
|
||||
'OF10001' => '제안',
|
||||
'OF10002' => '검토중',
|
||||
'OF10003' => '게시완료',
|
||||
'OF10004' => '게시불가',
|
||||
];
|
||||
|
||||
$offerHistory = [];
|
||||
|
||||
try {
|
||||
$pdo = db_conn();
|
||||
$pdo->exec("SET NAMES 'utf8mb4'");
|
||||
|
||||
// 상태 코드맵 동적 조회 (기본값 fallback 유지)
|
||||
$stmtCode = $pdo->prepare("
|
||||
SELECT base_code, code_name
|
||||
FROM edu_codes
|
||||
WHERE group_code = 'OF100'
|
||||
AND is_active = '1'
|
||||
ORDER BY code
|
||||
");
|
||||
$stmtCode->execute();
|
||||
|
||||
foreach ($stmtCode->fetchAll(PDO::FETCH_ASSOC) as $codeRow) {
|
||||
$offerStatusMap[$codeRow['base_code']] = $codeRow['code_name'];
|
||||
}
|
||||
|
||||
// 제안 이력 조회
|
||||
// 정렬 우선순위:
|
||||
// 1) 검토중(OF10002) 최상단
|
||||
// 2) 그 외 상태는 코드 우선순위대로
|
||||
// 3) 같은 상태 안에서는 최신순
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT
|
||||
co.offer_id,
|
||||
co.type_code,
|
||||
co.title,
|
||||
co.reference_url,
|
||||
co.reason,
|
||||
co.status_code,
|
||||
co.created_at,
|
||||
co.updated_at
|
||||
FROM edu_content_offer co
|
||||
WHERE co.member_id = :member_id
|
||||
AND co.sys_comp_code = :sys_comp_code
|
||||
ORDER BY
|
||||
CASE co.status_code
|
||||
WHEN 'OF10002' THEN 0 -- 검토중
|
||||
WHEN 'OF10001' THEN 1 -- 제안
|
||||
WHEN 'OF10003' THEN 2 -- 게시완료
|
||||
WHEN 'OF10004' THEN 3 -- 게시불가
|
||||
ELSE 9
|
||||
END,
|
||||
co.created_at DESC,
|
||||
co.offer_id DESC
|
||||
LIMIT 20
|
||||
");
|
||||
|
||||
$stmt->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$statusCode = trim((string)($row['status_code'] ?? ''));
|
||||
|
||||
$offerHistory[] = [
|
||||
'offer_id' => $row['offer_id'] ?? '',
|
||||
'type_code' => $row['type_code'] ?? '',
|
||||
'title' => $row['title'] ?? '',
|
||||
'reference_url' => $row['reference_url'] ?? '',
|
||||
'reason' => $row['reason'] ?? '',
|
||||
'status_code' => $statusCode,
|
||||
'status_name' => $offerStatusMap[$statusCode] ?? $statusCode,
|
||||
'created_at' => $row['created_at'] ?? '',
|
||||
'updated_at' => $row['updated_at'] ?? '',
|
||||
'created_at_dot' => !empty($row['created_at']) ? date('y.m.d', strtotime($row['created_at'])) : '',
|
||||
'is_consider' => ($statusCode === 'OF10002'),
|
||||
];
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
// 운영 시 로깅 권장
|
||||
// error_log($e->getMessage());
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
//=========================
|
||||
//한줄소감
|
||||
//=========================
|
||||
require_once __DIR__ . '/db_conn.php';
|
||||
|
||||
// TODO: 실제 로그인 세션 연동 후 교체
|
||||
$memberId = 'U001';
|
||||
$sysCompCode = 'COMP01';
|
||||
|
||||
$myCommentList = [];
|
||||
|
||||
try {
|
||||
$pdo = db_conn();
|
||||
$pdo->exec("SET NAMES 'utf8mb4'");
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
lh.content_id,
|
||||
lh.comment,
|
||||
lh.last_viewed_at,
|
||||
c.title,
|
||||
c.category_code,
|
||||
c.category_group,
|
||||
u.name
|
||||
FROM edu_learning_histories lh
|
||||
INNER JOIN edu_contents c
|
||||
ON c.content_id = lh.content_id
|
||||
INNER JOIN edu_users u
|
||||
ON u.member_id = lh.member_id
|
||||
AND u.sys_comp_code = lh.sys_comp_code
|
||||
WHERE lh.member_id = :member_id
|
||||
AND lh.sys_comp_code = :sys_comp_code
|
||||
AND c.category_code = 'CA10001' -- 마이클래스
|
||||
AND lh.comment IS NOT NULL
|
||||
AND TRIM(lh.comment) <> ''
|
||||
ORDER BY lh.last_viewed_at DESC
|
||||
LIMIT 20
|
||||
";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([
|
||||
':member_id' => $memberId,
|
||||
':sys_comp_code' => $sysCompCode,
|
||||
]);
|
||||
|
||||
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$myCommentList[] = [
|
||||
'content_id' => $row['content_id'],
|
||||
'title' => $row['title'],
|
||||
'comment' => $row['comment'],
|
||||
'member_name' => $row['name'],
|
||||
'last_viewed_at' => $row['last_viewed_at'],
|
||||
'date_dot' => !empty($row['last_viewed_at']) ? date('y.m.d', strtotime($row['last_viewed_at'])) : '',
|
||||
];
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
// 운영 시 로깅 권장
|
||||
}
|
||||
Reference in New Issue
Block a user