diff --git a/Admin/admin_page.php b/Admin/admin_page.php index a72a169c25770732021eddbf4fd502288d2317b9..8b91d371ea6ca0be7b4b6e0cda51689a4e04f0fe 100644 --- a/Admin/admin_page.php +++ b/Admin/admin_page.php @@ -27,6 +27,7 @@ if (!isset($_SESSION['user_type'])) { <li><a href="#" data-src="user_manage.php" class="block px-5 py-3 hover:bg-gray-700">Manage user detail</a></li> <li><a href="#" data-src="brs_manage.php" class="block px-5 py-3 hover:bg-gray-700">Manage Bristol Map</a></li> <li><a href="#" data-src="QA_manage.php" class="block px-5 py-3 hover:bg-gray-700">Question and answer management</a></li> + <li><a href="#" data-src="fb_manage.php" class="block px-5 py-3 hover:bg-gray-700">Feeddback management</a></li> </ul> </div> <!-- 主内容区 --> diff --git a/Admin/fb_manage.php b/Admin/fb_manage.php new file mode 100644 index 0000000000000000000000000000000000000000..337f4e7ae35c4848c4f2d9ce7725ad23452bf5ac --- /dev/null +++ b/Admin/fb_manage.php @@ -0,0 +1,86 @@ +<?php +include_once '../Logic/config.php'; +// 准备SQL查询 +$stmt = DB->prepare("SELECT * FROM feedback"); +$stmt->execute(); +$feedbacks = $stmt->fetchAll(PDO::FETCH_ASSOC); + +function deleteFeedback($id) +{ + $sql = "DELETE FROM feedback WHERE id = ?"; + $stmt = DB->prepare($sql); + return $stmt->execute([$id]); +} + + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + + // 处理表单提交的数据 + if ($_POST["formType"] == "delFeedbackForm") { + $id = $_POST['id']; + + deleteFeedback($id); + echo "<script>window.location.href ='../Admin/fb_manage.php';</script>"; + } + +} +?> +<!DOCTYPE html> +<html lang="zh-CN"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Uni-building Management</title> + <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> +</head> +<body class="bg-gray-100"> +<div class="container mx-auto p-4"> + <table class="min-w-full max-w-4xl mx-auto border-collapse"> + <thead class="bg-gray-800 text-white"> + <tr class="border-b"> + <th class="px-4 py-2 text-left rounded-tl-lg">Student ID</th> + <th class="px-4 py-2 text-left">Feedback</th> + <th class="px-4 py-2 text-left rounded-tr-lg">Operations</th> + </tr> + </thead> + <tbody> + <?php foreach ($feedbacks as $feedback) { ?> + <tr class="border-b"> + <td class="px-4 py-2"><?php echo htmlspecialchars($feedback['id']) ?></td> + <td class="px-4 py-2"><?php echo htmlspecialchars($feedback['feedback']) ?></td> + <td class="px-4 py-2 text-center"> + <!-- 删除按钮 --> + <form action="../Admin/fb_manage.php" method="post"> + <input type="hidden" name="id" + value="<?php echo htmlspecialchars($feedback['id']) ?>"> + <input type="hidden" name="formType" value="delFeedbackForm"> + <button type="submit" class="text-red-500 hover:text-red-700 mx-2"> + <i class="fas fa-trash-alt"></i> + </button> + </form> + </td> + </tr> + <?php } ?> + </tbody> + </table> +</div> + +<!-- 弹出框,初始时隐藏 --> +<div id="modal" + class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full flex items-center justify-center"> + <div class="bg-white p-10 rounded-lg shadow-lg max-w-2xl w-full mx-auto" id="modal-content"> + <!-- 弹出框内容 --> + </div> +</div> + +<div class="fixed bottom-0 right-0 p-4"> + <button onclick="window.location.reload()" + class="px-4 py-2 bg-gray-800 text-white rounded-md shadow-md hover:bg-gray-900 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"> + <i class="fas fa-sync-alt mr-2"></i> + </button> +</div> +</body> +</html> + + diff --git a/Admin/uni_manage.php b/Admin/uni_manage.php index d9ee7bc425e6096a5174cdbab3ef9cc1201dc801..6f750842d675da5e410ec4ef845957e53e1b1dd3 100644 --- a/Admin/uni_manage.php +++ b/Admin/uni_manage.php @@ -48,7 +48,6 @@ function addBuilding($openTime, $latitude, $longtitude, $description, $buildingN exit; } - //在数据库中创建新用户 $sql = "INSERT INTO building(openTime, `data-lat`, `data-lng`, description, name) VALUES (?, ?, ?, ?, ?)"; $stmt = DB->prepare($sql); return $stmt->execute([$openTime, $latitude, $longtitude, $description, $buildingName]); diff --git a/Presentation/interface.php b/Presentation/interface.php index 6603b68c6ce92d43ce508d3dbfba871ec82fe2eb..2694d84d5cb0249722d9e99cb3313367ef915136 100644 --- a/Presentation/interface.php +++ b/Presentation/interface.php @@ -1,4 +1,21 @@ -<?php require_once '../Logic/session_start.php'; ?> +<?php +require_once '../Logic/session_start.php'; +require_once '../Logic/config.php'; + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if ($_POST["formType"] == "feedbackForm") { + $student_id = $_SESSION['user_id']; + $feedback = $_POST['questions']; + + $sql = "INSERT INTO feedback(student_id, feedback) VALUES (?, ?)"; + $stmt = DB->prepare($sql); + $stmt->execute([$student_id, $feedback]); + + echo "<script>alert('Thank you for your feedback!');</script>"; + } + +} +?> <!DOCTYPE html> <html lang="en"> <head> @@ -22,6 +39,7 @@ <div id="sidebar"> <a href="#" class="sidebar-item" target="contentFrame" data-src="map.php">Around Frenchay Campus</a> <a href="#" class="sidebar-item" target="contentFrame" data-src="city.php">Around Bristol</a> + <a href="#" class="sidebar-item" target="contentFrame" data-src="chatbotpage.php">Ask Chat bot</a> <a href="#" class="sidebar-item" target="contentFrame" data-src="chatPage.php">Campus Voices</a> <a href="#" class="sidebar-item" target="contentFrame" data-src="settings.php">User Profile</a> <?php @@ -29,14 +47,35 @@ echo '<a href="../Admin/admin_page.php" class="sidebar-item" target="contentFrame">Admin Page</a>'; } ?> +<!-- feedback button--> + <button id="emailButton" class="bg-grey-500 p-4 rounded-full text-white"> + <i class="fas fa-envelope"></i> + </button> </div> <div id="chatContainer"> <iframe id="contentFrame" src="chatbotpage.php" style="width: 100%; height: 100%; border: none;"></iframe> </div> +</div> +<!--模态框--> +<div id="emailModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden justify-center items-center" style="display: none;"> + <div class="bg-white p-4 rounded-lg shadow-lg w-1/3"> + <form id="emailForm" method="post" action="interface.php"> + <input type="hidden" name="formType" value="feedbackForm"> + <input type="hidden" name="id" value="<?php echo $_SESSION['user_id'] ?>"> + <div class="mb-4"> + <label for="userEmail" class="block text-gray-700 text-sm font-bold mb-2">Your Requirements:</label> + <textarea id="questions" name="questions" class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" required></textarea> + </div> + <button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"> + Submit + </button> + </form> + </div> </div> + <script> document.querySelectorAll('a').forEach(link => { link.addEventListener('click', function(event) { @@ -46,6 +85,30 @@ } }); }); + + document.getElementById('emailButton').addEventListener('click', function() { + document.getElementById('emailModal').style.display = 'flex'; // 显示模态框 + }); + + document.getElementById('emailForm').addEventListener('submit', function(event) { + // event.preventDefault(); + // 这里可以添加发送邮件的JavaScript逻辑 + document.getElementById('emailModal').style.display = 'none'; // 隐藏模态框 + // 可选:在这里处理表单数据 + }); + + // 添加点击模态框背景关闭模态框的逻辑 + document.getElementById('emailModal').addEventListener('click', function(event) { + // 检查点击事件是否在模态框背景上发生 + if (event.target === this) { + this.style.display = 'none'; // 隐藏模态框 + } + }); + + // 阻止模态框内容区域的点击事件冒泡到背景层 + document.querySelector('#emailModal > div').addEventListener('click', function(event) { + event.stopPropagation(); + }); </script> </body> </html>