version1
This commit is contained in:
parent
eea139a530
commit
f0947adeb2
124
assets/css/custom.css
Normal file
124
assets/css/custom.css
Normal file
@ -0,0 +1,124 @@
|
||||
/* assets/css/custom.css */
|
||||
|
||||
body {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
background-color: #F8F9FA;
|
||||
color: #212529;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background-color: #2c3e50;
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.sidebar .nav-link {
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
border-radius: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.sidebar .nav-link:hover {
|
||||
color: #ffffff;
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.sidebar .nav-link.active {
|
||||
color: #ffffff;
|
||||
background-color: #4A90E2;
|
||||
}
|
||||
|
||||
.sidebar .nav-link .bi {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.sidebar hr {
|
||||
border-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
background-color: #F8F9FA;
|
||||
}
|
||||
|
||||
.btn-primary-custom {
|
||||
background-color: #4A90E2;
|
||||
border-color: #4A90E2;
|
||||
color: #ffffff;
|
||||
padding: 0.75rem 1.25rem;
|
||||
border-radius: 0.5rem;
|
||||
font-weight: 600;
|
||||
transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.btn-primary-custom:hover {
|
||||
background-color: #357ABD;
|
||||
border-color: #357ABD;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
|
||||
}
|
||||
|
||||
.card .card-header {
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #e3e6f0;
|
||||
padding: 1rem 1.25rem;
|
||||
}
|
||||
|
||||
.card .card-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.border-left-primary {
|
||||
border-left: 0.25rem solid #4A90E2 !important;
|
||||
}
|
||||
|
||||
.text-primary {
|
||||
color: #4A90E2 !important;
|
||||
}
|
||||
|
||||
.border-left-success {
|
||||
border-left: 0.25rem solid #1cc88a !important;
|
||||
}
|
||||
|
||||
.text-success {
|
||||
color: #1cc88a !important;
|
||||
}
|
||||
|
||||
.border-left-info {
|
||||
border-left: 0.25rem solid #36b9cc !important;
|
||||
}
|
||||
|
||||
.text-info {
|
||||
color: #36b9cc !important;
|
||||
}
|
||||
|
||||
.text-gray-300 {
|
||||
color: #dddfeb !important;
|
||||
}
|
||||
|
||||
.text-gray-800 {
|
||||
color: #5a5c69 !important;
|
||||
}
|
||||
|
||||
.font-weight-bold {
|
||||
font-weight: 700 !important;
|
||||
}
|
||||
|
||||
.text-xs {
|
||||
font-size: .7rem;
|
||||
}
|
||||
|
||||
.form-control, .form-select {
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.form-control:focus, .form-select:focus {
|
||||
box-shadow: 0 0 0 0.25rem rgba(74, 144, 226, 0.25);
|
||||
border-color: #4A90E2;
|
||||
}
|
||||
17
auth.php
Normal file
17
auth.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Optional: Role-based access control
|
||||
function require_role($role) {
|
||||
if ($_SESSION['role'] !== $role) {
|
||||
// Redirect to a generic dashboard or an error page
|
||||
header("Location: login.php?error=unauthorized");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
144
billing.php
Normal file
144
billing.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist');
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Handle status update
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'mark_paid') {
|
||||
$patient_id_to_update = $_POST['patient_id'] ?? null;
|
||||
if ($patient_id_to_update) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("UPDATE patients SET payment_status = 'paid' WHERE id = ?");
|
||||
$stmt->execute([$patient_id_to_update]);
|
||||
// Redirect to avoid form resubmission
|
||||
header("Location: billing.php");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
// Log error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch unpaid patients
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT p.*, u.username as doctor_name FROM patients p JOIN users u ON p.doctor_id = u.id WHERE p.status = 'Completed' AND p.payment_status = 'unpaid' ORDER BY p.updated_at DESC");
|
||||
$stmt->execute();
|
||||
$unpaid_patients = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$unpaid_patients = [];
|
||||
// Log error
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Billing Management</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<a href="index.php" class="sidebar-brand">
|
||||
<i class="bi bi-heart-pulse-fill"></i>
|
||||
<span>ClinicFlow</span>
|
||||
</a>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="reception.php" class="nav-link">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<span>Reception</span>
|
||||
</a>
|
||||
<a href="billing.php" class="nav-link active">
|
||||
<i class="bi bi-receipt"></i>
|
||||
<span>Billing</span>
|
||||
</a>
|
||||
<a href="doctor_dashboard.php" class="nav-link">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span>Doctor</span>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<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>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<div class="container-fluid">
|
||||
<div class="header">
|
||||
<h1 class="header-title">Billing</h1>
|
||||
<p class="header-subtitle">Manage outstanding payments.</p>
|
||||
</div>
|
||||
|
||||
<div class="card content-card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title-text"><i class="bi bi-hourglass-split me-2"></i>Pending Payments</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Patient Name</th>
|
||||
<th>Doctor</th>
|
||||
<th>Service Rendered</th>
|
||||
<th>Cost</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($unpaid_patients)):
|
||||
foreach ($unpaid_patients as $patient):
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="patient_profile.php?id=<?php echo $patient['id']; ?>"><?php echo htmlspecialchars($patient['patient_name']); ?></a></td>
|
||||
<td>Dr. <?php echo htmlspecialchars($patient['doctor_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($patient['service_rendered']); ?></td>
|
||||
<td>$<?php echo htmlspecialchars(number_format($patient['cost'], 2)); ?></td>
|
||||
<td>
|
||||
<form method="POST" action="billing.php" style="display:inline;">
|
||||
<input type="hidden" name="patient_id" value="<?php echo $patient['id']; ?>">
|
||||
<input type="hidden" name="action" value="mark_paid">
|
||||
<button type="submit" class="btn btn-sm btn-success"><i class="bi bi-check-lg"></i> Mark as Paid</button>
|
||||
</form>
|
||||
<a href="invoice.php?id=<?php echo $patient['id']; ?>" class="btn btn-sm btn-info" target="_blank"><i class="bi bi-printer"></i> Invoice</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else:
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted">No pending payments.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,17 +1,36 @@
|
||||
<?php
|
||||
// Generated by setup_mariadb_project.sh — edit as needed.
|
||||
define('DB_HOST', '127.0.0.1');
|
||||
define('DB_NAME', 'app_35705');
|
||||
define('DB_USER', 'app_35705');
|
||||
define('DB_PASS', 'cdc156d8-b1ec-4426-86fb-b1e546c1a442');
|
||||
// Prevent direct file access
|
||||
if (basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME'])) {
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
function db() {
|
||||
static $pdo;
|
||||
if (!$pdo) {
|
||||
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
|
||||
if ($pdo) {
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
$host = getenv('DB_HOST') ?: '127.0.0.1';
|
||||
$port = getenv('DB_PORT') ?: '3306';
|
||||
$dbname = getenv('DB_NAME') ?: 'app_35705';
|
||||
$user = getenv('DB_USER') ?: 'app_35705';
|
||||
$pass = getenv('DB_PASS') ?: 'cdc156d8-b1ec-4426-86fb-b1e546c1a442';
|
||||
$charset = 'utf8mb4';
|
||||
|
||||
$dsn = "mysql:host=$host;port=$port;dbname=$dbname;charset=$charset";
|
||||
$options = [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
}
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
];
|
||||
|
||||
try {
|
||||
$pdo = new PDO($dsn, $user, $pass, $options);
|
||||
return $pdo;
|
||||
} catch (PDOException $e) {
|
||||
// In a real app, you'd log this error and show a generic message
|
||||
throw new PDOException($e->getMessage(), (int)$e->getCode());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
248
doctor_dashboard.php
Normal file
248
doctor_dashboard.php
Normal file
@ -0,0 +1,248 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('doctor');
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Get doctor ID from session
|
||||
$doctor_id = $_SESSION['user_id'] ?? 0; // Default to 0 if not set
|
||||
|
||||
// Fetch patients assigned to the doctor
|
||||
try {
|
||||
$pdo = db();
|
||||
// Corrected to fetch patients for the logged-in doctor based on the user_id which corresponds to the doctor's ID in the `doctors` table
|
||||
$stmt = $pdo->prepare("SELECT p.* FROM patients p JOIN users u ON p.doctor_id = u.id WHERE u.id = ? AND DATE(p.created_at) = CURDATE() ORDER BY p.created_at DESC");
|
||||
$stmt->execute([$doctor_id]);
|
||||
$patients = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$patients = [];
|
||||
// In a real app, you'd want to log this error
|
||||
}
|
||||
|
||||
// Fetch doctor's details from users table
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->execute([$doctor_id]);
|
||||
$doctor = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$doctor = null;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Doctor's Dashboard</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<a href="index.php" class="sidebar-brand">
|
||||
<i class="bi bi-heart-pulse-fill"></i>
|
||||
<span>ClinicFlow</span>
|
||||
</a>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="reception.php" class="nav-link">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<span>Reception</span>
|
||||
</a>
|
||||
<a href="doctor_dashboard.php" class="nav-link active">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span>Doctor</span>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<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>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<div class="container-fluid">
|
||||
<div class="header">
|
||||
<h1 class="header-title">Doctor's Dashboard</h1>
|
||||
<p class="header-subtitle">Welcome, Dr. <?php echo htmlspecialchars($doctor['username'] ?? 'Doctor'); ?>!</p>
|
||||
</div>
|
||||
|
||||
<!-- Today's Patients -->
|
||||
<div class="card content-card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title-text"><i class="bi bi-list-ul me-2"></i>Today's Appointments</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Patient ID</th>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($patients)):
|
||||
foreach ($patients as $patient):
|
||||
?>
|
||||
<tr id="patient-row-<?php echo $patient['id']; ?>">
|
||||
<td><?php echo htmlspecialchars($patient['patient_id']); ?></td>
|
||||
<td>
|
||||
<a href="patient_profile.php?id=<?php echo $patient['id']; ?>"><?php echo htmlspecialchars($patient['patient_name']); ?></a>
|
||||
</td>
|
||||
<td><span class="badge bg-<?php echo get_status_badge_class($patient['status']); ?>-soft" id="status-<?php echo $patient['id']; ?>"><?php echo htmlspecialchars($patient['status']); ?></span></td>
|
||||
<td id="action-cell-<?php echo $patient['id']; ?>">
|
||||
<?php echo get_action_buttons($patient); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="notes-row" id="notes-row-<?php echo $patient['id']; ?>" style="<?php echo $patient['status'] !== 'In Progress' ? 'display: none;' : ''; ?>">
|
||||
<td colspan="4">
|
||||
<form class="notes-form" data-patient-id="<?php echo $patient['id']; ?>">
|
||||
<div class="mb-3">
|
||||
<label for="notes-<?php echo $patient['id']; ?>" class="form-label">Consultation Notes</label>
|
||||
<textarea class="form-control" id="notes-<?php echo $patient['id']; ?>" rows="3"><?php echo htmlspecialchars($patient['notes'] ?? ''); ?></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8 mb-3">
|
||||
<label for="service-<?php echo $patient['id']; ?>" class="form-label">Service Rendered</label>
|
||||
<input type="text" class="form-control" id="service-<?php echo $patient['id']; ?>" placeholder="e.g., General Consultation">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="cost-<?php echo $patient['id']; ?>" class="form-label">Cost ($)</label>
|
||||
<input type="number" class="form-control" id="cost-<?php echo $patient['id']; ?>" placeholder="e.g., 75.00" step="0.01">
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-sm btn-success">
|
||||
<i class="bi bi-check-circle me-1"></i>Complete Consultation & Bill
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else:
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted">No patients assigned for today.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('click', function(e) {
|
||||
if (e.target.matches('.start-consultation-btn')) {
|
||||
const patientId = e.target.dataset.patientId;
|
||||
updatePatientStatus(patientId, 'In Progress');
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('submit', function(e) {
|
||||
if (e.target.matches('.notes-form')) {
|
||||
e.preventDefault();
|
||||
const patientId = e.target.dataset.patientId;
|
||||
const notes = document.getElementById('notes-' + patientId).value;
|
||||
const service = document.getElementById('service-' + patientId).value;
|
||||
const cost = document.getElementById('cost-' + patientId).value;
|
||||
updatePatientStatus(patientId, 'Completed', notes, service, cost);
|
||||
}
|
||||
});
|
||||
|
||||
function updatePatientStatus(patientId, status, notes = null, service = null, cost = null) {
|
||||
const formData = new FormData();
|
||||
formData.append('patient_id', patientId);
|
||||
formData.append('status', status);
|
||||
if (notes !== null) {
|
||||
formData.append('notes', notes);
|
||||
}
|
||||
if (service !== null) {
|
||||
formData.append('service_rendered', service);
|
||||
}
|
||||
if (cost !== null) {
|
||||
formData.append('cost', cost);
|
||||
}
|
||||
|
||||
fetch('update_patient_status.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// Update status badge
|
||||
const statusBadge = document.getElementById('status-' + patientId);
|
||||
statusBadge.textContent = status;
|
||||
statusBadge.className = 'badge bg-' + data.status_class + '-soft';
|
||||
|
||||
// Update action buttons/form
|
||||
const actionCell = document.getElementById('action-cell-' + patientId);
|
||||
const notesRow = document.getElementById('notes-row-' + patientId);
|
||||
if (status === 'In Progress') {
|
||||
actionCell.innerHTML = '';
|
||||
notesRow.style.display = 'table-row';
|
||||
} else if (status === 'Completed') {
|
||||
actionCell.innerHTML = '<span class="text-success"><i class="bi bi-check-circle-fill me-1"></i>Completed</span>';
|
||||
notesRow.style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
alert('Error: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('An unexpected error occurred.');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
function get_status_badge_class($status) {
|
||||
switch ($status) {
|
||||
case 'Pending':
|
||||
return 'warning';
|
||||
case 'In Progress':
|
||||
return 'info';
|
||||
case 'Completed':
|
||||
return 'success';
|
||||
default:
|
||||
return 'secondary';
|
||||
}
|
||||
}
|
||||
|
||||
function get_action_buttons($patient) {
|
||||
switch ($patient['status']) {
|
||||
case 'Pending':
|
||||
return '<button class="btn btn-sm btn-primary start-consultation-btn" data-patient-id="' . $patient['id'] . '"><i class="bi bi-play-circle me-1"></i>Start Consultation</button>';
|
||||
case 'In Progress':
|
||||
return ''; // Form is shown in a separate row
|
||||
case 'Completed':
|
||||
return '<span class="text-success"><i class="bi bi-check-circle-fill me-1"></i>Completed</span>';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
152
index.php
152
index.php
@ -1,150 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
// This is the main entry point of the application.
|
||||
// It will redirect the user to the login page.
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<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=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
115
invoice.php
Normal file
115
invoice.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
$patient_id = $_GET['id'] ?? null;
|
||||
|
||||
if (!$patient_id) {
|
||||
die("Patient ID is required.");
|
||||
}
|
||||
|
||||
// Fetch patient and latest completed visit details
|
||||
try {
|
||||
$pdo = db();
|
||||
// This query fetches the most recent completed visit for the patient
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT p.*, u.username as doctor_name
|
||||
FROM patients p
|
||||
JOIN users u ON p.doctor_id = u.id
|
||||
WHERE p.id = ? AND p.status = 'Completed'
|
||||
ORDER BY p.updated_at DESC
|
||||
LIMIT 1
|
||||
");
|
||||
$stmt->execute([$patient_id]);
|
||||
$visit = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$visit = null;
|
||||
// Log error
|
||||
}
|
||||
|
||||
if (!$visit) {
|
||||
die("No completed visit found for this patient or an error occurred.");
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Invoice - <?php echo htmlspecialchars($visit['patient_id']); ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
body { font-family: 'Poppins', sans-serif; background-color: #f8f9fa; }
|
||||
.invoice-container { max-width: 800px; margin: 40px auto; padding: 40px; background: #fff; border-radius: 15px; box-shadow: 0 4px 20px rgba(0,0,0,0.05); }
|
||||
.invoice-header { text-align: center; margin-bottom: 40px; }
|
||||
.invoice-header h1 { font-weight: 600; color: #343a40; }
|
||||
.invoice-header .brand { font-size: 1.5rem; font-weight: 600; color: #0d6efd; }
|
||||
.invoice-details, .billing-details { margin-bottom: 30px; }
|
||||
.invoice-details h5, .billing-details h5 { font-weight: 600; margin-bottom: 15px; }
|
||||
.invoice-details p, .billing-details p { margin-bottom: 5px; }
|
||||
.table thead { background-color: #e9ecef; }
|
||||
.total-section { text-align: right; margin-top: 30px; }
|
||||
.total-section h4 { font-weight: 600; }
|
||||
.print-btn { display: block; width: 150px; margin: 30px auto 0; }
|
||||
@media print {
|
||||
body { background-color: #fff; }
|
||||
.invoice-container { margin: 0; box-shadow: none; border-radius: 0; }
|
||||
.print-btn, .btn-back { display: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="invoice-container">
|
||||
<div class="invoice-header">
|
||||
<div class="brand"><i class="bi bi-heart-pulse-fill"></i> ClinicFlow</div>
|
||||
<h1>Invoice</h1>
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-between invoice-details">
|
||||
<div class="col-md-6">
|
||||
<h5>Billed To:</h5>
|
||||
<p><strong><?php echo htmlspecialchars($visit['patient_name']); ?></strong></p>
|
||||
<p><?php echo htmlspecialchars($visit['address']); ?></p>
|
||||
<p><?php echo htmlspecialchars($visit['phone']); ?></p>
|
||||
</div>
|
||||
<div class="col-md-5 text-md-end">
|
||||
<p><strong>Invoice #:</strong> INV-<?php echo htmlspecialchars($visit['id']); ?></p>
|
||||
<p><strong>Date:</strong> <?php echo date("F j, Y", strtotime($visit['updated_at'])); ?></p>
|
||||
<p><strong>Status:</strong> <span class="badge bg-<?php echo $visit['payment_status'] === 'paid' ? 'success' : 'danger'; ?>"><?php echo ucfirst(htmlspecialchars($visit['payment_status'])); ?></span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="billing-details">
|
||||
<h5>Consultation Details:</h5>
|
||||
<p><strong>Consulting Doctor:</strong> Dr. <?php echo htmlspecialchars($visit['doctor_name']); ?></p>
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Service Rendered</th>
|
||||
<th class="text-end">Cost</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($visit['service_rendered']); ?></td>
|
||||
<td class="text-end">$<?php echo htmlspecialchars(number_format($visit['cost'], 2)); ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="total-section">
|
||||
<h4>Total: $<?php echo htmlspecialchars(number_format($visit['cost'], 2)); ?></h4>
|
||||
</div>
|
||||
|
||||
<button onclick="window.print();" class="btn btn-primary print-btn"><i class="bi bi-printer"></i> Print Invoice</button>
|
||||
<a href="billing.php" class="btn btn-secondary btn-back d-print-none" style="display: block; width: 150px; margin: 10px auto 0;">Back to Billing</a>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
120
login.php
Normal file
120
login.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
$error = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = $_POST['username'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
$error = 'Please enter both username and password.';
|
||||
} else {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM `users` WHERE `username` = ?");
|
||||
$stmt->execute([$username]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['username'] = $user['username'];
|
||||
$_SESSION['role'] = $user['role'];
|
||||
|
||||
// Redirect based on role
|
||||
if ($user['role'] === 'doctor') {
|
||||
header("Location: doctor_dashboard.php");
|
||||
} else {
|
||||
header("Location: reception.php");
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Invalid username or password.';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$error = 'Database error. Please try again later.';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login - Clinic 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://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
border: none;
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.1);
|
||||
}
|
||||
.login-card-header {
|
||||
background-color: #0d6efd;
|
||||
color: white;
|
||||
border-top-left-radius: 1rem;
|
||||
border-top-right-radius: 1rem;
|
||||
padding: 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
.login-card-header h3 {
|
||||
margin: 0;
|
||||
font-weight: 300;
|
||||
}
|
||||
.login-card-body {
|
||||
padding: 2rem;
|
||||
}
|
||||
.form-floating > .form-control {
|
||||
height: calc(3.5rem + 2px);
|
||||
padding: 1rem;
|
||||
}
|
||||
.form-floating > label {
|
||||
padding: 1rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<div class="card login-card">
|
||||
<div class="login-card-header">
|
||||
<h3><i class="fas fa-clinic-medical"></i> Clinic Login</h3>
|
||||
</div>
|
||||
<div class="card-body login-card-body">
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div>
|
||||
<?php endif; ?>
|
||||
<form action="login.php" method="POST">
|
||||
<div class="form-floating mb-3">
|
||||
<input type="text" class="form-control" id="username" name="username" placeholder="Username" required>
|
||||
<label for="username">Username</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
|
||||
<label for="password">Password</label>
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary btn-lg">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="mt-3 text-center">
|
||||
<small class="text-muted">Default Logins: reception/password, doctor/password</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
7
logout.php
Normal file
7
logout.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
?>
|
||||
162
patient_profile.php
Normal file
162
patient_profile.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Check if patient ID is provided
|
||||
if (!isset($_GET['id'])) {
|
||||
header("Location: reception.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
$patient_id = $_GET['id'];
|
||||
|
||||
// Fetch patient details
|
||||
$stmt = db()->prepare("SELECT * FROM patients WHERE id = ?");
|
||||
$stmt->execute([$patient_id]);
|
||||
$patient = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$patient) {
|
||||
die("Patient not found.");
|
||||
}
|
||||
|
||||
// Now, fetch all visits for this patient using their patient_id
|
||||
$history_stmt = db()->prepare(
|
||||
"SELECT p.*, d.username as doctor_name
|
||||
FROM patients p
|
||||
LEFT JOIN users d ON p.doctor_id = d.id
|
||||
WHERE p.patient_id = ?
|
||||
ORDER BY p.created_at DESC"
|
||||
);
|
||||
$history_stmt->execute([$patient['patient_id']]);
|
||||
$visit_history = $history_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Patient Profile - <?= htmlspecialchars($patient['patient_name']) ?></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 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 vh-100 d-flex flex-column p-3">
|
||||
<a href="reception.php" class="sidebar-brand d-flex align-items-center mb-4">
|
||||
<i class="bi bi-heart-pulse-fill me-2"></i>
|
||||
<span class="fs-5 fw-bold">ClinicSystem</span>
|
||||
</a>
|
||||
<ul class="nav flex-column mb-auto">
|
||||
<li class="nav-item">
|
||||
<a href="reception.php" class="nav-link active">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
<span>Patients</span>
|
||||
</a>
|
||||
</li>
|
||||
<!-- Add other nav items here -->
|
||||
</ul>
|
||||
<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">Patient Profile</h1>
|
||||
<a href="reception.php" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-arrow-left me-2"></i>Back to Dashboard
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<!-- Patient Details Card -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">
|
||||
<i class="bi bi-person-badge me-2"></i>
|
||||
<?= htmlspecialchars($patient['patient_name']) ?>
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p><strong>Phone:</strong> <?= htmlspecialchars($patient['phone_number']) ?></p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p><strong>Address:</strong> <?= htmlspecialchars($patient['address']) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Visit History -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">
|
||||
<i class="bi bi-clock-history me-2"></i>
|
||||
Visit History
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Visit Date</th>
|
||||
<th>Assigned Doctor</th>
|
||||
<th>Status</th>
|
||||
<th>Consultation Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($visit_history)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">No visit history found.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($visit_history as $visit): ?>
|
||||
<tr>
|
||||
<td><?= date("d M, Y h:i A", strtotime($visit['created_at'])) ?></td>
|
||||
<td><?= htmlspecialchars($visit['doctor_name'] ?? 'N/A') ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$status = htmlspecialchars($visit['status']);
|
||||
$badge_class = 'bg-secondary';
|
||||
if ($status == 'Pending') {
|
||||
$badge_class = 'bg-warning text-dark';
|
||||
} elseif ($status == 'In Progress') {
|
||||
$badge_class = 'bg-info text-dark';
|
||||
} elseif ($status == 'Completed') {
|
||||
$badge_class = 'bg-success';
|
||||
}
|
||||
?>
|
||||
<span class="badge <?= $badge_class ?>"><?= $status ?></span>
|
||||
</td>
|
||||
<td><?= nl2br(htmlspecialchars($visit['notes'] ?? 'No notes added.')) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</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>
|
||||
</body>
|
||||
</html>
|
||||
152
patient_register.php
Normal file
152
patient_register.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist');
|
||||
require_once 'db/config.php';
|
||||
|
||||
$message = '';
|
||||
$error = '';
|
||||
$doctors = [];
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
// Fetch doctors (users with role 'doctor') for the dropdown
|
||||
$stmt = $pdo->query("SELECT id, username FROM users WHERE role = 'doctor' ORDER BY username");
|
||||
$doctors = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$error = "Database error: " . $e->getMessage();
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$patient_name = trim($_POST['patient_name']);
|
||||
$phone_number = trim($_POST['phone_number']);
|
||||
$address = trim($_POST['address']);
|
||||
$doctor_id = $_POST['doctor_id'];
|
||||
|
||||
if (empty($patient_name) || empty($doctor_id)) {
|
||||
$error = "Patient name and assigned doctor are required.";
|
||||
} else {
|
||||
try {
|
||||
// Generate a unique patient ID
|
||||
$prefix = 'PT';
|
||||
$stmt = $pdo->query("SELECT MAX(id) FROM patients");
|
||||
$last_id = $stmt->fetchColumn();
|
||||
$next_id = ($last_id) ? $last_id + 1 : 1;
|
||||
$patient_id = $prefix . str_pad($next_id, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
// Set initial status
|
||||
$status = 'Pending';
|
||||
$total_fee = 20.00; // Example fee
|
||||
|
||||
$sql = "INSERT INTO patients (patient_id, patient_name, phone_number, address, doctor_id, status, total_fee) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
if ($stmt->execute([$patient_id, $patient_name, $phone_number, $address, $doctor_id, $status, $total_fee])) {
|
||||
$_SESSION['message'] = "Patient registered successfully! Patient ID: $patient_id";
|
||||
header("Location: reception.php");
|
||||
exit();
|
||||
} else {
|
||||
$error = "Failed to register patient.";
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$error = "Database error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Register Patient - 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>
|
||||
<ul class="nav nav-pills flex-column mb-auto">
|
||||
<li class="nav-item">
|
||||
<a href="reception.php" class="nav-link text-white">
|
||||
<i class="bi bi-grid-fill me-2"></i>
|
||||
Dashboard
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="patient_register.php" class="nav-link active" aria-current="page">
|
||||
<i class="bi bi-person-plus-fill me-2"></i>
|
||||
Register Patient
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<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">Register New Patient</h1>
|
||||
</header>
|
||||
|
||||
<?php if (!empty($error)): ?>
|
||||
<div class="alert alert-danger"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card shadow">
|
||||
<div class="card-body p-5">
|
||||
<form action="patient_register.php" method="post">
|
||||
<div class="mb-4">
|
||||
<label for="patient_name" class="form-label">Patient Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="patient_name" name="patient_name" required>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="phone_number" class="form-label">Phone Number</label>
|
||||
<input type="text" class="form-control" id="phone_number" name="phone_number">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="address" class="form-label">Address</label>
|
||||
<input type="text" class="form-control" id="address" name="address">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="doctor_id" class="form-label">Assign Doctor <span class="text-danger">*</span></label>
|
||||
<select class="form-select" id="doctor_id" name="doctor_id" required>
|
||||
<option value="">Select a Doctor</option>
|
||||
<?php foreach ($doctors as $doctor): ?>
|
||||
<option value="<?php echo htmlspecialchars($doctor['id']); ?>">
|
||||
Dr. <?php echo htmlspecialchars($doctor['username']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button type="submit" class="btn btn-primary-custom">Register Patient</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
201
reception.php
Normal file
201
reception.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?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="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>
|
||||
<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 Search -->
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">Find a Patient</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="reception.php" method="GET" class="d-flex">
|
||||
<input type="text" class="form-control me-2" name="search_query" placeholder="Enter Patient Name or ID..." value="<?php echo isset($_GET['search_query']) ? htmlspecialchars($_GET['search_query']) : ''; ?>">
|
||||
<button type="submit" class="btn btn-primary-custom">
|
||||
<i class="bi bi-search"></i> Search
|
||||
</button>
|
||||
</form>
|
||||
</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>Assigned Doctor</th>
|
||||
<th>Status</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$search_query = isset($_GET['search_query']) ? trim($_GET['search_query']) : '';
|
||||
|
||||
$sql = "SELECT p.*, d.doctor_name FROM patients p LEFT JOIN doctors d ON p.doctor_id = d.id";
|
||||
$params = [];
|
||||
|
||||
if (!empty($search_query)) {
|
||||
$sql .= " WHERE p.patient_name LIKE ? OR p.patient_id LIKE ?";
|
||||
$params = ["%$search_query%", "%$search_query%"];
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY p.created_at DESC LIMIT 10";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
while ($row = $stmt->fetch()) {
|
||||
echo "<tr>";
|
||||
echo "<td><a href='patient_profile.php?id=" . $row['id'] . "'>" . htmlspecialchars($row['patient_name']) . "</a></td>";
|
||||
echo "<td>" . htmlspecialchars($row['phone_number']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($row['doctor_name'] ?? 'N/A') . "</td>";
|
||||
echo "<td><span class='badge bg-secondary'>" . htmlspecialchars($row['status']) . "</span></td>";
|
||||
echo "<td>" . date("Y-m-d H:i", strtotime($row['created_at'])) . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
} else {
|
||||
echo '<tr><td colspan="6" 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>
|
||||
</body>
|
||||
</html>
|
||||
75
update_patient_status.php
Normal file
75
update_patient_status.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$response = ['success' => false, 'message' => 'Invalid request'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$patient_id = $_POST['patient_id'] ?? null;
|
||||
$status = $_POST['status'] ?? null;
|
||||
$notes = $_POST['notes'] ?? null;
|
||||
$service_rendered = $_POST['service_rendered'] ?? null;
|
||||
$cost = $_POST['cost'] ?? null;
|
||||
|
||||
if ($patient_id && $status) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$sql = "UPDATE patients SET status = ?";
|
||||
$params = [$status];
|
||||
|
||||
if ($notes !== null) {
|
||||
$sql .= ", notes = ?";
|
||||
$params[] = $notes;
|
||||
}
|
||||
|
||||
if ($service_rendered !== null) {
|
||||
$sql .= ", service_rendered = ?";
|
||||
$params[] = $service_rendered;
|
||||
}
|
||||
|
||||
if ($cost !== null) {
|
||||
$sql .= ", cost = ?";
|
||||
$params[] = $cost;
|
||||
}
|
||||
|
||||
// When completing, set payment_status to unpaid
|
||||
if ($status === 'Completed') {
|
||||
$sql .= ", payment_status = 'unpaid'";
|
||||
}
|
||||
|
||||
$sql .= " WHERE id = ?";
|
||||
$params[] = $patient_id;
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
if ($stmt->execute($params)) {
|
||||
$response['success'] = true;
|
||||
$response['message'] = 'Patient status updated successfully.';
|
||||
$response['status_class'] = get_status_badge_class($status);
|
||||
} else {
|
||||
$response['message'] = 'Failed to update patient status.';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$response['message'] = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$response['message'] = 'Missing patient ID or status.';
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
function get_status_badge_class($status) {
|
||||
switch ($status) {
|
||||
case 'Pending':
|
||||
return 'warning';
|
||||
case 'In Progress':
|
||||
return 'info';
|
||||
case 'Completed':
|
||||
return 'success';
|
||||
default:
|
||||
return 'secondary';
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user