diff --git a/tksupport/api/controllers/vacationDashboardController.js b/tksupport/api/controllers/vacationDashboardController.js
index b1e262c..de9eb22 100644
--- a/tksupport/api/controllers/vacationDashboardController.js
+++ b/tksupport/api/controllers/vacationDashboardController.js
@@ -46,6 +46,39 @@ const vacationDashboardController = {
console.error('휴가 대시보드 조회 오류:', error);
res.status(500).json({ success: false, error: '서버 오류가 발생했습니다' });
}
+ },
+
+ async getYearlyOverview(req, res) {
+ try {
+ const year = parseInt(req.query.year) || new Date().getFullYear();
+ const [users, balances] = await Promise.all([
+ vacationDashboardModel.getYearlyOverview(year),
+ vacationDashboardModel.getBalances(year)
+ ]);
+ res.json({ success: true, data: { users, balances } });
+ } catch (error) {
+ console.error('연간 총괄 조회 오류:', error);
+ res.status(500).json({ success: false, error: '서버 오류가 발생했습니다' });
+ }
+ },
+
+ async getMonthlyDetail(req, res) {
+ try {
+ const year = parseInt(req.query.year) || new Date().getFullYear();
+ const month = parseInt(req.query.month);
+ const departmentId = parseInt(req.query.department_id) || 0;
+ if (!month || month < 1 || month > 12) {
+ return res.status(400).json({ success: false, error: '유효하지 않은 월입니다' });
+ }
+ const [records, holidays] = await Promise.all([
+ vacationDashboardModel.getMonthlyDetail(year, month, departmentId),
+ vacationDashboardModel.getHolidays(year, month)
+ ]);
+ res.json({ success: true, data: { records, holidays } });
+ } catch (error) {
+ console.error('월간 상세 조회 오류:', error);
+ res.status(500).json({ success: false, error: '서버 오류가 발생했습니다' });
+ }
}
};
diff --git a/tksupport/api/models/vacationDashboardModel.js b/tksupport/api/models/vacationDashboardModel.js
index f42c98f..41559a9 100644
--- a/tksupport/api/models/vacationDashboardModel.js
+++ b/tksupport/api/models/vacationDashboardModel.js
@@ -49,6 +49,70 @@ const vacationDashboardModel = {
const [rows] = await db.query(query, params);
return rows;
+ },
+
+ // View 1: 연간 총괄 — 전직원 월별 사용 합계
+ async getYearlyOverview(year) {
+ const db = getPool();
+ const [rows] = await db.query(`
+ SELECT
+ su.user_id, su.name, su.username,
+ COALESCE(d.department_id, 0) as department_id,
+ COALESCE(d.department_name, '미배정') as department_name,
+ MONTH(vr.start_date) as month,
+ SUM(vr.days_used) as total_days
+ FROM sso_users su
+ LEFT JOIN departments d ON su.department_id = d.department_id
+ LEFT JOIN sp_vacation_requests vr
+ ON su.user_id = vr.user_id AND vr.status = 'approved' AND YEAR(vr.start_date) = ?
+ WHERE su.is_active = 1 AND su.hire_date IS NOT NULL
+ GROUP BY su.user_id, MONTH(vr.start_date)
+ ORDER BY d.department_name, su.name
+ `, [year]);
+ return rows;
+ },
+
+ // View 1: 연간 부여/사용 잔액
+ async getBalances(year) {
+ const db = getPool();
+ const [rows] = await db.query(`
+ SELECT user_id, SUM(total_days) as granted, SUM(used_days) as used
+ FROM sp_vacation_balances
+ WHERE year = ? AND balance_type = 'AUTO'
+ GROUP BY user_id
+ `, [year]);
+ return rows;
+ },
+
+ // View 2: 월간 상세 — 부서 전직원 일별 휴가 ($1=year ON, $2=month ON, $3=deptId WHERE, $4=deptId WHERE)
+ async getMonthlyDetail(year, month, departmentId) {
+ const db = getPool();
+ const [rows] = await db.query(`
+ SELECT
+ su.user_id, su.name, su.username,
+ vr.start_date, vr.end_date, vr.days_used,
+ vt.type_code, vt.type_name
+ FROM sso_users su
+ LEFT JOIN sp_vacation_requests vr
+ ON su.user_id = vr.user_id AND vr.status = 'approved'
+ AND YEAR(vr.start_date) = ? AND MONTH(vr.start_date) = ?
+ LEFT JOIN vacation_types vt ON vr.vacation_type_id = vt.id
+ WHERE su.is_active = 1 AND su.hire_date IS NOT NULL
+ AND (su.department_id = ? OR (? = 0 AND su.department_id IS NULL))
+ ORDER BY su.name, vr.start_date
+ `, [year, month, departmentId, departmentId]);
+ return rows;
+ },
+
+ // View 2: 공휴일 표시용
+ async getHolidays(year, month) {
+ const db = getPool();
+ const [rows] = await db.query(`
+ SELECT holiday_date, holiday_name
+ FROM company_holidays
+ WHERE YEAR(holiday_date) = ? AND MONTH(holiday_date) = ?
+ `, [year, month]);
+ return rows;
}
};
diff --git a/tksupport/api/routes/vacationDashboardRoutes.js b/tksupport/api/routes/vacationDashboardRoutes.js
index 6dfc382..5f9f443 100644
--- a/tksupport/api/routes/vacationDashboardRoutes.js
+++ b/tksupport/api/routes/vacationDashboardRoutes.js
@@ -6,5 +6,7 @@ const ctrl = require('../controllers/vacationDashboardController');
router.use(requireAuth);
router.get('/', requireSupportTeam, ctrl.getDashboard);
+router.get('/yearly-overview', requireSupportTeam, ctrl.getYearlyOverview);
+router.get('/monthly-detail', requireSupportTeam, ctrl.getMonthlyDetail);
module.exports = router;
diff --git a/tksupport/web/vacation-dashboard.html b/tksupport/web/vacation-dashboard.html
index a57a8c6..050e2ab 100644
--- a/tksupport/web/vacation-dashboard.html
+++ b/tksupport/web/vacation-dashboard.html
@@ -7,6 +7,14 @@
+
@@ -33,32 +41,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
부서별 현황
-
-
로딩 중...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
연간 사용현황
+
+
+
+
+ | 부서 |
+ 이름 |
+ 1월 | 2월 | 3월 |
+ 4월 | 5월 | 6월 |
+ 7월 | 8월 | 9월 |
+ 10월 | 11월 | 12월 |
+ 전체 |
+ 사용 |
+ 잔여 |
+
+
+
+ | 로딩 중... |
+
+
+
-
-
-
직원별 상세
-
-
-
-
- | 이름 |
- 부서 |
- 기본연차 |
- 이월 |
- 장기근속 |
- 총 잔여 |
-
-
-
- | 로딩 중... |
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 휴일
+ 연 연차
+ 반 반차
+ 반반 반반차
+ 조 조퇴
+ 유 유급
+ 특 특별
+ 병 병가
+
+
월간 상세
+
@@ -110,119 +147,233 @@