diff --git a/Admin/admin_page.php b/Admin/admin_page.php index 8b91d371ea6ca0be7b4b6e0cda51689a4e04f0fe..f947c1573471dace75059a85fb676658196462e3 100644 --- a/Admin/admin_page.php +++ b/Admin/admin_page.php @@ -4,7 +4,7 @@ include_once '../Logic/config.php'; // 检查用户是否是管理员,如果不是则重定向到主页面 if (!isset($_SESSION['user_type'])) { - header("Location: LoginPage.php"); + header("Location: http://localhost/zhushou/Presentation/LoginPage.php"); exit; } ?> @@ -27,7 +27,8 @@ 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> + <li><a href="#" data-src="fb_manage.php" class="block px-5 py-3 hover:bg-gray-700">Feedback management</a></li> + <li><a href="#" data-src="bus_manage.php" class="block px-5 py-3 hover:bg-gray-700">Bus line management</a></li> </ul> </div> <!-- 主内容区 --> diff --git a/Admin/brs_manage.php b/Admin/brs_manage.php index 97b32d363be04a3998e2dea4559b8fe0e5661d63..65c5ceb631254f2ac2f633a81386a7b7f4f447f9 100644 --- a/Admin/brs_manage.php +++ b/Admin/brs_manage.php @@ -15,7 +15,7 @@ function editBuildingInfo($data, $buildingName) // 遍历$data数组,只添加非空字段到SQL更新语句中 foreach ($data as $key => $value) { if (!empty($value)) { - $updates[] = "`$key` = ?"; + $updates[] = "$key = ?"; $params[] = $value; } } diff --git a/Admin/bus_manage.php b/Admin/bus_manage.php new file mode 100644 index 0000000000000000000000000000000000000000..35afaed96de4513ca0590d45951a479e4a0ff7b3 --- /dev/null +++ b/Admin/bus_manage.php @@ -0,0 +1,231 @@ +<?php +include_once '../Logic/config.php'; + +$stmt = DB->prepare("SELECT * FROM bus"); +$stmt->execute(); +$buses = $stmt->fetchAll(PDO::FETCH_ASSOC); + +function editBusInfo($data, $busService) { + // 初始化SQL语句的基础部分 + $sql = "UPDATE bus SET "; + $params = []; + $updates = []; + + // 遍历$data数组,只添加非空字段到SQL更新语句中 + foreach ($data as $key => $value) { + if (!empty($value)) { + $updates[] = "`$key` = ?"; + $params[] = $value; + } + } + + // 如果没有需要更新的数据,则直接返回 + if (empty($updates)) { + return false; + } + + // 将所有更新拼接到基础SQL语句后面 + $sql .= implode(', ', $updates); + $sql .= " WHERE service = ?"; + $params[] = $busService; + + // 准备和执行SQL语句 + $stmt = DB->prepare($sql); + return $stmt->execute($params); +} + +function addBusInfo($busService, $busLine) { + // 查询公交数据库 + $stmt = DB->prepare("SELECT * FROM bus WHERE service = ?"); + $stmt->execute([$busService]); + $bus = $stmt->fetch(PDO::FETCH_ASSOC); + if ($bus) { + // 该路线已存在 + echo "<script>alert('Already has this bus line!');</script>"; + echo "<script>window.location.href = window.location.href;</script>"; + exit; + } + //在数据库中创建新公交路线 + $sql = "INSERT INTO bus(service, bus_path) VALUES (?, ?)"; + $stmt = DB->prepare($sql); + return $stmt->execute([$busService, $busLine]); +} +function delBus($busService) { + $sql = "DELETE FROM bus WHERE service = ?"; + $stmt = DB->prepare($sql); + return $stmt->execute([$busService]); +} + + + + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + // 处理表单提交的数据 + if ($_POST["formType"] == "editBusForm") { + $busService = $_POST['busService']; + $data = [ + 'bus_path' => $_POST['busLine'], + 'service' => $_POST['serviceNum'] + ]; + + editBusInfo($data, $busService); +// echo "<script>window.location.href ='../Admin/bus_manage.php';</script>"; + } elseif ($_POST["formType"] == "addBusForm") { + $busService = $_POST['busService']; + $busLine = $_POST['busLine']; + + addBusInfo($busService, $busLine); + echo "<script>window.location.href ='../Admin/bus_manage.php';</script>"; + }elseif ($_POST["formType"] == "delBusForm") { + $busService = $_POST['busService']; + + delBus($busService); + echo "<script>window.location.href ='../Admin/bus_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>Bus Line 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">Bus line No.</th> + <th class="px-4 py-2 text-left">Bus line Services</th> + <th class="px-4 py-2 text-left rounded-tr-lg">Operations</th> + </tr> + </thead> + <tbody> + <?php foreach ($buses as $bus) { ?> + <tr class="border-b"> + <td class="px-4 py-2"><?php echo htmlspecialchars($bus['service']) ?></td> + <td class="px-4 py-2"><?php echo htmlspecialchars($bus['bus_path']) ?></td> + <td class="px-4 py-2 text-center"> + <!-- 编辑按钮 --> + <button class="edit-btn text-blue-500 hover:text-blue-700 mx-2" + data-id="<?php echo $bus['service'] ?>" + data-type="edit"> + <i class="fas fa-edit"></i> + </button> + <!-- 删除按钮 --> + <form action="../Admin/bus_manage.php" method="post" class="inline-block"> + <input type="hidden" name="busService" + value="<?php echo htmlspecialchars($bus['service']) ?>"> + <input type="hidden" name="formType" value="delBusForm"> + <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 } ?> + <!-- 增加按钮 --> + <tr class="border-b"> + <td colspan="6" class="px-4 py-2 text-center"> + <button class="add-btn text-green-500 hover:text-green-700 mx-2" data-type="add"> + <i class="fas fa-plus-square"></i> + </button> + </td> + </tr> + </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> + +<script> + document.addEventListener("DOMContentLoaded", () => { + const editButtons = document.querySelectorAll('.edit-btn'); + const addButtons = document.querySelectorAll('.add-btn'); + const modal = document.getElementById('modal'); + const modalContent = document.getElementById('modal-content'); + + // 编辑按钮点击事件 + editButtons.forEach(button => { + button.addEventListener('click', function () { + // 获取当前行 + const currentRow = button.closest('tr'); + // 从当前行中获取数据 + const busService = this.getAttribute('data-id'); + + modalContent.innerHTML = ` + <h2 class="text-lg font-bold mb-4">Edit Bus lines Info</h2> + <form id="editBusForm" class="space-y-4" action="../Admin/bus_manage.php" method="post"> + <input type="hidden" name="busService" value="${busService}"> + <input type="hidden" name="formType" value="editBusForm"> + <div> + <label class="block text-sm font-medium text-gray-700" for="busService">Bus Service Number</label> + <input type="text" name="serviceNum" placeholder="${busService}" id="serviceNum" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="busLine">Bus line</label> + <input type="text" name="busLine" id="busLine" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div class="flex justify-end"> + <button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-500 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 active:bg-blue-900 focus:outline-none focus:border-blue-900 focus:ring focus:ring-blue-300 disabled:opacity-25 transition"> + Submit + </button> + </div> + </form> + `; + // 显示模态框 + modal.classList.remove('hidden'); + }); + }); + + // 增加按钮点击事件 + addButtons.forEach(button => { + button.addEventListener('click', function () { + modalContent.innerHTML = ` + <h2 class="text-lg font-bold mb-4">Add Bus</h2> + <form id="addBusForm" class="space-y-4" action="../Admin/bus_manage.php" method="post"> + <input type="hidden" name="formType" value="addBusForm"> + <div> + <label class="block text-sm font-medium text-gray-700" for="account">Bus Service Number</label> + <input type="text" name="busService" id="busService" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div> + <label class="block text-sm font-medium text-gray-700" for="tele_Num">Bus line</label> + <input type="text" name="busLine" id="busLine" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + </div> + <div class="flex justify-end"> + <button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-500 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-700 active:bg-blue-900 focus:outline-none focus:border-blue-900 focus:ring focus:ring-blue-300 disabled:opacity-25 transition"> + Submit + </button> + </div> + </form> + `; + modal.classList.remove('hidden'); + }); + }); + + // 点击模态框外区域关闭模态框 + modal.addEventListener('click', function (e) { + if (e.target === modal) { + modal.classList.add('hidden'); + } + }); + }); +</script> diff --git a/Admin/fb_manage.php b/Admin/fb_manage.php index 337f4e7ae35c4848c4f2d9ce7725ad23452bf5ac..eed3a0e9c40eb287281c08071c6ac06564b74bbf 100644 --- a/Admin/fb_manage.php +++ b/Admin/fb_manage.php @@ -47,7 +47,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { <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['student_id']) ?></td> <td class="px-4 py-2"><?php echo htmlspecialchars($feedback['feedback']) ?></td> <td class="px-4 py-2 text-center"> <!-- 删除按钮 --> diff --git a/Admin/user_manage.php b/Admin/user_manage.php index b1cfb8f1e409f625975872fe85521c6d2caf02f4..72ee130f6263fc0295499b2ce4d572d8997b75fb 100644 --- a/Admin/user_manage.php +++ b/Admin/user_manage.php @@ -160,10 +160,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { <i class="fas fa-edit"></i> </button> <!-- 删除按钮 --> - <form action="../Admin/uni_manage.php" method="post" class="inline-block"> - <input type="hidden" name="buildingName" + <form action="../Admin/user_manage.php" method="post" class="inline-block"> + <input type="hidden" name="userId" value="<?php echo htmlspecialchars($user['id']) ?>"> - <input type="hidden" name="formType" value="delBuildingForm"> + <input type="hidden" name="formType" value="delUserForm"> <button type="submit" class="text-red-500 hover:text-red-700 mx-2"> <i class="fas fa-trash-alt"></i> </button> diff --git a/Logic/city.js b/Logic/city.js index 48ee79a4e0ea0fac0c83fe447ffdebb2fcab2282..cc8dcb8fd1a87ddd1246ccf9ea31540d97f50eb6 100644 --- a/Logic/city.js +++ b/Logic/city.js @@ -20,10 +20,10 @@ function initMap() { center: schoolLatLng, restriction: { latLngBounds: { - north: 51.545302312719976, // 调整为实际的北边界纬度 - south: 51.39364543097778, // 调整为实际的南边界纬度 - east: -2.452456079577689, // 调整为实际的东边界经度 - west: -2.7293783311528226 // 调整为实际的西边界经度 + north: 51.545302312719976, // 实际的北边界纬度 + south: 51.39364543097778, // 实际的南边界纬度 + east: -2.452456079577689, // 实际的东边界经度 + west: -2.7293783311528226 // 实际的西边界经度 }, strictBounds: true, // 当设置为true时,用户不能滚动到限制之外 } diff --git a/Logic/map.js b/Logic/map.js index 428c62c25136517b1317ac404b3d8088fa2c4e44..3553f23bd4718e73ab7862b4c0640322982e546f 100644 --- a/Logic/map.js +++ b/Logic/map.js @@ -132,7 +132,7 @@ function initMap() { title: place.name, position: place.geometry.location, icon: { - url: 'location-pin.png', + url: 'http://localhost/zhushou/Data/location-pin.png', scaledSize: new google.maps.Size(40, 40) // 可选:调整图标大小 } })); diff --git a/Logic/translate.php b/Logic/translate.php index 46bcdedd33ae6544ed613b6376f02944041414cb..4faeb60f3ff71dfb05292cb4e5cf63d9889b24c2 100644 --- a/Logic/translate.php +++ b/Logic/translate.php @@ -1,4 +1,4 @@ -<div id="google_translate_element" style="position: fixed; top: 0; right: 0; background-color: #232533; color: #FFFFFF; padding: 10px; z-index: 1000;"></div> +<div id="google_translate_element" style="position: fixed; top: 0; left: 0; background-color: #232533; color: #FFFFFF; padding: 10px; z-index: 1000;"></div> <script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement({ diff --git a/Presentation/chatPage.php b/Presentation/chatPage.php index 495fc303546a534678f3d6705cb98525ed35b2c2..8b4b095dea9ccbf86e5b831ed57e7ad9320e0da3 100644 --- a/Presentation/chatPage.php +++ b/Presentation/chatPage.php @@ -9,7 +9,6 @@ <link rel="stylesheet" href="../css/chatPage.css"> </head> <body> -<?php include '../Logic/translate.php'; ?> <!-- 在线用户列表容器 --> <div id="sidebar"> <h2>在线用户:</h2> diff --git a/Presentation/chatbotpage.php b/Presentation/chatbotpage.php index a14401c9d950325e3140a2ce0443be2062d6102c..793f752a882326ea609d7928d78f0261b0defb8d 100644 --- a/Presentation/chatbotpage.php +++ b/Presentation/chatbotpage.php @@ -24,7 +24,6 @@ function getPredefinedResponse($userInput) { return $response; } -// 假设这是 index.php if ($_SERVER["REQUEST_METHOD"] == "POST") { // 获取用户输入 $userInput = $_POST['userInput']; diff --git a/Presentation/city.php b/Presentation/city.php index 54ba70a77be78f95a7778b775b6ed232af4b8098..c4b9343aa9188a2c9cb5354ef2e58bf44b4bd919 100644 --- a/Presentation/city.php +++ b/Presentation/city.php @@ -5,6 +5,10 @@ require_once '../Logic/session_start.php'; $stmt = DB->prepare("SELECT * FROM city_building"); $stmt->execute(); $buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); + +$stmt = DB->prepare("SELECT * FROM bus"); +$stmt->execute(); +$buses = $stmt->fetchAll(PDO::FETCH_ASSOC); ?> <!DOCTYPE html> <html> @@ -15,7 +19,7 @@ $buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); <link rel="stylesheet" href="../css/city.css"> </head> <body> -<?php include '../Logic/translate.php'; ?> + <div id="map" style="height: 500px; width: 100%;"></div> <div id="place-search-bar"> @@ -29,7 +33,7 @@ $buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); data-lng="<?php echo htmlspecialchars($building['data-lng']); ?>" data-opentime="<?php echo htmlspecialchars($building['openTime']); ?>" data-description="<?php echo htmlspecialchars($building['description']); ?>" - data-address="<?php echo htmlspecialchars($building['address']); ?>"> + data-address="<?php echo htmlspecialchars($building['address']); ?>"> <?php echo htmlspecialchars($building['name']); ?> </button> <?php endforeach; ?> @@ -54,51 +58,12 @@ $buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); </tr> </thead> <tbody> - <tr> - <td>19</td> - <td>Bath - Bitton - Cherry Gardens - Cadbury Heath - Kingswood - Downend - Hambrook - Stoke Park - <span - class="highlighted">Frenchay</span> - Bristol Parkway Station - </td> - </tr> - <tr> - <td>48a</td> - <td>City Centre - Old Market - Easton - Eastville - Fishponds - Glenside - Stoke Park - <span - class="highlighted">Frenchay</span></td> - </tr> - <tr> - <td>70 (24/7 service between City Centre & UWE Frenchay)</td> - <td>Hengrove - Melvin Square - Bedminster - City Centre - Montpelier - Cromwell Road - Chesterfield Road - - Ashley Down Road - Muller Road - Filton Avenue - <span class="highlighted">Frenchay</span></td> - </tr> - <tr> - <td>72</td> - <td>Temple Meads Station - City Centre - Clifton Triangle - University of Bristol - Cotham - Redland - - Gloucester Road - Filton Avenue - Lockleaze - Cheswick Village - <span - class="highlighted">Frenchay</span></td> - </tr> - <tr> - <td>74</td> - <td>Temple Meads Station - City Centre - Montpelier - Gloucester Road - Horfield - Filton - <span - class="highlighted">Frenchay</span></td> - </tr> - <tr> - <td>m1 metrobus (U3 overnight between UWE Frenchay & City Centre)</td> - <td>Cribbs Causeway - Aztec West - Bradley Stoke - <span class="highlighted">Frenchay</span> - Stoke Park - - Begbrook - City Centre - Bedminster - Inns Court - Hengrove Park - </td> - </tr> - <tr> - <td>m3 metrobus</td> - <td>City Centre - Begbrook - Stoke Park - <span class="highlighted">Frenchay</span> - Hambrook - Willy - Wicket - Emerald Park - Science Park - Lyde Green P&R - Emersons Green - </td> - </tr> - <tr> - <td>m4 metrobus</td> - <td>City Centre - Begbrook - Stoke Park - <span class="highlighted">Frenchay</span> - Bristol Parkway - Station - Cribbs Causeway - </td> - </tr> + <?php foreach ($buses as $bus): ?> + <tr> + <td><?php echo htmlspecialchars($bus['service']); ?></td> + <td><?php echo htmlspecialchars($bus['bus_path']); ?></td> + </tr> + <?php endforeach; ?> </tbody> </table> diff --git a/Presentation/interface.php b/Presentation/interface.php index 2694d84d5cb0249722d9e99cb3313367ef915136..017248db9bd527bf0215422f051bfebc8779bda3 100644 --- a/Presentation/interface.php +++ b/Presentation/interface.php @@ -32,9 +32,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { <div id="appContainer"> - <div id="topbar"> - <div id="logo">UWE Student Assistant</div> - </div> +<!-- <div id="topbar">--> +<!-- <div id="logo">UWE Student Assistant</div>--> +<!-- </div>--> <div id="sidebar"> <a href="#" class="sidebar-item" target="contentFrame" data-src="map.php">Around Frenchay Campus</a> diff --git a/Presentation/map.php b/Presentation/map.php index 531e339882bf42ddfafff5ab2cd01f2bdd59731f..c17b8486995307240036f8751b88a7891e1931e8 100644 --- a/Presentation/map.php +++ b/Presentation/map.php @@ -15,7 +15,6 @@ $buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); <link rel="stylesheet" href="../css/map.css?version=1.2"> </head> <body> -<?php include '../Logic/translate.php'; ?> <div id="map" style="height: 500px; width: 100%;"></div> diff --git a/Presentation/settings.php b/Presentation/settings.php index d3785ccc28e79567cf6e04afe93022023b9e4cfc..a32a2d3fa3ed9fe1811b659b392dc257916ff525 100644 --- a/Presentation/settings.php +++ b/Presentation/settings.php @@ -68,13 +68,9 @@ $user = $stmt->fetch(PDO::FETCH_ASSOC); <link rel="stylesheet" href="../css/settings.css"> </head> <body> -<?php include '../Logic/translate.php'; ?> -<div class="container"> - <div id="topbar"> - <div id="logo">UWE Student Assistant</div> - </div> +<div class="container"> <div class="card"> <div class="avatar"> diff --git a/css/chatbotpage.css b/css/chatbotpage.css index 316c6fd306760e28f9ff6d589d9f67d66c4dfdb5..f1c1c5039c0cda245354919e4bd7cb73a0e4535d 100644 --- a/css/chatbotpage.css +++ b/css/chatbotpage.css @@ -15,7 +15,6 @@ html, body { background: #1E1E2E; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); overflow: hidden; - padding-top: 70px; } #chat-history { diff --git a/css/interface.css b/css/interface.css index 3c770248b6982d88d884e09be3a9c683ba15f2a6..8637727dec256cf916493719b5e4fbc172176e79 100644 --- a/css/interface.css +++ b/css/interface.css @@ -18,17 +18,16 @@ body, html { } #sidebar { - width: 150px; /* 更瘦小的宽度 */ + width: 205px; /* 更瘦小的宽度 */ background-color: #232533; /* Dark sidebar */ color: #fff; padding: 20px; - box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.5); /* 设置阴影,使其看起来悬浮 */ + box-shadow: 4px 4px 10px rgba(0, 0, 0, 0); /* 设置阴影,使其看起来悬浮 */ display: flex; flex-direction: column; align-items: center; position: fixed; /* 固定位置 */ top: 10%; /* 设置顶部为视口的50% */ - left: 15px; /* 与左侧边缘保持一定距离 */ bottom: 0; /* 底部对齐 */ overflow-x: hidden; /* 隐藏水平滚动条 */ z-index: 1000; /* 设置z-index确保它在其他内容之上 */