Files
2026-09-16 23:20:08 +07:00

54 lines
2.6 KiB
PHP

<?php
require_once 'header.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$folder_id = $_POST['google_drive_folder_id'] ?? '';
// Check if exists
$stmt = $pdo->prepare("SELECT COUNT(*) FROM settings WHERE setting_key = 'google_drive_folder_id'");
$stmt->execute();
$exists = $stmt->fetchColumn();
if ($exists) {
$stmt = $pdo->prepare("UPDATE settings SET setting_value = ? WHERE setting_key = 'google_drive_folder_id'");
$stmt->execute([$folder_id]);
} else {
$stmt = $pdo->prepare("INSERT INTO settings (setting_key, setting_value) VALUES ('google_drive_folder_id', ?)");
$stmt->execute([$folder_id]);
}
logActivity($pdo, 'UPDATE_SETTINGS', "อัปเดต Google Drive Folder ID");
$success = "บันทึกการตั้งค่าเรียบร้อยแล้ว";
}
$current_folder_id = getSetting($pdo, 'google_drive_folder_id');
?>
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">ตั้งค่าระบบ</h1>
</div>
<?php if (!empty($success)): ?>
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4" role="alert">
<span class="block sm:inline"><?= $success ?></span>
</div>
<?php endif; ?>
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 max-w-2xl">
<form action="" method="POST">
<div class="mb-4">
<label for="google_drive_folder_id" class="block text-sm font-medium text-gray-700 mb-2">Google Drive Folder ID</label>
<input type="text" id="google_drive_folder_id" name="google_drive_folder_id" value="<?= htmlspecialchars((string)$current_folder_id) ?>" class="appearance-none border border-gray-300 rounded-md w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:ring-2 focus:ring-green-500" placeholder="เช่น 1A2b3C4d5E6f7G8h9I0j">
<p class="text-sm text-gray-500 mt-2">หมายเหตุ: ต้องแชร์โฟลเดอร์ใน Google Drive ให้กับอีเมล Service Account ของคุณด้วย เพื่อให้ระบบสามารถอัปโหลดไฟล์เข้าไปได้</p>
</div>
<div class="mt-6">
<button type="submit" class="bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline transition-colors">
บันทึกการตั้งค่า
</button>
</div>
</form>
</div>
<?php require_once 'footer.php'; ?>