jasan/mfp.php
2026-02-08 17:12:56 +09:00

146 lines
No EOL
7.8 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"
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>
<!-- 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 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.account_id">
<tr @click="editMfp(mfp)" class="hover:bg-slate-50/80 transition-colors cursor-pointer group">
<td class="px-6 py-4 whitespace-nowrap">
<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">
<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" x-text="mfp.purpose || '-'">
</td>
<td class="px-6 py-4 whitespace-nowrap">
<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, 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));
});
},
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>