zhensolid 1 anno fa
parent
commit
c3af3d091a
7 ha cambiato i file con 376 aggiunte e 216 eliminazioni
  1. 40 0
      add_record.php
  2. 85 0
      byc_mysql.sql
  3. 0 149
      css/style.css
  4. 207 0
      css/styles.css
  5. 0 39
      index.html
  6. 34 21
      index.php
  7. 10 7
      search.php

+ 40 - 0
add_record.php

@@ -0,0 +1,40 @@
+<?php
+require 'config.php';
+
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+    $debtorName = $_POST['debtorName'];
+    $repaymentDate = $_POST['repaymentDate'];
+    $repaymentMethod = $_POST['repaymentMethod'];
+    $repaymentAmount = $_POST['repaymentAmount'];
+    $comments = $_POST['comments'];
+
+    $stmt = $pdo->prepare("INSERT INTO repayments (debtor_name, repayment_date, repayment_method, repayment_amount, comments) VALUES (:debtorName, :repaymentDate, :repaymentMethod, :repaymentAmount, :comments)");
+    $stmt->execute([
+        'debtorName' => $debtorName,
+        'repaymentDate' => $repaymentDate,
+        'repaymentMethod' => $repaymentMethod,
+        'repaymentAmount' => $repaymentAmount,
+        'comments' => $comments
+    ]);
+
+    header('Location: index.php');
+    exit;
+}
+?>
+
+<!DOCTYPE html>
+<html>
+<head>
+    <title>新增还款记录</title>
+</head>
+<body>
+    <form method="POST">
+        <label>姓名: <input type="text" name="debtorName" required></label><br>
+        <label>还款日期: <input type="date" name="repaymentDate" required></label><br>
+        <label>还款方式: <input type="text" name="repaymentMethod" value="微信"></label><br>
+        <label>还款金额: <input type="number" step="0.01" name="repaymentAmount" required></label><br>
+        <label>备注: <input type="text" name="comments"></label><br>
+        <button type="submit">完成</button>
+    </form>
+</body>
+</html> 

+ 85 - 0
byc_mysql.sql

@@ -0,0 +1,85 @@
+/*
+ Navicat Premium Dump SQL
+
+ Source Server         : Oracle_byc_mysql
+ Source Server Type    : MySQL
+ Source Server Version : 80036 (8.0.36)
+ Source Host           : 139.185.41.147:3306
+ Source Schema         : byc_mysql
+
+ Target Server Type    : MySQL
+ Target Server Version : 80036 (8.0.36)
+ File Encoding         : 65001
+
+ Date: 10/11/2024 17:29:00
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for debtors
+-- ----------------------------
+DROP TABLE IF EXISTS `debtors`;
+CREATE TABLE `debtors`  (
+  `id` int NOT NULL AUTO_INCREMENT,
+  `debtor_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+  `total_amount` decimal(10, 2) NULL DEFAULT 110000.00,
+  `last_updated` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`) USING BTREE,
+  UNIQUE INDEX `debtor_name`(`debtor_name` ASC) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
+
+-- ----------------------------
+-- Records of debtors
+-- ----------------------------
+INSERT INTO `debtors` VALUES (1, '白宇超', 122500.00, '2024-11-01 10:32:08');
+
+-- ----------------------------
+-- Table structure for repayments
+-- ----------------------------
+DROP TABLE IF EXISTS `repayments`;
+CREATE TABLE `repayments`  (
+  `id` int NOT NULL AUTO_INCREMENT,
+  `debtor_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+  `repayment_date` date NOT NULL,
+  `repayment_method` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '微信',
+  `repayment_amount` decimal(10, 2) NULL DEFAULT 1250.00,
+  `comments` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+  PRIMARY KEY (`id`) USING BTREE,
+  INDEX `debtor_name`(`debtor_name` ASC) USING BTREE,
+  CONSTRAINT `repayments_ibfk_1` FOREIGN KEY (`debtor_name`) REFERENCES `debtors` (`debtor_name`) ON DELETE CASCADE ON UPDATE RESTRICT
+) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
+
+-- ----------------------------
+-- Records of repayments
+-- ----------------------------
+INSERT INTO `repayments` VALUES (4, '白宇超', '2024-03-12', '微信', 2500.00, NULL);
+INSERT INTO `repayments` VALUES (5, '白宇超', '2024-04-12', '微信', 1250.00, NULL);
+INSERT INTO `repayments` VALUES (6, '白宇超', '2024-05-13', '微信', 1250.00, NULL);
+INSERT INTO `repayments` VALUES (7, '白宇超', '2024-06-12', '微信', 1250.00, NULL);
+INSERT INTO `repayments` VALUES (8, '白宇超', '2024-07-12', '微信', 1250.00, NULL);
+INSERT INTO `repayments` VALUES (9, '白宇超', '2024-08-12', '微信', 1250.00, NULL);
+INSERT INTO `repayments` VALUES (10, '白宇超', '2024-09-12', '微信', 1250.00, NULL);
+INSERT INTO `repayments` VALUES (11, '白宇超', '2024-10-12', '微信', 1250.00, NULL);
+
+-- ----------------------------
+-- View structure for debtstatus
+-- ----------------------------
+DROP VIEW IF EXISTS `debtstatus`;
+CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `debtstatus` AS select `d`.`debtor_name` AS `姓名`,`d`.`total_amount` AS `总欠款金额`,(`d`.`total_amount` - ifnull(sum(`r`.`repayment_amount`),0)) AS `剩余欠款金额` from (`debtors` `d` left join `repayments` `r` on((`d`.`debtor_name` = `r`.`debtor_name`))) group by `d`.`id`,`d`.`debtor_name`,`d`.`total_amount`;
+
+-- ----------------------------
+-- Event structure for monthly_increase
+-- ----------------------------
+DROP EVENT IF EXISTS `monthly_increase`;
+delimiter ;;
+CREATE EVENT `monthly_increase`
+ON SCHEDULE
+EVERY '1' MONTH STARTS '2024-12-01 00:00:00'
+DO UPDATE Debtors
+    SET total_amount = total_amount + 1250
+;;
+delimiter ;
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 0 - 149
css/style.css

@@ -1,149 +0,0 @@
-body { 
-    display: flex; 
-    align-items: center; 
-    justify-content: center; 
-    height: 100vh; 
-    font-family: Arial, sans-serif; 
-}
-
-.container { 
-    text-align: center; 
-}
-
-.search-bar { 
-    padding: 10px; 
-    font-size: 16px; 
-    width: 300px; 
-}
-
-.button { 
-    padding: 10px 20px; 
-    font-size: 16px; 
-}
-
-.result {
-    margin-top: 20px;
-    padding: 20px;
-    border-radius: 8px;
-    background-color: #f8f9fa;
-    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
-    max-width: 600px;
-    margin-left: auto;
-    margin-right: auto;
-}
-
-.result-item {
-    padding: 15px;
-    border-bottom: 1px solid #dee2e6;
-    text-align: left;
-}
-
-.result-item:last-child {
-    border-bottom: none;
-}
-
-.result-label {
-    font-weight: bold;
-    color: #495057;
-    margin-right: 10px;
-}
-
-.result-value {
-    color: #212529;
-}
-
-.no-result {
-    color: #dc3545;
-    padding: 15px;
-}
-
-.success-result {
-    color: #28a745;
-}
-
-/* 搜索结果样式 */
-.result-header {
-    margin-bottom: 30px;
-    padding-bottom: 15px;
-    border-bottom: 2px solid #eee;
-}
-
-.debtor-name {
-    color: #2c3e50;
-    margin: 0 0 10px 0;
-}
-
-.remaining-debt {
-    font-size: 18px;
-    color: #34495e;
-}
-
-.remaining-debt span {
-    font-weight: bold;
-    color: #e74c3c;
-}
-
-.repayment-section h3 {
-    color: #2c3e50;
-    margin-bottom: 20px;
-}
-
-.repayment-list {
-    display: flex;
-    flex-direction: column;
-    gap: 15px;
-}
-
-.repayment-item {
-    display: flex;
-    padding: 15px;
-    background: white;
-    border-radius: 8px;
-    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
-    transition: transform 0.2s;
-}
-
-.repayment-item:hover {
-    transform: translateY(-2px);
-    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
-}
-
-.repayment-date {
-    min-width: 100px;
-    color: #7f8c8d;
-    font-size: 14px;
-}
-
-.repayment-details {
-    flex: 1;
-    display: flex;
-    align-items: center;
-    gap: 20px;
-}
-
-.repayment-amount {
-    font-weight: bold;
-    color: #27ae60;
-    font-size: 16px;
-}
-
-.repayment-method {
-    color: #34495e;
-    background: #f7f9fc;
-    padding: 4px 12px;
-    border-radius: 4px;
-    font-size: 14px;
-}
-
-.repayment-comment {
-    color: #95a5a6;
-    font-size: 14px;
-}
-
-.no-repayments, .no-result, .no-input {
-    color: #7f8c8d;
-    text-align: center;
-    padding: 20px;
-    background: #f8f9fa;
-    border-radius: 8px;
-} 

+ 207 - 0
css/styles.css

@@ -0,0 +1,207 @@
+body {
+    font-family: Arial, sans-serif;
+    background-color: #f4f4f9;
+    margin: 0;
+    padding: 0;
+}
+.container {
+    max-width: 800px;
+    margin: 50px auto;
+    padding: 20px;
+    background-color: #fff;
+    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
+    border-radius: 8px;
+}
+h1 {
+    text-align: center;
+    color: #333;
+}
+.search-bar {
+    width: calc(100% - 22px);
+    padding: 10px;
+    margin-bottom: 10px;
+    border: 1px solid #ddd;
+    border-radius: 4px;
+}
+.button {
+    padding: 10px 20px;
+    margin: 5px;
+    background-color: #007bff;
+    color: #fff;
+    border: none;
+    border-radius: 4px;
+    cursor: pointer;
+}
+.button:hover {
+    background-color: #0056b3;
+}
+.result {
+    margin-top: 20px;
+}
+.pagination {
+    display: flex;
+    justify-content: center;
+    margin-top: 20px;
+}
+.page-item {
+    margin: 0 5px;
+    cursor: pointer;
+    color: #007bff;
+}
+.page-item.active {
+    font-weight: bold;
+    color: #333;
+}
+
+/* 查询结果表格样式 */
+.result table {
+    width: 100%;
+    border-collapse: collapse;
+    margin-top: 20px;
+    background-color: #fff;
+    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
+}
+
+.result th, .result td {
+    padding: 12px;
+    text-align: left;
+    border-bottom: 1px solid #ddd;
+}
+
+.result th {
+    background-color: #f5f5f5;
+    font-weight: bold;
+    color: #333;
+}
+
+.result tr:hover {
+    background-color: #f9f9f9;
+}
+
+/* 空结果样式 */
+.no-result {
+    padding: 20px;
+    text-align: center;
+    color: #666;
+    background-color: #f9f9f9;
+    border-radius: 4px;
+    margin-top: 20px;
+}
+
+/* 错误消息样式 */
+.error-message {
+    padding: 10px;
+    color: #721c24;
+    background-color: #f8d7da;
+    border: 1px solid #f5c6cb;
+    border-radius: 4px;
+    margin-top: 20px;
+}
+
+/* 搜索结果容器 */
+.search-result {
+    max-width: 800px;
+    margin: 20px auto;
+    padding: 20px;
+    background: #fff;
+    border-radius: 8px;
+    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
+}
+
+/* 结果头部样式 */
+.result-header {
+    border-bottom: 2px solid #eee;
+    padding-bottom: 15px;
+    margin-bottom: 20px;
+}
+
+.debtor-name {
+    color: #333;
+    font-size: 24px;
+    margin: 0 0 10px 0;
+}
+
+.remaining-debt {
+    font-size: 18px;
+    color: #666;
+}
+
+.remaining-debt .amount {
+    color: #e74c3c;
+    font-weight: bold;
+}
+
+/* 还款记录部分 */
+.repayment-section h3 {
+    color: #2c3e50;
+    margin-bottom: 15px;
+}
+
+.repayment-list {
+    display: flex;
+    flex-direction: column;
+    gap: 15px;
+}
+
+.repayment-item {
+    padding: 15px;
+    background: #f8f9fa;
+    border-radius: 6px;
+    border-left: 4px solid #3498db;
+}
+
+.repayment-date {
+    color: #666;
+    font-size: 14px;
+    margin-bottom: 8px;
+}
+
+.repayment-details {
+    display: grid;
+    gap: 8px;
+}
+
+.label {
+    color: #666;
+    font-weight: 500;
+}
+
+.repayment-amount {
+    color: #27ae60;
+    font-weight: bold;
+}
+
+/* 无记录提示 */
+.no-repayments, .no-result, .no-input {
+    text-align: center;
+    padding: 20px;
+    background: #f8f9fa;
+    border-radius: 6px;
+    color: #666;
+}
+
+.no-result, .no-input {
+    margin: 20px auto;
+    max-width: 400px;
+}
+
+/* 图标样式 */
+.fas {
+    margin-right: 8px;
+}
+
+/* 为表单添加样式 */
+#searchForm {
+    display: flex;
+    gap: 10px;
+    margin-bottom: 20px;
+}
+
+/* 为按钮添加不同状态 */
+#addRecordBtn {
+    background-color: #28a745; /* 区分普通查询按钮 */
+}
+
+#addRecordBtn:hover {
+    background-color: #218838;
+} 

+ 0 - 39
index.html

@@ -1,39 +0,0 @@
-<!doctype html>
-<html>
-<head>
-    <meta charset="utf-8">
-    <title>恭喜,站点创建成功!</title>
-    <style>
-        .container {
-            width: 60%;
-            margin: 10% auto 0;
-            background-color: #f0f0f0;
-            padding: 2% 5%;
-            border-radius: 10px
-        }
-
-        ul {
-            padding-left: 20px;
-        }
-
-            ul li {
-                line-height: 2.3
-            }
-
-        a {
-            color: #20a53a
-        }
-    </style>
-</head>
-<body>
-    <div class="container">
-        <h1>恭喜, 站点创建成功!</h1>
-        <h3>这是默认index.html,本页面由系统自动生成</h3>
-        <ul>
-            <li>本页面在FTP根目录下的index.html</li>
-            <li>您可以修改、删除或覆盖本页面</li>
-            <li>FTP相关信息,请到“面板系统后台 > FTP” 查看</li>
-        </ul>
-    </div>
-</body>
-</html>

+ 34 - 21
index.php

@@ -1,30 +1,43 @@
+<?php
+// 确保没有其他 PHP 逻辑会导致页面重定向
+?>
+
 <!DOCTYPE html>
-<html lang="zh-CN">
+<html>
 <head>
-    <meta charset="UTF-8">
     <title>欠款查询系统</title>
-    <link rel="stylesheet" href="css/style.css">
+    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
+    <link rel="stylesheet" type="text/css" href="css/styles.css">
 </head>
 <body>
+    <div class="container">
+        <h1>欠款查询系统</h1>
+        <form id="searchForm">
+            <input type="text" id="debtorName" name="debtorName" placeholder="请输入姓名" class="search-bar" required>
+            <button type="button" onclick="searchDebt()" class="button">查询</button>
+            <!-- 新增记录按钮 -->
+            <button type="button" id="addRecordBtn" class="button">新增记录</button>
+        </form>
+        <div id="result" class="result"></div>
+    </div>
 
-<div class="container">
-    <h1>欠款查询系统</h1>
-    <form id="searchForm">
-        <input type="text" id="debtorName" name="debtorName" placeholder="请输入姓名" class="search-bar" required>
-        <button type="button" onclick="searchDebt()" class="button">查询</button>
-    </form>
-    <div id="result" class="result"></div>
-</div>
-
-<script>
-function searchDebt() {
-    const debtorName = document.getElementById('debtorName').value;
-    fetch(`search.php?debtorName=${encodeURIComponent(debtorName)}`)
-        .then(response => response.text())
-        .then(data => document.getElementById('result').innerHTML = data)
-        .catch(error => console.error('查询出错:', error));
-}
-</script>
+    <script>
+        function searchDebt() {
+            const debtorName = document.getElementById('debtorName').value;
+            fetch(`search.php?debtorName=${encodeURIComponent(debtorName)}`)
+                .then(response => response.text())
+                .then(data => document.getElementById('result').innerHTML = data)
+                .catch(error => console.error('查询出错:', error));
+        }
 
+        document.getElementById('addRecordBtn').addEventListener('click', function() {
+            const password = prompt('请输入密码:');
+            if (password === 'uKPAYkIZ2cFlKPN[') { // 使用数据库管理密码
+                window.location.href = 'add_record.php';
+            } else {
+                alert('密码错误');
+            }
+        });
+    </script>
 </body>
 </html>

+ 10 - 7
search.php

@@ -20,10 +20,12 @@ if (isset($_GET['debtorName'])) {
         $viewStmt->execute(['debtorName' => $debtorName]);
         $viewData = $viewStmt->fetch(PDO::FETCH_ASSOC);
 
+        echo "<div class='search-result'>";
+
         // 更新后的输出格式
         echo "<div class='result-header'>";
         echo "<h2 class='debtor-name'>{$debtor['debtor_name']}</h2>";
-        echo "<p class='remaining-debt'>当前欠款余额: <span>¥{$viewData['剩余欠款金额']}</span></p>";
+        echo "<p class='remaining-debt'>当前欠款余额: <span class='amount'>¥{$viewData['剩余欠款金额']}</span></p>";
         echo "</div>";
 
         echo "<div class='repayment-section'>";
@@ -33,12 +35,12 @@ if (isset($_GET['debtorName'])) {
             echo "<div class='repayment-list'>";
             foreach ($repayments as $repayment) {
                 echo "<div class='repayment-item'>";
-                echo "<div class='repayment-date'>{$repayment['repayment_date']}</div>";
+                echo "<div class='repayment-date'><span class='label'>日期:</span> {$repayment['repayment_date']}</div>";
                 echo "<div class='repayment-details'>";
-                echo "<div class='repayment-amount'>¥{$repayment['repayment_amount']}</div>";
-                echo "<div class='repayment-method'>{$repayment['repayment_method']}</div>";
+                echo "<div class='repayment-amount'><span class='label'>金额:</span> ¥{$repayment['repayment_amount']}</div>";
+                echo "<div class='repayment-method'><span class='label'>支付方式:</span> {$repayment['repayment_method']}</div>";
                 if (!empty($repayment['comments'])) {
-                    echo "<div class='repayment-comment'>{$repayment['comments']}</div>";
+                    echo "<div class='repayment-comment'><span class='label'>备注:</span> {$repayment['comments']}</div>";
                 }
                 echo "</div>";
                 echo "</div>";
@@ -48,10 +50,11 @@ if (isset($_GET['debtorName'])) {
             echo "<p class='no-repayments'>暂无还款记录</p>";
         }
         echo "</div>";
+        echo "</div>";
     } else {
-        echo "<div class='no-result'>未找到相关记录</div>";
+        echo "<div class='no-result'><i class='fas fa-exclamation-circle'></i> 未找到相关记录</div>";
     }
 } else {
-    echo "<div class='no-input'>请输入姓名进行查询</div>";
+    echo "<div class='no-input'><i class='fas fa-info-circle'></i> 请输入姓名进行查询</div>";
 }
 ?>