Mini Kabibi Habibi
| Current Path : C:/xampp/htdocs/clinic/ |
|
|
| Current File : C:/xampp/htdocs/clinic/backup_admin_dashboard.php |
<?php
session_start();
include 'includes/db.php';
// ✅ Ensure user is logged in and is an admin
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
header("Location: login.php");
exit();
}
$username = $_SESSION['username'];
$page_title = "Admin Dashboard";
$today = date('Y-m-d');
// ✅ Today's logged patients count
$stmt = $pdo->prepare("SELECT COUNT(*) FROM logs WHERE log_date = :today");
$stmt->execute([':today' => $today]);
$logged_patients_today = $stmt->fetchColumn();
// ✅ Pending patients (no health record yet)
$stmt = $pdo->prepare("
SELECT COUNT(*) FROM logs l
WHERE l.log_date = :today
AND l.id NOT IN (SELECT log_id FROM health_records)
");
$stmt->execute([':today' => $today]);
$pending_count = $stmt->fetchColumn();
// ✅ Pending consultations (record exists but diagnosis or treatment is missing)
$stmt = $pdo->prepare("
SELECT COUNT(*) FROM health_records hr
INNER JOIN logs l ON l.id = hr.log_id
WHERE hr.date = :today
AND (
hr.diagnosis IS NULL OR hr.diagnosis = ''
OR hr.treatment IS NULL OR hr.treatment = ''
)
");
$stmt->execute([':today' => $today]);
$pending_consultations_count = $stmt->fetchColumn();
// ✅ Completed consultations (diagnosis and treatment provided)
$stmt = $pdo->prepare("
SELECT COUNT(*) FROM health_records hr
INNER JOIN logs l ON l.id = hr.log_id
WHERE hr.date = :today
AND hr.diagnosis IS NOT NULL AND hr.diagnosis != ''
AND hr.treatment IS NOT NULL AND hr.treatment != ''
");
$stmt->execute([':today' => $today]);
$completed_count = $stmt->fetchColumn();
// ✅ Total logged patients (all time)
$stmt = $pdo->prepare("SELECT COUNT(*) FROM logs");
$stmt->execute();
$total_logged_patients = $stmt->fetchColumn();
// ✅ Total health records (all time)
$stmt = $pdo->prepare("SELECT COUNT(*) FROM health_records");
$stmt->execute();
$total_health_records = $stmt->fetchColumn();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title><?= htmlspecialchars($page_title) ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" />
<style>
body {
display: flex;
min-height: 100vh;
background-color: #f8f9fa;
}
/* Make sidebar fixed on all screen sizes */
.sidebar {
position: fixed;
top: 0;
left: 0;
height: 100vh; /* full viewport height */
width: 250px; /* fixed width */
background-color: #2c3e50;
color: white;
overflow-y: auto; /* scroll if content is long */
z-index: 1000;
}
/* Sidebar links */
.sidebar a {
color: #ccc;
text-decoration: none;
padding: 15px;
display: block;
transition: 0.3s;
}
.sidebar a:hover {
background-color: #34495e;
color: #fff;
}
/* Main content moves right to avoid sidebar */
.main-content {
margin-left: 250px; /* same width as sidebar */
padding: 40px;
}
/* Optional: adjust padding on small screens */
@media (max-width: 768px) {
.main-content {
margin-left: 250px; /* keep sidebar visible, no collapsing */
padding: 20px;
}
}
.form-card {
background-color: #fff;
border-radius: 10px;
padding: 30px;
box-shadow: 0 0 15px rgba(0,0,0,0.05);
}
h2.page-title {
font-weight: 600;
margin-bottom: 30px;
}
.card {
min-height: 80px;
max-height: 120px;
font-size: 0.9rem;
}
.card-body {
padding: 10px !important;
}
.card-title {
font-size: 1rem;
margin-bottom: 0.5rem;
text-align: center;
}
.card-text {
font-size: 0.9rem;
text-align: center;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
</head>
<body>
<!-- Sidebar -->
<?php include 'sidebar.php'; ?>
<!-- Inside main-content, at the top -->
<button id="sidebarToggle" class="btn btn-outline-primary d-md-none mb-3">
<i class="bi bi-list"></i> Menu
</button>
<!-- Main content -->
<div class="main-content">
<h2>
SDO Batangas City - Clinic Management System (v1.0)<br>
</h2>
<!-- Dashboard Cards -->
<div class="row mt-4">
<!-- Total Logged Patients (All Time) -->
<div class="col-12 col-sm-6 col-md-3">
<div class="card text-white bg-info mb-3">
<div class="card-body">
<h5 class="card-title">Total Logged Patients (All Time)</h5>
<p class="card-text"><?= $total_logged_patients ?> total</p>
</div>
</div>
</div>
<!-- Total Health Records (All Time) -->
<div class="col-12 col-sm-6 col-md-3">
<div class="card text-white bg-danger mb-3">
<div class="card-body">
<h5 class="card-title">Total Health Records (All Time)</h5>
<p class="card-text"><?= $total_health_records ?> total</p>
</div>
</div>
</div>
<!-- Total Logged Patients Today -->
<div class="col-12 col-sm-6 col-md-3">
<div class="card text-white bg-primary mb-3">
<div class="card-body">
<h5 class="card-title">Total Logged Patients Today</h5>
<p class="card-text"><?= $logged_patients_today ?> total</p>
</div>
</div>
</div>
<!-- Pending Initial Assessments -->
<div class="col-12 col-sm-6 col-md-3">
<a href="initial_assessment.php" class="text-decoration-none">
<div class="card text-dark bg-warning mb-3">
<div class="card-body">
<h5 class="card-title">Pending Assessments Today</h5>
<p class="card-text"><?= $pending_count ?> total</p>
</div>
</div>
</a>
</div>
<!-- Pending Consultations -->
<div class="col-12 col-sm-6 col-md-3">
<a href="consultations.php" class="text-decoration-none">
<div class="card text-white bg-secondary mb-3">
<div class="card-body">
<h5 class="card-title">Pending Consultations Today</h5>
<p class="card-text"><?= $pending_consultations_count ?> total</p>
</div>
</div>
</a>
</div>
<!-- Completed Consultations -->
<div class="col-12 col-sm-6 col-md-3">
<a href="completed_consultations.php" class="text-decoration-none">
<div class="card text-white bg-success mb-3">
<div class="card-body">
<h5 class="card-title">Completed Consultations Today</h5>
<p class="card-text"><?= $completed_count ?> total</p>
</div>
</div>
</a>
</div>
</div>
<!-- 📽️ Local Medical Advertisement Video -->
<div class="mt-5">
<h4 class="mb-3">Medical Advertisement</h4>
<div class="rounded shadow-sm overflow-hidden" style="max-width: 800px;">
<video class="w-100" controls>
<source src="videos/medical_ad.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>