-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mac Air
authored and
Mac Air
committed
Nov 25, 2024
1 parent
768c019
commit bea75b0
Showing
36 changed files
with
1,723 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| <?php | ||
| // Include the database config and any necessary functions | ||
| require '../config/jkl_config.php'; | ||
|
|
||
| // Fetch statistics from the database | ||
| // Function to get the total number of patients | ||
| function getTotalPatients() { | ||
| global $pdo; | ||
| $stmt = $pdo->prepare("SELECT COUNT(*) FROM patients"); | ||
| $stmt->execute(); | ||
| return $stmt->fetchColumn(); | ||
| } | ||
|
|
||
| // Function to get the total number of caregivers | ||
| function getTotalCaregivers() { | ||
| global $pdo; | ||
| $stmt = $pdo->prepare("SELECT COUNT(*) FROM caregivers"); | ||
| $stmt->execute(); | ||
| return $stmt->fetchColumn(); | ||
| } | ||
|
|
||
| // Function to get the total number of appointments | ||
| function getTotalAppointments() { | ||
| global $pdo; | ||
| $stmt = $pdo->prepare("SELECT COUNT(*) FROM appointments"); | ||
| $stmt->execute(); | ||
| return $stmt->fetchColumn(); | ||
| } | ||
|
|
||
| // Function to get the number of upcoming appointments (within the next 7 days) | ||
| function getUpcomingAppointments() { | ||
| global $pdo; | ||
| $stmt = $pdo->prepare("SELECT COUNT(*) FROM appointments WHERE appointment_date >= CURDATE() AND appointment_date <= DATE_ADD(CURDATE(), INTERVAL 7 DAY)"); | ||
| $stmt->execute(); | ||
| return $stmt->fetchColumn(); | ||
| } | ||
|
|
||
| // Function to fetch available caregivers | ||
| function getAvailableCaregivers() { | ||
| global $pdo; | ||
| $stmt = $pdo->prepare(" | ||
| SELECT c.name | ||
| FROM caregivers c | ||
| WHERE c.id NOT IN (SELECT caregiver_id FROM caregiver_assignments) | ||
| "); | ||
| $stmt->execute(); | ||
| return $stmt->fetchAll(PDO::FETCH_ASSOC); | ||
| } | ||
|
|
||
| // Get statistics | ||
| $totalPatients = getTotalPatients(); | ||
| $totalCaregivers = getTotalCaregivers(); | ||
| $totalAppointments = getTotalAppointments(); | ||
| $upcomingAppointments = getUpcomingAppointments(); | ||
| $availableCaregivers = getAvailableCaregivers(); // Fetch available caregivers | ||
| ?> | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> | ||
| <link rel="stylesheet" href="../assets/css/jkl_styles.css"> | ||
| <title>Admin Dashboard</title> | ||
| </head> | ||
| <body> | ||
| <!-- Admin Navbar --> | ||
| <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | ||
| <a class="navbar-brand" href="#">JKL Healthcare Admin</a> | ||
| <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> | ||
| <span class="navbar-toggler-icon"></span> | ||
| </button> | ||
| <div class="collapse navbar-collapse" id="navbarNav"> | ||
| <ul class="navbar-nav ml-auto"> | ||
| <li class="nav-item active"> | ||
| <a class="nav-link" href="admin_dashboard.php">Dashboard</a> | ||
| </li> | ||
| <li class="nav-item"> | ||
| <a class="nav-link" href="manage_caregivers.php">Manage Caregivers</a> | ||
| </li> | ||
| <li class="nav-item"> | ||
| <a class="nav-link" href="manage_appointments.php">Manage Appointments</a> | ||
| </li> | ||
| <li class="nav-item"> | ||
| <a class="nav-link" href="track_caregiver_availability.php">Carer Availability</a> | ||
| </li> | ||
| <li class="nav-item"> | ||
| <a class="nav-link" href="admin_logout.php">Logout</a> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| </nav> | ||
|
|
||
| <div class="container mt-4"> | ||
| <h4>Welcome, Admin!</h4> | ||
| <p>This is the dashboard. Here you can monitor and manage various aspects of the healthcare system.</p> | ||
|
|
||
| <!-- Statistics Section --> | ||
| <div class="row"> | ||
| <!-- Total Patients --> | ||
| <div class="col-md-3"> | ||
| <div class="card text-white bg-primary mb-3"> | ||
| <div class="card-header">Total Patients</div> | ||
| <div class="card-body"> | ||
| <h5 class="card-title"><?php echo $totalPatients; ?></h5> | ||
| <p class="card-text">The total number of registered patients in the system.</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Total Caregivers --> | ||
| <div class="col-md-3"> | ||
| <div class="card text-white bg-success mb-3"> | ||
| <div class="card-header">Total Caregivers</div> | ||
| <div class="card-body"> | ||
| <h5 class="card-title"><?php echo $totalCaregivers; ?></h5> | ||
| <p class="card-text">The total number of caregivers available to patients.</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Total Appointments --> | ||
| <div class="col-md-3"> | ||
| <div class="card text-white bg-warning mb-3"> | ||
| <div class="card-header">Total Appointments</div> | ||
| <div class="card-body"> | ||
| <h5 class="card-title"><?php echo $totalAppointments; ?></h5> | ||
| <p class="card-text">The total number of appointments scheduled in the system.</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Upcoming Appointments (Next 7 days) --> | ||
| <div class="col-md-3"> | ||
| <div class="card text-white bg-info mb-3"> | ||
| <div class="card-header">Upcoming Appointments</div> | ||
| <div class="card-body"> | ||
| <h5 class="card-title"><?php echo $upcomingAppointments; ?></h5> | ||
| <p class="card-text">Appointments scheduled within the next 7 days.</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Carer Availability Section --> | ||
| <div id="carer-availability" class="mt-5"> | ||
| <h4>Carer Availability</h4> | ||
| <div class="card"> | ||
| <div class="card-header">Available Carers</div> | ||
| <div class="card-body"> | ||
| <ul class="list-group"> | ||
| <?php if (!empty($availableCaregivers)): ?> | ||
| <?php foreach ($availableCaregivers as $caregiver): ?> | ||
| <li class="list-group-item"><?php echo htmlspecialchars($caregiver['name']); ?></li> | ||
| <?php endforeach; ?> | ||
| <?php else: ?> | ||
| <li class="list-group-item">No carers are currently available.</li> | ||
| <?php endif; ?> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Include Bootstrap JS and dependencies --> | ||
| <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script> | ||
| <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||
| </body> | ||
| </html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| <?php | ||
| // admin_login.php | ||
| session_start(); | ||
| $errors = []; | ||
|
|
||
| // Check if the admin is already logged in, if so, redirect to the dashboard | ||
| if (isset($_SESSION['admin_id'])) { | ||
| header("Location: admin_dashboard.php"); | ||
| exit(); | ||
| } | ||
|
|
||
| // Process login when the form is submitted | ||
| if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
| $email = trim($_POST['email']); | ||
| $password = trim($_POST['password']); | ||
|
|
||
| // Simple validation | ||
| if (empty($email) || empty($password)) { | ||
| $errors[] = 'Please fill in both fields.'; | ||
| } | ||
|
|
||
| if (empty($errors)) { | ||
| // Include database configuration file | ||
| require '../config/jkl_config.php'; | ||
|
|
||
| // Check if the admin exists in the database | ||
| $stmt = $pdo->prepare("SELECT * FROM admins WHERE email = ?"); | ||
| $stmt->execute([$email]); | ||
| $admin = $stmt->fetch(); | ||
|
|
||
| // Verify the password | ||
| if ($admin && password_verify($password, $admin['password'])) { | ||
| // Store the admin ID in session | ||
| $_SESSION['admin_id'] = $admin['id']; | ||
| header("Location: admin_dashboard.php"); // Redirect to dashboard | ||
| exit(); | ||
| } else { | ||
| $errors[] = 'Invalid credentials. Please try again.'; | ||
| } | ||
| } | ||
| } | ||
| ?> | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> | ||
| <title>Admin Login</title> | ||
| </head> | ||
| <body> | ||
| <div class="container mt-5"> | ||
| <div class="row justify-content-center"> | ||
| <div class="col-md-4"> | ||
| <div class="card"> | ||
| <div class="card-header text-center"> | ||
| <h3>Admin Login</h3> | ||
| </div> | ||
| <div class="card-body"> | ||
| <?php if (!empty($errors)): ?> | ||
| <div class="alert alert-danger"> | ||
| <?php foreach ($errors as $error): ?> | ||
| <p><?php echo $error; ?></p> | ||
| <?php endforeach; ?> | ||
| </div> | ||
| <?php endif; ?> | ||
|
|
||
| <form method="POST"> | ||
| <div class="form-group"> | ||
| <label for="email">Email</label> | ||
| <input type="email" name="email" id="email" class="form-control" required> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="password">Password</label> | ||
| <input type="password" name="password" id="password" class="form-control" required> | ||
| </div> | ||
| <button type="submit" class="btn btn-primary btn-block">Login</button> | ||
| </form> | ||
| </div> | ||
| <div class="card-footer text-center"> | ||
| <p>Not an admin? <a href="">Patient Login</a></p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script> | ||
| <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||
| </body> | ||
| </html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <?php | ||
| session_start(); | ||
| session_destroy(); | ||
| header('Location: admin_login.php'); | ||
| exit(); | ||
| ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| <?php | ||
| // admin_register.php (for adding the first admin) | ||
|
|
||
| require '../config/jkl_config.php'; // Database config | ||
|
|
||
| // Check if the admin is already logged in | ||
| if (isset($_SESSION['admin_id'])) { | ||
| header("Location: admin_dashboard.php"); | ||
| exit(); | ||
| } | ||
|
|
||
| // Initialize variables | ||
| $email = $password = ''; | ||
| $errors = []; | ||
|
|
||
| // Process registration when the form is submitted | ||
| if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
| $email = trim($_POST['email']); | ||
| $password = trim($_POST['password']); | ||
|
|
||
| // Validate inputs | ||
| if (empty($email) || empty($password)) { | ||
| $errors[] = 'Please fill in both fields.'; | ||
| } | ||
|
|
||
| if (empty($errors)) { | ||
| // Hash the password before storing it | ||
| $hashed_password = password_hash($password, PASSWORD_DEFAULT); | ||
|
|
||
| // Insert admin into the database | ||
| $stmt = $pdo->prepare("INSERT INTO admins (email, password) VALUES (?, ?)"); | ||
| if ($stmt->execute([$email, $hashed_password])) { | ||
| // Redirect to login page | ||
| header("Location: admin_login.php"); | ||
| exit(); | ||
| } else { | ||
| $errors[] = 'Registration failed. Please try again.'; | ||
| } | ||
| } | ||
| } | ||
| ?> | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> | ||
| <title>Register Admin</title> | ||
| </head> | ||
| <body> | ||
| <div class="container mt-5"> | ||
| <div class="row justify-content-center"> | ||
| <div class="col-md-4"> | ||
| <div class="card"> | ||
| <div class="card-header text-center"> | ||
| <h3>Admin Registration</h3> | ||
| </div> | ||
| <div class="card-body"> | ||
| <?php if (!empty($errors)): ?> | ||
| <div class="alert alert-danger"> | ||
| <?php foreach ($errors as $error): ?> | ||
| <p><?php echo $error; ?></p> | ||
| <?php endforeach; ?> | ||
| </div> | ||
| <?php endif; ?> | ||
|
|
||
| <form method="POST"> | ||
| <div class="form-group"> | ||
| <label for="email">Email</label> | ||
| <input type="email" name="email" id="email" class="form-control" required> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="password">Password</label> | ||
| <input type="password" name="password" id="password" class="form-control" required> | ||
| </div> | ||
| <button type="submit" class="btn btn-primary btn-block">Register</button> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script> | ||
| <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.