jasan/mfp.php
2026-02-09 01:19:02 +09:00

261 lines
No EOL
15 KiB
PHP

<?php require_once 'auth_check.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>
[x-cloak] {
display: none !important;
}
.modal-bg {
background-color: rgba(15, 23, 42, 0.7);
backdrop-filter: blur(4px);
}
</style>
</head>
<body class="bg-[#f8fafc] text-slate-800" x-data="mfpManagement()">
<?php include 'nav.php'; ?>
<main class="max-w-[1600px] mx-auto p-8 pt-10">
<header class="mb-10 flex flex-col md:flex-row md:items-center justify-between gap-4">
<div>
<h2 class="text-3xl font-extrabold text-slate-900 tracking-tight">복합기 계정 관리</h2>
<p class="text-slate-500 mt-1">임시/공용 복합기 계정 및 비밀번호 관리</p>
</div>
<div class="flex items-center gap-3">
<div class="relative group">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-4 w-4 text-slate-400 group-focus-within:text-amber-500 transition-colors"
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>
</div>
<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-amber-500 transition-all text-sm shadow-sm"
placeholder="계정 ID, 사용 목적 검색...">
</div>
<button
@click="showModal = true; isEdit = false; formData = { id: '', account_id: '', account_pw: '', purpose: '' }"
class="bg-amber-600 text-white px-5 py-2.5 rounded-xl font-bold shadow-lg shadow-amber-200 hover:bg-amber-700 transition-all shrink-0">신규
계정 등록</button>
</div>
</header>
<!-- Bulk Actions (Fixed Floating Bar) -->
<div x-show="selectedIds.length > 0" x-transition x-cloak
class="fixed bottom-10 left-10 z-[200] bg-slate-900 text-white px-6 py-4 rounded-3xl flex items-center gap-6 shadow-2xl border border-white/10 animate-in fade-in slide-in-from-left-4 duration-300">
<div class="flex items-center gap-2">
<div class="w-10 h-10 bg-amber-600 rounded-full flex items-center justify-center font-black text-sm shadow-lg shadow-amber-500/30"
x-text="selectedIds.length"></div>
<div class="flex flex-col">
<span class="text-[10px] font-black text-slate-400 uppercase tracking-tighter">Selected</span>
<span class="text-xs font-bold">계정 선택됨</span>
</div>
</div>
<div class="h-8 w-px bg-white/10 mx-2"></div>
<div class="flex items-center gap-3">
<select x-model="bulkStatus"
class="bg-slate-800 border-none rounded-xl text-xs font-bold px-4 py-2 focus:ring-2 focus:ring-amber-500 appearance-none shadow-inner min-w-[150px]">
<option value="">상태 변경...</option>
<option value="active">사용중(active)</option>
<option value="inactive">비활성(inactive)</option>
</select>
<input type="text" x-model="bulkPurpose" placeholder="사용 목적 일괄 입력..."
class="bg-slate-800 border-none rounded-xl text-xs font-bold px-4 py-2 focus:ring-2 focus:ring-amber-500 shadow-inner w-48">
<button @click="applyBulkUpdate"
class="bg-amber-500 hover:bg-amber-600 px-6 py-2 rounded-xl text-xs font-black transition-all shadow-lg shadow-amber-500/20 active:scale-95">일괄
적용</button>
<button @click="selectedIds = []"
class="ml-2 w-8 h-8 flex items-center justify-center rounded-full hover:bg-white/10 text-slate-400 hover:text-white transition-all">
<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>
<!-- MFP List Table -->
<div class="bg-white rounded-3xl shadow-sm border border-slate-200 overflow-hidden"
x-show="!loading && filteredMfp.length > 0">
<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 w-10">
<input type="checkbox" @change="toggleSelectAll($event.target.checked)"
class="w-4 h-4 rounded border-slate-300 text-amber-600 focus:ring-amber-500">
</th>
<th class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">계정 ID
</th>
<th class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">
Password</th>
<th class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">사용 목적
</th>
<th class="px-6 py-4 text-left text-xs font-bold text-slate-500 uppercase tracking-wider">상태
</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
<template x-for="mfp in filteredMfp" :key="mfp.id">
<tr class="hover:bg-slate-50/80 transition-colors group">
<td class="px-6 py-4">
<input type="checkbox" :value="mfp.id" x-model="selectedIds"
class="w-4 h-4 rounded border-slate-300 text-amber-600 focus:ring-amber-500">
</td>
<td class="px-6 py-4 whitespace-nowrap cursor-pointer" @click="editMfp(mfp)">
<div class="flex items-center">
<div class="p-2 bg-amber-50 rounded-lg text-amber-600 mr-3">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z" />
</svg>
</div>
<span class="text-sm font-black text-slate-900" x-text="mfp.account_id"></span>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap cursor-pointer" @click="editMfp(mfp)">
<span
class="px-2 py-1 bg-slate-100 border border-slate-200 rounded text-xs font-mono font-bold text-slate-700"
x-text="mfp.account_pw"></span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-slate-500 cursor-pointer"
@click="editMfp(mfp)" x-text="mfp.purpose || '-'">
</td>
<td class="px-6 py-4 whitespace-nowrap cursor-pointer" @click="editMfp(mfp)">
<span
class="px-3 py-1 bg-emerald-100 text-emerald-600 rounded-full text-[10px] font-black uppercase tracking-tighter"
x-text="mfp.status"></span>
</td>
</tr>
</template>
</tbody>
</table>
</div>
<div x-show="loading" class="p-20 flex justify-center">
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-amber-600"></div>
</div>
<div x-show="!loading && filteredMfp.length === 0"
class="p-20 text-center bg-white rounded-3xl border border-dashed border-slate-300">
<template x-if="searchQuery">
<p class="text-slate-400 font-medium italic">검색 결과와 일치하는 계정이 없습니다.</p>
</template>
<template x-if="!searchQuery">
<p class="text-slate-400 font-medium italic">등록된 복합기 계정이 없습니다.</p>
</template>
</div>
</main>
<!-- MFP Modal -->
<div x-show="showModal" x-cloak class="fixed inset-0 z-[100] 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-md w-full relative z-[101] shadow-2xl">
<h3 class="text-2xl font-black mb-6" x-text="isEdit ? '계정 정보 수정' : '신규 계정 등록'"></h3>
<form @submit.prevent="submitMfp" class="space-y-4">
<div><label class="block text-xs font-bold text-slate-500 uppercase mb-2">ID (계정명)</label><input
type="text" x-model="formData.account_id" required
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl"></div>
<div><label class="block text-xs font-bold text-slate-500 uppercase mb-2">Password</label><input
type="text" x-model="formData.account_pw" required
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl"></div>
<div><label class="block text-xs font-bold text-slate-500 uppercase mb-2">사용 목적</label><input
type="text" x-model="formData.purpose"
class="w-full px-4 py-3 bg-slate-50 border border-slate-200 rounded-xl"></div>
<div class="pt-4 flex gap-3">
<button type="button" @click="showModal = false"
class="flex-1 py-3 bg-slate-100 rounded-xl font-bold">취소</button>
<button type="submit" class="flex-1 py-3 bg-amber-600 text-white rounded-xl font-bold"
x-text="isEdit ? '수정 완료' : '저장'"></button>
</div>
</form>
</div>
</div>
<script>
function mfpManagement() {
return {
mfpList: [],
showModal: false,
isEdit: false,
selectedIds: [],
loading: true,
searchQuery: '',
bulkStatus: '',
bulkPurpose: '',
formData: { id: '', account_id: '', account_pw: '', purpose: '' },
init() { this.fetchMfp(); },
fetchMfp() {
const scrollPos = window.scrollY;
this.loading = true;
fetch('api.php?action=get_mfp').then(res => res.json()).then(data => {
this.mfpList = data;
this.loading = false;
this.$nextTick(() => window.scrollTo(0, scrollPos));
});
},
get filteredMfp() {
if (!this.searchQuery) return this.mfpList;
const q = this.searchQuery.toLowerCase();
return this.mfpList.filter(m =>
(m.account_id && m.account_id.toLowerCase().includes(q)) ||
(m.purpose && m.purpose.toLowerCase().includes(q))
);
},
toggleSelectAll(checked) {
this.selectedIds = checked ? this.mfpList.map(m => m.id) : [];
},
applyBulkUpdate() {
if (this.selectedIds.length === 0) return;
if (!this.bulkStatus && !this.bulkPurpose) { alert('변경할 항목을 선택해주세요.'); return; }
fetch('api.php?action=bulk_update_mfp', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
ids: this.selectedIds,
status: this.bulkStatus,
purpose: this.bulkPurpose
})
}).then(res => res.json()).then(data => {
if (data.success) {
this.selectedIds = [];
this.bulkStatus = '';
this.bulkPurpose = '';
this.fetchMfp();
}
});
},
editMfp(mfp) {
this.isEdit = true;
this.formData = { ...mfp };
this.showModal = true;
},
submitMfp() {
const action = this.isEdit ? 'update_mfp' : 'add_mfp';
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.fetchMfp();
this.isEdit = false;
this.formData = { id: '', account_id: '', account_pw: '', purpose: '' };
}
});
}
}
}
</script>
</body>
</html>