Files

198 lines
7.6 KiB
PHP

<?php
// 세션 시작 (아직 시작되지 않은 경우에만)
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// 현재 파일명을 가져와서 메뉴 활성화에 사용
$current_page = basename($_SERVER['PHP_SELF']);
// 로그인 정보 시작 세션정보
$auth_level = $_SESSION['auth_level'] ?? ''; // 권한코드
$sys_comp_code = $_SESSION['sys_comp_code'] ?? ''; // 시스템 로그인 법인
$member_id = $_SESSION['member_id'] ?? ''; // 로그인 아이디
// 현재 년도의 법정의무교육 기간 조회
$legal_edu_period = '';
$user_qty = 0;
$user_name = '';
$comp_name = '';
try {
require_once __DIR__ . '/../../bbs/db_conn.php';
$current_year = date('Y');
$pdo = db_conn();
// 법정의무교육 기간 조회
$stmt = $pdo->prepare("
SELECT start_date, end_date
FROM edu_contents
WHERE category_code = 'CA10003'
AND base_year = ?
GROUP BY start_date, end_date
LIMIT 1
");
$stmt->execute([$current_year]);
$period = $stmt->fetch(PDO::FETCH_ASSOC);
if ($period && !empty($period['start_date']) && !empty($period['end_date'])) {
$start = date('Y.m.d', strtotime($period['start_date']));
$end = date('Y.m.d', strtotime($period['end_date']));
$legal_edu_period = "{$start} ~ {$end}";
}
// 전체 학습자 수 (퇴사자 제외) - 법정교육 기간 유무와 무관하게 항상 조회
$stmt_qty = $pdo->prepare("
SELECT COUNT(member_id)
FROM edu_users
WHERE (end_date IS NULL OR end_date > CURDATE())
AND sys_comp_code = working_comp
");
$stmt_qty->execute();
$user_qty = (int) $stmt_qty->fetchColumn();
// 관리자명 (이름 + 아이디)
$stmt_user_name = $pdo->prepare("
SELECT CONCAT(name, ' (', member_id, ')')
FROM edu_users
WHERE sys_comp_code = ?
AND member_id = ?
LIMIT 1
");
$stmt_user_name->execute([$sys_comp_code, $member_id]);
$user_name = $stmt_user_name->fetchColumn() ?: $member_id;
// 법인명
$stmt_comp_name = $pdo->prepare("
SELECT code_name
FROM edu_codes
WHERE group_code = 'CO100'
AND code = ?
LIMIT 1
");
$stmt_comp_name->execute([$sys_comp_code]);
$comp_name = $stmt_comp_name->fetchColumn() ?: $sys_comp_code;
} catch (Exception $e) {
// 오류 무시
}
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&display=swap');
body {
font-family: 'Noto Sans KR', sans-serif;
}
.nav-active {
background-color: rgba(255, 255, 255, 0.1);
font-weight: bold;
border-bottom: 4px solid rgba(255, 255, 255, 0.4);
}
</style>
<script>
// [DEBUG] 세션 auth_level 확인용 콘솔 출력
console.log('[auth_level]', '<?php echo addslashes($auth_level); ?>');
</script>
</head>
<body class="bg-[#f8fafc]">
<nav class="w-full shadow-md font-['Noto_Sans_KR'] sticky top-0 z-50">
<div class="bg-[#114b3d] text-white">
<div class="max-w-[1600px] mx-auto px-6 h-16 flex items-center justify-between">
<div class="flex items-center">
<h1 class="text-xl font-bold flex items-center tracking-tight cursor-pointer"
onclick="location.href='<?php echo ($auth_level === 'LE10002') ? 'legal_edu.php' : 'index.php'; ?>'">
<span class="bg-white text-[#114b3d] p-1 rounded mr-2"><i class="fa-solid fa-graduation-cap"></i></span>
배움터 <span class="ml-2 text-sm font-light opacity-70">관리자</span>
</h1>
</div>
<div class="hidden md:flex items-center h-full text-sm">
<?php
// 권한에 따른 탭 표시 제어
// LE10001: 전체권한 - 모든 탭 표시
// LE10002: 법인권한 - 전체학습현황, 학습자관리, 법정의무교육만 표시
// 그 외: 모든 탭 숨김
$is_full = ($auth_level === 'LE10001'); // 전체권한
$is_corp = ($auth_level === 'LE10002'); // 법인권한
$show_all = $is_full; // 콘텐츠입력, 설정 탭 표시 여부
$show_base = ($is_full || $is_corp); // 기본 3개 탭 표시 여부
?>
<?php if ($is_corp): ?>
<a href="legal_edu.php"
class="px-5 h-16 flex items-center hover:bg-white/10 transition space-x-2 <?php echo ($current_page == 'legal_edu.php') ? 'nav-active' : ''; ?>">
<i class="fa-solid fa-book opacity-80"></i>
<span>법정의무교육</span>
</a>
<?php
endif; ?>
<?php if ($show_all): ?>
<a href="index.php"
class="px-5 h-16 flex items-center hover:bg-white/10 transition space-x-2 <?php echo ($current_page == 'index.php') ? 'nav-active' : ''; ?>">
<i class="fa-solid fa-chart-line opacity-80"></i>
<span>전체학습현황</span>
</a>
<a href="member_list.php"
class="px-5 h-16 flex items-center hover:bg-white/10 transition space-x-2 <?php echo ($current_page == 'member_list.php') ? 'nav-active' : ''; ?>">
<i class="fa-solid fa-users opacity-80"></i>
<span>학습자관리</span>
</a>
<a href="legal_edu.php"
class="px-5 h-16 flex items-center hover:bg-white/10 transition space-x-2 <?php echo ($current_page == 'legal_edu.php') ? 'nav-active' : ''; ?>">
<i class="fa-solid fa-book opacity-80"></i>
<span>법정의무교육</span>
</a>
<a href="content_upload.php"
class="px-5 h-16 flex items-center hover:bg-white/10 transition space-x-2 <?php echo ($current_page == 'content_upload.php') ? 'nav-active' : ''; ?>">
<i class="fa-solid fa-pen-to-square opacity-80"></i>
<span>콘텐츠 입력</span>
</a>
<a href="settings.php"
class="ml-2 px-4 h-10 self-center flex items-center bg-white/10 hover:bg-white/20 rounded-lg transition <?php echo ($current_page == 'settings.php') ? 'ring-2 ring-white/50' : ''; ?>">
<i class="fa-solid fa-gear mr-2"></i>설정
</a>
<?php
endif; ?>
</div>
<div class="flex items-center space-x-4">
</div>
</div>
</div>
<div class="bg-[#0d3a2f] text-white/90 border-t border-white/5">
<div class="max-w-[1600px] mx-auto px-6 h-10 flex items-center text-[13px] space-x-8">
<div class="flex items-center border-l border-white/10 pl-8"><span class="opacity-60 mr-2">법인명:</span><span
class="font-bold"><?php echo $comp_name; ?></span></div>
<div class="flex items-center border-l border-white/10 pl-8"><span class="opacity-60 mr-2">관리자 ID:</span><span
class="font-bold"><?php echo $user_name; ?></span></div>
<div class="flex items-center border-l border-white/10 pl-8"><span class="opacity-60 mr-2">전체 학습자 수:</span><span
class="font-bold text-teal-300"> <?php echo $user_qty; ?></span></div>
<div class="flex items-center border-l border-white/10 pl-8"><span class="opacity-60 mr-2">법정의무교육
기간:</span><span
class="font-bold"><?php echo !empty($legal_edu_period) ? htmlspecialchars($legal_edu_period, ENT_QUOTES, 'UTF-8') : '미설정'; ?></span>
</div>
</div>
</div>
</nav>