206 lines
13 KiB
PHP
206 lines
13 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="th">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>เข้าสู่ระบบ | <?= htmlspecialchars(APP_NAME) ?></title>
|
|
<link rel="icon" type="image/png" href="<?= BASE_URL ?>/public/favicon.png">
|
|
<link rel="shortcut icon" type="image/x-icon" href="<?= BASE_URL ?>/public/favicon.ico">
|
|
<!-- Tailwind CSS CDN -->
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<script>
|
|
tailwind.config = {
|
|
darkMode: 'class',
|
|
theme: {
|
|
extend: {
|
|
fontFamily: {
|
|
sans: ['Inter', 'sans-serif'],
|
|
},
|
|
colors: {
|
|
primary: '#0ea5e9',
|
|
secondary: '#14b8a6',
|
|
dark: '#0f172a'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<!-- Google Fonts: Inter -->
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
<!-- Custom CSS -->
|
|
<link rel="stylesheet" href="<?= BASE_URL ?>/public/assets/css/style.css">
|
|
<style>
|
|
body {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.login-container {
|
|
width: 100%;
|
|
max-width: 450px;
|
|
padding: 15px;
|
|
}
|
|
.login-logo {
|
|
width: 80px;
|
|
height: 80px;
|
|
background: rgba(255, 255, 255, 0.5);
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0 auto 20px;
|
|
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
|
|
}
|
|
.login-logo svg {
|
|
width: 40px;
|
|
height: 40px;
|
|
color: var(--primary-color);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="h-screen w-screen overflow-hidden text-slate-800 dark:text-slate-200">
|
|
<!-- Full Screen Background Image -->
|
|
<div class="absolute inset-0 z-0 bg-cover bg-center" style="background-image: url('<?= BASE_URL ?>/public/assets/images/hospital_background_1783495310883.jpg');">
|
|
<!-- Overlay -->
|
|
<div class="absolute inset-0 z-10 bg-overlay backdrop-blur-sm"></div>
|
|
</div>
|
|
|
|
<!-- Login Container -->
|
|
<div class="relative z-20 flex items-center justify-center h-full px-4">
|
|
<div class="glass-card rounded-3xl p-8 md:p-12 w-full max-w-md shadow-2xl animate-float transition-all duration-300">
|
|
|
|
<!-- Logo Section -->
|
|
<div class="text-center mb-8">
|
|
<img src="<?= BASE_URL ?>/public/img/logo.png" alt="Logo" class="w-24 h-24 object-contain mx-auto mb-4">
|
|
<h1 class="text-2xl font-bold text-slate-900 dark:text-white"><?= APP_NAME ?></h1>
|
|
<p class="text-sm text-slate-600 dark:text-slate-400 mt-2">โรงพยาบาลเกาะสมุย (Koh Samui Hospital)</p>
|
|
</div>
|
|
|
|
<!-- Login Form -->
|
|
<form id="loginForm" action="<?= BASE_URL ?>/login" method="POST" class="space-y-6">
|
|
<div>
|
|
<label for="username" class="block text-sm font-medium mb-2">ชื่อผู้ใช้งาน</label>
|
|
<div class="relative">
|
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none text-slate-400">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0ZM4.501 20.118a7.5 7.5 0 0 1 14.998 0A17.933 17.933 0 0 1 12 21.75c-2.676 0-5.216-.584-7.499-1.632Z" /></svg>
|
|
</div>
|
|
<input type="text" id="username" name="username" class="block w-full pl-10 pr-3 py-3 border border-slate-300 dark:border-slate-600 rounded-xl focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary bg-white/50 dark:bg-slate-800/50 transition-all" placeholder="กรอกชื่อผู้ใช้งาน" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="password" class="block text-sm font-medium mb-2">รหัสผ่าน</label>
|
|
<div class="relative">
|
|
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none text-slate-400">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z" /></svg>
|
|
</div>
|
|
<input type="password" id="password" name="password" class="block w-full pl-10 pr-10 py-3 border border-slate-300 dark:border-slate-600 rounded-xl focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary bg-white/50 dark:bg-slate-800/50 transition-all" placeholder="กรอกรหัสผ่าน" required>
|
|
<button type="button" id="togglePassword" class="absolute inset-y-0 right-0 pr-3 flex items-center text-slate-400 hover:text-primary transition-colors">
|
|
<svg id="eyeIcon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" /></svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<button type="submit" id="submitBtn" class="w-full flex justify-center py-3 px-4 border border-transparent rounded-xl shadow-sm text-sm font-bold text-white bg-gradient-to-r from-primary to-secondary hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary transition-all group">
|
|
<span id="btnText">เข้าสู่ระบบ</span>
|
|
<svg id="btnSpinner" class="hidden animate-spin ml-2 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
|
|
</button>
|
|
</form>
|
|
|
|
<!-- Dark Mode Toggle & Footer -->
|
|
<div class="mt-8 pt-6 border-t border-slate-300 dark:border-slate-600 flex justify-between items-center">
|
|
<span class="text-xs text-slate-500">v<?= htmlspecialchars((new \app\Models\SystemSettingModel())->getSetting('app_version', '1.0.0')) ?></span>
|
|
<button id="themeToggle" class="text-slate-500 hover:text-primary transition-colors p-2 rounded-full hover:bg-slate-200 dark:hover:bg-slate-700">
|
|
<svg id="themeIcon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z" /></svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- SweetAlert2 & JS -->
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Theme Toggle Logic
|
|
const themeToggle = document.getElementById('themeToggle');
|
|
const themeIcon = document.getElementById('themeIcon');
|
|
const html = document.documentElement;
|
|
|
|
// Check local storage for theme
|
|
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
html.classList.add('dark');
|
|
themeIcon.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z" />';
|
|
} else {
|
|
html.classList.remove('dark');
|
|
}
|
|
|
|
themeToggle.addEventListener('click', () => {
|
|
if (html.classList.contains('dark')) {
|
|
html.classList.remove('dark');
|
|
localStorage.theme = 'light';
|
|
themeIcon.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z" />';
|
|
} else {
|
|
html.classList.add('dark');
|
|
localStorage.theme = 'dark';
|
|
themeIcon.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z" />';
|
|
}
|
|
});
|
|
|
|
// Show/Hide Password Logic
|
|
const togglePassword = document.getElementById('togglePassword');
|
|
const password = document.getElementById('password');
|
|
const eyeIcon = document.getElementById('eyeIcon');
|
|
|
|
togglePassword.addEventListener('click', function (e) {
|
|
const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
|
|
password.setAttribute('type', type);
|
|
|
|
if (type === 'text') {
|
|
eyeIcon.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M3.98 8.223A10.477 10.477 0 0 0 1.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.451 10.451 0 0 1 12 4.5c4.756 0 8.773 3.162 10.065 7.498a10.522 10.522 0 0 1-4.293 5.774M6.228 6.228 3 3m3.228 3.228 3.65 3.65m7.894 7.894L21 21m-3.228-3.228-3.65-3.65m0 0a3 3 0 1 0-4.243-4.243m4.242 4.242L9.88 9.88" />';
|
|
} else {
|
|
eyeIcon.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />';
|
|
}
|
|
});
|
|
|
|
// Loading State Logic
|
|
const form = document.getElementById('loginForm');
|
|
const submitBtn = document.getElementById('submitBtn');
|
|
const btnText = document.getElementById('btnText');
|
|
const btnSpinner = document.getElementById('btnSpinner');
|
|
|
|
form.addEventListener('submit', function() {
|
|
submitBtn.disabled = true;
|
|
btnText.textContent = 'กำลังเข้าสู่ระบบ...';
|
|
btnSpinner.classList.remove('hidden');
|
|
submitBtn.classList.add('opacity-75', 'cursor-not-allowed');
|
|
});
|
|
|
|
// Alerts
|
|
const Toast = Swal.mixin({
|
|
toast: true,
|
|
position: 'top-end',
|
|
showConfirmButton: false,
|
|
timer: 3000,
|
|
timerProgressBar: true,
|
|
});
|
|
|
|
<?php if (isset($_SESSION['error'])): ?>
|
|
Toast.fire({
|
|
icon: 'error',
|
|
title: '<?= htmlspecialchars($_SESSION['error'], ENT_QUOTES, 'UTF-8') ?>'
|
|
});
|
|
<?php unset($_SESSION['error']); ?>
|
|
<?php endif; ?>
|
|
|
|
<?php if (isset($_SESSION['success'])): ?>
|
|
Toast.fire({
|
|
icon: 'success',
|
|
title: '<?= htmlspecialchars($_SESSION['success'], ENT_QUOTES, 'UTF-8') ?>'
|
|
});
|
|
<?php unset($_SESSION['success']); ?>
|
|
<?php endif; ?>
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|