239 lines
11 KiB
PHP
239 lines
11 KiB
PHP
<?php
|
|
require_once 'auth.php';
|
|
require_role('receptionist');
|
|
require_once 'db/config.php';
|
|
|
|
$pdo = db();
|
|
|
|
// Fetch stats for dashboard cards
|
|
$patients_today = $pdo->query("SELECT count(id) FROM patients WHERE DATE(created_at) = CURDATE()")->fetchColumn();
|
|
$total_patients = $pdo->query("SELECT count(id) FROM patients")->fetchColumn();
|
|
$total_revenue = $pdo->query("SELECT SUM(total_fee) FROM patients WHERE status = 'Completed'")->fetchColumn();
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Reception Dashboard - Hospital Management</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div class="d-flex">
|
|
<!-- Sidebar -->
|
|
<div class="sidebar d-flex flex-column flex-shrink-0 p-3" style="width: 280px;">
|
|
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none">
|
|
<i class="bi bi-heart-pulse-fill me-2"></i>
|
|
<span class="fs-4">ClinicSys</span>
|
|
</a>
|
|
<hr>
|
|
<nav class="sidebar-nav">
|
|
<a href="reception.php" class="nav-link active">
|
|
<i class="bi bi-people-fill"></i>
|
|
<span>Reception</span>
|
|
</a>
|
|
<a href="billing.php" class="nav-link">
|
|
<i class="bi bi-receipt"></i>
|
|
<span>Billing</span>
|
|
</a>
|
|
<a href="lab_imaging_config.php" class="nav-link">
|
|
<i class="bi bi-gear-fill"></i>
|
|
<span>Test Config</span>
|
|
</a>
|
|
<a href="lab_reports.php" class="nav-link">
|
|
<i class="bi bi-file-earmark-medical"></i>
|
|
<span>Lab Reports</span>
|
|
</a>
|
|
<a href="pharmacy.php" class="nav-link">
|
|
<i class="bi bi-capsule-pill"></i>
|
|
<span>Pharmacy</span>
|
|
</a>
|
|
<a href="doctor_dashboard.php" class="nav-link">
|
|
<i class="bi bi-person-fill"></i>
|
|
<span>Doctor</span>
|
|
</a>
|
|
</nav>
|
|
<hr>
|
|
<div class="dropdown">
|
|
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<i class="bi bi-person-circle me-2"></i>
|
|
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
|
</a>
|
|
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
|
|
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<div class="main-content flex-grow-1 p-4">
|
|
<header class="d-flex justify-content-between align-items-center mb-4">
|
|
<h1 class="h3 mb-0 text-gray-800">Receptionist Dashboard</h1>
|
|
<div class="search-container">
|
|
<input type="text" id="patientSearch" class="form-control" placeholder="Search Patient by Name or ID...">
|
|
<div id="searchResults" class="search-results"></div>
|
|
</div>
|
|
<a href="patient_register.php" class="btn btn-primary-custom">
|
|
<i class="bi bi-person-plus-fill me-2"></i>
|
|
Register New Patient
|
|
</a>
|
|
</header>
|
|
|
|
<!-- Info Cards -->
|
|
<div class="row">
|
|
<div class="col-xl-4 col-md-6 mb-4">
|
|
<div class="card border-left-primary shadow h-100 py-2">
|
|
<div class="card-body">
|
|
<div class="row no-gutters align-items-center">
|
|
<div class="col mr-2">
|
|
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
|
|
Patients Registered (Today)</div>
|
|
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $patients_today; ?></div>
|
|
</div>
|
|
<div class="col-auto">
|
|
<i class="bi bi-calendar-day fs-2 text-gray-300"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-xl-4 col-md-6 mb-4">
|
|
<div class="card border-left-success shadow h-100 py-2">
|
|
<div class="card-body">
|
|
<div class="row no-gutters align-items-center">
|
|
<div class="col mr-2">
|
|
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">
|
|
Total Patients</div>
|
|
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $total_patients; ?></div>
|
|
</div>
|
|
<div class="col-auto">
|
|
<i class="bi bi-people-fill fs-2 text-gray-300"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-xl-4 col-md-6 mb-4">
|
|
<div class="card border-left-info shadow h-100 py-2">
|
|
<div class="card-body">
|
|
<div class="row no-gutters align-items-center">
|
|
<div class="col mr-2">
|
|
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">Total Revenue
|
|
</div>
|
|
<div class="h5 mb-0 font-weight-bold text-gray-800">$<?php echo number_format($total_revenue, 2); ?></div>
|
|
</div>
|
|
<div class="col-auto">
|
|
<i class="bi bi-currency-dollar fs-2 text-gray-300"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Patient List -->
|
|
<div class="card shadow">
|
|
<div class="card-header py-3">
|
|
<h6 class="m-0 font-weight-bold text-primary"><?php echo isset($_GET['search_query']) ? 'Search Results' : 'Recent Patients'; ?></h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
|
|
<thead>
|
|
<tr>
|
|
<th>Patient ID</th>
|
|
<th>Patient Name</th>
|
|
<th>Phone Number</th>
|
|
<th>Registration Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$sql = "SELECT * FROM patients ORDER BY created_at DESC LIMIT 10";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute();
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
while ($row = $stmt->fetch()) {
|
|
echo "<tr>";
|
|
echo "<td><a href='patient_profile.php?id=" . $row['id'] . "'>" . htmlspecialchars($row['patient_id']) . "</a></td>";
|
|
echo "<td><a href='patient_profile.php?id=" . $row['id'] . "'>" . htmlspecialchars($row['patient_name']) . "</a></td>";
|
|
echo "<td>" . htmlspecialchars($row['phone']) . "</td>";
|
|
echo "<td>" . date("Y-m-d H:i", strtotime($row['created_at'])) . "</td>";
|
|
echo "</tr>";
|
|
}
|
|
} else {
|
|
echo '<tr><td colspan="4" class="text-center">No patients found.</td></tr>';
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script>
|
|
document.getElementById('patientSearch').addEventListener('input', function() {
|
|
const searchTerm = this.value;
|
|
const resultsContainer = document.getElementById('searchResults');
|
|
|
|
if (searchTerm.length < 2) {
|
|
resultsContainer.innerHTML = '';
|
|
resultsContainer.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
fetch(`search_patient.php?term=${encodeURIComponent(searchTerm)}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
resultsContainer.innerHTML = '';
|
|
if (data.length > 0) {
|
|
data.forEach(patient => {
|
|
const patientLink = document.createElement('a');
|
|
patientLink.href = `patient_profile.php?id=${patient.id}`;
|
|
patientLink.textContent = `${patient.patient_name} (${patient.patient_id})`;
|
|
resultsContainer.appendChild(patientLink);
|
|
});
|
|
resultsContainer.style.display = 'block';
|
|
} else {
|
|
resultsContainer.innerHTML = '<a href="#" class="disabled">No patients found</a>';
|
|
resultsContainer.style.display = 'block';
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
resultsContainer.innerHTML = '<a href="#" class="disabled">Search error</a>';
|
|
resultsContainer.style.display = 'block';
|
|
});
|
|
});
|
|
|
|
// Hide results when clicking outside
|
|
document.addEventListener('click', function(e) {
|
|
const searchContainer = document.querySelector('.search-container');
|
|
if (searchContainer && !searchContainer.contains(e.target)) {
|
|
const resultsContainer = document.getElementById('searchResults');
|
|
if (resultsContainer) {
|
|
resultsContainer.style.display = 'none';
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|