455 lines
No EOL
25 KiB
PHP
455 lines
No EOL
25 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>직원 마스터 리스트 | FKI ASSET</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
|
<link href="https://fonts.googleapis.com/css2?family=Pretendard:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/style.css">
|
|
<style>
|
|
body {
|
|
font-family: 'Pretendard', sans-serif;
|
|
}
|
|
|
|
[x-cloak] {
|
|
display: none !important;
|
|
}
|
|
|
|
.modal-bg {
|
|
background-color: rgba(15, 23, 42, 0.7);
|
|
backdrop-filter: blur(4px);
|
|
}
|
|
|
|
.sort-icon {
|
|
transition: transform 0.2s;
|
|
}
|
|
|
|
.sort-active {
|
|
color: #2563eb;
|
|
}
|
|
|
|
.no-scrollbar::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="bg-[#f8fafc] text-slate-800" x-data="userManagement()">
|
|
|
|
<?php include 'nav.php'; ?>
|
|
|
|
<!-- Main Content -->
|
|
<main class="max-w-[1600px] mx-auto p-8 pt-10">
|
|
<header class="mb-6 flex flex-col md:flex-row md:items-center justify-between gap-4">
|
|
<div>
|
|
<div class="flex items-center gap-3">
|
|
<h2 class="text-3xl font-extrabold text-slate-900 tracking-tight">직원 마스터</h2>
|
|
<div
|
|
class="flex items-baseline gap-1 bg-white px-4 py-1.5 rounded-2xl border border-slate-200 shadow-sm">
|
|
<span class="text-lg font-black text-blue-600" x-text="visibleCount"></span>
|
|
<span class="text-xs font-bold text-slate-400">/</span>
|
|
<span class="text-sm font-bold text-slate-500" x-text="users.length"></span>
|
|
<span class="text-[10px] font-bold text-slate-400 ml-1 uppercase">명 (목록인원/전체)</span>
|
|
</div>
|
|
</div>
|
|
<p class="text-slate-500 mt-1">임직원 기본 정보 및 부서 체계 관리</p>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-3">
|
|
<div class="relative">
|
|
<span class="absolute inset-y-0 left-0 pl-3 flex items-center text-slate-400">
|
|
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
|
</svg>
|
|
</span>
|
|
<input type="text" x-model="searchQuery"
|
|
class="block w-64 pl-10 pr-3 py-2.5 border border-slate-200 rounded-xl leading-5 bg-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all text-sm"
|
|
placeholder="이름, 사번, 이메일 검색...">
|
|
</div>
|
|
<button @click="openAddModal()"
|
|
class="bg-blue-600 text-white px-5 py-2.5 rounded-xl font-bold shadow-lg shadow-blue-200 hover:bg-blue-700 transition-all flex items-center shrink-0">
|
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
|
|
</svg>
|
|
신규 등록
|
|
</button>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Filters & Bulk Actions -->
|
|
<div class="mb-6 flex flex-wrap items-center justify-between gap-4">
|
|
<div class="flex items-center gap-2">
|
|
<button @click="filterRetired = !filterRetired"
|
|
:class="filterRetired ? 'bg-rose-600 text-white border-rose-600 shadow-md shadow-rose-100' : 'bg-white text-slate-500 border-slate-200 hover:border-rose-300 hover:text-rose-500'"
|
|
class="px-4 py-2 rounded-xl text-xs font-bold border transition-all flex items-center">
|
|
<div class="w-2 h-2 rounded-full mr-2" :class="filterRetired ? 'bg-white' : 'bg-rose-500'"></div>
|
|
퇴사자 포함
|
|
</button>
|
|
<button @click="filterOnLeave = !filterOnLeave"
|
|
:class="filterOnLeave ? 'bg-amber-500 text-white border-amber-500 shadow-md shadow-amber-100' : 'bg-white text-slate-500 border-slate-200 hover:border-amber-300 hover:text-amber-500'"
|
|
class="px-4 py-2 rounded-xl text-xs font-bold border transition-all flex items-center">
|
|
<div class="w-2 h-2 rounded-full mr-2" :class="filterOnLeave ? 'bg-white' : 'bg-amber-500'"></div>
|
|
휴직자 표시
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Bulk Command Center (appears when checked) -->
|
|
<div x-show="selectedIds.length > 0" x-transition x-cloak
|
|
class="bg-slate-900 text-white px-6 py-3 rounded-2xl flex items-center gap-6 shadow-xl animate-in fade-in slide-in-from-top-4 duration-300">
|
|
<div class="flex items-center gap-2">
|
|
<span class="text-blue-400 font-black" x-text="selectedIds.length"></span>
|
|
<span class="text-xs font-bold text-slate-400">명 선택됨</span>
|
|
</div>
|
|
<div class="h-4 w-px bg-slate-700"></div>
|
|
<div class="flex items-center gap-3">
|
|
<span class="text-xs font-bold text-slate-400 uppercase">일괄 변경:</span>
|
|
<select x-model="bulkStatus"
|
|
class="bg-slate-800 border-none rounded-lg text-xs font-bold px-3 py-1.5 focus:ring-1 focus:ring-blue-500">
|
|
<option value="">상태 변경...</option>
|
|
<option value="active">재직</option>
|
|
<option value="retired">퇴사</option>
|
|
<option value="on_leave">휴직</option>
|
|
</select>
|
|
<select x-model="bulkDeptId"
|
|
class="max-w-[150px] bg-slate-800 border-none rounded-lg text-xs font-bold px-3 py-1.5 focus:ring-1 focus:ring-blue-500">
|
|
<option value="">부서 이동...</option>
|
|
<template x-for="dept in depts" :key="dept.id">
|
|
<option :value="dept.id" x-text="dept.name"></option>
|
|
</template>
|
|
</select>
|
|
<button @click="applyBulkUpdate"
|
|
class="bg-blue-500 hover:bg-blue-600 px-4 py-1.5 rounded-lg text-xs font-black transition-all">적용</button>
|
|
<button @click="selectedIds = []" class="text-slate-400 hover:text-white transition-colors">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- User Table -->
|
|
<div class="bg-white rounded-3xl shadow-sm border border-slate-200 overflow-hidden">
|
|
<table class="min-w-full divide-y divide-slate-100">
|
|
<thead class="bg-slate-50/50">
|
|
<tr>
|
|
<th class="px-6 py-4 text-left">
|
|
<input type="checkbox" @change="toggleSelectAll($event.target.checked)"
|
|
class="w-4 h-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500">
|
|
</th>
|
|
<th @click="toggleSort('name')"
|
|
class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider cursor-pointer hover:text-blue-600 transition-colors">
|
|
<div class="flex items-center">
|
|
이름 / 사번
|
|
<span class="ml-1" x-show="sortKey === 'name'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</div>
|
|
</th>
|
|
<th @click="toggleSort('dept_name')"
|
|
class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider cursor-pointer hover:text-blue-600 transition-colors">
|
|
<div class="flex items-center">
|
|
부서 / 직위
|
|
<span class="ml-1" x-show="sortKey === 'dept_name'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</div>
|
|
</th>
|
|
<th class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">연락처
|
|
</th>
|
|
<th @click="toggleSort('accounting_type')"
|
|
class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider cursor-pointer hover:text-blue-600 transition-colors">
|
|
<div class="flex items-center">
|
|
회계구분
|
|
<span class="ml-1" x-show="sortKey === 'accounting_type'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</div>
|
|
</th>
|
|
<th @click="toggleSort('status')"
|
|
class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider cursor-pointer hover:text-blue-600 transition-colors">
|
|
<div class="flex items-center">
|
|
상태
|
|
<span class="ml-1" x-show="sortKey === 'status'"
|
|
x-text="sortOrder === 'asc' ? '↑' : '↓'"></span>
|
|
</div>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-50">
|
|
<template x-for="user in filteredUsers" :key="user.id">
|
|
<tr class="hover:bg-slate-50/80 transition-colors group">
|
|
<td class="px-6 py-4">
|
|
<input type="checkbox" :value="user.id" x-model="selectedIds"
|
|
class="w-4 h-4 rounded border-slate-300 text-blue-600 focus:ring-blue-500">
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap cursor-pointer" @click="editUser(user)">
|
|
<div class="flex items-center">
|
|
<div class="h-10 w-10 flex-shrink-0 bg-indigo-100 rounded-xl flex items-center justify-center text-indigo-600 font-bold"
|
|
x-text="user.name.charAt(0)"></div>
|
|
<div class="ml-4">
|
|
<div class="text-sm font-bold text-slate-900 group-hover:text-blue-600 transition-colors"
|
|
x-text="user.name"></div>
|
|
<div class="text-xs text-slate-400" x-text="user.emp_id"></div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap cursor-pointer" @click="editUser(user)">
|
|
<div class="text-sm font-semibold text-slate-700" x-text="user.dept_name || '미소속'">
|
|
</div>
|
|
<div class="text-xs text-slate-400" x-text="user.position || '-'"></div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<div class="text-sm text-slate-600 font-medium" x-text="user.email || '-'"></div>
|
|
<div class="text-xs text-slate-400" x-text="user.mobile || user.phone || '-'"></div>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<span
|
|
class="px-3 py-1 text-[10px] font-black rounded-lg border border-slate-200 bg-slate-50 text-slate-500 uppercase"
|
|
x-text="user.accounting_type"></span>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
<template x-if="user.status === 'active'">
|
|
<span
|
|
class="px-3 py-1 text-xs font-bold rounded-full bg-emerald-50 text-emerald-600 border border-emerald-100">재직
|
|
중</span>
|
|
</template>
|
|
<template x-if="user.status === 'retired'">
|
|
<span
|
|
class="px-3 py-1 text-xs font-bold rounded-full bg-rose-50 text-rose-600 border border-rose-100">퇴사</span>
|
|
</template>
|
|
<template x-if="user.status === 'on_leave'">
|
|
<span
|
|
class="px-3 py-1 text-xs font-bold rounded-full bg-amber-50 text-amber-600 border border-amber-100">휴직</span>
|
|
</template>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
</tbody>
|
|
</table>
|
|
<div x-show="filteredUsers.length === 0" class="py-20 text-center bg-white">
|
|
<div class="text-slate-300 mb-2">
|
|
<svg class="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
|
|
</svg>
|
|
</div>
|
|
<p class="text-slate-400 font-medium">검색 결과가 없습니다.</p>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- User Registration/Edit Modal -->
|
|
<div x-show="showModal" x-cloak class="fixed inset-0 z-[110] flex items-center justify-center p-4">
|
|
<div class="fixed inset-0 modal-bg" @click="showModal = false"></div>
|
|
<div class="bg-white rounded-3xl p-8 max-w-xl w-full relative z-[111] shadow-2xl overflow-hidden">
|
|
<h3 class="text-2xl font-black text-slate-900 mb-8" x-text="isEdit ? '직원 정보 수정' : '신규 직원 등록'"></h3>
|
|
<form @submit.prevent="submitUser" class="space-y-6">
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">이름</label>
|
|
<input type="text" x-model="formData.name" required
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">사번</label>
|
|
<input type="text" x-model="formData.emp_id" required
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">부서</label>
|
|
<select x-model="formData.department_id"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
<option value="">부서 선택</option>
|
|
<template x-for="dept in depts" :key="dept.id">
|
|
<option :value="dept.id" x-text="dept.path"></option>
|
|
</template>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">직위</label>
|
|
<input type="text" x-model="formData.position"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">이메일</label>
|
|
<input type="email" x-model="formData.email"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">휴대폰</label>
|
|
<input type="text" x-model="formData.mobile"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
</div>
|
|
</div>
|
|
<div class="grid grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">회계구분</label>
|
|
<select x-model="formData.accounting_type"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
<option value="일반회계">일반회계</option>
|
|
<option value="특별회계">특별회계</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs font-bold text-slate-500 uppercase mb-2">상태</label>
|
|
<select x-model="formData.status"
|
|
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl focus:ring-2 focus:ring-blue-500 outline-none transition-all">
|
|
<option value="active">재직</option>
|
|
<option value="retired">퇴사</option>
|
|
<option value="on_leave">휴직</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="pt-6 flex gap-4">
|
|
<button type="button" @click="showModal = false"
|
|
class="flex-1 py-4 bg-slate-100 text-slate-600 rounded-2xl font-bold hover:bg-slate-200 transition-all">취소</button>
|
|
<button type="submit"
|
|
class="flex-1 py-4 bg-blue-600 text-white rounded-2xl font-bold shadow-lg shadow-blue-200 hover:bg-blue-700 transition-all"
|
|
x-text="isEdit ? '수정 완료' : '직원 추가'"></button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function userManagement() {
|
|
return {
|
|
users: [],
|
|
depts: [],
|
|
loading: true,
|
|
showModal: false,
|
|
isEdit: false,
|
|
searchQuery: '',
|
|
filterRetired: false,
|
|
filterOnLeave: true,
|
|
sortKey: 'name',
|
|
sortOrder: 'asc',
|
|
selectedIds: [],
|
|
bulkStatus: '',
|
|
bulkDeptId: '',
|
|
formData: { id: '', name: '', emp_id: '', department_id: '', position: '', email: '', mobile: '', accounting_type: '일반회계', status: 'active' },
|
|
|
|
init() {
|
|
this.fetchUsers();
|
|
this.fetchDepts();
|
|
},
|
|
|
|
get visibleCount() {
|
|
return this.filteredUsers.length;
|
|
},
|
|
|
|
get filteredUsers() {
|
|
let result = [...this.users];
|
|
if (this.searchQuery) {
|
|
const q = this.searchQuery.toLowerCase();
|
|
result = result.filter(u => u.name.toLowerCase().includes(q) || u.emp_id.toLowerCase().includes(q) || (u.email && u.email.toLowerCase().includes(q)));
|
|
}
|
|
if (!this.filterRetired) result = result.filter(u => u.status !== 'retired');
|
|
if (!this.filterOnLeave) result = result.filter(u => u.status !== 'on_leave');
|
|
|
|
if (this.sortKey) {
|
|
result.sort((a, b) => {
|
|
let valA = a[this.sortKey] || '';
|
|
let valB = b[this.sortKey] || '';
|
|
if (typeof valA === 'string') valA = valA.toLowerCase();
|
|
if (typeof valB === 'string') valB = valB.toLowerCase();
|
|
if (valA < valB) return this.sortOrder === 'asc' ? -1 : 1;
|
|
if (valA > valB) return this.sortOrder === 'asc' ? 1 : -1;
|
|
return 0;
|
|
});
|
|
}
|
|
return result;
|
|
},
|
|
|
|
fetchUsers() {
|
|
const scrollPos = window.scrollY;
|
|
this.loading = true;
|
|
fetch('api.php?action=get_users')
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
this.users = data;
|
|
this.loading = false;
|
|
this.$nextTick(() => window.scrollTo(0, scrollPos));
|
|
});
|
|
},
|
|
|
|
fetchDepts() {
|
|
fetch('api.php?action=get_departments').then(res => res.json()).then(data => { this.depts = data; });
|
|
},
|
|
|
|
toggleSort(key) {
|
|
if (this.sortKey === key) {
|
|
this.sortOrder = this.sortOrder === 'asc' ? 'desc' : 'asc';
|
|
} else {
|
|
this.sortKey = key;
|
|
this.sortOrder = 'asc';
|
|
}
|
|
},
|
|
|
|
toggleSelectAll(checked) {
|
|
this.selectedIds = checked ? this.filteredUsers.map(u => u.id) : [];
|
|
},
|
|
|
|
openAddModal() {
|
|
this.resetForm();
|
|
this.showModal = true;
|
|
},
|
|
|
|
editUser(user) {
|
|
this.isEdit = true;
|
|
this.formData = { ...user };
|
|
this.showModal = true;
|
|
},
|
|
|
|
submitUser() {
|
|
const action = this.isEdit ? 'update_user' : 'add_user';
|
|
fetch(`api.php?action=${action}`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(this.formData)
|
|
}).then(res => res.json()).then(data => {
|
|
if (data.success) {
|
|
this.showModal = false;
|
|
this.fetchUsers();
|
|
}
|
|
});
|
|
},
|
|
|
|
applyBulkUpdate() {
|
|
if (!this.bulkStatus && !this.bulkDeptId) return;
|
|
fetch('api.php?action=bulk_update_users', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
user_ids: this.selectedIds,
|
|
status: this.bulkStatus,
|
|
department_id: this.bulkDeptId
|
|
})
|
|
}).then(res => res.json()).then(data => {
|
|
if (data.success) {
|
|
this.selectedIds = [];
|
|
this.bulkStatus = '';
|
|
this.bulkDeptId = '';
|
|
this.fetchUsers();
|
|
}
|
|
});
|
|
},
|
|
|
|
resetForm() {
|
|
this.isEdit = false;
|
|
this.formData = { id: '', name: '', emp_id: '', department_id: '', position: '', email: '', mobile: '', accounting_type: '일반회계', status: 'active' };
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|