216 lines
No EOL
12 KiB
PHP
216 lines
No EOL
12 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>
|
|
[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 justify-between items-center">
|
|
<div>
|
|
<h2 class="text-3xl font-extrabold text-slate-900 tracking-tight">복합기 계정 관리</h2>
|
|
<p class="text-slate-500 mt-1">임시/공용 복합기 계정 및 비밀번호 관리</p>
|
|
</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">신규
|
|
계정 등록</button>
|
|
</header>
|
|
|
|
<!-- Bulk Actions -->
|
|
<div x-show="selectedIds.length > 0" x-transition x-cloak
|
|
class="mb-6 bg-slate-900 text-white px-6 py-3 rounded-2xl flex items-center justify-between shadow-xl">
|
|
<div class="flex items-center gap-4">
|
|
<div class="flex items-center gap-2">
|
|
<span class="text-amber-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-amber-500">
|
|
<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-lg text-xs font-bold px-3 py-1.5 focus:ring-1 focus:ring-amber-500 w-48">
|
|
<button @click="applyBulkUpdate"
|
|
class="bg-amber-500 hover:bg-amber-600 px-4 py-1.5 rounded-lg text-xs font-black transition-all">적용</button>
|
|
</div>
|
|
</div>
|
|
<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>
|
|
|
|
<!-- MFP List Table -->
|
|
<div class="bg-white rounded-3xl shadow-sm border border-slate-200 overflow-hidden" x-show="mfpList.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 mfpList" :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>
|
|
</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: [],
|
|
bulkStatus: '',
|
|
bulkPurpose: '',
|
|
formData: { id: '', account_id: '', account_pw: '', purpose: '' },
|
|
init() { this.fetchMfp(); },
|
|
fetchMfp() {
|
|
const scrollPos = window.scrollY;
|
|
fetch('api.php?action=get_mfp').then(res => res.json()).then(data => {
|
|
this.mfpList = data;
|
|
this.$nextTick(() => window.scrollTo(0, scrollPos));
|
|
});
|
|
},
|
|
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>
|