1+ <?php
2+ include '../includes/admin_auth.php ' ;
3+ include '../includes/db.php ' ;
4+ include_once '../includes/functions.php ' ;
5+ /** @var mysqli $conn **/
6+
7+ $ message = "" ;
8+
9+ // Update the fine rate
10+ if ($ _SERVER ['REQUEST_METHOD ' ] == 'POST ' ) {
11+ $ new_rate = $ _POST ['fine_rate ' ];
12+ $ stmt = $ conn ->prepare ("UPDATE settings SET setting_value = ? WHERE setting_key = 'fine_rate' " );
13+ $ stmt ->bind_param ("s " , $ new_rate );
14+
15+ if ($ stmt ->execute ()) {
16+ $ message = "<div class='alert alert-success'>Fine rate updated successfully!</div> " ;
17+ }
18+ }
19+
20+ // Get the current rate to display in the input
21+ $ res = $ conn ->query ("SELECT setting_value FROM settings WHERE setting_key = 'fine_rate' " );
22+ $ current_rate = $ res ->fetch_assoc ()['setting_value ' ];
23+ ?>
24+
25+ <!DOCTYPE html>
26+ <html lang="en">
27+ <head>
28+ <meta charset="UTF-8">
29+ <title>Fine Settings | Admin Panel</title>
30+ <link rel="stylesheet" href="../assets/css/bootstrap.min.css">
31+ <style>
32+ body { background-color: #f8f9fa; }
33+ .sidebar { min-height: 100vh; background-color: #212529; position: fixed; width: 16.666667%; padding-top: 20px; }
34+ .sidebar a { color: #adb5bd; padding: 12px 20px; display: block; text-decoration: none; }
35+ .sidebar a.active { background-color: #007bff; color: white; }
36+ .main-content { margin-left: 16.666667%; padding: 40px; }
37+ </style>
38+ </head>
39+ <body>
40+ <div class="container-fluid">
41+ <div class="row">
42+ <nav class="col-md-2 d-none d-md-block sidebar">
43+ <h4 class="text-center fw-bold mb-4 text-primary">Admin Panel</h4>
44+ <a href="dashboard.php">Dashboard</a>
45+ <a href="add_book.php">Add New Book</a>
46+ <a href="manage_users.php">Manage Users</a>
47+ <a href="view_books.php">View Bookshelf</a>
48+ <a href="fine_settings.php" class="active">Fine Settings</a>
49+ <hr class="text-secondary">
50+ <a href="../logout.php" class="text-danger">Logout</a>
51+ </nav>
52+
53+ <main class="col-md-10 ms-sm-auto px-md-4 main-content">
54+ <h2 class="fw-bold mb-4">Edit Daily Fine Amount</h2>
55+ <?php echo $ message ; ?>
56+
57+ <div class="card shadow-sm p-4" style="max-width: 500px;">
58+ <form method="POST">
59+ <div class="mb-3">
60+ <label class="form-label fw-bold">Daily Fine Rate ($)</label>
61+ <input type="number" step="0.01" name="fine_rate" class="form-control" value="<?php echo e ($ current_rate ); ?> " required>
62+ <div class="form-text">Example: 0.50 for 50 cents per day.</div>
63+ </div>
64+ <button type="submit" class="btn btn-primary">Update Rate</button>
65+ </form>
66+ </div>
67+ </main>
68+ </div>
69+ </div>
70+ </body>
71+ </html>
0 commit comments