76 lines
3.8 KiB
PHP
76 lines
3.8 KiB
PHP
<?php
|
|
require_once '../init.php';
|
|
requireLogin();
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="th">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>ตั้งค่าระบบ - <?= htmlspecialchars($globalSettings['site_name'] ?? 'ศูนย์รวมเว็บหน่วยงาน') ?></title>
|
|
<link rel="icon" type="image/png" href="../assets/images/logo.png">
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link rel="stylesheet" href="../assets/css/style.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
</head>
|
|
<body class="antialiased min-h-screen bg-gray-50 py-10 px-4">
|
|
|
|
<div class="w-full max-w-4xl mx-auto glass-container">
|
|
|
|
<div class="flex flex-wrap justify-between items-center mb-8 border-b border-gray-200 pb-4 gap-4">
|
|
<h1 class="text-2xl font-bold text-gray-800"><i class="fa-solid fa-gear mr-2"></i> ตั้งค่าระบบ</h1>
|
|
<div class="flex flex-wrap gap-2">
|
|
<a href="index.php" class="magic-btn-outline"><i class="fa-solid fa-list mr-1"></i> จัดการเว็บไซต์</a>
|
|
<a href="../index.php" class="magic-btn-outline"><i class="fa-solid fa-home mr-1"></i> หน้าหลัก</a>
|
|
<a href="logout.php" class="bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-xl transition"><i class="fa-solid fa-right-from-bracket mr-1"></i> ออกจากระบบ</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-white rounded-xl shadow-sm p-6 border border-gray-100">
|
|
<form id="settingsForm" onsubmit="saveSettings(event)">
|
|
<input type="hidden" name="action" value="save_settings">
|
|
|
|
<div class="mb-4">
|
|
<label class="block text-gray-700 mb-2 font-medium">ชื่อระบบ (Site Name)</label>
|
|
<input type="text" name="site_name" class="magic-input border border-gray-300" value="<?= htmlspecialchars($globalSettings['site_name'] ?? '') ?>" required>
|
|
</div>
|
|
|
|
<div class="mb-6">
|
|
<label class="block text-gray-700 mb-2 font-medium">คำอธิบายระบบ (Site Subtitle)</label>
|
|
<input type="text" name="site_subtitle" class="magic-input border border-gray-300" value="<?= htmlspecialchars($globalSettings['site_subtitle'] ?? '') ?>">
|
|
</div>
|
|
|
|
<button type="submit" class="magic-btn w-full md:w-auto"><i class="fa-solid fa-save mr-1"></i> บันทึกการตั้งค่า</button>
|
|
</form>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
function saveSettings(e) {
|
|
e.preventDefault();
|
|
const formData = new FormData(e.target);
|
|
|
|
fetch('api.php', {
|
|
method: 'POST',
|
|
body: formData
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if(data.success) {
|
|
Swal.fire('สำเร็จ', 'บันทึกการตั้งค่าเรียบร้อยแล้ว', 'success').then(() => {
|
|
location.reload();
|
|
});
|
|
} else {
|
|
Swal.fire('ข้อผิดพลาด', data.message, 'error');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
Swal.fire('ข้อผิดพลาด', 'ไม่สามารถเชื่อมต่อเซิร์ฟเวอร์ได้', 'error');
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|